1 | unit UCDManager;
|
---|
2 |
|
---|
3 | {$mode Delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UCDCommon, Controls, Contnrs, Dialogs,
|
---|
9 | UCDPopupMenu, LCLType, LCLIntf, LMessages, Graphics, Buttons,
|
---|
10 | UCDConjoinForm, Menus, StdCtrls, ExtCtrls, Forms;
|
---|
11 |
|
---|
12 | const
|
---|
13 | GrabberSize = 22;
|
---|
14 |
|
---|
15 | type
|
---|
16 | TCDManager = class;
|
---|
17 | TCDManagerItem = class;
|
---|
18 |
|
---|
19 | TCDPanelForm = class(TForm)
|
---|
20 | Panel: TPanel;
|
---|
21 | end;
|
---|
22 |
|
---|
23 | { TCDHeaderButton }
|
---|
24 |
|
---|
25 | TCDHeaderButton = class
|
---|
26 | Icon: TImage;
|
---|
27 | Visible: Boolean;
|
---|
28 | constructor Create;
|
---|
29 | destructor Destroy; override;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | { TCDHeader }
|
---|
33 |
|
---|
34 | TCDHeader = class(TPanel)
|
---|
35 | private
|
---|
36 | MyFont: hFont;
|
---|
37 | procedure CloseButtonClick(Sender: TObject);
|
---|
38 | procedure PaintExecute(Sender: TObject);
|
---|
39 | procedure RearrangeButtons;
|
---|
40 | public
|
---|
41 | Buttons: TObjectList; // TList<TCDHeaderButton>
|
---|
42 | Icon: TImage;
|
---|
43 | Control: TControl;
|
---|
44 | constructor Create(TheOwner: TComponent); override;
|
---|
45 | destructor Destroy; override;
|
---|
46 | end;
|
---|
47 |
|
---|
48 | { TCDPanelHeader }
|
---|
49 |
|
---|
50 | TCDPanelHeader = class(TPanel)
|
---|
51 | private
|
---|
52 | FHeaderPos: THeaderPos;
|
---|
53 | function GetHeaderVisible: Boolean;
|
---|
54 | procedure SetHeaderPos(const AValue: THeaderPos);
|
---|
55 | procedure SetHeaderVisible(const AValue: Boolean);
|
---|
56 | public
|
---|
57 | Header: TCDHeader;
|
---|
58 | ControlPanel: TPanel;
|
---|
59 | property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos;
|
---|
60 | property HeaderVisible: Boolean read GetHeaderVisible write SetHeaderVisible;
|
---|
61 | constructor Create(TheOwner: TComponent);
|
---|
62 | destructor Destroy; override;
|
---|
63 | end;
|
---|
64 |
|
---|
65 | { TCDManagerItem }
|
---|
66 |
|
---|
67 | TCDManagerItem = class
|
---|
68 | private
|
---|
69 | FControl: TWinControl;
|
---|
70 | function GetHideType: TCDHideType;
|
---|
71 | procedure ResizeExecute(Sender: TObject);
|
---|
72 | procedure SetHideType(const AValue: TCDHideType);
|
---|
73 | public
|
---|
74 | Manager: TCDManager;
|
---|
75 | procedure SetControl(const AValue: TWinControl); virtual;
|
---|
76 | procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
77 | Shift: TShiftState; X, Y: Integer);
|
---|
78 | procedure Paint(Sender: TObject); virtual;
|
---|
79 | procedure VisibleChange(Sender: TObject); virtual;
|
---|
80 | procedure VisibleChanging(Sender: TObject); virtual;
|
---|
81 | constructor Create; virtual;
|
---|
82 | destructor Destroy; override;
|
---|
83 | property HideType: TCDHideType read GetHideType write SetHideType;
|
---|
84 | property Control: TWinControl read FControl write SetControl;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | { TCDManager }
|
---|
88 |
|
---|
89 | TCDManager = class(TCDManagerBase)
|
---|
90 | private
|
---|
91 | FDockSite: TWinControl;
|
---|
92 | FHeaderPos: THeaderPos;
|
---|
93 | FHeaderVisible: Boolean;
|
---|
94 | function GetDockSite: TWinControl;
|
---|
95 | function GetMoveDuration: Integer;
|
---|
96 | procedure SetDockStyle(const AValue: TCDStyleType);
|
---|
97 | procedure SetHeaderVisible(const AValue: Boolean);
|
---|
98 | procedure SetMoveDuration(const AValue: Integer);
|
---|
99 | public
|
---|
100 | Locked: Boolean;
|
---|
101 | PopupMenu: TCDPopupMenu;
|
---|
102 | FDockStyle: TCDStyleType;
|
---|
103 | FreeParentIfEmpty: Boolean; // Free or not parent conjoin forms
|
---|
104 | procedure SetVisible(const AValue: Boolean); virtual;
|
---|
105 | constructor Create(ADockSite: TWinControl); override;
|
---|
106 | destructor Destroy; override;
|
---|
107 | procedure UpdateClientSize; virtual;
|
---|
108 | procedure Switch(Index: Integer); virtual;
|
---|
109 | procedure ChangeVisible(Control: TWinControl; Visible: Boolean); virtual;
|
---|
110 | procedure Assign(Source: TCDManager); virtual;
|
---|
111 | procedure InsertControlPanel(Control: TControl; InsertAt: TAlign;
|
---|
112 | DropCtl: TControl); virtual;
|
---|
113 | procedure SetHeaderPos(const AValue: THeaderPos); virtual;
|
---|
114 | function GetHeaderPos: THeaderPos; virtual;
|
---|
115 |
|
---|
116 | // Inherited from TDockManager
|
---|
117 | procedure BeginUpdate; override;
|
---|
118 | procedure EndUpdate; override;
|
---|
119 | procedure GetControlBounds(Control: TControl;
|
---|
120 | out AControlBounds: TRect); override;
|
---|
121 | function GetDockEdge(ADockObject: TDragDockObject): boolean; override;
|
---|
122 | procedure InsertControl(ADockObject: TDragDockObject); override; overload;
|
---|
123 | procedure InsertControl(Control: TControl; InsertAt: TAlign;
|
---|
124 | DropCtl: TControl); override; overload;
|
---|
125 | procedure LoadFromStream(Stream: TStream); override;
|
---|
126 | procedure PaintSite(DC: HDC); override;
|
---|
127 | procedure MessageHandler(Sender: TControl; var Message: TLMessage); override;
|
---|
128 | procedure PositionDockRect(ADockObject: TDragDockObject); override; overload;
|
---|
129 | procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign;
|
---|
130 | var DockRect: TRect); override; overload;
|
---|
131 | procedure RemoveControl(Control: TControl); override;
|
---|
132 | procedure ResetBounds(Force: Boolean); override;
|
---|
133 | procedure SaveToStream(Stream: TStream); override;
|
---|
134 | procedure SetReplacingControl(Control: TControl); override;
|
---|
135 | function AutoFreeByControl: Boolean; override;
|
---|
136 |
|
---|
137 | function FindControlInPanels(Control: TControl): TCDManagerItem; virtual;
|
---|
138 | function CreateConjoinForm: TCDConjoinForm;
|
---|
139 | function CreateDockableForm: TCDPanelForm;
|
---|
140 | property DockStyle: TCDStyleType read FDockStyle write SetDockStyle;
|
---|
141 | property MoveDuration: Integer read GetMoveDuration write SetMoveDuration;
|
---|
142 | property DockSite: TWinControl read GetDockSite;
|
---|
143 | property HeaderPos: THeaderPos read GetHeaderPos write SetHeaderPos;
|
---|
144 | property HeaderVisible: Boolean read FHeaderVisible write SetHeaderVisible;
|
---|
145 | property Visible: Boolean write SetVisible;
|
---|
146 | end;
|
---|
147 |
|
---|
148 |
|
---|
149 | implementation
|
---|
150 |
|
---|
151 | uses
|
---|
152 | UCDManagerRegions, UCDManagerTabs, UCDManagerRegionsPopup, UCDManagerTabsPopup,
|
---|
153 | UCDResource, UCDClient;
|
---|
154 |
|
---|
155 | function CreateRotatedFont(F: TFont; Angle: Integer): Integer;
|
---|
156 | var
|
---|
157 | LF: TLogFont;
|
---|
158 | begin
|
---|
159 | FillChar(LF, SizeOf(LF), #0);
|
---|
160 | with LF do begin
|
---|
161 | lfHeight := F.Height;
|
---|
162 | lfWidth := 0;
|
---|
163 | lfEscapement := Angle * 10;
|
---|
164 | lfOrientation := 0;
|
---|
165 | if fsBold in F.Style then
|
---|
166 | lfWeight := FW_BOLD
|
---|
167 | else
|
---|
168 | lfWeight := FW_NORMAL;
|
---|
169 | lfItalic := Byte(fsItalic in F.Style);
|
---|
170 | lfUnderline := Byte(fsUnderline in F.Style);
|
---|
171 | lfStrikeOut := Byte(fsStrikeOut in F.Style);
|
---|
172 | lfCharSet := DEFAULT_CHARSET;
|
---|
173 | StrPCopy(lfFaceName, F.Name);
|
---|
174 | lfQuality := DEFAULT_QUALITY;
|
---|
175 | {everything else as default}
|
---|
176 | lfOutPrecision := OUT_DEFAULT_PRECIS;
|
---|
177 | lfClipPrecision := CLIP_DEFAULT_PRECIS;
|
---|
178 | case F.Pitch of
|
---|
179 | fpVariable: lfPitchAndFamily := VARIABLE_PITCH;
|
---|
180 | fpFixed: lfPitchAndFamily := FIXED_PITCH;
|
---|
181 | else
|
---|
182 | lfPitchAndFamily := DEFAULT_PITCH;
|
---|
183 | end;
|
---|
184 | end;
|
---|
185 | Result := CreateFontIndirect(LF);
|
---|
186 | end;
|
---|
187 |
|
---|
188 | { TCDHeaderButton }
|
---|
189 |
|
---|
190 | constructor TCDHeaderButton.Create;
|
---|
191 | begin
|
---|
192 | inherited;
|
---|
193 | Icon := TImage.Create(nil);
|
---|
194 | end;
|
---|
195 |
|
---|
196 | destructor TCDHeaderButton.Destroy;
|
---|
197 | begin
|
---|
198 | Icon.Free;
|
---|
199 | inherited Destroy;
|
---|
200 | end;
|
---|
201 |
|
---|
202 | { TCDPanelHeader }
|
---|
203 |
|
---|
204 | procedure TCDPanelHeader.SetHeaderPos(const AValue: THeaderPos);
|
---|
205 | begin
|
---|
206 | if FHeaderPos=AValue then exit;
|
---|
207 | FHeaderPos:=AValue;
|
---|
208 |
|
---|
209 | //Paint(Self);
|
---|
210 | end;
|
---|
211 |
|
---|
212 | function TCDPanelHeader.GetHeaderVisible: Boolean;
|
---|
213 | begin
|
---|
214 | Result := Header.Visible;
|
---|
215 | end;
|
---|
216 |
|
---|
217 | procedure TCDPanelHeader.SetHeaderVisible(const AValue: Boolean);
|
---|
218 | begin
|
---|
219 | Header.Visible := AValue;
|
---|
220 | end;
|
---|
221 |
|
---|
222 | constructor TCDPanelHeader.Create(TheOwner: TComponent);
|
---|
223 | begin
|
---|
224 | inherited;
|
---|
225 | //Paint.OnPaint := Paint;
|
---|
226 | // Header.Shape.OnMouseDown := DockPanelMouseDown;
|
---|
227 | // Header.Title.OnMouseDown := DockPanelMouseDown;
|
---|
228 | HeaderPos := hpTop;
|
---|
229 | Constraints.MinHeight := GrabberSize;
|
---|
230 | Align := alClient;
|
---|
231 |
|
---|
232 | ControlPanel := TPanel.Create(Self);
|
---|
233 | with ControlPanel do begin
|
---|
234 | Parent := Self;
|
---|
235 | Visible := True;
|
---|
236 | DockSite := True;
|
---|
237 | UseDockManager := True;
|
---|
238 | Align := alClient;
|
---|
239 | BevelInner := bvNone;
|
---|
240 | BevelOuter := bvNone;
|
---|
241 | //Color := clGreen;
|
---|
242 | end;
|
---|
243 | Header := TCDHeader.Create(Self);
|
---|
244 | with Header do begin
|
---|
245 | Parent := Self;
|
---|
246 | Visible := True;
|
---|
247 | Align := alTop;
|
---|
248 | Height := GrabberSize;
|
---|
249 | //ManagerItem := Self;
|
---|
250 | end;
|
---|
251 | //OnResize := ResizeExecute;
|
---|
252 | BevelInner := bvNone;
|
---|
253 | BevelOuter := bvNone;
|
---|
254 | HeaderVisible := True;
|
---|
255 | end;
|
---|
256 |
|
---|
257 | destructor TCDPanelHeader.Destroy;
|
---|
258 | begin
|
---|
259 | inherited Destroy;
|
---|
260 | end;
|
---|
261 |
|
---|
262 | { TCDManagerItem }
|
---|
263 |
|
---|
264 | procedure TCDManagerItem.Paint(Sender: TObject);
|
---|
265 | begin
|
---|
266 | end;
|
---|
267 |
|
---|
268 | constructor TCDManagerItem.Create;
|
---|
269 | begin
|
---|
270 |
|
---|
271 | end;
|
---|
272 |
|
---|
273 | function TCDManagerItem.GetHideType: TCDHideType;
|
---|
274 | begin
|
---|
275 | Result := TCDHideType(Control.Tag);
|
---|
276 | end;
|
---|
277 |
|
---|
278 | procedure TCDManagerItem.ResizeExecute(Sender: TObject);
|
---|
279 | begin
|
---|
280 | (* if Assigned(Control) then begin
|
---|
281 | Control.Top := GrabberSize;
|
---|
282 | Control.Left := 0;
|
---|
283 | Control.Width := Width;
|
---|
284 | Control.Height := Height - GrabberSize;
|
---|
285 | //Control.SetBounds(0, GrabberSize, Width - Control.Left,
|
---|
286 | // Height - Control.Top);
|
---|
287 | end;*)
|
---|
288 | end;
|
---|
289 |
|
---|
290 | procedure TCDManagerItem.SetControl(const AValue: TWinControl);
|
---|
291 | begin
|
---|
292 | if FControl = AValue then Exit;
|
---|
293 | FControl := AValue;
|
---|
294 | end;
|
---|
295 |
|
---|
296 | procedure TCDManagerItem.SetHideType(const AValue: TCDHideType);
|
---|
297 | begin
|
---|
298 | Control.Tag := Integer(AValue);
|
---|
299 | end;
|
---|
300 |
|
---|
301 | procedure TCDManagerItem.DockPanelMouseDown(Sender: TObject;
|
---|
302 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
---|
303 | begin
|
---|
304 | if Control is TForm then begin
|
---|
305 | TForm(Control).SetFocus;
|
---|
306 | Paint(Self);
|
---|
307 | end;
|
---|
308 | if (Button = mbLeft) then begin
|
---|
309 | //(Control as TWinControl).DockSite := False;
|
---|
310 | //ClientAreaPanel.DockSite := False;
|
---|
311 | if not Manager.Locked then begin
|
---|
312 | (Control as TWinControl).BeginDrag(False, 10);
|
---|
313 | DragManager.DragStart(Control, False, 1);
|
---|
314 | end;
|
---|
315 | end;
|
---|
316 | end;
|
---|
317 |
|
---|
318 | destructor TCDManagerItem.Destroy;
|
---|
319 | begin
|
---|
320 | if Assigned(Control) then
|
---|
321 | Control.RemoveHandlerOnVisibleChanged(VisibleChange);
|
---|
322 | inherited Destroy;
|
---|
323 | end;
|
---|
324 |
|
---|
325 | procedure TCDManagerItem.VisibleChange(Sender: TObject);
|
---|
326 | begin
|
---|
327 | end;
|
---|
328 |
|
---|
329 | procedure TCDManagerItem.VisibleChanging(Sender: TObject);
|
---|
330 | begin
|
---|
331 |
|
---|
332 | end;
|
---|
333 |
|
---|
334 | { TCDManager }
|
---|
335 |
|
---|
336 | function TCDManager.FindControlInPanels(Control: TControl
|
---|
337 | ): TCDManagerItem;
|
---|
338 | begin
|
---|
339 | Result := nil;
|
---|
340 | end;
|
---|
341 |
|
---|
342 | function TCDManager.GetDockSite: TWinControl;
|
---|
343 | begin
|
---|
344 | Result := FDockSite;
|
---|
345 | end;
|
---|
346 |
|
---|
347 | function TCDManager.GetHeaderPos: THeaderPos;
|
---|
348 | begin
|
---|
349 | Result := FHeaderPos;
|
---|
350 | end;
|
---|
351 |
|
---|
352 | function TCDManager.GetMoveDuration: Integer;
|
---|
353 | begin
|
---|
354 |
|
---|
355 | end;
|
---|
356 |
|
---|
357 | constructor TCDManager.Create(ADockSite: TWinControl);
|
---|
358 | var
|
---|
359 | NewMenuItem: TMenuItem;
|
---|
360 | NewMenuItem2: TMenuItem;
|
---|
361 | begin
|
---|
362 | inherited Create(ADockSite);
|
---|
363 |
|
---|
364 | FDockSite := ADockSite;
|
---|
365 |
|
---|
366 | FreeParentIfEmpty := True;
|
---|
367 |
|
---|
368 | FDockStyle := dsList; // dsNone
|
---|
369 | FHeaderVisible := True;
|
---|
370 | PopupMenu := TCDPopupMenu.Create(Self);
|
---|
371 | PopupMenu.Parent := ADockSite;
|
---|
372 | end;
|
---|
373 |
|
---|
374 | destructor TCDManager.Destroy;
|
---|
375 | begin
|
---|
376 | PopupMenu.Free;
|
---|
377 | inherited Destroy;
|
---|
378 | end;
|
---|
379 |
|
---|
380 | procedure TCDManager.BeginUpdate;
|
---|
381 | begin
|
---|
382 | inherited BeginUpdate;
|
---|
383 | end;
|
---|
384 |
|
---|
385 | procedure TCDManager.EndUpdate;
|
---|
386 | begin
|
---|
387 | inherited EndUpdate;
|
---|
388 | end;
|
---|
389 |
|
---|
390 | procedure TCDManager.GetControlBounds(Control: TControl; out
|
---|
391 | AControlBounds: TRect);
|
---|
392 | begin
|
---|
393 | end;
|
---|
394 |
|
---|
395 | function TCDManager.GetDockEdge(ADockObject: TDragDockObject): boolean;
|
---|
396 | begin
|
---|
397 | Result := inherited GetDockEdge(ADockObject);
|
---|
398 | end;
|
---|
399 |
|
---|
400 | procedure TCDManager.InsertControl(ADockObject: TDragDockObject);
|
---|
401 | begin
|
---|
402 | inherited InsertControl(ADockObject);
|
---|
403 | end;
|
---|
404 |
|
---|
405 | procedure TCDManager.InsertControlPanel(Control: TControl; InsertAt: TAlign;
|
---|
406 | DropCtl: TControl);
|
---|
407 | begin
|
---|
408 | end;
|
---|
409 |
|
---|
410 | procedure TCDManager.InsertControl(Control: TControl; InsertAt: TAlign;
|
---|
411 | DropCtl: TControl);
|
---|
412 | var
|
---|
413 | NewSplitter: TSplitter;
|
---|
414 | NewDockPanel: TCDManagerItem;
|
---|
415 | NewPanel: TPanel;
|
---|
416 | I: Integer;
|
---|
417 | NewConjoinDockForm: TCDConjoinForm;
|
---|
418 | NewDockSite: TWinControl;
|
---|
419 | NewForm: TForm;
|
---|
420 | begin
|
---|
421 | if (FDockSite is TForm) and (not (FDockSite is TCDConjoinForm)) then begin
|
---|
422 | if (not Assigned(FDockSite.Parent)) then begin
|
---|
423 | // Create conjointed form
|
---|
424 | NewConjoinDockForm := CreateConjoinForm;
|
---|
425 | FDockSite.ManualDock(NewConjoinDockForm);
|
---|
426 | Control.ManualDock(NewConjoinDockForm, nil, InsertAt);
|
---|
427 | NewConjoinDockForm.UpdateCaption;
|
---|
428 | end else begin
|
---|
429 | NewConjoinDockForm := CreateConjoinForm;
|
---|
430 | NewDockSite := FDockSite.HostDockSite;
|
---|
431 | // FDockSite.ManualFloat(FDockSite.BoundsRect);
|
---|
432 | NewConjoinDockForm.ManualDock(NewDockSite, nil, InsertAt);
|
---|
433 | FDockSite.ManualDock(NewConjoinDockForm);
|
---|
434 | Control.ManualDock(NewConjoinDockForm, nil, InsertAt);
|
---|
435 | NewConjoinDockForm.UpdateCaption;
|
---|
436 | end;
|
---|
437 | end else
|
---|
438 | if (FDockSite is TCDConjoinForm) or (FDockSite is TPanel) then begin
|
---|
439 | InsertControlPanel(Control, InsertAt, DropCtl);
|
---|
440 | end;
|
---|
441 | if FDockSite is TCDConjoinForm then
|
---|
442 | TCDConjoinForm(FDockSite).UpdateCaption;
|
---|
443 |
|
---|
444 | // FDockPanel.Invalidate;
|
---|
445 | //inherited;
|
---|
446 | end;
|
---|
447 |
|
---|
448 | procedure TCDManager.LoadFromStream(Stream: TStream);
|
---|
449 | begin
|
---|
450 | end;
|
---|
451 |
|
---|
452 | procedure TCDManager.PaintSite(DC: HDC);
|
---|
453 | begin
|
---|
454 | end;
|
---|
455 |
|
---|
456 | procedure TCDManager.MessageHandler(Sender: TControl;
|
---|
457 | var Message: TLMessage);
|
---|
458 | begin
|
---|
459 | inherited MessageHandler(Sender, Message);
|
---|
460 | end;
|
---|
461 |
|
---|
462 | procedure TCDManager.PositionDockRect(ADockObject: TDragDockObject);
|
---|
463 | begin
|
---|
464 | inherited PositionDockRect(ADockObject);
|
---|
465 | end;
|
---|
466 |
|
---|
467 | procedure TCDManager.PositionDockRect(Client, DropCtl: TControl;
|
---|
468 | DropAlign: TAlign; var DockRect: TRect);
|
---|
469 | begin
|
---|
470 | case DropAlign of
|
---|
471 | alNone: begin
|
---|
472 | DockRect := Rect(0, 0, FDockSite.ClientWidth, FDockSite.ClientHeight);
|
---|
473 | end;
|
---|
474 | alRight: begin
|
---|
475 | DockRect := Rect(FDockSite.ClientWidth div 2, 0, FDockSite.ClientWidth, FDockSite.ClientHeight);
|
---|
476 | end;
|
---|
477 | alLeft: begin
|
---|
478 | DockRect := Rect(0, 0, FDockSite.ClientWidth div 2, FDockSite.ClientHeight);
|
---|
479 | end;
|
---|
480 | alTop: begin
|
---|
481 | DockRect := Rect(0, 0, FDockSite.ClientWidth, FDockSite.ClientHeight div 2);
|
---|
482 | end;
|
---|
483 | alBottom: begin
|
---|
484 | DockRect := Rect(0, FDockSite.ClientHeight div 2, FDockSite.ClientWidth, FDockSite.ClientHeight);
|
---|
485 | end;
|
---|
486 | end;
|
---|
487 | DockRect.TopLeft := FDockSite.ClientToScreen(DockRect.TopLeft);
|
---|
488 | DockRect.BottomRight := FDockSite.ClientToScreen(DockRect.BottomRight);
|
---|
489 | end;
|
---|
490 |
|
---|
491 | procedure TCDManager.RemoveControl(Control: TControl);
|
---|
492 | begin
|
---|
493 | if FDockSite is TCDConjoinForm then
|
---|
494 | TCDConjoinForm(FDockSite).UpdateCaption;
|
---|
495 | end;
|
---|
496 |
|
---|
497 | procedure TCDManager.ResetBounds(Force: Boolean);
|
---|
498 | var
|
---|
499 | I: Integer;
|
---|
500 | Control: TControl;
|
---|
501 | R: TRect;
|
---|
502 | begin
|
---|
503 | end;
|
---|
504 |
|
---|
505 | procedure TCDManager.SaveToStream(Stream: TStream);
|
---|
506 | begin
|
---|
507 | end;
|
---|
508 |
|
---|
509 | procedure TCDManager.SetReplacingControl(Control: TControl);
|
---|
510 | begin
|
---|
511 | inherited SetReplacingControl(Control);
|
---|
512 | end;
|
---|
513 |
|
---|
514 | function TCDManager.AutoFreeByControl: Boolean;
|
---|
515 | begin
|
---|
516 | Result := inherited AutoFreeByControl;
|
---|
517 | end;
|
---|
518 |
|
---|
519 | function TCDManager.CreateConjoinForm: TCDConjoinForm;
|
---|
520 | var
|
---|
521 | NewDockSite: TWinControl;
|
---|
522 | NewConjoinDockForm: TCDConjoinForm;
|
---|
523 | begin
|
---|
524 | NewConjoinDockForm := TCDConjoinForm.Create(Application);
|
---|
525 | NewConjoinDockForm.Name := GetUniqueName('ConjoinForm');
|
---|
526 | //NewConjoinDockForm.Visible := True;
|
---|
527 | NewConjoinDockForm.BoundsRect := FDockSite.BoundsRect;
|
---|
528 | NewConjoinDockForm.CoolDockClient.Master := Self.Master;
|
---|
529 | NewDockSite := FDockSite.HostDockSite;
|
---|
530 | // FDockSite.ManualFloat(FDockSite.BoundsRect);
|
---|
531 | //NewConjoinDockForm.ManualDock(NewDockSite, nil, InsertAt);
|
---|
532 | Result := NewConjoinDockForm;
|
---|
533 | end;
|
---|
534 |
|
---|
535 | function TCDManager.CreateDockableForm: TCDPanelForm;
|
---|
536 | var
|
---|
537 | NewClient: TCDClient;
|
---|
538 | begin
|
---|
539 | Application.CreateForm(TCDPanelForm, Result);
|
---|
540 | Result.Name := GetUniqueName('DockForm');
|
---|
541 | NewClient := TCDClient.Create(Result);
|
---|
542 | Result.Panel := TPanel.Create(Result);
|
---|
543 | Result.Panel.Parent := Result;
|
---|
544 | //Result.Panel.Visible := True;
|
---|
545 | Result.Panel.BevelInner := bvNone;
|
---|
546 | Result.Panel.BevelOuter := bvNone;
|
---|
547 | NewClient.Panel := Result.Panel;
|
---|
548 | NewClient.Master := Self.Master;
|
---|
549 | NewClient.Dockable := False;
|
---|
550 | end;
|
---|
551 |
|
---|
552 | procedure TCDManager.SetDockStyle(const AValue: TCDStyleType);
|
---|
553 | var
|
---|
554 | I: Integer;
|
---|
555 | NewManager: TCDManager;
|
---|
556 | begin
|
---|
557 | if FDockStyle <> AValue then begin
|
---|
558 | FDockStyle := AValue;
|
---|
559 | if AValue = dsTabs then begin
|
---|
560 | NewManager := TCDManagerTabs.Create(FDockSite);
|
---|
561 | end else
|
---|
562 | if AValue = dsList then begin
|
---|
563 | NewManager := TCDManagerRegions.Create(FDockSite);
|
---|
564 | end else
|
---|
565 | if AValue = dsPopupList then begin
|
---|
566 | NewManager := TCDManagerPopupRegions.Create(FDockSite);
|
---|
567 | end else
|
---|
568 | if AValue = dsPopupTabs then begin
|
---|
569 | NewManager := TCDManagerTabsPopup.Create(FDockSite);
|
---|
570 | end;
|
---|
571 | if DockSite.DockManager is TCDManager then
|
---|
572 | NewManager.Assign(TCDManager(DockSite.DockManager));
|
---|
573 | DockSite.DockManager := NewManager;
|
---|
574 | NewManager.UpdateClientSize;
|
---|
575 | end;
|
---|
576 | end;
|
---|
577 |
|
---|
578 | procedure TCDManager.SetHeaderVisible(const AValue: Boolean);
|
---|
579 | begin
|
---|
580 | if FHeaderVisible = AValue then Exit;
|
---|
581 | FHeaderVisible := AValue;
|
---|
582 | if Assigned(DockSite.HostDockSite) then
|
---|
583 | TCDManager(DockSite.HostDockSite.DockManager).UpdateClientSize;
|
---|
584 | end;
|
---|
585 |
|
---|
586 | procedure TCDManager.SetHeaderPos(const AValue: THeaderPos);
|
---|
587 | begin
|
---|
588 | FHeaderPos := AValue;
|
---|
589 | end;
|
---|
590 |
|
---|
591 | procedure TCDManager.SetMoveDuration(const AValue: Integer);
|
---|
592 | begin
|
---|
593 | end;
|
---|
594 |
|
---|
595 | procedure TCDManager.SetVisible(const AValue: Boolean);
|
---|
596 | begin
|
---|
597 | end;
|
---|
598 |
|
---|
599 | procedure TCDManager.UpdateClientSize;
|
---|
600 | begin
|
---|
601 | end;
|
---|
602 |
|
---|
603 | procedure TCDManager.Switch(Index: Integer);
|
---|
604 | begin
|
---|
605 |
|
---|
606 | end;
|
---|
607 |
|
---|
608 | procedure TCDManager.ChangeVisible(Control: TWinControl; Visible: Boolean);
|
---|
609 | begin
|
---|
610 |
|
---|
611 | end;
|
---|
612 |
|
---|
613 | procedure TCDManager.Assign(Source: TCDManager);
|
---|
614 | begin
|
---|
615 | FDockStyle := Source.FDockStyle;
|
---|
616 | FDockSite := Source.FDockSite;
|
---|
617 | end;
|
---|
618 |
|
---|
619 | { TCDHeader }
|
---|
620 |
|
---|
621 | constructor TCDHeader.Create(TheOwner: TComponent);
|
---|
622 | var
|
---|
623 | NewButton: TCDHeaderButton;
|
---|
624 | begin
|
---|
625 | inherited Create(TheOwner);
|
---|
626 | OnPaint := PaintExecute;
|
---|
627 | //MyFont := CreateRotatedFont(Canvas.Font, 90);
|
---|
628 |
|
---|
629 | Buttons := TObjectList.Create;
|
---|
630 |
|
---|
631 | NewButton := TCDHeaderButton.Create;
|
---|
632 | with NewButton do begin
|
---|
633 | DataModule2.ImageList1.GetBitmap(0, Icon.Picture.Bitmap);
|
---|
634 | Icon.Parent := Self;
|
---|
635 | Icon.OnClick := CloseButtonClick;
|
---|
636 | Visible := True;
|
---|
637 | end;
|
---|
638 | Buttons.Add(NewButton);
|
---|
639 | NewButton := TCDHeaderButton.Create;
|
---|
640 | with NewButton do begin
|
---|
641 | DataModule2.ImageList1.GetBitmap(1, Icon.Picture.Bitmap);
|
---|
642 | Icon.Parent := Self;
|
---|
643 | Icon.OnClick := nil;
|
---|
644 | Visible := False;
|
---|
645 | end;
|
---|
646 | Buttons.Add(NewButton);
|
---|
647 | NewButton := TCDHeaderButton.Create;
|
---|
648 | with NewButton do begin
|
---|
649 | DataModule2.ImageList1.GetBitmap(2, Icon.Picture.Bitmap);
|
---|
650 | Icon.Parent := Self;
|
---|
651 | Icon.OnClick := nil;
|
---|
652 | Visible := False;
|
---|
653 | end;
|
---|
654 | Buttons.Add(NewButton);
|
---|
655 | RearrangeButtons;
|
---|
656 |
|
---|
657 | Icon := TImage.Create(Self);
|
---|
658 | with Icon do begin
|
---|
659 | Parent := Self;
|
---|
660 | Left := 4;
|
---|
661 | Top := 2;
|
---|
662 | Visible := True;
|
---|
663 | end;
|
---|
664 |
|
---|
665 | BevelInner := bvNone;
|
---|
666 | BevelOuter := bvNone;
|
---|
667 | end;
|
---|
668 |
|
---|
669 | destructor TCDHeader.Destroy;
|
---|
670 | begin
|
---|
671 | Buttons.Free;
|
---|
672 | inherited Destroy;
|
---|
673 | end;
|
---|
674 |
|
---|
675 | procedure TCDHeader.PaintExecute(Sender: TObject);
|
---|
676 | const
|
---|
677 | Corner: Integer = 2;
|
---|
678 | Border: Integer = 1;
|
---|
679 | BorderColor: TColor = $B9C3C6;
|
---|
680 | TopColor: TColor = $CFD6D9;
|
---|
681 | BottomColor: TColor = $DAE0E1;
|
---|
682 | var
|
---|
683 | Points: array of TPoint;
|
---|
684 | TitleLeft: Integer;
|
---|
685 | TitleWidth: Integer;
|
---|
686 | TitleMaxWidth: Integer;
|
---|
687 | I: Integer;
|
---|
688 | Title: string;
|
---|
689 | R: TRect;
|
---|
690 | begin
|
---|
691 | if Assigned(Control) and Assigned(TWinControl(Control).DockManager) then
|
---|
692 | with TCDManager(TWinControl(Control).DockManager) do
|
---|
693 | case HeaderPos of
|
---|
694 | hpLeft: begin
|
---|
695 | Align := alLeft;
|
---|
696 | Width := GrabberSize;
|
---|
697 | end;
|
---|
698 | hpTop, hpAuto: begin
|
---|
699 | Align := alTop;
|
---|
700 | Height := GrabberSize;
|
---|
701 | end;
|
---|
702 | hpRight: begin
|
---|
703 | Align := alRight;
|
---|
704 | Width := GrabberSize;
|
---|
705 | end;
|
---|
706 | hpBottom: begin
|
---|
707 | Align := alBottom;
|
---|
708 | Height := GrabberSize;
|
---|
709 | end;
|
---|
710 | end;
|
---|
711 |
|
---|
712 | if Assigned(Control) then
|
---|
713 | if (Control as TWinControl).Focused then
|
---|
714 | Canvas.Font.Style := Canvas.Font.Style + [fsBold]
|
---|
715 | else Canvas.Font.Style := Canvas.Font.Style - [fsBold];
|
---|
716 |
|
---|
717 | RearrangeButtons;
|
---|
718 |
|
---|
719 | with Canvas do begin
|
---|
720 | GradientFill(Rect(Border, Border, Width - Border,
|
---|
721 | Height - Border), TopColor, BottomColor, gdVertical);
|
---|
722 | Brush.Color := clBtnFace;
|
---|
723 | Brush.Style := bsSolid;
|
---|
724 | Pen.Color := clBtnFace;
|
---|
725 | Pen.Style := psSolid;
|
---|
726 | SetLength(Points, 3);
|
---|
727 | Points[0] := Point(Border, Border);
|
---|
728 | Points[1] := Point(Border, Border + Corner);
|
---|
729 | Points[2] := Point(Border + Corner, Border);
|
---|
730 | Polygon(Points);
|
---|
731 | Points[0] := Point(Width - 1 - Border, Border);
|
---|
732 | Points[1] := Point(Width - 1 - Border, Border + Corner);
|
---|
733 | Points[2] := Point(Width - 1 - Border - Corner, Border);
|
---|
734 | Polygon(Points);
|
---|
735 | Points[0] := Point(Border, Height - 1 - Border);
|
---|
736 | Points[1] := Point(Border, Height - 1 - Border - Corner);
|
---|
737 | Points[2] := Point(Border + Corner, Height - 1 - Border);
|
---|
738 | Polygon(Points);
|
---|
739 | Points[0] := Point(Width - 1 - Border, Height - 1 - Border);
|
---|
740 | Points[1] := Point(Width - 1 - Border, Height - 1 - Border - Corner);
|
---|
741 | Points[2] := Point(Width - 1 - Border - Corner, Height - 1 - Border);
|
---|
742 | Polygon(Points);
|
---|
743 |
|
---|
744 | SetLength(Points, 9);
|
---|
745 | Points[0] := Point(Border, Border + Corner);
|
---|
746 | Points[1] := Point(Border + Corner, Border);
|
---|
747 | Points[2] := Point(Width - 1 - Border - Corner, Border);
|
---|
748 | Points[3] := Point(Width - 1 - Border, Border + Corner);
|
---|
749 | Points[4] := Point(Width - 1 - Border, Height - 1 - Border - Corner);
|
---|
750 | Points[5] := Point(Width - 1 - Border - Corner, Height - 1 - Border);
|
---|
751 | Points[6] := Point(Border + Corner, Height - 1 - Border);
|
---|
752 | Points[7] := Point(Border, Height - 1 - Border - Corner);
|
---|
753 | Points[8] := Point(Border, Border + Corner);
|
---|
754 | Pen.Color := BorderColor;
|
---|
755 | Polyline(Points);
|
---|
756 |
|
---|
757 | Canvas.Brush.Style := bsClear;
|
---|
758 | TitleMaxWidth := Self.Width - 6;
|
---|
759 | for I := 0 to Buttons.Count - 1 do
|
---|
760 | if TCDHeaderButton(Buttons[I]).Visible then
|
---|
761 | Dec(TitleMaxWidth, TCDHeaderButton(Buttons[I]).Icon.Width + 2);
|
---|
762 | if Icon.Picture.Width > 0 then begin
|
---|
763 | TitleLeft := 8 + Icon.Picture.Width;
|
---|
764 | Dec(TitleMaxWidth, Icon.Picture.Width + 2)
|
---|
765 | end else TitleLeft := 6;
|
---|
766 |
|
---|
767 | //SelectObject(Canvas.Handle, MyFont);
|
---|
768 | if Assigned(Control) then
|
---|
769 | Title := Control.Caption else Title := '';
|
---|
770 | if (TextWidth(Title) > TitleMaxWidth) then begin
|
---|
771 | while (Length(Title) > 0) and (TextWidth(Title + '...') > TitleMaxWidth) do begin
|
---|
772 | Delete(Title, Length(Title), 1);
|
---|
773 | end;
|
---|
774 | Title := Title + '...';
|
---|
775 | end;
|
---|
776 |
|
---|
777 | R := Rect(TitleLeft, 4, TitleLeft + TitleMaxWidth, 4 + TextHeight(Title));
|
---|
778 | TextRect(R, TitleLeft, 4, Title);
|
---|
779 | end;
|
---|
780 | end;
|
---|
781 |
|
---|
782 | procedure TCDHeader.RearrangeButtons;
|
---|
783 | const
|
---|
784 | Separation: Integer = 4;
|
---|
785 | var
|
---|
786 | LeftPos: Integer;
|
---|
787 | I: Integer;
|
---|
788 | begin
|
---|
789 | LeftPos := Self.Width;
|
---|
790 | for I := 0 to Buttons.Count - 1 do
|
---|
791 | with TCDHeaderButton(Buttons[I]) do
|
---|
792 | if Visible then begin
|
---|
793 | Icon.Anchors := [akRight, akTop];
|
---|
794 | //Icon.Picture.Bitmap.SetSize(16, 16);
|
---|
795 | Icon.Width := Icon.Picture.Bitmap.Width;
|
---|
796 | Icon.Height := Icon.Picture.Bitmap.Height;
|
---|
797 | LeftPos := LeftPos - Icon.Width - Separation;
|
---|
798 | Icon.Left := LeftPos;
|
---|
799 | Icon.Top := (GrabberSize - Icon.Height) div 2;
|
---|
800 |
|
---|
801 | //ShowMessage(IntToStr(Icon.Width) + ' ' + InttoStr(Icon.Height));
|
---|
802 | Icon.Visible := True;
|
---|
803 | end else Icon.Visible := False;
|
---|
804 | end;
|
---|
805 |
|
---|
806 | procedure TCDHeader.CloseButtonClick(Sender: TObject);
|
---|
807 | begin
|
---|
808 | if Assigned(Control) then
|
---|
809 | Control.Hide;
|
---|
810 | end;
|
---|
811 |
|
---|
812 | end.
|
---|
813 |
|
---|