Repository navigation
Expand file tree
/
Copy pathSCTabSet.pas
More file actions
3980 lines (3415 loc) · 109 KB
/
Copy pathSCTabSet.pas
File metadata and controls
3980 lines (3415 loc) · 109 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 SCTabSet;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, StdActns, ActnList, Menus, SCCommon, SCConsts, SCControl;
type
TSCCustomTabset = class;
TSCTabsetPanel = class;
TSCTabsetPanelActionLink = class(TSCCollectionActionLink)
protected
FClient: TSCTabsetPanel;
procedure AssignClient(AClient: TObject); override;
function IsCaptionLinked: Boolean; override;
function IsEnabledLinked: Boolean; override;
function IsHintLinked: Boolean; override;
function IsImageIndexLinked: Boolean; override;
function IsVisibleLinked: Boolean; override;
function IsOnExecuteLinked: Boolean; override;
procedure SetCaption(const Value: string); override;
procedure SetEnabled(Value: Boolean); override;
procedure SetHint(const Value: string); override;
procedure SetImageIndex(Value: Integer); override;
procedure SetVisible(Value: Boolean); override;
procedure SetOnExecute(Value: TNotifyEvent); override;
end;
TSCTabsetPanel = class(TSCCollectionItem)
private
FText: string;
FWidth: Integer;
FAlignment: TLeftRight;
FColor: TColor;
FData: TObject;
FParentColor: Boolean;
FImageIndex: TImageIndex;
FVisible: Boolean;
FEnabled: Boolean;
FFontColor: TColor;
FActionLink: TSCTabsetPanelActionLink;
FEndEllipsis: Boolean;
FHint: String;
FSelected: Boolean;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnMouseDown: TMouseEvent;
FOnMouseMove: TMouseMoveEvent;
FOnMouseUp: TMouseEvent;
procedure SetAlignment(Value: TLeftRight);
procedure SetColor(Value: TColor);
procedure SetEndEllipsis(Value: Boolean);
procedure SetEnabled(Value: Boolean);
procedure SetFontColor(Value: TColor);
procedure SetParentColor(Value: Boolean);
procedure SetSelected(Value: Boolean);
procedure SetImageIndex(Value: TImageIndex);
procedure SetText(const Value: string);
procedure SetVisible(Value: Boolean);
procedure SetWidth(Value: Integer);
function GetAction: TBasicAction;
procedure SetAction(const Value: TBasicAction);
function GetTabset: TSCCustomTabset;
protected
function GetDisplayName: string; override;
function GetParentColor: TColor; virtual;
function IsAutoSized: Boolean;
function IsCaptionStored: Boolean;
function IsEnabledStored: Boolean;
function IsHintStored: Boolean;
function IsImageIndexStored: Boolean;
function IsOnClickStored: Boolean;
function IsVisibleStored: Boolean;
procedure DoActionChange(Sender: TObject);
function OwnerState: TComponentState;
function GetDefaultColor: TColor;
function GetImages: TCustomImageList;
procedure UpdateTabSelection; virtual;
function GetActionLinkClass: TSCCollectionActionLinkClass; dynamic;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
property ActionLink: TSCTabsetPanelActionLink read FActionLink write FActionLink;
property Tabset: TSCCustomTabset read GetTabset;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property Data: TObject read FData write FData;
published
property Action: TBasicAction read GetAction write SetAction;
property Alignment: TLeftRight read FAlignment write SetAlignment default taLeftJustify;
property Color: TColor read FColor write SetColor stored True;
property Enabled: Boolean read FEnabled write SetEnabled stored IsEnabledStored default True;
property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default True;
property FontColor: TColor read FFontColor write SetFontColor default clNone;
property Hint: String read FHint write FHint;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex
stored IsImageIndexStored default -1;
property ParentColor: Boolean read FParentColor write SetParentColor stored True default False;
property Selected: Boolean read FSelected write SetSelected default False;
property Text: string read FText write SetText stored IsCaptionStored;
property Visible: Boolean read FVisible write SetVisible stored IsVisibleStored default True;
property Width: Integer read FWidth write SetWidth default 50;
property OnClick: TNotifyEvent read FOnClick write FOnClick stored IsOnClickStored;
property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown;
property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove;
property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp;
end;
TSCTabsetPanels = class(TCollection)
private
FTabset: TSCCustomTabset;
FOldCount: Integer;
function GetItem(Index: Integer): TSCTabsetPanel;
procedure SetItem(Index: Integer; Value: TSCTabsetPanel);
function GetComponentState: TComponentState;
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
property ComponentState: TComponentState read GetComponentState;
public
constructor Create(AOwner: TSCCustomTabset);
function Add: TSCTabsetPanel;
{$IFDEF SC_DELPHI5_AND_EARLY}
property Owner: TSCCustomTabset read FTabset;
{$ENDIF}
property Items[Index: Integer]: TSCTabsetPanel read GetItem write SetItem; default;
end;
TSCTabChangeEvent = procedure(Sender: TObject; NewTab: Integer; var AllowChange: Boolean) of object;
TSCDrawTabEvent = procedure(Sender: TObject; ATab: TSCTabsetPanel;
ACanvas: TCanvas; const ARect: TRect) of object;
TSCOwnerDrawEvent = procedure(Sender: TObject; ACanvas: TCanvas; const ARect: TRect) of object;
TSCOwnerDrawScrollerEvent = procedure(Sender: TObject; ACanvas: TCanvas;
const ARect: TRect; const IsLeft: Boolean) of object;
TSCTabsetStyle = (sctsDotNet, sctsMac, sctsWindows, sctsWinXP, sctsOfficeXP,
sctsOwnerDraw);
TSCTabsetPosition = (sctpTop, sctpBottom);
TSCCustomTabset = class(TSCCustomControl)
private
FAutoSizeTabs: Boolean;
FAutoShowButton: Boolean;
FAutoShowScrollers: Boolean;
FIsButtonVisible: Boolean;
FButtonColor: TColor;
FButtonVisible: Boolean;
FDefaultTabColor: TColor;
FDrawBorder: Boolean;
FFlatButton: Boolean;
FFirstTabIndex: Integer;
FScrollersVisible: Boolean;
FScrollButtons: Boolean;
FScrollerColor: TColor;
FScrollArrowColor: TColor;
FSelectedColor: TColor;
FSelectedFontColor: TColor;
FStyle: TSCTabsetStyle;
FTabPosition: TSCTabsetPosition;
FTabs: TSCTabsetPanels;
FUseSystemFont: Boolean;
FUseDefaultColor: Boolean;
FXPHotColor: TColor;
FOnButton: Boolean;
FMouseDownTab: Integer;
FTabDblClicked: Boolean;
FOldCursor: TCursor;
FBtnPressed: Boolean;
FScrollPressed: Boolean;
FScrollerIsHot: Boolean;
FIsLeftScroller: Boolean;
FLeftScrollEnabled: Boolean;
FRightScrollEnabled: Boolean;
FChanging: Boolean;
FOnBtnClick: TNotifyEvent;
FOnBtnMouseUp: TMouseEvent;
FOnChange: TSCTabChangeEvent;
FOnBtnMouseDown: TMouseEvent;
FOnDrawBkground: TSCOwnerDrawEvent;
FOnDrawButton: TSCOwnerDrawEvent;
FOnDrawScroller: TSCOwnerDrawScrollerEvent;
FOnDrawTab: TSCDrawTabEvent;
FOnHint: TNotifyEvent;
procedure SetAutoSizeTabs(Value: Boolean);
procedure SetAutoShowButton(Value: Boolean);
procedure SetAutoShowScrollers(Value: Boolean);
procedure SetButtonColor(Value: TColor);
procedure SetDefaultTabColor(Value: TColor);
procedure SetTabPosition(Value: TSCTabsetPosition);
procedure SetFlatButton(Value: Boolean);
procedure SetFirstTabIndex(Value: Integer);
procedure SetDrawBorder(Value: Boolean);
procedure SetStyle(Value: TSCTabsetStyle);
procedure SetSelectedFontColor(Value: TColor);
procedure SetButtonVisible(Value: Boolean);
procedure SetScrollArrowColor(Value: TColor);
procedure SetScrollButtons(Value: Boolean);
procedure SetScrollerColor(Value: TColor);
function GetSelected: Integer;
procedure SetSelected(Value: Integer);
procedure SetSelectedColor(Value: TColor);
procedure SetTabs(Value: TSCTabsetPanels);
procedure SetUseSystemFont(const Value: Boolean);
procedure SetUseDefaultColor(Value: Boolean);
procedure SetXPHotColor(Value: TColor);
function GetSelectedPanel: TSCTabsetPanel;
procedure UpdateButtonAndScrollers(X, Y: Integer);
procedure DoDrawTab(ATab: TSCTabsetPanel; ACanvas: TCanvas; const ARect: TRect);
procedure DoDrawBackground(ACanvas: TCanvas; const ARect: TRect);
procedure DoDrawButton(ACanvas: TCanvas; const ARect: TRect);
procedure DoDrawScrollerEvent(ACanvas: TCanvas; const ARect: TRect; const IsLeft: Boolean);
procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure CMHintShow(var Msg: TMessage); message CM_HINTSHOW;
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
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 WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
protected
procedure Loaded; override;
procedure Paint; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
function CheckScrollersEnabled: Boolean;
function CheckScrollersVisible(var StateChanged: Boolean): Boolean;
function CheckButtonIsVisible(var StateChanged: Boolean): Boolean;
procedure CheckFirstTab(var Value: Integer);
function GetBlendValue: Word; override;
procedure MouseInControlChanged; override;
procedure SetIndent(Value: Integer); override;
function CanChange(NewIndex: Integer): Boolean;
function DoHint: Boolean; virtual;
procedure DoSelectionChange; 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;
function IsFontStored: Boolean;
procedure SyncToSystemFont;
function GetTabFontColor(ATab: TSCTabsetPanel): TColor;
procedure UpdateTabColors(OldColor: TColor);
procedure UpdateTab(Index: Integer; Repaint: Boolean); virtual;
procedure RedrawTab(Index: Integer);
procedure UpdateTabs; dynamic;
function GetTopIndent: Integer; dynamic;
function GetLeftIndent: Integer; dynamic;
function GetRightIndent(IsBtnVisible, IsScrollerVisible: Boolean): Integer; dynamic;
function GetTabsRect: TRect; virtual;
function GetButtonRect(IsVisible: Boolean): TRect; virtual;
function GetScrollerWidth: Integer; virtual;
function GetScrollersRect(IsVisible: Boolean): TRect; virtual;
function ActiveTab: TSCTabsetPanel;
function IsValidTab(ATab: Integer): Boolean;
function GetTabTextRect(ACanvas: TCanvas; ATab: TSCTabsetPanel): TRect; virtual;
function GetTabImageRect(ATab: TSCTabsetPanel): TRect; virtual;
procedure UpdateBorder(ACanvas: TCanvas);
procedure UpdateScrollersOn(ACanvas: TCanvas);
function GetTabColor(ATab: TSCTabsetPanel): TColor;
procedure DrawTab(Tab: TSCTabsetPanel; TabCanvas: TCanvas; const ARect: TRect);
procedure DrawTabEdge(ATab: TSCTabsetPanel; TabCanvas: TCanvas; const ARect: TRect);
procedure DrawScrollers(ACanvas: TCanvas; X, Y: Integer);
procedure DrawButton(ACanvas: TCanvas);
property SelectedPanel: TSCTabsetPanel read GetSelectedPanel;
property AutoShowButton: Boolean read FAutoShowButton write SetAutoShowButton default False;
property AutoShowScrollers: Boolean read FAutoShowScrollers write SetAutoShowScrollers default False;
property AutoSizeTabs: Boolean read FAutoSizeTabs write SetAutoSizeTabs default False;
property ButtonColor: TColor read FButtonColor write SetButtonColor default clBtnFace;
property ButtonVisible: Boolean read FButtonVisible write SetButtonVisible default True;
property Color default clBtnFace;
property DefaultTabColor: TColor read FDefaultTabColor write SetDefaultTabColor default clBtnFace;
property DrawBorder: Boolean read FDrawBorder write SetDrawBorder default True;
property FlatButton: Boolean read FFlatButton write SetFlatButton default False;
property Font stored IsFontStored;
property ParentColor default False;
property ParentFont default False;
property ScrollButtons: Boolean read FScrollButtons write SetScrollButtons default False;
property ScrollArrowColor: TColor read FScrollArrowColor write SetScrollArrowColor default clWindowFrame;
property ScrollerColor: TColor read FScrollerColor write SetScrollerColor default clBtnface;
property SelectedColor: TColor read FSelectedColor write SetSelectedColor default clBtnface;
property SelectedFontColor: TColor read FSelectedFontColor write SetSelectedFontColor default clWindowText;
property Tabs: TSCTabsetPanels read FTabs write SetTabs;
property TabPosition: TSCTabsetPosition read FTabPosition write SetTabPosition default sctpBottom;
property Style: TSCTabsetStyle read FStyle write SetStyle default sctsMac;
property UseSystemFont: Boolean read FUseSystemFont write SetUseSystemFont default True;
property UseDefaultColor: Boolean read FUseDefaultColor write SetUseDefaultColor default False;
property XPHotColor: TColor read FXPHotColor write SetXPHotColor default SC_HottrackColor;
{ These properties must be written after Tabs to be applied
on load of the component after Tabs are created }
property Selected: Integer read GetSelected write SetSelected stored False;
property OnBtnClick: TNotifyEvent read FOnBtnClick write FOnBtnClick;
property OnBtnMouseUp: TMouseEvent read FOnBtnMouseUp write FOnBtnMouseUp;
property OnBtnMouseDown: TMouseEvent read FOnBtnMouseDown write FOnBtnMouseDown;
property OnChange: TSCTabChangeEvent read FOnChange write FOnChange;
property OnDrawBkground: TSCOwnerDrawEvent read FOnDrawBkground write FOnDrawBkground;
property OnDrawButton: TSCOwnerDrawEvent read FOnDrawButton write FOnDrawButton;
property OnDrawScroller: TSCOwnerDrawScrollerEvent read FOnDrawScroller write FOnDrawScroller;
property OnDrawTab: TSCDrawTabEvent read FOnDrawTab write FOnDrawTab;
property OnHint: TNotifyEvent read FOnHint write FOnHint;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
procedure ArrangeForWindows(ATab: TSCTabsetPanel; var ARect: TRect);
function GetFirstVisibleTab: Integer;
function GetLastVisibleTab: Integer;
function AllTabsInView: Boolean;
function GetTabWidth(ATab: TSCTabsetPanel): Integer; virtual;
function GetTabRect(ATab: TSCTabsetPanel): TRect; dynamic;
function IsLeftScrollerPos(X, Y: Integer): Boolean; virtual;
function IsCursorOverLeftScroller: Boolean;
function IsRightScrollerPos(X, Y: Integer): Boolean; virtual;
function IsCursorOverRightScroller: Boolean;
function IsButtonPos(X, Y: Integer): Boolean; virtual;
function IsCursorOverButton: Boolean;
function GetClickedTab: Integer; dynamic;
function TabAtPos(P: TPoint): Integer; dynamic;
function ClientToTab(P: TPoint): TPoint;
function GetLeftSpareRect: TRect; virtual;
function GetRightSpareRect: TRect; virtual;
procedure ScrollToNext(FromTab: Integer);
procedure ScrollToPrev(FromTab: Integer);
property LeftScrollEnabled: Boolean read FLeftScrollEnabled;
property RightScrollEnabled: Boolean read FRightScrollEnabled;
property ScrollPressed: Boolean read FScrollPressed;
property BtnPressed: Boolean read FBtnPressed;
property IsLeftScroller: Boolean read FIsLeftScroller;
property FirstTabIndex: Integer read FFirstTabIndex;
end;
TSCTabset = class(TSCCustomTabset)
public
property SelectedPanel;
published
property Align;
property Anchors;
property AutoShowButton;
property AutoShowScrollers;
property AutoSizeTabs;
property BlendColor;
property ButtonColor;
property ButtonVisible;
property Color;
property Constraints;
property Cursor;
property DefaultTabColor;
property DragCursor;
property DragKind;
property DragMode;
property DrawBorder;
property Enabled;
property FlatButton;
property Font;
property Hint;
property Images;
property Indent;
property ParentColor;
property ParentFont;
property ParentShowHint;
property ScrollButtons;
property ScrollArrowColor;
property ScrollerColor;
property SelectedColor;
property SelectedFontColor;
property Tabs;
property TabPosition;
property ShowHint;
property Style;
property Tag;
property UseSystemFont;
property UseDefaultColor;
property XPHotColor;
{ These properties must be written after Tabs to be applied
on load of the component after Tabs are created }
property Selected;
property OnBtnClick;
property OnBtnMouseUp;
property OnBtnMouseDown;
property OnCanResize;
property OnClick;
property OnChange;
property OnContextPopup;
property OnDragDrop;
property OnDragOver;
property OnDrawBkground;
property OnDrawButton;
property OnDrawScroller;
property OnDrawTab;
property OnDblClick;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnHint;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
implementation
uses
SCExtControls;
{ TSCTabsetPanelActionLink }
procedure TSCTabsetPanelActionLink.AssignClient(AClient: TObject);
begin
inherited AssignClient(AClient);
FClient := AClient as TSCTabsetPanel;
end;
function TSCTabsetPanelActionLink.IsCaptionLinked: Boolean;
begin
Result := inherited IsCaptionLinked and
AnsiSameText(FClient.Text, (Action as TCustomAction).Caption);
end;
function TSCTabsetPanelActionLink.IsEnabledLinked: Boolean;
begin
Result := inherited IsEnabledLinked and
(FClient.Enabled = (Action as TCustomAction).Enabled);
end;
function TSCTabsetPanelActionLink.IsHintLinked: Boolean;
begin
Result := inherited IsHintLinked and
(FClient.Hint = (Action as TCustomAction).Hint);
end;
function TSCTabsetPanelActionLink.IsImageIndexLinked: Boolean;
begin
Result := inherited IsImageIndexLinked and
(FClient.ImageIndex = (Action as TCustomAction).ImageIndex);
end;
function TSCTabsetPanelActionLink.IsOnExecuteLinked: Boolean;
begin
Result := inherited IsOnExecuteLinked and
(@FClient.OnClick = @Action.OnExecute);
end;
function TSCTabsetPanelActionLink.IsVisibleLinked: Boolean;
begin
Result := inherited IsVisibleLinked and
(FClient.Visible = (Action as TCustomAction).Visible);
end;
procedure TSCTabsetPanelActionLink.SetCaption(const Value: string);
begin
if IsCaptionLinked then FClient.Text := Value;
end;
procedure TSCTabsetPanelActionLink.SetEnabled(Value: Boolean);
begin
if IsEnabledLinked then FClient.Enabled := Value;
end;
procedure TSCTabsetPanelActionLink.SetHint(const Value: string);
begin
if IsHintLinked then FClient.Hint := Value;
end;
procedure TSCTabsetPanelActionLink.SetImageIndex(Value: Integer);
begin
if IsImageIndexLinked then FClient.ImageIndex := Value;
end;
procedure TSCTabsetPanelActionLink.SetOnExecute(Value: TNotifyEvent);
begin
if IsOnExecuteLinked then FClient.OnClick := Value;
end;
procedure TSCTabsetPanelActionLink.SetVisible(Value: Boolean);
begin
if IsVisibleLinked then FClient.Visible := Value;
end;
{ TSCTabsetPanel }
procedure TSCTabsetPanel.ActionChange(Sender: TObject;
CheckDefaults: Boolean);
begin
if Action is TCustomAction then
with TCustomAction(Sender) do
begin
if not CheckDefaults or (Self.Text = '') then
Self.Text := Caption;
if not CheckDefaults or (Self.Enabled = True) then
Self.Enabled := Enabled;
if not CheckDefaults or (Self.ImageIndex = -1) then
Self.ImageIndex := ImageIndex;
if not CheckDefaults or (Self.Visible = True) then
Self.Visible := Visible;
if not CheckDefaults or not Assigned(Self.OnClick) then
Self.OnClick := OnExecute;
end;
end;
procedure TSCTabsetPanel.Assign(Source: TPersistent);
begin
if Source is TSCTabsetPanel then
begin
try
if Collection <> nil then
Collection.BeginUpdate;
with TSCTabsetPanel(Source) do
begin
Self.Alignment := Alignment;
Self.Color := Color;
Self.Enabled := Enabled;
Self.EndEllipsis := EndEllipsis;
Self.FontColor := FontColor;
Self.Hint := Hint;
Self.ImageIndex := ImageIndex;
Self.ParentColor := ParentColor;
Self.Selected := Selected;
Self.Text := Text;
Self.Visible := Visible;
Self.Width := Width;
end;
finally
if Collection <> nil then
Collection.EndUpdate;
end;
end else
inherited Assign(Source);
end;
constructor TSCTabsetPanel.Create(Collection: TCollection);
begin
FWidth := 50;
FImageIndex := -1;
inherited Create(Collection);
FFontColor := clNone;
FSelected := False;
FParentColor := False;
FColor := clBtnFace;
if csDesigning in OwnerState then
FColor := GetDefaultColor;
FVisible := True;
FEnabled := True;
FEndEllipsis := True;
end;
destructor TSCTabsetPanel.Destroy;
begin
FreeAndNil(FActionLink);
inherited Destroy;
end;
procedure TSCTabsetPanel.DoActionChange(Sender: TObject);
begin
if Sender = Action then ActionChange(Sender, False);
end;
function TSCTabsetPanel.GetAction: TBasicAction;
begin
Result := nil;
if FActionLink <> nil then Result := FActionLink.Action;
end;
function TSCTabsetPanel.GetActionLinkClass: TSCCollectionActionLinkClass;
begin
Result := TSCTabsetPanelActionLink;
end;
function TSCTabsetPanel.GetDefaultColor: TColor;
begin
Result := clBtnShadow;
if Tabset <> nil then Result := Tabset.DefaultTabColor;
end;
function TSCTabsetPanel.GetDisplayName: string;
begin
Result := Text;
if Result = '' then Result := inherited GetDisplayName;
end;
function TSCTabsetPanel.GetImages: TCustomImageList;
begin
Result := nil;
if Tabset <> nil then Result := Tabset.Images;
end;
function TSCTabsetPanel.GetParentColor: TColor;
var
AOwner: TPersistent;
begin
AOwner := TSCTabsetPanels(Collection).Owner;
if (AOwner <> nil) and (AOwner is TSCCustomTabset) then
Result := TSCCustomTabset(AOwner).Color
else Result := clBtnFace;
end;
function TSCTabsetPanel.GetTabset: TSCCustomTabset;
begin
Result := nil;
if TSCTabsetPanels(Collection) <> nil then
Result := TSCTabsetPanels(Collection).FTabset;
end;
function TSCTabsetPanel.IsAutoSized: Boolean;
begin
Result := True;
if Tabset <> nil then Result := Tabset.AutoSizeTabs;
end;
function TSCTabsetPanel.IsCaptionStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsCaptionLinked;
end;
function TSCTabsetPanel.IsEnabledStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsEnabledLinked;
end;
function TSCTabsetPanel.IsHintStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsHintLinked;
end;
function TSCTabsetPanel.IsImageIndexStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsImageIndexLinked;
end;
function TSCTabsetPanel.IsOnClickStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsOnExecuteLinked;
end;
function TSCTabsetPanel.IsVisibleStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsVisibleLinked;
end;
function TSCTabsetPanel.OwnerState: TComponentState;
begin
Result := [csLoading];
if Tabset <> nil then Result := Tabset.ComponentState;
end;
procedure TSCTabsetPanel.SetAction(const Value: TBasicAction);
begin
if Value = nil then
begin
FActionLink.Free;
FActionLink := nil;
end
else
begin
if FActionLink = nil then
FActionLink := TSCTabsetPanelActionLink(GetActionLinkClass.Create(Self));
FActionLink.Action := Value;
FActionLink.OnChange := DoActionChange;
ActionChange(Value, csLoading in Value.ComponentState);
end;
end;
procedure TSCTabsetPanel.SetAlignment(Value: TLeftRight);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
Changed(False);
end;
end;
procedure TSCTabsetPanel.SetColor(Value: TColor);
begin
if FColor <> Value then
begin
FColor := Value;
if FParentColor and
(Value <> GetParentColor) then
FParentColor := False;
Changed(True);
end;
end;
procedure TSCTabsetPanel.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
Changed(False);
end;
end;
procedure TSCTabsetPanel.SetEndEllipsis(Value: Boolean);
begin
if FEndEllipsis <> Value then
begin
FEndEllipsis := Value;
if Text <> '' then
Changed(False);
end;
end;
procedure TSCTabsetPanel.SetFontColor(Value: TColor);
begin
if FFontColor <> Value then
begin
FFontColor := Value;
if Visible then
Changed(False);
end;
end;
procedure TSCTabsetPanel.SetImageIndex(Value: TImageIndex);
begin
if FImageIndex <> Value then
begin
FImageIndex := Value;
if Visible then
if IsAutoSized then Changed(True)
else Changed(False);
end;
end;
procedure TSCTabsetPanel.SetParentColor(Value: Boolean);
begin
if FParentColor <> Value then
begin
FParentColor := Value;
if Value then Color := GetParentColor;
end;
end;
procedure TSCTabsetPanel.SetSelected(Value: Boolean);
begin
if not FEnabled and Value then
Value := False;
if FSelected <> Value then
begin
FSelected := Value;
if Value then UpdateTabSelection;
Changed(True);
if Value and (Tabset <> nil) then
Tabset.DoSelectionChange;
end;
end;
procedure TSCTabsetPanel.SetText(const Value: string);
begin
if FText <> Value then
begin
FText := Value;
if Visible then
if IsAutoSized then Changed(True)
else Changed(False);
end;
end;
procedure TSCTabsetPanel.SetVisible(Value: Boolean);
begin
if FVisible <> Value then
begin
FVisible := Value;
Changed(True);
end;
end;
procedure TSCTabsetPanel.SetWidth(Value: Integer);
begin
if FWidth <> Value then
begin
FWidth := Value;
if Visible then
if not IsAutoSized then
Changed(True);
end;
end;
procedure TSCTabsetPanel.UpdateTabSelection;
var
I: Integer;
P: TSCTabsetPanel;
begin
for I := 0 to Collection.Count-1 do
begin
P := TSCTabsetPanels(Collection).Items[I];
P.SetSelected(P = Self);
end;
end;
{ TSCTabsetPanels }
function TSCTabsetPanels.Add: TSCTabsetPanel;
begin
Result := TSCTabsetPanel(inherited Add);
end;
constructor TSCTabsetPanels.Create(AOwner: TSCCustomTabset);
begin
inherited Create(TSCTabsetPanel);
FTabset := AOwner;
FOldCount := 0;
end;
function TSCTabsetPanels.GetItem(Index: Integer): TSCTabsetPanel;
begin
Result := TSCTabsetPanel(inherited GetItem(Index));
end;
function TSCTabsetPanels.GetOwner: TPersistent;
begin
Result := FTabset;
end;
function TSCTabsetPanels.GetComponentState: TComponentState;
begin
Result := [csLoading];
if FTabset <> nil then Result := FTabset.ComponentState;
end;
procedure TSCTabsetPanels.SetItem(Index: Integer; Value: TSCTabsetPanel);
begin
inherited SetItem(Index, Value);
end;
procedure TSCTabsetPanels.Update(Item: TCollectionItem);
var
Cnt, FI: Integer;
Sp: TSCTabsetPanel;
Cs: TComponentState;
begin
if FTabset = nil then Exit;
Cnt := Count;
Cs := ComponentState;
if (Item = nil) and (FOldCount <> Cnt) then
begin
FOldCount := Cnt;
if not (csLoading in Cs) then
begin
FI := 0;
if not (csDesigning in Cs) then
FI := FTabset.FirstTabIndex;
if Cnt > 0 then
begin
Sp := FTabset.SelectedPanel;
if (Sp = nil) or (csDesigning in Cs) then
Items[Cnt-1].Selected := True;
end;
FTabset.SetFirstTabIndex(FI);
if FTabset.FirstTabIndex <> FI then
Exit;
end;
end;
if Item <> nil then
FTabset.UpdateTab(Item.Index, False) else
FTabset.UpdateTabs;
end;
{ TSCCustomTabset }
function TSCCustomTabset.ActiveTab: TSCTabsetPanel;
var
Indx: Integer;
begin
Result := nil;
if FTabs <> nil then
begin
Indx := GetSelected;
if IsValidTab(Indx) then Result := FTabs[Indx];
end;
end;
function TSCCustomTabset.AllTabsInView: Boolean;
var
I, FrstTab: Integer;
CR, R, R2: TRect;
begin
Result := True;
if not (CanGetClientRect and
(FTabs <> nil) and (FTabs.Count > 0)) then Exit;
FrstTab := FirstTabIndex;
CheckFirstTab(FrstTab);
if FrstTab > 0 then
begin
Result := False;
Exit;
end;
CR := ClientRect;
Inc(CR.Left, GetLeftIndent);
Dec(CR.Right, GetRightIndent(False, False));
if IsRectEmpty(CR) then
begin
Result := False;
Exit;
end;
R := CR;
R.Right := R.Left;
if FrstTab = 0 then
begin
Inc(R.Right, GetTabWidth(FTabs[FrstTab]));
IntersectRect(R2, R, CR);
if not EqualRect(R2, R) then
begin
Result := False;
Exit;
end;
end;
for I := FrstTab + 1 to FTabs.Count-1 do
begin
if not FTabs[I].Visible then Continue;
OffsetRect(R, GetTabWidth(FTabs[I]), 0);
IntersectRect(R2, R, CR);
if not EqualRect(R2, R) then
begin
Result := False;
Exit;
end;
end;
end;
procedure TSCCustomTabset.ArrangeForWindows(ATab: TSCTabsetPanel;
var ARect: TRect);
var
SIndx: Integer;
begin
if (FStyle = sctsWindows) and ATab.Visible then
begin
SIndx := -1;
if ATab.Selected then SIndx := Selected;
if IsValidTab(SIndx) and (ATab.Index = SIndx) then
InflateRect(ARect, 2, 0)
else
if FTabPosition = sctpBottom then
Inc(ARect.Top, 2)
else
Dec(ARect.Bottom, 2);
end;
end;
function TSCCustomTabset.CanChange(NewIndex: Integer): Boolean;
begin