-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJvDockSupportControl.pas
3667 lines (3342 loc) · 106 KB
/
JvDockSupportControl.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvDockSupportControl.pas, released on 2003-12-31.
The Initial Developer of the Original Code is luxiaoban.
Portions created by luxiaoban are Copyright (C) 2002, 2003 luxiaoban.
All Rights Reserved.
Contributor(s):
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvDockSupportControl;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Messages, Windows, CommCtrl, Graphics, Controls, Forms, ImgList, Classes, ExtCtrls,
ComCtrls,
{$IFDEF HAS_UNIT_SYSTEM_UITYPES}
System.UITypes,
{$ENDIF HAS_UNIT_SYSTEM_UITYPES}
JvComponent, JvAppStorage,
JvDockTree;
type
TJvAlphaBlendedForm = class(TForm)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
TJvDockDragDockObject = class(TObject)
private
// FDockClient:TObject;{NEW: Opaque reference to TJvDockClient}
FMouseDeltaX: Double;
FMouseDeltaY: Double;
FControl: TControl;
FDragTarget: Pointer;
FDragPos: TPoint;
FDropOnControl: TControl;
FDropAlign: TAlign;
FDragHandle: THandle;
FDragTargetPos: TPoint;
FCancelling: Boolean;
FFloating: Boolean;
FFrameWidth: Integer;
FBrush: TBrush;
FCtrlDown: Boolean;
FDockRect: TRect;
FEraseDockRect: TRect;
FAlphaBlendedForm: TJvAlphaBlendedForm;
FAlphaBlendedTab: TJvAlphaBlendedForm;
procedure SetBrush(const Value: TBrush);
procedure SetDropAlign(const Value: TAlign);
procedure SetDropOnControl(const Value: TControl);
function GetTargetControl: TWinControl;
procedure SetTargetControl(const Value: TWinControl);
function GetAlphaBlendedTab: TJvAlphaBlendedForm;
protected
property AlphaBlendedForm: TJvAlphaBlendedForm read FAlphaBlendedForm;
property AlphaBlendedTab: TJvAlphaBlendedForm read GetAlphaBlendedTab;
procedure DefaultDockImage(Erase: Boolean); virtual;
procedure DrawDragRect(DoErase: Boolean); virtual;
procedure GetBrush_PenSize_DrawRect(var ABrush: TBrush; var PenSize: Integer;
var DrawRect: TRect; Erase: Boolean); virtual;
function GetFrameWidth: Integer; virtual;
procedure SetFrameWidth(const Value: Integer); virtual;
procedure MouseMsg(var Msg: TMessage); virtual;
function CanLeave(NewTarget: TWinControl): Boolean; virtual;
public
constructor Create(AControl: TControl); virtual;
destructor Destroy; override;
procedure AdjustDockRect(const ARect: TRect); virtual;
function Capture: THandle;
function DragFindWindow(const Pos: TPoint): THandle; virtual;
procedure ReleaseCapture(Handle: THandle);
procedure EndDrag(Target: TObject; X, Y: Integer); virtual;
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); virtual;
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; virtual;
function GetDragImages: TDragImageList; virtual;
procedure DrawDragDockImage; virtual;
procedure EraseDragDockImage; virtual;
function GetDropCtl: TControl; virtual;
property MouseDeltaX: Double read FMouseDeltaX write FMouseDeltaX;
property MouseDeltaY: Double read FMouseDeltaY write FMouseDeltaY;
property Control: TControl read FControl write FControl;
property DockRect: TRect read FDockRect write FDockRect;
property DragTarget: Pointer read FDragTarget write FDragTarget;
property DragPos: TPoint read FDragPos write FDragPos;
property DropOnControl: TControl read FDropOnControl write SetDropOnControl;
property DropAlign: TAlign read FDropAlign write SetDropAlign;
property DragHandle: THandle read FDragHandle write FDragHandle;
property DragTargetPos: TPoint read FDragTargetPos write FDragTargetPos;
property EraseDockRect: TRect read FEraseDockRect;
property Cancelling: Boolean read FCancelling write FCancelling;
property Floating: Boolean read FFloating write FFloating;
property FrameWidth: Integer read GetFrameWidth write SetFrameWidth;
property Brush: TBrush read FBrush write SetBrush;
property CtrlDown: Boolean read FCtrlDown write FCtrlDown;
property TargetControl: TWinControl read GetTargetControl write SetTargetControl;
{DockClient: Opaque reference to TJvDockClient. Nil if none.}
// property DockClient:TObject read FDockClient write FDockClient;
end;
TJvDockCustomControl = class(TJvCustomControl)
private
function GetJvDockManager: IJvDockManager;
protected
procedure WndProc(var Msg: TMessage); override;
procedure CustomStartDock(var Source: TJvDockDragDockObject); virtual;
procedure CustomGetSiteInfo(Source: TJvDockDragDockObject;
Client: TControl; var InfluenceRect: TRect; MousePos: TPoint;
var CanDock: Boolean); virtual;
procedure CustomDockOver(Source: TJvDockDragDockObject; X, Y: Integer;
State: TDragState; var Accept: Boolean); virtual;
procedure CustomPositionDockRect(Source: TJvDockDragDockObject; X, Y: Integer); virtual;
procedure CustomDockDrop(Source: TJvDockDragDockObject; X, Y: Integer); virtual;
procedure CustomEndDock(Target: TObject; X, Y: Integer); virtual;
function CustomUnDock(Source: TJvDockDragDockObject; NewTarget: TWinControl; Client: TControl): Boolean; virtual;
procedure CustomGetDockEdge(Source: TJvDockDragDockObject; MousePos: TPoint; var DropAlign: TAlign); virtual;
public
procedure UpdateCaption(Exclude: TControl); virtual;
property DockManager;
property JvDockManager: IJvDockManager read GetJvDockManager{ write SetJvDockManager};
end;
TJvDockCustomPanel = class(TJvDockCustomControl)
protected
function CreateDockManager: IDockManager; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property DockSite;
end;
TJvDockCustomTabControl = class;
TJvDockTabStrings = class(TStrings)
private
FTabControl: TJvDockCustomTabControl;
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetObject(Index: Integer): TObject; override;
procedure Put(Index: Integer; const S: string); override;
procedure PutObject(Index: Integer; AObject: TObject); override;
procedure SetUpdateState(Updating: Boolean); override;
public
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
end;
TJvDockDrawTabEvent = procedure(Control: TJvDockCustomTabControl; TabIndex: Integer;
const Rect: TRect; Active: Boolean) of object;
TJvDockPageControl = class;
TJvDockCustomTabControl = class(TJvDockCustomControl)
private
FHotTrack: Boolean;
FImageChangeLink: TChangeLink;
FImages: TCustomImageList;
FMultiLine: Boolean;
FMultiSelect: Boolean;
FOwnerDraw: Boolean;
FRaggedRight: Boolean;
FSaveTabIndex: Integer;
FSaveTabs: TStringList;
FScrollOpposite: Boolean;
FStyle: TTabStyle;
FTabPosition: TTabPosition;
FTabs: TJvDockTabStrings;
FTabSize: TSmallPoint;
FUpdating: Boolean;
FSavedAdjustRect: TRect;
FOnChange: TNotifyEvent;
FOnChanging: TTabChangingEvent;
FOnDrawTab: TJvDockDrawTabEvent;
FOnGetImageIndex: TTabGetImageEvent;
function GetDisplayRect: TRect;
function GetTabIndex: Integer;
function GetTabs: TStrings;
procedure ImageListChange(Sender: TObject);
function InternalSetMultiLine(Value: Boolean): Boolean;
procedure SetMultiLine(Value: Boolean);
procedure SetMultiSelect(Value: Boolean);
procedure SetOwnerDraw(Value: Boolean);
procedure SetRaggedRight(Value: Boolean);
procedure SetScrollOpposite(Value: Boolean);
procedure SetStyle(Value: TTabStyle);
procedure SetTabIndex(Value: Integer);
procedure SetTabs(Value: TStrings);
procedure SetTabWidth(Value: Smallint);
procedure TabsChanged;
procedure UpdateTabSize;
procedure CMFontChanged(var Msg); message CM_FONTCHANGED;
procedure CMSysColorChange(var Msg: TMessage); message CM_SYSCOLORCHANGE;
procedure CMTabStopChanged(var Msg: TMessage); message CM_TABSTOPCHANGED;
procedure CNNotify(var Msg: TWMNotify); message CN_NOTIFY;
procedure CMDialogChar(var Msg: TCMDialogChar); message CM_DIALOGCHAR;
procedure CNDrawItem(var Msg: TWMDrawItem); message CN_DRAWITEM;
procedure TCMAdjustRect(var Msg: TMessage); message TCM_ADJUSTRECT;
procedure WMDestroy(var Msg: TWMDestroy); message WM_DESTROY;
procedure WMNotifyFormat(var Msg: TMessage); message WM_NOTIFYFORMAT;
procedure WMSize(var Msg: TMessage); message WM_SIZE;
protected
procedure AdjustClientRect(var Rect: TRect); override;
function CanChange: Boolean; dynamic;
function CanShowTab(TabIndex: Integer): Boolean; virtual;
procedure Change; dynamic;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean); virtual;
function GetImageIndex(TabIndex: Integer): Integer; virtual;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure PaintWindow(DC: HDC); override;
procedure SetHotTrack(Value: Boolean); virtual;
procedure SetImages(Value: TCustomImageList); virtual;
procedure SetTabHeight(Value: Smallint); virtual;
procedure SetTabPosition(Value: TTabPosition); virtual;
procedure UpdateTabImages;
property DisplayRect: TRect read GetDisplayRect;
property HotTrack: Boolean read FHotTrack write SetHotTrack default False;
property Images: TCustomImageList read FImages write SetImages;
property MultiLine: Boolean read FMultiLine write SetMultiLine default False;
property MultiSelect: Boolean read FMultiSelect write SetMultiSelect default False;
property OwnerDraw: Boolean read FOwnerDraw write SetOwnerDraw default False;
property RaggedRight: Boolean read FRaggedRight write SetRaggedRight default False;
property ScrollOpposite: Boolean read FScrollOpposite
write SetScrollOpposite default False;
property Style: TTabStyle read FStyle write SetStyle default tsTabs;
property TabHeight: Smallint read FTabSize.Y write SetTabHeight default 0;
property TabIndex: Integer read GetTabIndex write SetTabIndex default -1;
property TabPosition: TTabPosition read FTabPosition write SetTabPosition default tpTop;
property Tabs: TStrings read GetTabs write SetTabs;
property TabWidth: Smallint read FTabSize.X write SetTabWidth default 0;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChanging: TTabChangingEvent read FOnChanging write FOnChanging;
property OnDrawTab: TJvDockDrawTabEvent read FOnDrawTab write FOnDrawTab;
property OnGetImageIndex: TTabGetImageEvent read FOnGetImageIndex write FOnGetImageIndex;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function IndexOfTabAt(X, Y: Integer): Integer;
function GetHitTestInfoAt(X, Y: Integer): THitTests;
function TabRect(Index: Integer): TRect;
function RowCount: Integer;
procedure ScrollTabs(Delta: Integer);
property TabStop default True;
end;
TJvDockTabSheet = class(TJvWinControl)
private
FImageIndex: TImageIndex;
FPageControl: TJvDockPageControl;
FTabVisible: Boolean;
FTabShowing: Boolean;
FHighlighted: Boolean;
FOnHide: TNotifyEvent;
FOnShow: TNotifyEvent;
function GetPageIndex: Integer;
function GetTabIndex: Integer;
procedure SetHighlighted(Value: Boolean);
procedure SetImageIndex(Value: TImageIndex);
procedure SetPageIndex(Value: Integer);
procedure SetTabShowing(Value: Boolean);
procedure SetTabVisible(Value: Boolean);
procedure CMTextChanged(var Msg: TMessage); message CM_TEXTCHANGED;
procedure CMShowingChanged(var Msg: TMessage); message CM_SHOWINGCHANGED;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure SetPageControl(APageControl: TJvDockPageControl); virtual;
procedure ReadState(Reader: TReader); override;
procedure DoHide; dynamic;
procedure DoShow; dynamic;
procedure UpdateTabShowing; dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property PageControl: TJvDockPageControl read FPageControl write SetPageControl;
property TabIndex: Integer read GetTabIndex;
published
property Caption;
property Height stored False;
property Highlighted: Boolean read FHighlighted write SetHighlighted default False;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
property Left stored False;
property PageIndex: Integer read GetPageIndex write SetPageIndex stored False;
property TabVisible: Boolean read FTabVisible write SetTabVisible default True;
property Top stored False;
property Visible stored False;
property Width stored False;
property OnHide: TNotifyEvent read FOnHide write FOnHide;
property OnShow: TNotifyEvent read FOnShow write FOnShow;
end;
TJvDockTabSheetClass = class of TJvDockTabSheet;
TJvDockPageControl = class(TJvDockCustomTabControl)
private
FPages: TList;
FActivePage: TJvDockTabSheet;
FNewDockSheet: TJvDockTabSheet;
FUndockingPage: TJvDockTabSheet;
FTabSheetClass: TJvDockTabSheetClass;
procedure ChangeActivePage(Page: TJvDockTabSheet);
procedure DeleteTab(Page: TJvDockTabSheet; Index: Integer);
function GetActivePageIndex: Integer;
function GetPage(Index: Integer): TJvDockTabSheet;
function GetCount: Integer;
procedure InsertPage(Page: TJvDockTabSheet);
procedure InsertTab(Page: TJvDockTabSheet);
procedure MoveTab(CurIndex, NewIndex: Integer);
procedure RemovePage(Page: TJvDockTabSheet);
procedure SetActivePageIndex(const Value: Integer);
procedure UpdateTab(Page: TJvDockTabSheet);
procedure UpdateTabHighlights;
procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY;
procedure CMDockClient(var Msg: TCMDockClient); message CM_DOCKCLIENT;
procedure CMDockNotification(var Msg: TCMDockNotification); message CM_DOCKNOTIFICATION;
procedure CMUnDockClient(var Msg: TCMUnDockClient); message CM_UNDOCKCLIENT;
procedure WMLButtonDown(var Msg: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMLButtonDblClk(var Msg: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure WMLButtonUp(var Msg: TWMLButtonUp); message WM_LBUTTONUP;
procedure WMRButtonDown(var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
procedure WMRButtonDblClk(var Msg: TWMRButtonDblClk); message WM_RBUTTONDBLCLK;
procedure WMRButtonUp(var Msg: TWMRButtonUp); message WM_RBUTTONUP;
procedure WMMButtonDown(var Msg: TWMMButtonDown); message WM_MBUTTONDOWN;
procedure WMMButtonDblClk(var Msg: TWMMButtonDblClk); message WM_MBUTTONDBLCLK;
procedure WMMButtonUp(var Msg: TWMMButtonUp); message WM_MBUTTONUP;
protected
function CanShowTab(TabIndex: Integer): Boolean; override;
procedure Change; override;
procedure DoAddDockClient(Client: TControl; const ARect: TRect); override;
procedure DockOver(Source: TDragDockObject; X, Y: Integer;
State: TDragState; var Accept: Boolean); override;
function DoMouseEvent(var Msg: TWMMouse; Control: TControl): TWMNCHitMessage; virtual;
procedure DoRemoveDockClient(Client: TControl); override;
function GetDockClientFromMousePos(MousePos: TPoint): TControl; virtual;
function GetImageIndex(TabIndex: Integer): Integer; override;
function GetPageFromDockClient(Client: TControl): TJvDockTabSheet;
procedure GetSiteInfo(Client: TControl; var InfluenceRect: TRect;
MousePos: TPoint; var CanDock: Boolean); override;
procedure Loaded; override;
procedure SetActivePage(Page: TJvDockTabSheet); virtual;
procedure ShowControl(AControl: TControl); override;
procedure UpdateActivePage; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override; // public in D2009
function FindNextPage(CurPage: TJvDockTabSheet;
GoForward, CheckTabVisible: Boolean): TJvDockTabSheet;
procedure SelectNextPage(GoForward: Boolean; CheckTabVisible: Boolean = True);
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
property ActivePage: TJvDockTabSheet read FActivePage write SetActivePage;
property ActivePageIndex: Integer read GetActivePageIndex
write SetActivePageIndex;
property Count: Integer read GetCount;
property Pages[Index: Integer]: TJvDockTabSheet read GetPage;
property PageSheets: TList read FPages;
property TabSheetClass: TJvDockTabSheetClass read FTabSheetClass write FTabSheetClass;
end;
TJvDockDragOperation = (dopNone, dopDrag, dopDock);
PSiteInfoRec = ^TSiteInfoRec;
TSiteInfoRec = record
Site: TWinControl;
TopParent: THandle;
end;
TSiteList = class(TList)
public
procedure AddSite(ASite: TWinControl);
procedure Clear; override;
function Find(ParentWnd: THandle; var Index: Integer): Boolean;
function GetTopSite: TWinControl;
end;
TJvDockManager = class(TObject)
private
FLoadCount: Integer;
FSaveCount: Integer;
FDragObject: TJvDockDragDockObject;
FDragControl: TControl;
FDragFreeObject: Boolean;
FDragCapture: THandle;
FDragStartPos: TPoint;
FDragSaveCursor: HCURSOR;
FDragThreshold: Integer;
FActiveDrag: TJvDockDragOperation;
FDragImageList: TDragImageList;
FDockSiteList: TList;
FQualifyingSites: TSiteList;
procedure BeginLoad;
procedure EndLoad;
procedure BeginSave;
procedure EndSave;
public
procedure CalcDockSizes(Control: TControl);
constructor Create; virtual;
destructor Destroy; override;
function IsDockLoading: Boolean;
function IsSaving: Boolean;
procedure ShowDockForm(DockWindow: TWinControl);
procedure HideDockForm(DockWindow: TWinControl);
function GetFormVisible(DockWindow: TWinControl): Boolean;
procedure SetTabDockHostBorderStyle(Value: TFormBorderStyle);
procedure SetConjoinDockHostBorderStyle(Value: TFormBorderStyle);
procedure SaveDockTreeToAppStorage(AppStorage: TJvCustomAppStorage; const AppStoragePath: string = '');
procedure LoadDockTreeFromAppStorage(AppStorage: TJvCustomAppStorage; const AppStoragePath: string = '');
procedure BeginDrag(Control: TControl; Immediate: Boolean; Threshold: Integer = -1); virtual;
procedure DragInitControl(Control: TControl; Immediate: Boolean; Threshold: Integer); virtual;
procedure DragInit(ADragObject: TJvDockDragDockObject; Immediate: Boolean; Threshold: Integer); virtual;
procedure DragTo(const Pos: TPoint); virtual;
procedure DragDone(Drop: Boolean); virtual;
procedure CancelDrag; virtual;
procedure ResetCursor; virtual;
function DragFindTarget(const Pos: TPoint; var Handle: THandle;
DragKind: TDragKind; Client: TControl): Pointer; virtual;
procedure DoGetSiteInfo(Target, Client: TControl; var InfluenceRect: TRect;
MousePos: TPoint; var CanDock: Boolean); virtual;
function DoDockOver(DragState: TDragState): Boolean; virtual;
procedure DoDockDrop(Source: TJvDockDragDockObject; Pos: TPoint); virtual;
function DoUnDock(Source: TJvDockDragDockObject; Target: TWinControl; Client: TControl): Boolean; virtual;
procedure DoEndDrag(Target: TObject; X, Y: Integer); virtual;
function DragFindWindow(const Pos: TPoint): THandle; virtual;
function GetDockSiteAtPos(MousePos: TPoint; Client: TControl): TWinControl; virtual;
procedure DoGetDockEdge(Target: TControl; MousePos: TPoint; var DropAlign: TAlign); virtual;
procedure RegisterDockSite(Site: TWinControl; DoRegister: Boolean); virtual;
property DragObject: TJvDockDragDockObject read FDragObject write FDragObject;
end;
TJvDockCustomPanelSplitter = class(TJvGraphicControl)
private
FActiveControl: TWinControl;
FAutoSnap: Boolean;
FBeveled: Boolean;
FBrush: TBrush;
FControl: TControl;
FDownPos: TPoint;
FLineDC: HDC;
FLineVisible: Boolean;
FMinSize: NaturalNumber;
FMaxSize: Integer;
FNewSize: Integer;
FOldKeyDown: TKeyEvent;
FOldSize: Integer;
FPrevBrush: HBRUSH;
FResizeStyle: TResizeStyle;
FSplit: Integer;
FOnCanResize: TCanResizeEvent;
FOnMoved: TNotifyEvent;
FOnPaint: TNotifyEvent;
procedure AllocateLineDC;
procedure CalcSplitSize(X, Y: Integer; var NewSize, Split: Integer);
procedure DrawLine;
procedure FocusKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ReleaseLineDC;
procedure SetBeveled(Value: Boolean);
procedure UpdateControlSize;
procedure UpdateSize(X, Y: Integer);
protected
function CanResize(var NewSize: Integer): Boolean; reintroduce; virtual;
function DoCanResize(var NewSize: Integer): Boolean; virtual;
function FindControl: TControl; virtual;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure Paint; override;
procedure RequestAlign; override;
procedure StopSizing; dynamic;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas;
published
property Align default alLeft;
property AutoSnap: Boolean read FAutoSnap write FAutoSnap default True;
property Beveled: Boolean read FBeveled write SetBeveled default False;
property Color;
property Constraints;
property MinSize: NaturalNumber read FMinSize write FMinSize default 30;
property ParentColor;
property ResizeStyle: TResizeStyle read FResizeStyle write FResizeStyle
default rsPattern;
property Visible;
property OnCanResize: TCanResizeEvent read FOnCanResize write FOnCanResize;
property OnMoved: TNotifyEvent read FOnMoved write FOnMoved;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
Types, ComStrs, Consts, SysUtils,
{$IFNDEF COMPILER12_UP}
JvJCLUtils,
{$ENDIF ~COMPILER12_UP}
JvDockGlobals, JvDockControlForm, JvDockSupportProc, JvJVCLUtils;
type
TlbNCButtonProc = procedure(Msg: TWMNCHitMessage; Button: TMouseButton;
MouseStation: TJvDockMouseStation) of object;
PCheckTargetInfo = ^TCheckTargetInfo;
TCheckTargetInfo = record
ClientWnd: THandle;
TargetWnd: THandle;
CurrentWnd: THandle;
MousePos: TPoint;
Found: Boolean;
end;
TControlAccessProtected = class(TControl);
TWinControlAccessProtected = class(TWinControl);
//=== Local procedures =======================================================
function ButtonEvent(Page: TJvDockPageControl; Msg: TWMMouse;
Button: TMouseButton; MouseStation: TJvDockMouseStation; Proc: TlbNCButtonProc): TControl;
begin
Result := Page.GetDockClientFromMousePos(SmallPointToPoint(Msg.Pos));
if (Result <> nil) and Assigned(Proc) then
begin
JvGlobalDockClient := FindDockClient(Result);
Proc(Page.DoMouseEvent(Msg, Page), Button, MouseStation);
end;
end;
procedure TabControlError(const S: string);
begin
raise EListError.Create(S);
end;
procedure SetComCtlStyle(Ctl: TWinControl; Value: Integer; UseStyle: Boolean);
var
Style: Integer;
begin
if Ctl.HandleAllocated then
begin
Style := GetWindowLong(Ctl.Handle, GWL_STYLE);
if not UseStyle then
Style := Style and not Value
else
Style := Style or Value;
SetWindowLong(Ctl.Handle, GWL_STYLE, Style);
end;
end;
function IsBeforeTargetWindow(Window: HWND; Data: Longint): Bool; stdcall;
var
R: TRect;
begin
if Window = PCheckTargetInfo(Data)^.TargetWnd then
Result := False
else
begin
if PCheckTargetInfo(Data)^.CurrentWnd = 0 then
begin
GetWindowRect(Window, R);
if PtInRect(R, PCheckTargetInfo(Data)^.MousePos) then
PCheckTargetInfo(Data)^.CurrentWnd := Window;
end;
if Window = PCheckTargetInfo(Data)^.CurrentWnd then
begin
Result := False;
PCheckTargetInfo(Data)^.Found := True;
end
else
if Window = PCheckTargetInfo(Data)^.ClientWnd then
begin
Result := True;
PCheckTargetInfo(Data)^.CurrentWnd := 0;
end
else
Result := True;
end;
end;
//=== { TJvDockCustomControl } ===============================================
procedure TJvDockCustomControl.CustomDockDrop(Source: TJvDockDragDockObject;
X, Y: Integer);
var
DestRect: TRect;
Form: TCustomForm;
begin
DestRect := Source.DockRect;
MapWindowPoints(0, Handle, DestRect, 2);
DisableAlign;
try
Source.Control.Dock(Self, DestRect);
if UseDockManager and (DockManager <> nil) then
DockManager.InsertControl(Source.Control,
Source.DropAlign, Source.DropOnControl);
finally
EnableAlign;
end;
Form := GetParentForm(Self);
if Form <> nil then
Form.BringToFront;
if Source.Control is TForm then
begin
TForm(Source.Control).ActiveControl := nil;
SetDockSite(TForm(Source.Control), False);
end;
end;
procedure TJvDockCustomControl.CustomDockOver(Source: TJvDockDragDockObject;
X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
CustomPositionDockRect(Source, X, Y);
end;
procedure TJvDockCustomControl.CustomEndDock(Target: TObject; X, Y: Integer);
begin
end;
procedure TJvDockCustomControl.CustomGetDockEdge(Source: TJvDockDragDockObject;
MousePos: TPoint; var DropAlign: TAlign);
begin
DropAlign := GetDockEdge(MousePos);
end;
procedure TJvDockCustomControl.CustomGetSiteInfo(Source: TJvDockDragDockObject;
Client: TControl; var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
begin
GetWindowRect(Handle, InfluenceRect);
InflateRect(InfluenceRect, DefExpandoRect, DefExpandoRect);
end;
procedure TJvDockCustomControl.CustomPositionDockRect(Source: TJvDockDragDockObject;
X, Y: Integer);
var
NewWidth, NewHeight: Integer;
TempX, TempY: Double;
R: TRect;
begin
with Source do
begin
if (DragTarget = nil) or (not TWinControlAccessProtected(DragTarget).UseDockManager) then
begin
NewWidth := Control.UndockWidth;
NewHeight := Control.UndockHeight;
TempX := DragPos.X - ((NewWidth) * MouseDeltaX);
TempY := DragPos.Y - ((NewHeight) * MouseDeltaY);
R := DockRect;
R.Left := Round(TempX);
R.Top := Round(TempY);
R.Right := R.Left + NewWidth;
R.Bottom := R.Top + NewHeight;
DockRect := R;
AdjustDockRect(DockRect);
end
else
begin
GetWindowRect(TargetControl.Handle, R);
DockRect := R;
if TWinControlAccessProtected(DragTarget).UseDockManager then
if TargetControl is TJvDockCustomPanel then
if TJvDockCustomPanel(DragTarget).JvDockManager <> nil then
begin
R := DockRect;
TJvDockCustomPanel(DragTarget).JvDockManager.PositionDockRect(Control,
DropOnControl, DropAlign, R);
DockRect := R;
end;
end;
end;
end;
procedure TJvDockCustomControl.CustomStartDock(var Source: TJvDockDragDockObject);
begin
end;
function TJvDockCustomControl.CustomUnDock(Source: TJvDockDragDockObject;
NewTarget: TWinControl; Client: TControl): Boolean;
begin
Result := (Perform(CM_UNDOCKCLIENT, WPARAM(NewTarget), LPARAM(Client)) = 0);
end;
function TJvDockCustomControl.GetJvDockManager: IJvDockManager;
begin
Result := IJvDockManager(DockManager);
end;
procedure TJvDockCustomControl.UpdateCaption(Exclude: TControl);
var
I: Integer;
Host: TJvDockableForm;
begin
if Parent is TJvDockableForm then
begin
Host := TJvDockableForm(Parent);
Host.Caption := '';
for I := 0 to Host.DockableControl.DockClientCount - 1 do
if Host.DockableControl.DockClients[I].Visible and (Host.DockableControl.DockClients[I] <> Exclude) then
Host.Caption := Host.Caption + TCustomForm(Host.DockableControl.DockClients[I]).Caption + RsDockStringSplitter;
if Host.HostDockSite is TJvDockTabPageControl then
with TJvDockTabPageControl(Host.HostDockSite) do
if (ActivePage <> nil) and (ActivePage.Controls[0] = Self) then
ActivePage.Caption := Host.Caption;
if Host.HostDockSite is TJvDockCustomControl then
TJvDockCustomControl(Host.HostDockSite).UpdateCaption(nil);
end;
end;
procedure TJvDockCustomControl.WndProc(var Msg: TMessage);
var
CMUnDockClient: TCMUnDockClient;
DockableForm: TJvDockableForm;
begin
if Msg.Msg = CM_UNDOCKCLIENT then
begin
CMUnDockClient := TCMUnDockClient(Msg);
if CMUnDockClient.Client is TJvDockableForm then
begin
DockableForm := TJvDockableForm(CMUnDockClient.Client);
if DockableForm.FloatingChild <> nil then
begin
if Self is TJvDockTabPageControl then
DockableForm.FloatingChild.ManualDock(Self)
else
begin
DisableAlign;
try
{ using a null-rect as parameter for Dock causes align problems }
// DockableForm.FloatingChild.Dock(Self, Rect(0, 0, 0, 0));
DockableForm.FloatingChild.Dock(Self, Self.BoundsRect);
finally
EnableAlign;
end;
end;
DockableForm.FloatingChild.Visible := True;
if Self is TJvDockCustomPanel then
JvDockManager.ReplaceZoneChild(DockableForm, DockableForm.FloatingChild);
end;
end;
end;
inherited WndProc(Msg);
end;
//=== { TJvDockCustomPanel } =================================================
constructor TJvDockCustomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csSetCaption, csOpaque, csDoubleClicks, csReplicatable];
Color := clBtnFace;
UseDockManager := True;
end;
destructor TJvDockCustomPanel.Destroy;
begin
SetDockSite(Self, False);
inherited Destroy;
end;
function TJvDockCustomPanel.CreateDockManager: IDockManager;
begin
if (DockManager = nil) and DockSite and UseDockManager then
Result := DefaultDockTreeClass.Create(Self, DefaultDockZoneClass, nil) as IJvDockManager
else
Result := DockManager;
DoubleBuffered := DoubleBuffered or (Result <> nil);
end;
//=== { TJvDockCustomPanelSplitter } =========================================
constructor TJvDockCustomPanelSplitter.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAutoSnap := True;
Align := alLeft;
Width := 3;
Cursor := crHSplit;
FMinSize := 30;
FResizeStyle := rsPattern;
FOldSize := -1;
end;
destructor TJvDockCustomPanelSplitter.Destroy;
begin
FBrush.Free;
inherited Destroy;
end;
procedure TJvDockCustomPanelSplitter.AllocateLineDC;
begin
FLineDC := GetDCEx(Parent.Handle, 0,
DCX_CACHE or DCX_CLIPSIBLINGS or DCX_LOCKWINDOWUPDATE);
if ResizeStyle = rsPattern then
begin
if FBrush = nil then
begin
FBrush := TBrush.Create;
FBrush.Bitmap := AllocPatternBitmap(clBlack, clWhite);
end;
FPrevBrush := SelectObject(FLineDC, FBrush.Handle);
end;
end;
procedure TJvDockCustomPanelSplitter.CalcSplitSize(X, Y: Integer; var NewSize, Split: Integer);
var
S: Integer;
begin
if Align in [alLeft, alRight] then
Split := X - FDownPos.X
else
Split := Y - FDownPos.Y;
S := 0;
case Align of
alLeft:
S := FControl.Width + Split;
alRight:
S := FControl.Width - Split;
alTop:
S := FControl.Height + Split;
alBottom:
S := FControl.Height - Split;
end;
NewSize := S;
if S < FMinSize then
NewSize := FMinSize
else
if S > FMaxSize then
NewSize := FMaxSize;
if S <> NewSize then
begin
if Align in [alRight, alBottom] then
S := S - NewSize
else
S := NewSize - S;
Inc(Split, S);
end;
end;
function TJvDockCustomPanelSplitter.CanResize(var NewSize: Integer): Boolean;
begin
Result := True;
if Assigned(FOnCanResize) then
FOnCanResize(Self, NewSize, Result);
end;
function TJvDockCustomPanelSplitter.DoCanResize(var NewSize: Integer): Boolean;
begin
Result := CanResize(NewSize);
if Result and (NewSize <= MinSize) and FAutoSnap then
NewSize := 0;
end;
procedure TJvDockCustomPanelSplitter.DrawLine;
var
X, Y: Integer;
begin
FLineVisible := not FLineVisible;
X := Left;
Y := Top;
if Align in [alLeft, alRight] then
X := Left + FSplit
else
Y := Top + FSplit;
PatBlt(FLineDC, X, Y, Width, Height, PATINVERT);
end;
function TJvDockCustomPanelSplitter.FindControl: TControl;
var
P: TPoint;
I: Integer;
R: TRect;
begin
Result := nil;
P := Point(Left, Top);
case Align of
alLeft:
Dec(P.X);
alRight:
Inc(P.X, Width);
alTop:
Dec(P.Y);
alBottom:
Inc(P.Y, Height);
else
Exit;
end;
for I := 0 to Parent.ControlCount - 1 do
begin
Result := Parent.Controls[I];
if Result.Visible and Result.Enabled then
begin
R := Result.BoundsRect;
if (R.Right - R.Left) = 0 then
if Align in [alTop, alLeft] then
Dec(R.Left)
else
Inc(R.Right);
if (R.Bottom - R.Top) = 0 then
if Align in [alTop, alLeft] then
Dec(R.Top)
else
Inc(R.Bottom);
if PtInRect(R, P) then
Exit;
end;
end;
Result := nil;
end;
procedure TJvDockCustomPanelSplitter.FocusKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_ESCAPE then
StopSizing
else
if Assigned(FOldKeyDown) then
FOldKeyDown(Sender, Key, Shift);
end;
procedure TJvDockCustomPanelSplitter.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
I: Integer;
begin
inherited MouseDown(Button, Shift, X, Y);
if Button = mbLeft then
begin
FControl := FindControl;
FDownPos := Point(X, Y);
if Assigned(FControl) then
begin
if Align in [alLeft, alRight] then
begin
FMaxSize := Parent.ClientWidth - FMinSize;
for I := 0 to Parent.ControlCount - 1 do
with Parent.Controls[I] do
if Visible and (Align in [alLeft, alRight]) then
Dec(FMaxSize, Width);
Inc(FMaxSize, FControl.Width);
end
else
begin
FMaxSize := Parent.ClientHeight - FMinSize;
for I := 0 to Parent.ControlCount - 1 do
with Parent.Controls[I] do
if Align in [alTop, alBottom] then
Dec(FMaxSize, Height);
Inc(FMaxSize, FControl.Height);
end;
UpdateSize(X, Y);
AllocateLineDC;
with ValidParentForm(Self) do
if ActiveControl <> nil then
begin
FActiveControl := ActiveControl;
FOldKeyDown := TWinControlAccessProtected(FActiveControl).OnKeyDown;
TWinControlAccessProtected(FActiveControl).OnKeyDown := FocusKeyDown;
end;
if ResizeStyle in [rsLine, rsPattern] then