| 1 | unit UCDClient;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | // Date: 2010-09-17
|
|---|
| 6 |
|
|---|
| 7 | interface
|
|---|
| 8 |
|
|---|
| 9 | uses
|
|---|
| 10 | Classes, SysUtils, Controls, Graphics,
|
|---|
| 11 | Buttons, ExtCtrls, Forms, Dialogs, Menus,
|
|---|
| 12 | UCDCustomize, UCDCommon;
|
|---|
| 13 |
|
|---|
| 14 | const
|
|---|
| 15 | GrabberSize = 22;
|
|---|
| 16 |
|
|---|
| 17 | type
|
|---|
| 18 |
|
|---|
| 19 | { TCDClient }
|
|---|
| 20 |
|
|---|
| 21 | TCDClient = class(TCDClientBase)
|
|---|
| 22 | private
|
|---|
| 23 | FDockable: Boolean;
|
|---|
| 24 | FFloatable: Boolean;
|
|---|
| 25 | procedure SetDockable(const AValue: Boolean);
|
|---|
| 26 | procedure SetFloatable(const AValue: Boolean);
|
|---|
| 27 | protected
|
|---|
| 28 | procedure SetPanel(const AValue: TPanel); override;
|
|---|
| 29 | public
|
|---|
| 30 | constructor Create(AOwner: TComponent); override;
|
|---|
| 31 | destructor Destroy; override;
|
|---|
| 32 | published
|
|---|
| 33 | property Dockable: Boolean read FDockable
|
|---|
| 34 | write SetDockable default True;
|
|---|
| 35 | property Floatable: Boolean read FFloatable
|
|---|
| 36 | write SetFloatable default True;
|
|---|
| 37 | end;
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | procedure Register;
|
|---|
| 41 |
|
|---|
| 42 | resourcestring
|
|---|
| 43 | SWrongOwner = 'Owner of TCoolDockClient have to be TForm';
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | implementation
|
|---|
| 47 |
|
|---|
| 48 | uses
|
|---|
| 49 | UCDManagerRegions;
|
|---|
| 50 |
|
|---|
| 51 | procedure Register;
|
|---|
| 52 | begin
|
|---|
| 53 | RegisterComponents('CoolDocking', [TCDClient, TCDCustomize]);
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | { TCDClient }
|
|---|
| 57 |
|
|---|
| 58 | procedure TCDClient.SetDockable(const AValue: Boolean);
|
|---|
| 59 | begin
|
|---|
| 60 | if FDockable = AValue then Exit;
|
|---|
| 61 | FDockable := AValue;
|
|---|
| 62 | if (Owner is TForm) then
|
|---|
| 63 | with (Owner as TForm) do
|
|---|
| 64 | if AValue then begin
|
|---|
| 65 | DragKind := dkDock;
|
|---|
| 66 | DragMode := dmAutomatic;
|
|---|
| 67 | DockSite := True;
|
|---|
| 68 | end else begin
|
|---|
| 69 | DragKind := dkDrag;
|
|---|
| 70 | DragMode := dmManual;
|
|---|
| 71 | DockSite := False;
|
|---|
| 72 | end;
|
|---|
| 73 | end;
|
|---|
| 74 |
|
|---|
| 75 | procedure TCDClient.SetFloatable(const AValue: Boolean);
|
|---|
| 76 | begin
|
|---|
| 77 | if FFloatable = AValue then Exit;
|
|---|
| 78 | FFloatable := AValue;
|
|---|
| 79 | end;
|
|---|
| 80 |
|
|---|
| 81 | procedure TCDClient.SetPanel(const AValue: TPanel);
|
|---|
| 82 | begin
|
|---|
| 83 | inherited SetPanel(AValue);
|
|---|
| 84 | if not (csDesigning in ComponentState) then begin
|
|---|
| 85 | if Assigned(Panel) then
|
|---|
| 86 | with Panel do begin
|
|---|
| 87 | DockSite := True;
|
|---|
| 88 | UseDockManager := True;
|
|---|
| 89 | DockManager := TCDManagerRegions.Create(Panel);
|
|---|
| 90 | end;
|
|---|
| 91 | end;
|
|---|
| 92 | end;
|
|---|
| 93 |
|
|---|
| 94 | constructor TCDClient.Create(AOwner: TComponent);
|
|---|
| 95 | begin
|
|---|
| 96 | inherited Create(AOwner);
|
|---|
| 97 | FDockable := True;
|
|---|
| 98 | if not (AOwner is TForm) then
|
|---|
| 99 | raise Exception.Create(SWrongOwner);
|
|---|
| 100 | with (AOwner as TForm) do begin
|
|---|
| 101 | if not (csDesigning in ComponentState) then begin
|
|---|
| 102 | if Dockable then begin
|
|---|
| 103 | DragKind := dkDock;
|
|---|
| 104 | DragMode := dmAutomatic;
|
|---|
| 105 | DockSite := True;
|
|---|
| 106 | end;
|
|---|
| 107 | UseDockManager := True;
|
|---|
| 108 | DockManager := TCDManagerRegions.Create(TWinControl(AOwner));
|
|---|
| 109 | //FormStyle := fsStayOnTop;
|
|---|
| 110 | end;
|
|---|
| 111 | end;
|
|---|
| 112 | end;
|
|---|
| 113 |
|
|---|
| 114 | destructor TCDClient.Destroy;
|
|---|
| 115 | begin
|
|---|
| 116 | inherited Destroy;
|
|---|
| 117 | Master := nil;
|
|---|
| 118 | end;
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 | end.
|
|---|
| 122 |
|
|---|