-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComCtrls.pas
22894 lines (21167 loc) · 642 KB
/
ComCtrls.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
{*******************************************************}
{ }
{ Borland Delphi Visual Component Library }
{ }
{ Copyright (c) 1996-2002 Borland Software Corporation }
{ }
{*******************************************************}
unit ComCtrls;
{$R-,T-,H+,X+}
interface
uses
{$IFDEF LINUX}
WinUtils,
{$ENDIF}
Messages, Windows, SysUtils, CommCtrl, Classes, Controls, Forms, Menus,
Graphics, StdCtrls, RichEdit, ToolWin, ImgList, ExtCtrls, ListActns,
ShlObj;
type
THitTest = (htAbove, htBelow, htNowhere, htOnItem, htOnButton, htOnIcon,
htOnIndent, htOnLabel, htOnRight, htOnStateIcon, htToLeft, htToRight);
THitTests = set of THitTest;
TCustomTabControl = class;
TTabChangingEvent = procedure(Sender: TObject;
var AllowChange: Boolean) of object;
TTabPosition = (tpTop, tpBottom, tpLeft, tpRight);
TTabStyle = (tsTabs, tsButtons, tsFlatButtons);
TDrawTabEvent = procedure(Control: TCustomTabControl; TabIndex: Integer;
const Rect: TRect; Active: Boolean) of object;
TTabGetImageEvent = procedure(Sender: TObject; TabIndex: Integer;
var ImageIndex: Integer) of object;
TCustomTabControl = class(TWinControl)
private
FCanvas: TCanvas;
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: TStrings;
FTabSize: TSmallPoint;
FUpdating: Boolean;
FSavedAdjustRect: TRect;
FOnChange: TNotifyEvent;
FOnChanging: TTabChangingEvent;
FOnDrawTab: TDrawTabEvent;
FOnGetImageIndex: TTabGetImageEvent;
function GetDisplayRect: TRect;
function GetTabIndex: Integer;
procedure ImageListChange(Sender: TObject);
function InternalSetMultiLine(Value: Boolean): Boolean;
procedure SetHotTrack(Value: Boolean);
procedure SetImages(Value: TCustomImageList);
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 SetTabHeight(Value: Smallint);
procedure SetTabPosition(Value: TTabPosition);
procedure SetTabs(Value: TStrings);
procedure SetTabWidth(Value: Smallint);
procedure TabsChanged;
procedure UpdateTabSize;
procedure CMFontChanged(var Message); message CM_FONTCHANGED;
procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMTabStopChanged(var Message: TMessage); message CM_TABSTOPCHANGED;
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
procedure TCMAdjustRect(var Message: TMessage); message TCM_ADJUSTRECT;
procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY;
procedure WMNotifyFormat(var Message: TMessage); message WM_NOTIFYFORMAT;
procedure WMSize(var Message: 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 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;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetTabIndex(Value: Integer); virtual;
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 FTabs 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: TDrawTabEvent 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 Canvas: TCanvas read FCanvas;
property TabStop default True;
end;
TTabControl = class(TCustomTabControl)
public
property DisplayRect;
published
property Align;
property Anchors;
property BiDiMode;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HotTrack;
property Images;
property MultiLine;
property MultiSelect;
property OwnerDraw;
property ParentBiDiMode;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RaggedRight;
property ScrollOpposite;
property ShowHint;
property Style;
property TabHeight;
property TabOrder;
property TabPosition;
property Tabs;
property TabIndex; // must be after Tabs
property TabStop;
property TabWidth;
property Visible;
property OnChange;
property OnChanging;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnDrawTab;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetImageIndex;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
TPageControl = class;
TTabSheet = class(TWinControl)
private
FImageIndex: TImageIndex;
FPageControl: TPageControl;
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 SetPageControl(APageControl: TPageControl);
procedure SetPageIndex(Value: Integer);
procedure SetTabShowing(Value: Boolean);
procedure SetTabVisible(Value: Boolean);
procedure UpdateTabShowing;
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
procedure WMPrintClient(var Message: TWMPrintClient); message WM_PRINTCLIENT;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure DoHide; dynamic;
procedure DoShow; dynamic;
procedure ReadState(Reader: TReader); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property PageControl: TPageControl read FPageControl write SetPageControl;
property TabIndex: Integer read GetTabIndex;
published
property BorderWidth;
property Caption;
property DragMode;
property Enabled;
property Font;
property Height stored False;
property Highlighted: Boolean read FHighlighted write SetHighlighted default False;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default 0;
property Left stored False;
property Constraints;
property PageIndex: Integer read GetPageIndex write SetPageIndex stored False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabVisible: Boolean read FTabVisible write SetTabVisible default True;
property Top stored False;
property Visible stored False;
property Width stored False;
property OnContextPopup;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnHide: TNotifyEvent read FOnHide write FOnHide;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnShow: TNotifyEvent read FOnShow write FOnShow;
property OnStartDrag;
end;
TPageControl = class(TCustomTabControl)
private
FPages: TList;
FActivePage: TTabSheet;
FNewDockSheet: TTabSheet;
FUndockingPage: TTabSheet;
FInSetActivePage: Boolean;
procedure ChangeActivePage(Page: TTabSheet);
procedure DeleteTab(Page: TTabSheet; Index: Integer);
function GetActivePageIndex: Integer;
function GetDockClientFromMousePos(MousePos: TPoint): TControl;
function GetPage(Index: Integer): TTabSheet;
function GetPageCount: Integer;
procedure InsertPage(Page: TTabSheet);
procedure InsertTab(Page: TTabSheet);
procedure MoveTab(CurIndex, NewIndex: Integer);
procedure RemovePage(Page: TTabSheet);
procedure SetActivePageIndex(const Value: Integer);
procedure UpdateTab(Page: TTabSheet);
procedure UpdateTabHighlights;
procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
procedure CMDockClient(var Message: TCMDockClient); message CM_DOCKCLIENT;
procedure CMDockNotification(var Message: TCMDockNotification); message CM_DOCKNOTIFICATION;
procedure CMUnDockClient(var Message: TCMUnDockClient); message CM_UNDOCKCLIENT;
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure WMEraseBkGnd(var Message: TWMEraseBkGnd); message WM_ERASEBKGND;
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;
procedure DoRemoveDockClient(Client: TControl); override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
function GetImageIndex(TabIndex: Integer): Integer; override;
function GetPageFromDockClient(Client: TControl): TTabSheet;
procedure GetSiteInfo(Client: TControl; var InfluenceRect: TRect;
MousePos: TPoint; var CanDock: Boolean); override;
procedure Loaded; override;
procedure SetActivePage(Page: TTabSheet);
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
procedure SetTabIndex(Value: Integer); override;
procedure ShowControl(AControl: TControl); override;
procedure UpdateActivePage; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function FindNextPage(CurPage: TTabSheet;
GoForward, CheckTabVisible: Boolean): TTabSheet;
procedure SelectNextPage(GoForward: Boolean; CheckTabVisible: Boolean = True);
property ActivePageIndex: Integer read GetActivePageIndex
write SetActivePageIndex;
property PageCount: Integer read GetPageCount;
property Pages[Index: Integer]: TTabSheet read GetPage;
published
property ActivePage: TTabSheet read FActivePage write SetActivePage;
property Align;
property Anchors;
property BiDiMode;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HotTrack;
property Images;
property MultiLine;
property OwnerDraw;
property ParentBiDiMode;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RaggedRight;
property ScrollOpposite;
property ShowHint;
property Style;
property TabHeight;
property TabIndex stored False;
property TabOrder;
property TabPosition;
property TabStop;
property TabWidth;
property Visible;
property OnChange;
property OnChanging;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnDrawTab;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetImageIndex;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
{ TCustomStatusBar }
TCustomStatusBar = class;
TStatusPanels = class;
TStatusPanelStyle = (psText, psOwnerDraw);
TStatusPanelBevel = (pbNone, pbLowered, pbRaised);
TStatusPanelClass = class of TStatusPanel;
TStatusPanel = class(TCollectionItem)
private
FText: string;
FWidth: Integer;
FAlignment: TAlignment;
FBevel: TStatusPanelBevel;
FBiDiMode: TBiDiMode;
FParentBiDiMode: Boolean;
FStyle: TStatusPanelStyle;
FUpdateNeeded: Boolean;
procedure SetAlignment(Value: TAlignment);
procedure SetBevel(Value: TStatusPanelBevel);
procedure SetBiDiMode(Value: TBiDiMode);
procedure SetParentBiDiMode(Value: Boolean);
procedure SetStyle(Value: TStatusPanelStyle);
procedure SetText(const Value: string);
procedure SetWidth(Value: Integer);
function IsBiDiModeStored: Boolean;
protected
function GetDisplayName: string; override;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
procedure ParentBiDiModeChanged;
function UseRightToLeftAlignment: Boolean;
function UseRightToLeftReading: Boolean;
published
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property Bevel: TStatusPanelBevel read FBevel write SetBevel default pbLowered;
property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode stored IsBiDiModeStored;
property ParentBiDiMode: Boolean read FParentBiDiMode write SetParentBiDiMode default True;
property Style: TStatusPanelStyle read FStyle write SetStyle default psText;
property Text: string read FText write SetText;
property Width: Integer read FWidth write SetWidth;
end;
TStatusPanels = class(TCollection)
private
FStatusBar: TCustomStatusBar;
function GetItem(Index: Integer): TStatusPanel;
procedure SetItem(Index: Integer; Value: TStatusPanel);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(StatusBar: TCustomStatusBar);
function Add: TStatusPanel;
function AddItem(Item: TStatusPanel; Index: Integer): TStatusPanel;
function Insert(Index: Integer): TStatusPanel;
property Items[Index: Integer]: TStatusPanel read GetItem write SetItem; default;
end;
TCustomDrawPanelEvent = procedure(StatusBar: TCustomStatusBar; Panel: TStatusPanel;
const Rect: TRect) of object;
TSBCreatePanelClassEvent = procedure(Sender: TCustomStatusBar;
var PanelClass: TStatusPanelClass) of object;
TCustomStatusBar = class(TWinControl)
private
FPanels: TStatusPanels;
FCanvas: TCanvas;
FSimpleText: string;
FSimplePanel: Boolean;
FSizeGrip, FSizeGripValid: Boolean;
FUseSystemFont: Boolean;
FAutoHint: Boolean;
FOnDrawPanel: TCustomDrawPanelEvent;
FOnHint: TNotifyEvent;
FOnCreatePanelClass: TSBCreatePanelClassEvent;
procedure DoRightToLeftAlignment(var Str: string; AAlignment: TAlignment;
ARTLAlignment: Boolean);
procedure SetPanels(Value: TStatusPanels);
procedure SetSimplePanel(Value: Boolean);
procedure UpdateSimpleText;
procedure SetSimpleText(const Value: string);
procedure SetSizeGrip(Value: Boolean);
procedure SyncToSystemFont;
procedure UpdatePanel(Index: Integer; Repaint: Boolean);
procedure UpdatePanels(UpdateRects, UpdateText: Boolean);
procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMWinIniChange(var Message: TMessage); message CM_WININICHANGE;
procedure CMSysFontChanged(var Message: TMessage); message CM_SYSFONTCHANGED;
procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
procedure WMEraseBkGnd(var Message: TWMEraseBkGnd); message WM_ERASEBKGND;
procedure WMGetTextLength(var Message: TWMGetTextLength); message WM_GETTEXTLENGTH;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure SetUseSystemFont(const Value: Boolean);
procedure ValidateSizeGrip(ARecreate: Boolean);
protected
procedure ChangeScale(M, D: Integer); override;
function CreatePanel: TStatusPanel; virtual;
function CreatePanels: TStatusPanels; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
function DoHint: Boolean; virtual;
procedure DrawPanel(Panel: TStatusPanel; const Rect: TRect); dynamic;
function GetPanelClass: TStatusPanelClass; virtual;
function IsFontStored: Boolean;
procedure SetParent(AParent: TWinControl); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
procedure FlipChildren(AllLevels: Boolean); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
property Canvas: TCanvas read FCanvas;
property AutoHint: Boolean read FAutoHint write FAutoHint;
property Panels: TStatusPanels read FPanels write SetPanels;
property SimplePanel: Boolean read FSimplePanel write SetSimplePanel;
property SimpleText: string read FSimpleText write SetSimpleText;
property SizeGrip: Boolean read FSizeGrip write SetSizeGrip;
property UseSystemFont: Boolean read FUseSystemFont write SetUseSystemFont;
property OnCreatePanelClass: TSBCreatePanelClassEvent read FOnCreatePanelClass
write FOnCreatePanelClass;
property OnHint: TNotifyEvent read FOnHint write FOnHint;
property OnDrawPanel: TCustomDrawPanelEvent read FOnDrawPanel write FOnDrawPanel;
end;
{ TStatusBar }
TStatusBar = class;
TDrawPanelEvent = procedure(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect) of object;
TStatusBar = class(TCustomStatusBar)
private
function GetOnDrawPanel: TDrawPanelEvent;
procedure SetOnDrawPanel(const Value: TDrawPanelEvent);
published
property Action;
property AutoHint default False;
property Align default alBottom;
property Anchors;
property BiDiMode;
property BorderWidth;
property Color default clBtnFace;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font stored IsFontStored;
property Constraints;
property Panels;
property ParentBiDiMode;
property ParentColor default False;
property ParentFont default False;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property SimplePanel default False;
property SimpleText;
property SizeGrip default True;
property UseSystemFont default True;
property Visible;
property OnClick;
property OnContextPopup;
property OnCreatePanelClass;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnHint;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
// Required for backwards compatibility with the old event signature
property OnDrawPanel: TDrawPanelEvent read GetOnDrawPanel write SetOnDrawPanel;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
{ Custom draw }
TCustomDrawTarget = (dtControl, dtItem, dtSubItem);
TCustomDrawStage = (cdPrePaint, cdPostPaint, cdPreErase, cdPostErase);
TCustomDrawState = set of (cdsSelected, cdsGrayed, cdsDisabled, cdsChecked,
cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate);
{ TCustomHeaderControl }
TCustomHeaderControl = class;
{ THeaderControl }
THeaderControl = class;
THeaderSectionStyle = (hsText, hsOwnerDraw);
THeaderSectionClass = class of THeaderSection;
THeaderSection = class(TCollectionItem)
private
FText: string;
FWidth: Integer;
FMinWidth: Integer;
FMaxWidth: Integer;
FAlignment: TAlignment;
FStyle: THeaderSectionStyle;
FAllowClick: Boolean;
FAutoSize: Boolean;
FImageIndex: TImageIndex;
FBiDiMode: TBiDiMode;
FParentBiDiMode: Boolean;
function GetLeft: Integer;
function GetRight: Integer;
function IsBiDiModeStored: Boolean;
procedure SetAlignment(Value: TAlignment);
procedure SetAutoSize(Value: Boolean);
procedure SetBiDiMode(Value: TBiDiMode);
procedure SetMaxWidth(Value: Integer);
procedure SetMinWidth(Value: Integer);
procedure SetParentBiDiMode(Value: Boolean);
procedure SetStyle(Value: THeaderSectionStyle);
procedure SetText(const Value: string);
procedure SetWidth(Value: Integer);
procedure SetImageIndex(const Value: TImageIndex);
protected
function GetDisplayName: string; override;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
procedure ParentBiDiModeChanged;
function UseRightToLeftAlignment: Boolean;
function UseRightToLeftReading: Boolean;
property Left: Integer read GetLeft;
property Right: Integer read GetRight;
published
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property AllowClick: Boolean read FAllowClick write FAllowClick default True;
property AutoSize: Boolean read FAutoSize write SetAutoSize default False;
property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode stored IsBiDiModeStored;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex;
property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 10000;
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
property ParentBiDiMode: Boolean read FParentBiDiMode write SetParentBiDiMode default True;
property Style: THeaderSectionStyle read FStyle write SetStyle default hsText;
property Text: string read FText write SetText;
property Width: Integer read FWidth write SetWidth;
end;
THeaderSections = class(TCollection)
private
FHeaderControl: TCustomHeaderControl;
function GetItem(Index: Integer): THeaderSection;
procedure SetItem(Index: Integer; Value: THeaderSection);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(HeaderControl: TCustomHeaderControl);
function Add: THeaderSection;
function AddItem(Item: THeaderSection; Index: Integer): THeaderSection;
function Insert(Index: Integer): THeaderSection;
property Items[Index: Integer]: THeaderSection read GetItem write SetItem; default;
end;
TSectionTrackState = (tsTrackBegin, tsTrackMove, tsTrackEnd);
TCustomDrawSectionEvent = procedure(HeaderControl: TCustomHeaderControl;
Section: THeaderSection; const Rect: TRect; Pressed: Boolean) of object;
TCustomSectionNotifyEvent = procedure(HeaderControl: TCustomHeaderControl;
Section: THeaderSection) of object;
TCustomSectionTrackEvent = procedure(HeaderControl: TCustomHeaderControl;
Section: THeaderSection; Width: Integer;
State: TSectionTrackState) of object;
TSectionDragEvent = procedure (Sender: TObject; FromSection, ToSection: THeaderSection;
var AllowDrag: Boolean) of object;
TCustomHCCreateSectionClassEvent = procedure(Sender: TCustomHeaderControl;
var SectionClass: THeaderSectionClass) of object;
THeaderStyle = (hsButtons, hsFlat);
TCustomHeaderControl = class(TWinControl)
private
FSections: THeaderSections;
FSectionStream: TMemoryStream;
FUpdatingSectionOrder,
FSectionDragged: Boolean;
FCanvas: TCanvas;
FFromIndex,
FToIndex: Integer;
FFullDrag: Boolean;
FHotTrack: Boolean;
FDragReorder: Boolean;
FImageChangeLink: TChangeLink;
FImages: TCustomImageList;
FStyle: THeaderStyle;
FTrackSection: THeaderSection;
FTrackWidth: Integer;
FTrackPos: TPoint;
FOnDrawSection: TCustomDrawSectionEvent;
FOnSectionClick: TCustomSectionNotifyEvent;
FOnSectionResize: TCustomSectionNotifyEvent;
FOnSectionTrack: TCustomSectionTrackEvent;
FOnSectionDrag: TSectionDragEvent;
FOnSectionEndDrag: TNotifyEvent;
FOnCreateSectionClass: TCustomHCCreateSectionClassEvent;
function DoSectionDrag(FromSection, ToSection: THeaderSection): Boolean;
procedure DoSectionEndDrag;
procedure ImageListChange(Sender: TObject);
procedure SetDragReorder(const Value: Boolean);
procedure SetFullDrag(Value: Boolean);
procedure SetHotTrack(Value: Boolean);
procedure SetSections(Value: THeaderSections);
procedure SetStyle(Value: THeaderStyle);
procedure UpdateItem(Message, Index: Integer);
procedure UpdateSection(Index: Integer);
procedure UpdateSections;
procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
protected
function CreateSection: THeaderSection; virtual;
function CreateSections: THeaderSections; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
procedure DrawSection(Section: THeaderSection; const Rect: TRect;
Pressed: Boolean); dynamic;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SectionClick(Section: THeaderSection); dynamic;
procedure SectionDrag(FromSection, ToSection: THeaderSection; var AllowDrag: Boolean); dynamic;
procedure SectionEndDrag; dynamic;
procedure SectionResize(Section: THeaderSection); dynamic;
procedure SectionTrack(Section: THeaderSection; Width: Integer;
State: TSectionTrackState); dynamic;
procedure SetImages(Value: TCustomImageList); virtual;
procedure WndProc(var Message: TMessage); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas: TCanvas read FCanvas;
procedure FlipChildren(AllLevels: Boolean); override;
published
property Align default alTop;
property Anchors;
property BiDiMode;
property BorderWidth;
property DragCursor;
property DragKind;
property DragMode;
property DragReorder: Boolean read FDragReorder write SetDragReorder default False;
property FullDrag: Boolean read FFullDrag write SetFullDrag;
property HotTrack: Boolean read FHotTrack write SetHotTrack;
property Enabled;
property Font;
property Images: TCustomImageList read FImages write SetImages;
property Constraints;
property Sections: THeaderSections read FSections write SetSections;
property Style: THeaderStyle read FStyle write SetStyle;
property OnCreateSectionClass: TCustomHCCreateSectionClassEvent read FOnCreateSectionClass
write FOnCreateSectionClass;
property OnDrawSection: TCustomDrawSectionEvent read FOnDrawSection write FOnDrawSection;
property OnSectionClick: TCustomSectionNotifyEvent read FOnSectionClick
write FOnSectionClick;
property OnSectionDrag: TSectionDragEvent read FOnSectionDrag
write FOnSectionDrag;
property OnSectionEndDrag: TNotifyEvent read FOnSectionEndDrag
write FOnSectionEndDrag;
property OnSectionResize: TCustomSectionNotifyEvent read FOnSectionResize
write FOnSectionResize;
property OnSectionTrack: TCustomSectionTrackEvent read FOnSectionTrack
write FOnSectionTrack;
end;
{ THeaderControl }
TDrawSectionEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection; const Rect: TRect; Pressed: Boolean) of object;
TSectionNotifyEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection) of object;
TSectionTrackEvent = procedure(HeaderControl: THeaderControl;
Section: THeaderSection; Width: Integer;
State: TSectionTrackState) of object;
THCCreateSectionClassEvent = procedure(Sender: THeaderControl;
var SectionClass: THeaderSectionClass) of object;
THeaderControl = class(TCustomHeaderControl)
private
function GetOnDrawSection: TDrawSectionEvent;
function GetOnSectionClick: TSectionNotifyEvent;
function GetOnSectionResize: TSectionNotifyEvent;
function GetOnSectionTrack: TSectionTrackEvent;
procedure SetOnDrawSection(const Value: TDrawSectionEvent);
procedure SetOnSectionClick(const Value: TSectionNotifyEvent);
procedure SetOnSectionResize(const Value: TSectionNotifyEvent);
procedure SetOnSectionTrack(const Value: TSectionTrackEvent);
published
property Align default alTop;
property Anchors;
property BiDiMode;
property BorderWidth;
property DragCursor;
property DragKind;
property DragMode;
property DragReorder;
property Enabled;
property Font;
property FullDrag default True;
property HotTrack default False;
property Images;
property Constraints;
property Sections;
property ShowHint;
property Style default hsButtons;
property ParentBiDiMode;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Visible;
property OnContextPopup;
property OnCreateSectionClass;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
// Required for backwards compatibility with the old events
property OnDrawSection: TDrawSectionEvent read GetOnDrawSection write SetOnDrawSection;
property OnSectionClick: TSectionNotifyEvent read GetOnSectionClick
write SetOnSectionClick;
property OnSectionResize: TSectionNotifyEvent read GetOnSectionResize
write SetOnSectionResize;
property OnSectionTrack: TSectionTrackEvent read GetOnSectionTrack
write SetOnSectionTrack;
property OnSectionDrag;
property OnSectionEndDrag;
property OnStartDock;
property OnStartDrag;
end;
{ TTreeNode }
TCustomTreeView = class;
TTreeNodes = class;
TNodeState = (nsCut, nsDropHilited, nsFocused, nsSelected, nsExpanded);
TNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);
TAddMode = (taAddFirst, taAdd, taInsert);
PNodeInfo = ^TNodeInfo;
TNodeInfo = packed record
ImageIndex: Integer;
SelectedIndex: Integer;
StateIndex: Integer;
OverlayIndex: Integer;
Data: Pointer;
Count: Integer;
Text: string[255];
end;
TTreeNodeClass = class of TTreeNode;
TTreeNode = class(TPersistent)
private
FOwner: TTreeNodes;
FText: string;
FData: Pointer;
FItemId: HTreeItem;
FImageIndex: TImageIndex;
FSelectedIndex: Integer;
FOverlayIndex: Integer;
FStateIndex: Integer;
FDeleting: Boolean;
FInTree: Boolean;
function CompareCount(CompareMe: Integer): Boolean;
function DoCanExpand(Expand: Boolean): Boolean;
procedure DoExpand(Expand: Boolean);
procedure ExpandItem(Expand: Boolean; Recurse: Boolean);
function GetAbsoluteIndex: Integer;
function GetExpanded: Boolean;
function GetLevel: Integer;
function GetParent: TTreeNode;
function GetChildren: Boolean;
function GetCut: Boolean;
function GetDropTarget: Boolean;
function GetFocused: Boolean;
function GetIndex: Integer;
function GetItem(Index: Integer): TTreeNode;
function GetSelected: Boolean;
function GetCount: Integer;
function GetTreeView: TCustomTreeView;
procedure InternalMove(ParentNode, Node: TTreeNode; HItem: HTreeItem;
AddMode: TAddMode);
function IsEqual(Node: TTreeNode): Boolean;
function IsNodeVisible: Boolean;
procedure ReadData(Stream: TStream; Info: PNodeInfo);
procedure SetChildren(Value: Boolean);
procedure SetCut(Value: Boolean);
procedure SetData(Value: Pointer);
procedure SetDropTarget(Value: Boolean);
procedure SetItem(Index: Integer; Value: TTreeNode);
procedure SetExpanded(Value: Boolean);
procedure SetFocused(Value: Boolean);
procedure SetImageIndex(Value: TImageIndex);
procedure SetOverlayIndex(Value: Integer);
procedure SetSelectedIndex(Value: Integer);
procedure SetSelected(Value: Boolean);
procedure SetStateIndex(Value: Integer);
procedure SetText(const S: string);
procedure WriteData(Stream: TStream; Info: PNodeInfo);
protected
function GetState(NodeState: TNodeState): Boolean;
procedure SetState(NodeState: TNodeState; Value: Boolean);
procedure SetSelectedBit(Value: Boolean);
public
constructor Create(AOwner: TTreeNodes);
destructor Destroy; override;
function AlphaSort(ARecurse: Boolean = False): Boolean;
procedure Assign(Source: TPersistent); override;
procedure Collapse(Recurse: Boolean);
function CustomSort(SortProc: TTVCompare; Data: Longint; ARecurse: Boolean = False): Boolean;
procedure Delete;
procedure DeleteChildren;
function DisplayRect(TextOnly: Boolean): TRect;
function EditText: Boolean;
procedure EndEdit(Cancel: Boolean);
procedure Expand(Recurse: Boolean);
function getFirstChild: TTreeNode; {GetFirstChild conflicts with C++ macro}
function GetHandle: HWND;
function GetLastChild: TTreeNode;
function GetNext: TTreeNode;
function GetNextChild(Value: TTreeNode): TTreeNode;
function getNextSibling: TTreeNode; {GetNextSibling conflicts with C++ macro}
function GetNextVisible: TTreeNode;
function GetPrev: TTreeNode;
function GetPrevChild(Value: TTreeNode): TTreeNode;
function getPrevSibling: TTreeNode; {GetPrevSibling conflicts with a C++ macro}
function GetPrevVisible: TTreeNode;
function HasAsParent(Value: TTreeNode): Boolean;
function IndexOf(Value: TTreeNode): Integer;
procedure MakeVisible;
procedure MoveTo(Destination: TTreeNode; Mode: TNodeAttachMode); virtual;
property AbsoluteIndex: Integer read GetAbsoluteIndex;
function IsFirstNode: Boolean;
property Count: Integer read GetCount;
property Cut: Boolean read GetCut write SetCut;
property Data: Pointer read FData write SetData;
property Deleting: Boolean read FDeleting;
property Focused: Boolean read GetFocused write SetFocused;
property DropTarget: Boolean read GetDropTarget write SetDropTarget;
property Selected: Boolean read GetSelected write SetSelected;
property Expanded: Boolean read GetExpanded write SetExpanded;
property Handle: HWND read GetHandle;
property HasChildren: Boolean read GetChildren write SetChildren;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex;
property Index: Integer read GetIndex;
property IsVisible: Boolean read IsNodeVisible;
property Item[Index: Integer]: TTreeNode read GetItem write SetItem; default;
property ItemId: HTreeItem read FItemId;
property Level: Integer read GetLevel;
property OverlayIndex: Integer read FOverlayIndex write SetOverlayIndex;
property Owner: TTreeNodes read FOwner;
property Parent: TTreeNode read GetParent;
property SelectedIndex: Integer read FSelectedIndex write SetSelectedIndex;
property StateIndex: Integer read FStateIndex write SetStateIndex;
property Text: string read FText write SetText;
property TreeView: TCustomTreeView read GetTreeView;
end;
{ TTreeNodes }
PNodeCache = ^TNodeCache;
TNodeCache = record
CacheNode: TTreeNode;
CacheIndex: Integer;
end;
TTreeNodes = class(TPersistent)
private
FOwner: TCustomTreeView;
FUpdateCount: Integer;
FNodeCache: TNodeCache;
FReading: Boolean;
procedure AddedNode(Value: TTreeNode);
function GetHandle: HWND;
function GetNodeFromIndex(Index: Integer): TTreeNode;
procedure ReadData(Stream: TStream);
procedure Repaint(Node: TTreeNode);
procedure WriteData(Stream: TStream);
procedure ClearCache;
procedure WriteExpandedState(Stream: TStream);
procedure ReadExpandedState(Stream: TStream);
protected
function AddItem(Parent, Target: HTreeItem; const Item: TTVItem;
AddMode: TAddMode): HTreeItem;
procedure DefineProperties(Filer: TFiler); override;
function CreateItem(Node: TTreeNode): TTVItem;
function GetCount: Integer;
procedure SetItem(Index: Integer; Value: TTreeNode);
procedure SetUpdateState(Updating: Boolean);
property Reading: Boolean read FReading;
public
constructor Create(AOwner: TCustomTreeView);
destructor Destroy; override;
function AddChildFirst(Parent: TTreeNode; const S: string): TTreeNode;
function AddChild(Parent: TTreeNode; const S: string): TTreeNode;
function AddChildObjectFirst(Parent: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddChildObject(Parent: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddFirst(Sibling: TTreeNode; const S: string): TTreeNode;
function Add(Sibling: TTreeNode; const S: string): TTreeNode;
function AddObjectFirst(Sibling: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;
function AddObject(Sibling: TTreeNode; const S: string;
Ptr: Pointer): TTreeNode;