dockmanager example: updated MiniIDE project

git-svn-id: trunk@25212 -
This commit is contained in:
dodi 2010-05-05 12:26:23 +00:00
parent e6e762d899
commit b6df08db05
11 changed files with 84 additions and 44 deletions

View File

@ -1,7 +1,8 @@
inherited EditBook: TEditBook
Left = 670
Top = 115
Left = 464
Top = 175
Caption = 'EditBook'
DragKind = dkDock
OnActivate = FormActivate
OnClose = FormClose
end

View File

@ -1,6 +1,7 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TEditBook','FORMDATA',[
'TPF0'#241#9'TEditBook'#8'EditBook'#4'Left'#3#158#2#3'Top'#2's'#7'Caption'#6#8
+'EditBook'#10'OnActivate'#7#12'FormActivate'#7'OnClose'#7#9'FormClose'#0#0
'TPF0'#241#9'TEditBook'#8'EditBook'#4'Left'#3#208#1#3'Top'#3#175#0#7'Caption'
+#6#8'EditBook'#8'DragKind'#7#6'dkDock'#10'OnActivate'#7#12'FormActivate'#7'O'
+'nClose'#7#9'FormClose'#0#0
]);

View File

@ -22,6 +22,8 @@ uses
type
TEditPage = class(TSynEdit)
protected
function GetFloatingDockSiteClass: TWinControlClass; override;
public
FileName: string;
procedure LoadFile(const AName: string);
@ -52,7 +54,7 @@ uses
constructor TEditBook.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
DockMaster.AddElasticSites(self, [alLeft, alRight, alBottom]);
//DockMaster.AddElasticSites(self, [alLeft, alRight, alBottom]);
end;
procedure TEditBook.FormActivate(Sender: TObject);
@ -107,6 +109,12 @@ end;
{ TEditPage }
function TEditPage.GetFloatingDockSiteClass: TWinControlClass;
begin
//Result:=inherited GetFloatingDockSiteClass;
Result := TEditBook; //try auto-wrap
end;
procedure TEditPage.LoadFile(const AName: string);
begin
FileName := AName;

View File

@ -77,7 +77,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\"/>
<OtherUnitFiles Value="..\easyedit\;..\..\..\components\synedit\"/>
<OtherUnitFiles Value="..\easyedit\"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>

View File

@ -7,7 +7,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, LResources, fminiide, EasyDockMgr, fclientform, fEditBook
Forms, fminiide, EasyDockMgr, fclientform, fEditBook
{ you can add units after this };
{$IFDEF WINDOWS}{.$R MiniIDE.rc}{$ENDIF}

View File

@ -13,6 +13,7 @@ unit fEditBook;
{ TODO : figure out what's wrong with the mru list - with multiple windows }
{$DEFINE mru} //problems with MRU list???
{$DEFINE DockSite}
interface
@ -51,6 +52,9 @@ type
*)
{$IFDEF dockSite}
TEditBook = class(TCustomDockSite)
{$ELSE}
TEditBook = class(TForm)
{$ENDIF}
protected
FEdit: TEditPages;
public
@ -59,19 +63,8 @@ type
function AddFile(const AName: string): boolean; //virtual;
procedure LoadFromStream(strm: TStream); override;
procedure SaveToStream(strm: TStream); override;
property Pages: TEditPages read FEdit;
end;
{$ELSE}
TEditBook = class(TForm)
protected
FEdit: TEditPages;
public
constructor Create(TheOwner: TComponent); override;
function OpenFile(const AName: string): boolean; //virtual;
function AddFile(const AName: string): boolean; //virtual;
procedure LoadFromStream(strm: TStream); //override;
procedure SaveToStream(strm: TStream); //override;
end;
{$ENDIF}
const
EditBookID = CustomDockSiteID + 1;
@ -96,6 +89,7 @@ begin
FEdit.Visible := True;
FEdit.DragMode := dmManual; //disallow undocking
FEdit.StayDocked := True;
//problem: what happens with additional dock clients, when the last page is closed?
DockMaster.AddElasticSites(self, [alLeft, alRight, alBottom]);
end;

View File

@ -1,10 +1,10 @@
object MainBar: TMainBar
Left = 248
Left = 252
Height = 66
Top = 113
Top = 121
Width = 400
Caption = 'MainBar'
ClientHeight = 47
ClientHeight = 46
ClientWidth = 400
Menu = MainMenu1
OnCreate = FormCreate

View File

@ -212,6 +212,7 @@ type
protected //added
function FindControlZone(zone: TEasyZone; Control: TControl): TEasyZone;
procedure RemoveZone(Zone: TEasyZone);
procedure MakeVisible(ctl: TControl);
//Lazarus extension
private
FHeader: TEasyDockHeader;
@ -1165,8 +1166,10 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
begin
Stream.Read(ZoneRec, SizeOf(ZoneRec));
Result := ZoneRec.Level;
if Result > 0 then
if Result > 0 then begin
ZoneName := Stream.ReadAnsiString;
DockLoader.IdToRec(ZoneName);
end;
//debug
if Result > 0 then
DebugLn('reload %s @%d [%d,%d]', [ZoneName, Result, ZoneRec.BottomRight.x, ZoneRec.BottomRight.y])
@ -1209,15 +1212,15 @@ procedure TEasyTree.LoadFromStream(Stream: TStream);
if NewCtl = nil then begin
//debug: create some control
NewCtl := TPanel.Create(DockSite);
TryRename(NewCtl, ZoneName);
TryRename(NewCtl, DockLoader.ControlDescriptor.Name); // ZoneName);
end;
if NewCtl <> nil then begin
NewCtl.Visible := True;
NewZone.ChildControl := NewCtl;
SetReplacingControl(NewCtl); //prevent DockManager actions
NewCtl.ManualDock(DockSite);
NewCtl.Width := ZoneRec.BottomRight.x;
NewCtl.Height := ZoneRec.BottomRight.y;
NewCtl.Visible := True;
end;
{$IFDEF oldOrient}
{$ELSE}
@ -1252,6 +1255,8 @@ begin
//remove all leafs without a child control?
//refresh the site
ResetBounds(True);
//assure everything is visible
MakeVisible(FDockSite);
end;
function TEasyTree.ReloadDockedControl(const AName: string): TControl;
@ -1535,6 +1540,14 @@ begin
DockSite.Invalidate;
end;
procedure TEasyTree.MakeVisible(ctl: TControl);
begin
while assigned(ctl) do begin
ctl.Visible := True;
ctl := ctl.Parent;
end;
end;
{ TEasyZone }
constructor TEasyZone.Create(ATree: TEasyTree);

View File

@ -7,7 +7,6 @@ inherited EasyDockBook: TEasyDockBook
ClientHeight = 300
ClientWidth = 400
DockSite = True
DragKind = dkDock
OnClose = FormClose
OnCreate = FormCreate
OnDockDrop = FormDockDrop

View File

@ -98,9 +98,9 @@ type
Tabs: TTabs;
CurTab: TTabButton;
protected
function GetFloatingDockSiteClass: TWinControlClass; override;
function GetDefaultDockCaption: string; override;
function GetControlTab(AControl: TControl): TTabButton;
function GetFloatingDockSiteClass: TWinControlClass; override;
function GetDefaultDockCaption: string; override;
function GetControlTab(AControl: TControl): TTabButton;
procedure AfterUndock(tabidx: integer); virtual;
public
{$IFDEF undockFix}
@ -109,6 +109,8 @@ type
{$IFDEF closeFix}
destructor Destroy; override;
{$ENDIF}
procedure LoadFromStream(strm: TStream); override;
procedure SaveToStream(strm: TStream); override;
end;
//procedure Register;
@ -204,7 +206,10 @@ end;
procedure TEasyDockBook.FormCreate(Sender: TObject);
begin
Tabs := TTabs.Create(self);
Visible := True;
//also this?
DragKind := dkDock;
DragMode := dmAutomatic;
Visible := True; //immediately?
end;
procedure TEasyDockBook.FormDockDrop(Sender: TObject; Source: TDragDockObject;
@ -241,7 +246,7 @@ procedure TEasyDockBook.FormGetSiteInfo(Sender: TObject; DockClient: TControl;
begin
//override TCustomForm behaviour!
CanDock := True;
InfluenceRect := ScreenRect(pnlDock);
InfluenceRect := ScreenRect(pnlDock); //exclude eventual elastic sites
end;
procedure TEasyDockBook.FormUnDock(Sender: TObject; Client: TControl;
@ -319,12 +324,16 @@ We can be either:
Caption := GetDefaultDockCaption;
end else if not StayDocked then begin
//last tab removed - close ONLY if we are docked or floating
if (Parent = nil) then begin
//and if we have no other controls (elastic sites!) - detect how?
if (Parent = nil) and (DragKind = dkDock)
//and (ControlCount <= 1)
then begin
//we are floating
Release;
exit;
end else if (HostDockSite <> nil) then begin //may be cleared already???
ManualDock(nil); //undock before closing
Visible := False;
ManualDock(nil); //undock before closing?
Release;
exit;
end;
@ -379,23 +388,38 @@ begin
Result:= TFloatingSite;
end;
{$IFDEF new}
procedure TEasyDockBook.LoadFromStream(strm: TStream);
var
i, n: integer;
ctl: TControl;
cn: string;
begin
(*
*)
inherited LoadFromStream(strm);
if False then inherited LoadFromStream(strm);
n := strm.ReadByte;
for i := 1 to n do begin
cn := strm.ReadAnsiString;
ctl := DockLoader.ReloadControl(cn, self);
if ctl <> nil then
ctl.ManualDock(self); //orientation???
//make visible?
end;
end;
procedure TEasyDockBook.SaveToStream(strm: TStream);
var
i, n: integer;
ctl: TControl;
s: string;
begin
(* Save docked pages, residing in?
*)
if false then inherited SaveToStream(strm);
...
if False then inherited SaveToStream(strm);
n := DockClientCount;
strm.WriteByte(n);
for i := 0 to n-1 do begin
ctl := DockClients[i];
s := DockLoader.SaveControl(ctl, self);
strm.WriteAnsiString(s);
end;
end;
{$ELSE}
{$ENDIF}
procedure TEasyDockBook.ToolButton1Click(Sender: TObject);
var

View File

@ -402,7 +402,7 @@ var
host.BoundsRect := SiteRec.Bounds;
Result.BoundsRect := SiteRec.Extent;
Result.AutoExpand := SiteRec.AutoExpand;
Result.EnableAlign;
//Result.EnableAlign; ???
Result.Visible := True;
exit;
end;