Repository navigation
Expand file tree
/
Copy pathSCPageControl.pas
More file actions
9838 lines (8353 loc) · 242 KB
/
Copy pathSCPageControl.pas
File metadata and controls
9838 lines (8353 loc) · 242 KB
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
{*******************************************************}
{ }
{ CA SweetControls Component Library }
{ }
{ Copyright (c) 1996,2004 CodeAccelerate Corporation }
{ }
{*******************************************************}
unit SCPageControl;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ImgList, {$IFDEF SC_DELPHI6_UP} Types, Variants, {$ENDIF}
SCCommon, SCConsts, SCControl;
type
TSCBaseTabControl = class;
TSCCustomTabControl = class;
TSCTabPoints = array of TPoint;
PSCTabPoints = ^TSCTabPoints;
TSCTabData = class(TPersistent)
private
FCaption: String;
FColor: TColor;
FEnabled: Boolean;
FFontColor: TColor;
FHint: String;
FDisabledImage: TImageIndex;
FHotImage: TImageIndex;
FImageIndex: TImageIndex;
FVisible: Boolean;
FTag: Longint;
FPoints: TSCTabPoints;
FTabItem: TObject;
FIndex: Integer;
FTabRect: TRect;
FRegion: HRGN;
FShowing: Boolean;
function GetPoints: TSCTabPoints;
procedure SetPoints(Value: TSCTabPoints);
procedure SetRegion(Value: HRGN);
procedure SetTabRect(Value: TRect);
protected
property Index: Integer read FIndex write FIndex;
property Points: TSCTabPoints read GetPoints write SetPoints;
property TabItem: TObject read FTabItem write FTabItem;
property TabRect: TRect read FTabRect write SetTabRect;
property Region: HRGN read FRegion write SetRegion;
property Showing: Boolean read FShowing write FShowing;
public
constructor Create;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property Caption: String read FCaption write FCaption;
property Color: TColor read FColor write FColor;
property Enabled: Boolean read FEnabled write FEnabled;
property FontColor: TColor read FFontColor write FFontColor;
property Hint: String read FHint write FHint;
property DisabledImage: TImageIndex read FDisabledImage write FDisabledImage;
property HotImage: TImageIndex read FHotImage write FHotImage;
property ImageIndex: TImageIndex read FImageIndex write FImageIndex;
property Tag: Longint read FTag write FTag;
property Visible: Boolean read FVisible write FVisible;
end;
TSCDataList = class(TObject)
private
FList: TList;
function Get(Index: Integer): TSCTabData;
public
constructor Create;
destructor Destroy; override;
function Count: Integer;
function Add: TSCTabData;
procedure Delete(Index: Integer);
procedure Clear;
property Items[Index: Integer]: TSCTabData read Get; default;
end;
TSCTabStyle = (sctbButton, sctbEclipse, sctbWin2K, sctbDotNet,
sctbDotNetFlat, sctbFlatButton, sctbOffice12, sctbOfficeXP, sctbNew,
sctbNewX, sctbXP, sctbWhidbey);
TSCTabPosition = (sctpTop, sctpBottom, sctpLeft, sctpRight);
TSCTabOrientation = (sctoDefault, sctoHorizontal, sctoVertical);
TSCTabHitTest = (scphNowhere, scphClient, scphCard, scphCloseButton,
scphLeftScroll, scphRightScroll, scphTab);
TSCTabHottrackStyle = (schsTab, schsText, schsTabAndText);
TSCTabHitInfo = record
X: Integer;
Y: Integer;
Tab: Integer;
Clicked: Boolean;
LeftButton: Boolean;
HitPos: TSCTabHitTest;
end;
PSCTabHitInfo = ^TSCTabHitInfo;
TSCTabColors = class(TPersistent)
private
FHighlightBar: TColor;
FHottrackBar: TColor;
FHottrackText: TColor;
FUnselected: TColor;
FUnselectedText: TColor;
FOwner: TSCBaseTabControl;
procedure SetHighlightBar(Value: TColor);
procedure SetHottrackBar(Value: TColor);
procedure SetHottrackText(Value: TColor);
procedure SetUnselected(Value: TColor);
procedure SetUnselectedText(Value: TColor);
protected
procedure DoChange;
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TSCBaseTabControl); virtual;
procedure Assign(Source: TPersistent); override;
published
property HighlightBar: TColor read FHighlightBar write SetHighlightBar default clHighlight;
property HottrackBar: TColor read FHottrackBar write SetHottrackBar default SC_HottrackColor;
property HottrackText: TColor read FHottrackText write SetHottrackText default clBlue;
property Unselected: TColor read FUnselected write SetUnselected default clNone;
property UnselectedText: TColor read FUnselectedText write SetUnselectedText default clNone;
end;
TSCTabGradient = (sctgNone, sctgDefault, sctgHorizontal, sctgVertical);
TSCTabPart = (sctpClient, sctpTab, sctpCloseBtn, sctpLeftBtn, sctpRightBtn);
TSCTabCloseEvent = procedure(Sender: TObject; var AllowClose: Boolean) of object;
TSCTabChangingEvent = procedure(Sender: TObject; NewIndex: Integer;
var AllowChange: Boolean) of object;
TSCTabEllipsisType = (scteNone, scteEndEllipsis, sctePathEllipsis);
TSCBaseTabControl = class(TSCCustomControl)
private
FAlignment: TLeftRight;
FAutoTabSize: Boolean;
FBackgroundColor: TColor;
FButtonColor: TColor;
FButtonIconColor: TColor;
FDefaultTabSize: Word;
FEllipsisType: TSCTabEllipsisType;
FFrameColor: TColor;
FImageSpacing: Integer;
FTabGradient: TSCTabGradient;
FHottrack: Boolean;
FHottrackStyle: TSCTabHottrackStyle;
FTabOrientation: TSCTabOrientation;
FTabPosition: TSCTabPosition;
FShowCardFrame: Boolean;
FShowCloseButton: Boolean;
FShowFocusRect: Boolean;
FStyle: TSCTabStyle;
FTabColors: TSCTabColors;
FTabIndex: Integer;
FTabIndexDefault: Integer;
FDataList: TSCDataList;
FHitInfo: TSCTabHitInfo;
FHottrackInfo: TSCTabHitInfo;
FTabsRect: TRect;
FScrollersVisible: Boolean;
FVisibleTabCount: Integer;
FTextHeight: Integer;
FTabSize: Integer;
FBufferUpdate: Integer;
FPaintBuffer: TBitmap;
FDesignChange: Boolean;
FUseTabColors: Boolean;
FOnTabClick: TNotifyEvent;
FOnTabChange: TNotifyEvent;
FOnTabChanging: TSCTabChangingEvent;
FOnTabClose: TSCTabCloseEvent;
FScrolling: Boolean;
FScrollingLeft: Boolean;
FScrollingPaused: Boolean;
FScrollTimer: Integer;
FFirstTab: Integer;
FControlLoaded: Boolean;
FMaximumWidth: Integer;
procedure SetAlignment(Value: TLeftRight);
procedure SetAutoTabSize(Value: Boolean);
procedure SetBackgroundColor(Value: TColor);
procedure SetButtonColor(Value: TColor);
procedure SetButtonIconColor(Value: TColor);
procedure SetDefaultTabSize(Value: Word);
procedure SetEllipsisType(Value: TSCTabEllipsisType);
procedure SetFrameColor(Value: TColor);
procedure SetImageSpacing(Value: Integer);
procedure SetHottrack(Value: Boolean);
procedure SetHottrackStyle(Value: TSCTabHottrackStyle);
procedure SetMaximumWidth(Value: Integer);
procedure SetShowCardFrame(Value: Boolean);
procedure SetShowCloseButton(Value: Boolean);
procedure SetShowFocusRect(Value: Boolean);
procedure SetStyle(Value: TSCTabStyle);
procedure SetTabColors(Value: TSCTabColors);
procedure SetTabGradient(Value: TSCTabGradient);
procedure SetTabIndex(Value: Integer);
procedure SetTabOrientation(Value: TSCTabOrientation);
procedure SetTabPosition(Value: TSCTabPosition);
function GetBandRect: TRect;
function GetTabsRect: TRect;
function GetCardRect: TRect;
procedure ColorsChanged;
procedure TabIndexChanged;
procedure UpdateFontSize;
procedure CloseClick;
procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CMFocusChanged(var Message: TCMFocusChanged); message CM_FOCUSCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMTimer(var Message: TWMTimer); message WM_TIMER;
protected
procedure DefineProperties(Filer: TFiler); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure AdjustClientRect(var ARect: TRect); override;
procedure Loaded; override;
procedure CreateWnd; override;
procedure Paint; override;
function GetControlLoaded: Boolean;
procedure SetControlLoaded(Value: Boolean);
function GetTabIndexDefault: Integer;
procedure SetTabIndexDefault(Value: Integer);
procedure UpdateDesigner;
procedure ReadActiveTab(Reader: TReader); virtual;
procedure WriteActiveTab(Writer: TWriter); virtual;
function CanClose: Boolean; dynamic;
procedure Changing(NewIndex: Integer; var Allowed: Boolean); virtual;
procedure SetUseTabColors(Value: Boolean); virtual;
procedure DestroyActiveTab; virtual;
procedure ActiveTabMoved(Index: Integer); virtual;
procedure RedrawTabs; virtual;
procedure UpdateBuffer(OnlyTabs: Boolean = False);
function GetDataList: TSCDataList;
procedure InitializeHitTest(AHitInfo: PSCTabHitInfo);
procedure StopTracking; override;
procedure SpacingChanged; override;
procedure UpdateHottrackInfo;
procedure CheckMouseUpdate(OldHot: TSCTabHitInfo);
function RectFromPoints(Points: TSCTabPoints): TRect;
function GetFrameColor: TColor; virtual;
function GetTabColor(Tab: TSCTabData): TColor; virtual;
function GetTabTextColor(Tab: TSCTabData): TColor; virtual;
function GetTabFontColor(Tab: TSCTabData): TColor; virtual;
function GetTabImage(Tab: TSCTabData): TImageIndex; virtual;
procedure DrawTabs; virtual;
procedure DrawCloseButton; virtual;
procedure DrawScrollers(Left: Boolean); virtual;
procedure PaintTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawShadow(Tab: TSCTabData; R: TRect); virtual;
procedure DrawHottrack(Tab: TSCTabData; R: TRect); virtual;
procedure DrawBackground(Tab: TSCTabData; R: TRect); virtual;
procedure DrawImageAndText(Tab: TSCTabData; R: TRect); virtual;
procedure DrawButtonTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawDotNetTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawDotNetFlatTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawEclipseTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawFlatButtonTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawOffice12Tab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawOfficeXpTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawNewTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawNewXTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawXpTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawWhidbeyTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawWin2KTab(C: TCanvas; Tab: TSCTabData); virtual;
procedure DrawCard(R: TRect); virtual;
procedure DrawCardBackground(R: TRect); virtual;
procedure DrawDotNetCard(R: TRect); virtual;
procedure DrawDotNetFlatCard(R: TRect); virtual;
procedure DrawEclipseCard(R: TRect); virtual;
procedure DrawNewCard(R: TRect); virtual;
procedure DrawNewXCard(R: TRect); virtual;
procedure DrawOffice12Card(R: TRect); virtual;
procedure DrawXpCard(R: TRect); virtual;
procedure DrawWhidbeyCard(R: TRect); virtual;
procedure DrawWin2KCard(R: TRect); virtual;
procedure ScrollTabs(Left: Boolean);
function CanScroll: Boolean;
procedure PauseScroll;
procedure ResumeScroll;
procedure StopScroll;
function Scrolling: Boolean;
function ScrollPaused: Boolean;
procedure FirstTabChanged; virtual;
function ArrangeFirstTab(Value: Integer): Integer; virtual;
procedure SetFirstTab(Value: Integer);
procedure MakeTabVisible(Index: Integer;
UpdateAfter: Boolean); dynamic;
function GetIndent: Integer; override;
procedure SetIndent(Value: Integer); override;
procedure IndentChanged; override;
procedure ImageListChange(Sender: TObject); override;
procedure DoColorsChanged; virtual;
procedure DoTabIndexChanged; virtual;
procedure UpdateTabs(Realign: Boolean = False);
procedure StoreCalcValues;
procedure FillDataList; virtual;
procedure UpdateTabRects; virtual;
procedure DoCloseClick; virtual;
procedure TabClick; virtual;
function GetMaximumTabSize: Integer;
function CheckVisible(Index: Integer): Integer;
function GetScrollersVisible: Boolean; virtual;
function GetVisibleTabCount: Integer; virtual;
function GetBorderIndent: Integer; virtual;
function GetActiveIndex: Integer; dynamic;
function GetVisibleIndexOf(Index: Integer): Integer; dynamic;
function GetFirstShowingTab: Integer; dynamic;
function GetLastShowingTab: Integer; dynamic;
function GetFirstVisibleTab: Integer; dynamic;
function GetLastVisibleTab: Integer; dynamic;
function GetPrevVisibleTab(Index: Integer): Integer; dynamic;
function GetNextVisibleTab(Index: Integer): Integer; dynamic;
function GetTabSize: Integer; dynamic;
procedure CalculateTabSize(Index: Integer; var W, H: Integer); dynamic;
function GetTabSpacing: Integer; virtual;
function GetTabRect(Index: Integer): TRect; virtual;
function GetTabPoints(R: TRect; ForRegion: Boolean;
Rounding, FrameIndex: Integer): TSCTabPoints; virtual;
function GetCloseButtonRect: TRect; virtual;
function GetScrollerRect(Left: Boolean): TRect; virtual;
function HitTest(const P: TPoint): TSCTabHitInfo; 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;
property DataList: TSCDataList read FDataList;
property TabsRect: TRect read FTabsRect;
property ScrollersVisible: Boolean read FScrollersVisible;
property VisibleTabCount: Integer read FVisibleTabCount;
property TabSize: Integer read FTabSize;
property TextHeight: Integer read FTextHeight;
property Spacing default 0;
property ControlLoaded: Boolean read FControlLoaded;
property Alignment: TLeftRight read FAlignment write SetAlignment default taLeftJustify;
property AutoTabSize: Boolean read FAutoTabSize write SetAutoTabSize default True;
property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor default clNone;
property ButtonColor: TColor read FButtonColor write SetButtonColor default clBtnFace;
property ButtonIconColor: TColor read FButtonIconColor write
SetButtonIconColor default clWindowText;
property DefaultTabSize: Word read FDefaultTabSize write SetDefaultTabSize default 72;
property EllipsisType: TSCTabEllipsisType read FEllipsisType write SetEllipsisType default scteEndEllipsis;
property FrameColor: TColor read FFrameColor write SetFrameColor default clBtnShadow;
property Hottrack: Boolean read FHottrack write SetHottrack default True;
property HottrackStyle: TSCTabHottrackStyle read FHottrackStyle write SetHottrackStyle default schsTabAndText;
property ImageSpacing: Integer read FImageSpacing write SetImageSpacing default 2;
property MaximumWidth: Integer read FMaximumWidth write SetMaximumWidth default -1;
property ShowCardFrame: Boolean read FShowCardFrame write SetShowCardFrame default True;
property ShowCloseButton: Boolean read FShowCloseButton write SetShowCloseButton default False;
property ShowFocusRect: Boolean read FShowFocusRect write SetShowFocusRect default True;
property Style: TSCTabStyle read FStyle write SetStyle default sctbWin2K;
property TabColors: TSCTabColors read FTabColors write SetTabColors;
property TabGradient: TSCTabGradient read FTabGradient write SetTabGradient default sctgDefault;
property TabIndex: Integer read FTabIndex write SetTabIndex default -1;
property TabOrientation: TSCTabOrientation read FTabOrientation write SetTabOrientation default sctoDefault;
property TabPosition: TSCTabPosition read FTabPosition write SetTabPosition default sctpTop;
property UseTabColors: Boolean read FUseTabColors write SetUseTabColors default False;
property OnTabClick: TNotifyEvent read FOnTabClick write FOnTabClick;
property OnTabChange: TNotifyEvent read FOnTabChange write FOnTabChange;
property OnTabChanging: TSCTabChangingEvent read FOnTabChanging write FOnTabChanging;
property OnTabClose: TSCTabCloseEvent read FOnTabClose write FOnTabClose;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function TabAtPos(const P: TPoint): Integer;
procedure CloseActiveTab;
procedure HideAllTabs; virtual;
procedure ShowAllTabs; virtual;
end;
TSCTabItem = class(TCollectionItem)
private
FCaption: string;
FColor: TColor;
FEnabled: Boolean;
FFontColor: TColor;
FHint: string;
FDisabledImage: TImageIndex;
FHotImage: TImageIndex;
FImageIndex: TImageIndex;
FVisible: Boolean;
FShowing: Boolean;
FTag: Longint;
FData: TObject;
FTabRect: TRect;
function GetShowing: Boolean;
procedure SetCaption(const Value: String);
procedure SetColor(Value: TColor);
procedure SetEnabled(Value: Boolean);
procedure SetFontColor(Value: TColor);
procedure SetHint(const Value: String);
procedure SetDisabledImage(Value: TImageIndex);
procedure SetHotImage(Value: TImageIndex);
procedure SetImageIndex(Value: TImageIndex);
procedure SetVisible(Value: Boolean);
procedure SetTabRect(Value: TRect);
protected
function GetDisplayName: string; override;
procedure AssignTo(Dest: TPersistent); override;
property TabRect: TRect read FTabRect write SetTabRect;
public
constructor Create(Collection: TCollection); override;
procedure Assign(Source: TPersistent); override;
property Showing: Boolean read GetShowing;
property Data: TObject read FData write FData;
published
property Caption: String read FCaption write SetCaption;
property Color: TColor read FColor write SetColor default clBtnFace;
property Enabled: Boolean read FEnabled write SetEnabled default True;
property FontColor: TColor read FFontColor write SetFontColor default clNone;
property Hint: String read FHint write SetHint;
property DisabledImage: TImageIndex read FDisabledImage write SetDisabledImage default -1;
property HotImage: TImageIndex read FHotImage write SetHotImage default -1;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
property Tag: Longint read FTag write FTag default 0;
property Visible: Boolean read FVisible write SetVisible default True;
end;
TSCTabItems = class(TCollection)
private
FOwner: TSCCustomTabControl;
function GetItem(Index: Integer): TSCTabItem;
procedure SetItem(Index: Integer; Value: TSCTabItem);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(AOwner: TSCCustomTabControl); virtual;
function Add: TSCTabItem;
procedure Delete(Index: Integer);
procedure Move(CurIndex, NewIndex: Integer);
procedure Clear;
property Items[Index: Integer]: TSCTabItem read GetItem write SetItem; default;
end;
TSCCustomTabControl = class(TSCBaseTabControl)
private
FTabs: TSCTabItems;
procedure SetTabs(Value: TSCTabItems);
protected
procedure FillDataList; override;
procedure UpdateTabRects; override;
function GetFirstShowingTab: Integer; override;
function GetLastShowingTab: Integer; override;
function GetFirstVisibleTab: Integer; override;
function GetLastVisibleTab: Integer; override;
function GetTabSize: Integer; override;
function GetActiveIndex: Integer; override;
procedure CalculateTabSize(Index: Integer; var W, H: Integer); override;
function GetScrollersVisible: Boolean; override;
function GetVisibleTabCount: Integer; override;
procedure DoCloseClick; override;
property Tabs: TSCTabItems read FTabs write SetTabs;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure HideAllTabs; override;
procedure ShowAllTabs; override;
end;
TSCTabControl = class(TSCCustomTabControl)
published
property Align;
property Alignment;
property AutoTabSize;
property BackgroundColor;
property ButtonColor;
property ButtonIconColor;
property ClickFocus;
property Color;
property DefaultTabSize;
property EllipsisType;
property FrameColor;
property Font;
property TabGradient;
property Hottrack;
property HottrackStyle;
property Images;
property ImageSpacing;
property Indent;
property MaximumWidth;
property ParentColor;
property ParentFont;
property ShowCardFrame;
property ShowCloseButton;
property ShowFocusRect;
property Spacing;
property Style;
property TabColors;
property TabIndex;
property TabOrientation;
property TabPosition;
property Tabs;
property UseTabColors;
property Visible;
property OnClick;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property OnTabClick;
property OnTabClose;
property OnTabChange;
property OnTabChanging;
property OnUnDock;
end;
TSCCustomPageControl = class;
TSCTabSheet = class(TSCCustomControl)
private
FImageIndex: TImageIndex;
FDisabledImage: TImageIndex;
FHotImage: TImageIndex;
FPageControl: TSCCustomPageControl;
FTabEnabled: Boolean;
FTabVisible: Boolean;
FData: Pointer;
FShowing: Boolean;
FTabRect: TRect;
FFontColor: TColor;
procedure Changed;
procedure InternalSetVisible(Value: Boolean);
function GetColor: TColor;
procedure SetColor(Value: TColor);
procedure SetFontColor(Value: TColor);
procedure SetImageIndex(Value: TImageIndex);
procedure SetDisabledImage(Value: TImageIndex);
procedure SetHotImage(Value: TImageIndex);
procedure SetPageControl(APageControl: TSCCustomPageControl);
function GetPageIndex: Integer;
procedure SetPageIndex(Value: Integer);
procedure SetTabEnabled(Value: Boolean);
function GetTabIndex: Integer;
procedure SetTabVisible(Value: Boolean);
function GetVisible: Boolean;
procedure SetVisible(Value: Boolean);
procedure SetTabRect(Value: TRect);
function GetTabVisible: Boolean;
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
protected
procedure AssignTo(Dest: TPersistent); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
procedure ReadState(Reader: TReader); override;
function GetImages: TCustomImageList; override;
property TabRect: TRect read FTabRect write SetTabRect;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Data: Pointer read FData write FData;
property TabIndex: Integer read GetTabIndex;
property Visible: Boolean read GetVisible write SetVisible;
property PageControl: TSCCustomPageControl read FPageControl write SetPageControl;
published
property Color: TColor read GetColor write SetColor default clBtnFace;
property FontColor: TColor read FFontColor write SetFontColor default clNone;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
property HotImage: TImageIndex read FHotImage write SetHotImage default -1;
property DisabledImage: TImageIndex read FDisabledImage write SetDisabledImage default -1;
property PageIndex: Integer read GetPageIndex write SetPageIndex stored False;
property TabEnabled: Boolean read FTabEnabled write SetTabEnabled default True;
property TabVisible: Boolean read FTabVisible write SetTabVisible default True;
property Caption;
property Constraints;
property Enabled;
property Font;
property Height stored False;
property Left stored False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Top stored False;
property Width stored False;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
end;
TSCCustomPageControl = class(TSCBaseTabControl)
private
FPages: TList;
FActivePage: TSCTabSheet;
FNewDockSheet: TSCTabSheet;
FUndockingPage: TSCTabSheet;
FInitActivePage: Boolean;
procedure InsertPage(Page: TSCTabSheet);
procedure RemovePage(Page: TSCTabSheet);
procedure ChangeActivePage(Page: TSCTabSheet);
function GetDockClientAt(P: TPoint): TControl;
procedure ReadEmptyData(Reader: TReader);
procedure WriteEmptyData(Writer: TWriter);
procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
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;
protected
procedure DefineProperties(Filer: TFiler); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure Loaded; override;
procedure FillDataList; override;
procedure UpdateTabRects; override;
procedure Changing(NewIndex: Integer; var Allowed: Boolean); override;
function GetFirstShowingTab: Integer; override;
function GetLastShowingTab: Integer; override;
function GetFirstVisibleTab: Integer; override;
function GetLastVisibleTab: Integer; override;
function GetTabSize: Integer; override;
function GetActiveIndex: Integer; override;
procedure CalculateTabSize(Index: Integer; var W, H: Integer); override;
function GetScrollersVisible: Boolean; override;
function GetVisibleTabCount: Integer; override;
procedure DoCloseClick; override;
procedure DoTabIndexChanged; override;
procedure DestroyActiveTab; override;
procedure ActiveTabMoved(Index: Integer); override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
procedure ShowControl(AControl: TControl); 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;
function GetPageFromDockClient(Client: TControl): TSCTabSheet;
procedure GetSiteInfo(Client: TControl; var InfluenceRect: TRect;
MousePos: TPoint; var CanDock: Boolean); override;
function GetPage(Index: Integer): TSCTabSheet; virtual;
function GetPageCount: Integer; virtual;
procedure SetActivePage(Page: TSCTabSheet); virtual;
function GetActivePageIndex: Integer; virtual;
procedure SetActivePageIndex(Value: Integer); virtual;
procedure SetUseTabColors(Value: Boolean); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Change; override;
function FindNextPage(CurPage: TSCTabSheet; GoForward,
CheckTabVisible: Boolean): TSCTabSheet;
function PageForTab(ATabIndex: Integer): TSCTabSheet;
procedure SelectNextPage(GoForward: Boolean);
procedure HideAllTabs; override;
procedure ShowAllTabs; override;
procedure MakeControlVisible(AControl: TControl);
property PageCount: Integer read GetPageCount;
property Pages[Index: Integer]: TSCTabSheet read GetPage;
property ActivePageIndex: Integer read GetActivePageIndex write SetActivePageIndex;
property ActivePage: TSCTabSheet read FActivePage write SetActivePage;
property Color default clBtnFace;
end;
TSCPageControl = class(TSCCustomPageControl)
published
property ActivePage;
property Align;
property Alignment;
property Anchors;
property AutoTabSize;
property BackgroundColor;
property Color;
property UseTabColors;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property EllipsisType;
property Enabled;
property Font;
property FrameColor;
property HelpContext;
property Hint;
property Hottrack;
property HottrackStyle;
property Images;
property ImageSpacing;
property Indent;
property MaximumWidth;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowCardFrame;
property ShowCloseButton;
property ShowFocusRect;
property ShowHint;
property Spacing;
property Style;
property TabColors;
property TabGradient;
property TabOrientation;
property TabPosition;
property TabStop;
property Visible;
property OnClick;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property OnTabClick;
property OnTabClose;
property OnTabChange;
property OnTabChanging;
property OnUnDock;
end;
implementation
var
Registered: Boolean = False;
const
SC_TabsMinHeight = 21;
ButtonStyles = [sctbButton, sctbEclipse, sctbFlatButton, sctbOfficeXP];
GradientStyles = [sctbDotNetFlat, sctbEclipse, sctbOffice12, sctbOfficeXP,
sctbNew, sctbNewX, sctbXP, sctbWhidbey];
type
TSCFakeControl = class(TControl);
{ TSCTabItem }
procedure TSCTabItem.Assign(Source: TPersistent);
begin
if Source is TSCTabItem then
begin
with TSCTabItem(Source) do
begin
Self.FCaption := Caption;
Self.FColor := Color;
Self.FEnabled := Enabled;
Self.FFontColor := FontColor;
Self.FVisible := Visible;
Self.FHint := Hint;
Self.FDisabledImage := DisabledImage;
Self.FHotImage := HotImage;
Self.FImageIndex := ImageIndex;
Self.FTag := Tag;
end;
Changed(True);
end else
if Source is TSCTabData then
begin
with TSCTabData(Source) do
begin
Self.FCaption := Caption;
Self.FColor := Color;
Self.FEnabled := Enabled;
Self.FFontColor := FontColor;
Self.FVisible := Visible;
Self.FHint := Hint;
Self.FDisabledImage := DisabledImage;
Self.FHotImage := HotImage;
Self.FImageIndex := ImageIndex;
Self.FTag := Tag;
end;
Changed(True);
end else
inherited Assign(Source);
end;
procedure TSCTabItem.AssignTo(Dest: TPersistent);
begin
if Dest is TSCTabData then
begin
with TSCTabData(Dest) do
begin
FCaption := Self.Caption;
FColor := Self.Color;
FEnabled := Self.Enabled;
FFontColor := Self.FontColor;
FVisible := Self.Visible;
FHint := Self.Hint;
FDisabledImage := Self.DisabledImage;
FHotImage := Self.HotImage;
FImageIndex := Self.ImageIndex;
FTag := Self.Tag;
end;
end else
inherited AssignTo(Dest);
end;
constructor TSCTabItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FTabRect := Rect(0, 0, 0, 0);
FColor := clBtnFace;
FEnabled := True;
FFontColor := clNone;
FVisible := True;
FShowing := True;
FDisabledImage := -1;
FHotImage := -1;
FImageIndex := -1;
end;
function TSCTabItem.GetDisplayName: string;
begin
Result := FCaption;
if Result = '' then Result := inherited GetDisplayName;
end;
function TSCTabItem.GetShowing: Boolean;
begin
Result := FShowing and FVisible;
end;
procedure TSCTabItem.SetCaption(const Value: String);
begin
if FCaption <> Value then
begin
FCaption := Value;
if FVisible then
Changed(True);
end;
end;
procedure TSCTabItem.SetColor(Value: TColor);
begin
if FColor <> Value then
begin
FColor := Value;
if FVisible then
Changed(True);
end;
end;
procedure TSCTabItem.SetDisabledImage(Value: TImageIndex);
begin
if FDisabledImage <> Value then
begin
FDisabledImage := Value;
if FVisible then
Changed(True);
end;
end;
procedure TSCTabItem.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
if FVisible then
Changed(True);
end;
end;
procedure TSCTabItem.SetFontColor(Value: TColor);
begin
if FFontColor <> Value then
begin
FFontColor := Value;
if FVisible then
Changed(True);
end;
end;