forked from pyscripter/pyscripter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JvDockVSNetStyle.pas
3871 lines (3515 loc) · 115 KB
/
JvDockVSNetStyle.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: JvDockVSNetStyle.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 JvDockVSNetStyle;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Windows, Messages, Classes, Graphics, Controls, Forms, ExtCtrls,
JvDockControlForm, JvDockSupportControl, JvDockTree, JvDockVIDStyle,
JvDockGlobals, Contnrs;
type
TJvDockVSNETConjoinServerOption = class(TJvDockVIDConjoinServerOption)
protected
procedure UpdateDefaultSystemCaptionInfo; override;
public
constructor Create(ADockStyle: TJvDockObservableStyle); override;
end;
TJvDockVSNETTabServerOption = class(TJvDockVIDTabServerOption)
public
constructor Create(ADockStyle: TJvDockObservableStyle); override;
published
property InactiveSheetColor default VSNETPageInactiveSheetColor;
property ShowTabImages default True;
end;
TJvDockVSNETChannelOption = class(TJvDockBasicServerOption)
private
FActivePaneSize: Integer;
FShowImage: Boolean;
FMouseleaveHide: Boolean;
FHideHoldTime: Integer;
FTabColor: TColor;
procedure SetActivePaneSize(Value: Integer);
procedure SetShowImage(const Value: Boolean);
procedure SetHideHoldTime(const Value: Integer);
procedure SetMouseleaveHide(const Value: Boolean);
procedure SetTabColor(const Value: TColor);
public
constructor Create(ADockStyle: TJvDockObservableStyle); override;
procedure Assign(Source: TPersistent); override;
published
property ActivePaneSize: Integer read FActivePaneSize write SetActivePaneSize default 100;
{ ShowImage is not used }
property ShowImage: Boolean read FShowImage write SetShowImage default True;
property MouseleaveHide: Boolean read FMouseleaveHide write SetMouseleaveHide default True;
property HideHoldTime: Integer read FHideHoldTime write SetHideHoldTime default 1000;
property TabColor: TColor read FTabColor write SetTabColor default clBtnFace;
end;
TJvDockVSNETChannelOptionClass = class of TJvDockVSNETChannelOption;
TJvDockVSBlock = class;
TJvDockVSChannel = class;
TJvDockVSNETPanel = class;
TJvDockVSPopupPanel = class;
TJvDockVSPopupPanelSplitter = class;
TJvDockVSPane = class(TObject)
private
FBlock: TJvDockVSBlock;
FDockForm: TCustomForm;
FIndex: Integer;
FWidth: Integer;
FVisible: Boolean;
function GetActive: Boolean;
public
constructor Create(ABlock: TJvDockVSBlock; AForm: TCustomForm; AWidth: Integer; AIndex: Integer); virtual;
destructor Destroy; override;
// KV added
property Active: Boolean read GetActive;
property Visible: Boolean read FVisible;
property DockForm: TCustomForm read FDockForm;
end;
TJvDockBlockType = (btConjoinBlock, btTabBlock);
TJvDockVSBlock = class(TObject)
private
FVSChannel: TJvDockVSChannel;
FVSPanes: TObjectList;
FActiveBlockWidth: Integer;
FInactiveBlockWidth: Integer;
FBlockType: TJvDockBlockType;
FImageList: TImageList;
FBlockStartPos: Integer;
FActivePane: TJvDockVSPane;
function GetVSPane(Index: Integer): TJvDockVSPane;
function GetVSPaneCount: Integer;
function GetActiveDockControl: TWinControl;
procedure SetActivePane(APane: TJvDockVSPane);
protected
procedure ResetActiveBlockWidth;
function AddPane(AControl: TControl; const AWidth: Integer): TJvDockVSPane;
procedure DeletePane(Index: Integer);
procedure UpdateActivePane(StartIndex: Integer);
{ Following names should be ActivePaneWidth, InactivePaneWidth }
{ ActivePane has size ActiveBlockWidth.. }
property ActiveBlockWidth: Integer read FActiveBlockWidth write FActiveBlockWidth;
{ ..other panes have size InactiveBlockWidth }
property InactiveBlockWidth: Integer read FInactiveBlockWidth write FInactiveBlockWidth;
{ The popup dock form of ActivePane }
property ActiveDockControl: TWinControl read GetActiveDockControl;
{ Pane that last displayed its popup dock form. A block always has an
ActivePane. If no Pane has shown its popup dock form, then the last
added pane is the ActivePane }
property ActivePane: TJvDockVSPane read FActivePane write SetActivePane;
property BlockType: TJvDockBlockType read FBlockType;
{ Owner }
property VSChannel: TJvDockVSChannel read FVSChannel;
public
constructor Create(AOwner: TJvDockVSChannel); virtual;
destructor Destroy; override;
procedure AddDockControl(Control: TWinControl);
procedure RemoveDockControl(Control: TWinControl);
function FindDockControl(Control: TWinControl; var PaneIndex: Integer): Boolean;
function GetTotalWidth: Integer;
property VSPaneCount: Integer read GetVSPaneCount;
property VSPane[Index: Integer]: TJvDockVSPane read GetVSPane;
// KV properties added
property ImageList: TImageList read FImageList;
end;
TJvDockChannelState = (csShow, csHide);
{
TJvDockServer
|
|----- TJvDockVSNETPanel (4x per server)
|
|----- TJvDockVSChannel
|
|---- TJvDockVSPopupPanel
|
|---- TJvDockVSPopupPanelSplitter
-------- = maintains/creates
}
TJvDockVSChannel = class(TCustomControl)
private
FAnimationDelayTimer: TTimer;
FPopupPane: TJvDockVSPane;
FVSNETDockPanel: TJvDockVSNETPanel; { Owner }
FCurrentPos: Integer;
FBlocks: TObjectList;
FChannelWidth: Integer;
FBlockStartOffset: Integer;
FBlockUpOffset: Integer;
FBlockInterval: Integer;
FVSPopupPanel: TJvDockVSPopupPanel;
FVSPopupPanelSplitter: TJvDockVSPopupPanelSplitter;
FActivePaneSize: Integer;
FDelayPane: TJvDockVSPane;
FStyleLink: TJvDockStyleLink;
FTabColor: TColor;
function GetBlockCount: Integer;
function GetBlock(Index: Integer): TJvDockVSBlock;
function PaneAtPos(MousePos: TPoint): TJvDockVSPane;
procedure SetBlockStartOffset(const Value: Integer);
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
procedure FreeBlockList;
procedure SetActivePaneSize(const Value: Integer);
procedure DoAnimationDelay(Sender: TObject);
procedure DockStyleChanged(Sender: TObject);
procedure SetTabColor(const Value: TColor);
function GetDockServer: TJvDockServer;
function GetDockStyle: TJvDockObservableStyle;
function GetActiveDockForm: TCustomForm;
protected
// KV move GetBlockRect to protected
procedure GetBlockRect(Block: TJvDockVSBlock; Index: Integer; var ARect: TRect);
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure InternalInsertControl(AWinControl: TWinControl);
procedure InternalRemoveControl(AWinControl: TWinControl);
procedure SetPopupPane(APane: TJvDockVSPane);
procedure PopupPaneChanged; virtual;
procedure ResetFontAngle; virtual;
procedure ResetBlock; virtual;
procedure Paint; override;
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 SetVSPopupPanelSplitterPosition;
procedure SyncWithStyle; virtual;
property ChannelWidth: Integer read FChannelWidth;
property BlockStartOffset: Integer read FBlockStartOffset write SetBlockStartOffset;
property BlockUpOffset: Integer read FBlockUpOffset;
property BlockInterval: Integer read FBlockInterval;
property DockServer: TJvDockServer read GetDockServer;
// KV property added
property CurrentPos: Integer read FCurrentPos write FCurrentPos;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterConstruction; override;
{ Same as FindPane? }
function GetPaneWithControl(AControl: TControl): TJvDockVSPane;
procedure CreateVSPopupPanel;
procedure DestroyVSPopupPanel;
procedure ResetPosition;
procedure AddDockControl(Control: TWinControl);
procedure RemoveDockControl(Control: TWinControl);
function FindDockControl(Control: TWinControl; var BlockIndex: Integer;
var PaneIndex: Integer): Boolean;
function FindPane(Control: TWinControl): TJvDockVSPane;
procedure AutoFocusActiveDockForm;
{ Slides the window into view }
procedure PopupDockForm(Pane: TJvDockVSPane); overload;
procedure PopupDockForm(Control: TWinControl); overload;
{ Disables auto-hide }
procedure ShowPopupPanel(Pane: TJvDockVSPane); overload;
procedure ShowPopupPanel(Control: TWinControl); overload;
{ Hides the window by sliding it to the edge of the form }
procedure HidePopupPanel(Pane: TJvDockVSPane); overload;
procedure HidePopupPanel(Control: TWinControl); overload;
procedure HidePopupPanelWithAnimate;
procedure ResetActivePaneWidth;
procedure ResetPopupPanelHeight;
procedure RemoveAllBlock;
procedure DeleteBlock(Index: Integer);
property BlockCount: Integer read GetBlockCount;
property Block[Index: Integer]: TJvDockVSBlock read GetBlock;
property VSPopupPanel: TJvDockVSPopupPanel read FVSPopupPanel;
property VSPopupPanelSplitter: TJvDockVSPopupPanelSplitter read FVSPopupPanelSplitter;
{ Popup dock form that is visible; nil if no popup form is visible }
property ActiveDockForm: TCustomForm read GetActiveDockForm;
{ Maximum size of a block's active pane }
property ActivePaneSize: Integer read FActivePaneSize write SetActivePaneSize;
{ Pane that has a visible popup dock form; nil if no popup dock form is visible }
property PopupPane: TJvDockVSPane read FPopupPane;
property TabColor: TColor read FTabColor write SetTabColor;
property DockStyle: TJvDockObservableStyle read GetDockStyle;
end;
TJvDockVSChannelClass = class of TJvDockVSChannel;
{$IFDEF RTL230_UP}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF RTL230_UP}
TJvDockVSNetStyle = class(TJvDockVIDStyle)
private
FTimer: TTimer;
FDockServers: TList;
FCurrentTimer: Integer;
FChannelOption: TJvDockVSNETChannelOption;
FChannelOptionClass: TJvDockVSNETChannelOptionClass;
procedure Timer(Sender: TObject);
function GetChannelOption: TJvDockVSNETChannelOption;
procedure SetChannelOption(const Value: TJvDockVSNETChannelOption);
protected
function DockServerWindowProc(DockServer: TJvDockServer; var Msg: TMessage): Boolean; override;
function DockClientWindowProc(DockClient: TJvDockClient; var Msg: TMessage): Boolean; override;
procedure AddDockBaseControl(ADockBaseControl: TJvDockBaseControl); override;
procedure RemoveDockBaseControl(ADockBaseControl: TJvDockBaseControl); override;
procedure CreateServerOption; override; { AfterConstruction }
procedure FreeServerOption; override; { Destroy }
procedure BeginPopup(AChannel: TJvDockVSChannel);
procedure EndPopup(AChannel: TJvDockVSChannel);
{ construction/destruction of timer is a bit rigid }
procedure CreateTimer;
procedure DestroyTimer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure DoUnAutoHideDockForm(DockWindow: TWinControl); virtual;
procedure DoShowDockForm(DockWindow: TWinControl); override;
procedure DoHideDockForm(DockWindow: TWinControl); override;
procedure SetDockFormVisible(ADockClient: TJvDockClient; AVisible: Boolean);
procedure ShowDockForm(ADockClient: TJvDockClient); override;
procedure HideDockForm(ADockClient: TJvDockClient); override;
function GetDockFormVisible(ADockClient: TJvDockClient): Boolean; override;
procedure RestoreClient(DockClient: TJvDockClient); override;
class procedure SetAnimationInterval(const Value: Integer);
class function GetAnimationInterval: Integer;
class function GetAnimationStartInterval: Integer;
class procedure SetAnimationMoveWidth(const Value: Integer);
class function GetAnimationMoveWidth: Integer;
published
property ChannelOption: TJvDockVSNETChannelOption read GetChannelOption write SetChannelOption;
end;
TJvDockVSNETSplitter = class(TJvDockVIDSplitter);
{ A 'pure' TJvDockVSNETPanel maintains a TJvDockVSChannel (A TJvDockVSPopupPanel
component that is a TJvDockVSNETPanel descendant does NOT, see
TJvDockVSNETPanel.AddDockServer)
}
TJvDockVSNETPanel = class(TJvDockVIDPanel)
private
FVSChannelClass: TJvDockVSChannelClass;
FVSChannel: TJvDockVSChannel;
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure AddDockServer(ADockServer: TJvDockServer); override;
procedure RemoveDockServer(ADockServer: TJvDockServer); override;
procedure CustomDockDrop(Source: TJvDockDragDockObject; X, Y: Integer); override;
procedure Resize; override;
//KV
property VSChannelClass: TJvDockVSChannelClass
read FVSChannelClass write FVSChannelClass;
public
constructor Create(AOwner: TComponent); override;
procedure CreateVSChannel;
procedure DestroyVSChannel;
procedure DoAutoHideControl(Control: TWinControl);
procedure DoHideControl(Control: TWinControl);
procedure DoShowControl(Control: TWinControl);
property VSChannel: TJvDockVSChannel read FVSChannel;
end;
TJvDockVSPopupPanel = class(TJvDockVSNETPanel)
private
FVSNETDockPanel: TJvDockVSNETPanel;
{procedure SetVSNETDockPanel(const Value: TJvDockVSNETPanel);}
function GetVSChannel: TJvDockVSChannel;
protected
function CreateDockManager: IDockManager; override;
procedure SetParent(AParent: TWinControl); override;
public
// Can't put 'override' this one because signature is different!
// But it MUST have DockStyle in the constructor now! -Wpostma!
constructor Create(AOwner: TComponent; APanel: TJvDockVSNETPanel); reintroduce; virtual;
procedure ShowDockPanel(MakeVisible: Boolean; Client: TControl;
PanelSizeFrom: TJvDockSetDockPanelSizeFrom); override;
{ Dirty override; solve with virtual method? }
property VSChannel: TJvDockVSChannel read GetVSChannel;
{ Owner }
property VSNETDockPanel: TJvDockVSNETPanel read FVSNETDockPanel {write SetVSNETDockPanel};
end;
TJvDockVSNETConjoinPanel = class(TJvDockVIDConjoinPanel);
TJvDockBtnState = (bsUp, bsNormal, bsDown);
TJvDockVSNETZone = class(TJvDockVIDZone)
private
FAutoHideBtnDown: Boolean;
FAutoHideBtnState: TJvDockBtnState;
FCloseBtnState: TJvDockBtnState;
FVSPaneVisible: Boolean;
procedure SetAutoHideBtnState(const Value: TJvDockBtnState);
procedure SetCloseBtnState(const Value: TJvDockBtnState);
procedure SetAutoHideBtnDown(const Value: Boolean);
procedure SetVSPaneVisible(const Value: Boolean);
protected
procedure DoCustomSetControlName; override;
procedure SetChildControlVisible(Client: TControl; AVisible: Boolean); override;
property AutoHideBtnDown: Boolean read FAutoHideBtnDown write SetAutoHideBtnDown;
property AutoHideBtnState: TJvDockBtnState read FAutoHideBtnState write SetAutoHideBtnState;
property CloseBtnState: TJvDockBtnState read FCloseBtnState write SetCloseBtnState;
property VSPaneVisible: Boolean read FVSPaneVisible write SetVSPaneVisible;
public
constructor Create(Tree: TJvDockTree); override;
end;
TJvDockVSNETTree = class(TJvDockVIDTree)
private
FAutoHideZone: TJvDockVSNETZone;
protected
procedure IgnoreZoneInfor(Stream: TMemoryStream); override;
procedure BeginDrag(Control: TControl;
Immediate: Boolean; Threshold: Integer = -1); override;
function DoLButtonDown(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer): Boolean; override;
procedure DoLButtonUp(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer); override;
procedure DoLButtonDbClk(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer); override;
procedure DoMouseMove(var Msg: TWMMouse;
var AZone: TJvDockZone; out HTFlag: Integer); override;
procedure DoHideZoneChild(AZone: TJvDockZone); override;
function GetTopGrabbersHTFlag(const MousePos: TPoint;
out HTFlag: Integer; Zone: TJvDockZone): TJvDockZone; override;
procedure DrawDockGrabber(Control: TWinControl; const ARect: TRect); override;
procedure PaintDockGrabberRect(Canvas: TCanvas; Control: TWinControl;
const ARect: TRect; PaintAlways: Boolean = False); override;
procedure DrawCloseButton(Canvas: TCanvas; Zone: TJvDockZone;
Left, Top: Integer); override;
procedure DrawAutoHideButton(Zone: TJvDockZone;
Left, Top: Integer); virtual;
procedure GetCaptionRect(var Rect: TRect); override;
procedure DoOtherHint(Zone: TJvDockZone;
HTFlag: Integer; var HintStr: string); override;
procedure CustomSaveZone(Stream: TStream;
Zone: TJvDockZone); override;
procedure CustomLoadZone(Stream: TStream;
var Zone: TJvDockZone); override;
property AutoHideZone: TJvDockVSNETZone read FAutoHideZone
write FAutoHideZone;
public
constructor Create(DockSite: TWinControl; DockZoneClass: TJvDockZoneClass;
ADockStyle: TJvDockObservableStyle); override;
end;
TJvDockVSNETTabSheet = class(TJvDockVIDTabSheet)
private
FOldVisible: Boolean;
procedure SetOldVisible(const Value: Boolean);
public
constructor Create(AOwner: TComponent); override;
property OldVisible: Boolean read FOldVisible write SetOldVisible;
end;
TJvDockVSNETTabPanel = class(TJvDockTabPanel)
public
constructor Create(AOwner: TComponent); override;
end;
TJvDockVSNETTabPageControl = class(TJvDockVIDTabPageControl)
protected
procedure ShowControl(AControl: TControl); override;
public
constructor Create(AOwner: TComponent); override;
end;
TJvDockVSNETDragDockObject = class(TJvDockVIDDragDockObject);
TJvDockVSPopupPanelSplitter = class(TCustomControl)
private
FVSPopupPanel: TJvDockVSPopupPanel;
FSplitWidth: Integer;
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;
function FindControl: TControl;
procedure FocusKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ReleaseLineDC;
procedure SetBeveled(Value: Boolean);
procedure UpdateControlSize;
procedure UpdateSize(X, Y: Integer);
procedure SetVSPopupPanel(Value: TJvDockVSPopupPanel);
function GetVSChannelAlign: TAlign;
procedure SetSplitWidth(const Value: Integer);
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
function CanResize(var NewSize: Integer): Boolean; reintroduce; virtual;
function DoCanResize(var NewSize: Integer): Boolean; 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;
{ Owner of the Owner }
property VSPopupPanel: TJvDockVSPopupPanel read FVSPopupPanel write SetVSPopupPanel;
property SplitWidth: Integer read FSplitWidth write SetSplitWidth;
published
property Align default alLeft;
property VSChannelAlign: TAlign read GetVSChannelAlign;
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;
procedure HideAllPopupPanel(ExcludeChannel: TJvDockVSChannel);
{ Disables auto-hide for ADockWindow. If ADockWindow is not auto-hidden then
the procedures works the same as JvDockControlForm.ShowDockForm }
procedure UnAutoHideDockForm(ADockWindow: TWinControl);
function RetrieveChannel(HostDockSite: TWinControl): TJvDockVSChannel;
var
DefaultVSChannelClass: TJvDockVSChannelClass = nil;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
Types, SysUtils, Math, ImgList, {AppEvnts,} JvJVCLUtils,
JvDockSupportProc;
type
TAnimateState = (asPopup, asHide);
TCustomFormAccess = class(TCustomForm);
TWinControlAccessProtected = class(TWinControl);
TCustomControlAccessProtected = class(TCustomControl);
{ Enumerates the channels of a dock server; Ensure MoveNext returns true
before reading Current }
TChannelEnumerator = class
private
FIndex: Integer;
FDockServer: TJvDockServer;
function GetCurrent: TJvDockVSChannel;
public
constructor Create(ADockServer: TJvDockServer);
function MoveNext: Boolean;
property Current: TJvDockVSChannel read GetCurrent;
end;
TPopupPanelAnimate = class(TTimer)
private
FMaxWidth: Integer;
FCurrentWidth: Integer;
FActiveChannel: TJvDockVSChannel;
FState: TAnimateState;
protected
procedure Timer; override;
procedure OnCustomTimer(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
{ Animates the popup of the form }
procedure PopupForm(AChannel: TJvDockVSChannel; MaxWidth: Integer); virtual;
{ Animates the hiding of the form }
procedure HideForm(AChannel: TJvDockVSChannel; MaxWidth: Integer); virtual;
end;
var
GlobalPopupPanelAnimate: TPopupPanelAnimate = nil;
GlobalPopupPanelAnimateInterval: Integer = 20;
GlobalPopupPanelAnimateMoveWidth: Integer = 20;
GlobalPopupPanelStartAnimateInterval: Integer = 400;
//=== Local procedures =======================================================
function PopupPanelAnimate: TPopupPanelAnimate;
begin
if GlobalPopupPanelAnimate = nil then
GlobalPopupPanelAnimate := TPopupPanelAnimate.Create(nil);
Result := GlobalPopupPanelAnimate;
end;
procedure ResetChannelBlockStartOffset(Channel: TJvDockVSChannel);
var
LeftChannel: TJvDockVSChannel;
OldOffset: Integer;
LeftAlignArea: Integer;
begin
LeftChannel := TJvDockVSNETPanel(Channel.DockServer.LeftDockPanel).VSChannel;
if LeftChannel <> nil then
begin
LeftAlignArea := GetClientAlignControlArea(LeftChannel.Parent, alLeft);
with TChannelEnumerator.Create(Channel.DockServer) do
try
while MoveNext do
if Current.Align in [alTop, alBottom] then
begin
OldOffset := Current.BlockStartOffset;
Current.BlockStartOffset := 2 + LeftAlignArea;
if OldOffset <> Current.BlockStartOffset then
Current.Invalidate;
end;
finally
Free;
end;
end;
end;
procedure SetControlBringToFront(Control: TWinControl; Align: TAlign);
var
I: Integer;
begin
for I := Control.ControlCount - 1 downto 0 do
if Control.Controls[I].Visible and (Control.Controls[I].Align = Align) and
not (Control.Controls[I] is TJvDockVSChannel) and
not (Control.Controls[I] is TJvDockPanel) and
not (Control.Controls[I] is TJvDockSplitter) then
Control.Controls[I].BringToFront;
end;
function ControlIsOnPopup(AControl: TControl): Boolean;
begin
Result := False;
while Assigned(AControl) do
begin
if (AControl is TJvDockVSPopupPanel) or
(AControl is TJvDockVSPopupPanelSplitter) or
(AControl is TJvDockVSChannel) then
begin
Result := True;
Exit;
end;
AControl := AControl.Parent;
end;
end;
//=== Global procedures ======================================================
procedure HideAllPopupPanel(ExcludeChannel: TJvDockVSChannel);
var
I: Integer;
DockServer: TJvDockServer;
begin
for I := 0 to JvGlobalDockManager.DockServerCount - 1 do
begin
DockServer := JvGlobalDockManager.DockServer[I];
if Assigned(DockServer) then
with TChannelEnumerator.Create(DockServer) do
try
while MoveNext do
if Current <> ExcludeChannel then
Current.HidePopupPanel(Current.PopupPane);
finally
Free;
end;
end;
end;
{ Returns the channel of a form that is docked onto a popup panel }
function RetrieveChannel(HostDockSite: TWinControl): TJvDockVSChannel;
begin
Result := nil;
if HostDockSite is TJvDockVSPopupPanel then
// normal docked forms
Result := TJvDockVSPopupPanel(HostDockSite).VSChannel
else
if Assigned(HostDockSite) and Assigned(HostDockSite.Parent) then
begin
HostDockSite := HostDockSite.Parent.HostDockSite;
if HostDockSite is TJvDockVSPopupPanel then
// tab docked forms
Result := TJvDockVSPopupPanel(HostDockSite).VSChannel
end;
end;
procedure UnAutoHideDockForm(ADockWindow: TWinControl);
var
ADockClient: TJvDockClient;
begin
// delegate to style
ADockClient := FindDockClient(ADockWindow);
if Assigned(ADockClient) and (ADockClient.DockStyle is TJvDockVSNetStyle) then
TJvDockVSNetStyle(ADockClient.DockStyle).DoUnAutoHideDockForm(ADockWindow);
end;
//=== { TChannelEnumerator } =================================================
constructor TChannelEnumerator.Create(ADockServer: TJvDockServer);
begin
inherited Create;
FIndex := -1;
FDockServer := ADockServer;
end;
function TChannelEnumerator.GetCurrent: TJvDockVSChannel;
begin
Result := TJvDockVSNETPanel(FDockServer.DockPanelWithAlign[TAlign(FIndex)]).VSChannel;
end;
function TChannelEnumerator.MoveNext: Boolean;
var
I: Integer;
Panel: TJvDockPanel;
begin
I := FIndex + 1;
while I <= Ord(High(TAlign)) do
begin
Panel := FDockServer.DockPanelWithAlign[TAlign(I)];
if (Panel is TJvDockVSNETPanel) and Assigned(TJvDockVSNETPanel(Panel).VSChannel) then
Break;
Inc(I);
end;
Result := I <= Ord(High(TAlign));
if Result then
FIndex := I;
end;
//=== { TJvDockVSBlock } =====================================================
constructor TJvDockVSBlock.Create(AOwner: TJvDockVSChannel);
begin
inherited Create;
FVSChannel := AOwner;
FVSPanes := TObjectList.Create;
FImageList := TImageList.CreateSize(16, 16);
{$IFDEF RTL200_UP}
FImageList.ColorDepth := cd32Bit;
{$ENDIF RTL200_UP}
FInactiveBlockWidth := 24;
FActiveBlockWidth := 24;
end;
destructor TJvDockVSBlock.Destroy;
begin
FImageList.Free;
FVSPanes.Free;
inherited Destroy;
end;
procedure TJvDockVSBlock.AddDockControl(Control: TWinControl);
var
I, PaneWidth, FirstIndex: Integer;
function GetPaneWidth: Integer;
begin
Result := 100;
if Control = nil then
Exit;
case VSChannel.Align of
alLeft, alRight:
Result := Control.Width;
alTop, alBottom:
Result := Control.Height;
end;
end;
var
NewPane: TJvDockVSPane;
Form: TCustomForm;
APageControl: TJvDockTabPageControl;
begin
PaneWidth := GetPaneWidth;
if Control is TJvDockTabHostForm then
begin
FBlockType := btTabBlock;
APageControl := TJvDockTabHostForm(Control).PageControl;
FirstIndex := VSPaneCount;
{ Mantis 3989: (Kiriakos) PageControl.DockClients does NOT have to be in the
same order as PageControl.Pages; for example, if we reorder the pages. }
for I := 0 to APageControl.Count - 1 do
begin
Form := APageControl.DockForm[I];
if Assigned(Form) then
begin
NewPane := AddPane(Form, PaneWidth);
TJvDockVSNETTabSheet(APageControl.Pages[I]).OldVisible := Form.Visible;
if APageControl.Pages[I] <> APageControl.ActivePage then
Form.Visible := False
else if Assigned(NewPane) then
ActivePane := NewPane;
end;
end;
if not Assigned(ActivePane) then
UpdateActivePane(FirstIndex);
end
else
begin
FBlockType := btConjoinBlock;
NewPane := AddPane(Control, PaneWidth);
if Assigned(NewPane) then
ActivePane := NewPane;
end;
ResetActiveBlockWidth;
end;
function TJvDockVSBlock.AddPane(AControl: TControl; const AWidth: Integer): TJvDockVSPane;
const
ANDbits: array[0..2*16-1] of Byte = ($FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF,
$FF,$FF);
XORbits: array[0..2*16-1] of Byte = ($00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00,
$00,$00);
var
Icon: TIcon;
ADockClient: TJvDockClient;
begin
if not (AControl is TCustomForm) then
begin
Result := nil;
Exit;
end;
Result := TJvDockVSPane.Create(Self, TCustomForm(AControl), AWidth, VSPaneCount);
FVSPanes.Add(Result);
if not JvGlobalDockIsLoading then
begin
ADockClient := FindDockClient(AControl);
if ADockClient <> nil then
ADockClient.VSPaneWidth := AWidth;
end;
{ Add the form icon }
if not Assigned(TCustomFormAccess(AControl).Icon) or not TCustomFormAccess(AControl).Icon.HandleAllocated then
begin
Icon := TIcon.Create;
try
Icon.Width := 16;
Icon.Height := 16;
//2. Adding an Icon without real bitmap does nothing,
//so transparent icon needed
Icon.Handle := CreateIcon(hInstance,16,16,1,1,@ANDbits,@XORbits);
FImageList.AddIcon(Icon);
finally
Icon.Free;
end;
end
else
FImageList.AddIcon(TCustomFormAccess(AControl).Icon);
end;
procedure TJvDockVSBlock.DeletePane(Index: Integer);
var
I: Integer;
ActivePaneRemoved: Boolean;
begin
for I := Index to VSPaneCount - 2 do
VSPane[I + 1].FIndex := VSPane[I].FIndex;
ActivePaneRemoved := VSPane[Index] = Self.ActivePane;
FVSPanes.Delete(Index);
{ Remove the form icon }
if Index < FImageList.Count then
FImageList.Delete(Index);
if ActivePaneRemoved then
UpdateActivePane(Index);
end;
function TJvDockVSBlock.FindDockControl(Control: TWinControl;
var PaneIndex: Integer): Boolean;
var
I: Integer;
begin
Result := False;
PaneIndex := -1;
if Control = nil then
Exit;
for I := 0 to VSPaneCount - 1 do
if VSPane[I].FDockForm = Control then
begin
PaneIndex := I;
Result := True;
Exit;
end;
if FBlockType = btTabBlock then
begin
if (VSPaneCount > 0) and (VSPane[0].FDockForm.HostDockSite.Parent = Control) then
begin
PaneIndex := 0;
Result := True;
Exit;
end;
end;
end;
function TJvDockVSBlock.GetActiveDockControl: TWinControl;
begin
if Assigned(ActivePane) then
Result := ActivePane.DockForm
else
Result := nil;
end;
function TJvDockVSBlock.GetTotalWidth: Integer;
begin
// 1 pane is active, the rest is inactive
Result := (VSPaneCount - 1) * FInactiveBlockWidth + FActiveBlockWidth;
end;
function TJvDockVSBlock.GetVSPane(Index: Integer): TJvDockVSPane;
begin
Result := TJvDockVSPane(FVSPanes[Index]);
end;
function TJvDockVSBlock.GetVSPaneCount: Integer;
begin
Result := FVSPanes.Count;
end;
procedure TJvDockVSBlock.RemoveDockControl(Control: TWinControl);
begin
ResetActiveBlockWidth;
end;
procedure TJvDockVSBlock.ResetActiveBlockWidth;
var
I: Integer;
TextWidth: Integer;
Canvas: TCanvas;
begin
FActiveBlockWidth := 0;
if VSPaneCount > 0 then
begin
if VSChannel.Parent is TCustomControl then
Canvas := TCustomControlAccessProtected(VSChannel.Parent).Canvas
else if VSChannel.Parent is TCustomForm then
Canvas := TForm(VSChannel.Parent).Canvas
else
Canvas := nil;
if Canvas <> nil then
begin
for I := 0 to VSPaneCount - 1 do
begin
TextWidth := Canvas.TextWidth(VSPane[I].FDockForm.Caption) + InactiveBlockWidth + 10;
if TextWidth >= VSChannel.ActivePaneSize then
begin
FActiveBlockWidth := VSChannel.ActivePaneSize;
Exit;
end;
FActiveBlockWidth := Max(FActiveBlockWidth, TextWidth);
end;
end;
end;
if FActiveBlockWidth = 0 then
FActiveBlockWidth := VSChannel.ActivePaneSize;
end;