source: Docking/CoolDocking/UCDClient.pas

Last change on this file was 437, checked in by chronos, 12 years ago
  • Fixed: Better switching tabbed controls.
File size: 2.6 KB
Line 
1unit UCDClient;
2
3{$mode delphi}{$H+}
4
5// Date: 2010-09-17
6
7interface
8
9uses
10 Classes, SysUtils, Controls, Graphics,
11 Buttons, ExtCtrls, Forms, Dialogs, Menus,
12 UCDCustomize, UCDCommon;
13
14const
15 GrabberSize = 22;
16
17type
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
40procedure Register;
41
42resourcestring
43 SWrongOwner = 'Owner of TCoolDockClient have to be TForm';
44
45
46implementation
47
48uses
49 UCDManagerRegions;
50
51procedure Register;
52begin
53 RegisterComponents('CoolDocking', [TCDClient, TCDCustomize]);
54end;
55
56{ TCDClient }
57
58procedure TCDClient.SetDockable(const AValue: Boolean);
59begin
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;
73end;
74
75procedure TCDClient.SetFloatable(const AValue: Boolean);
76begin
77 if FFloatable = AValue then Exit;
78 FFloatable := AValue;
79end;
80
81procedure TCDClient.SetPanel(const AValue: TPanel);
82begin
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;
92end;
93
94constructor TCDClient.Create(AOwner: TComponent);
95begin
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;
112end;
113
114destructor TCDClient.Destroy;
115begin
116 inherited Destroy;
117 Master := nil;
118end;
119
120
121end.
122
Note: See TracBrowser for help on using the repository browser.