Repository navigation
Expand file tree
/
Copy pathSCExtControls.pas
More file actions
2855 lines (2435 loc) · 75.1 KB
/
Copy pathSCExtControls.pas
File metadata and controls
2855 lines (2435 loc) · 75.1 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 SCExtControls;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, StdActns, ActnList, Menus, SCCommon, SCConsts, SCControl,
SCStdControls;
type
TSCHeaderColumn = class;
TSCCustomHeader = class;
TSCHeaderColActionLink = class(TActionLink)
protected
FClient: TSCHeaderColumn;
procedure AssignClient(AClient: TObject); override;
function IsCaptionLinked: Boolean; override;
function IsEnabledLinked: Boolean; override;
function IsHintLinked: Boolean; override;
function IsImageIndexLinked: Boolean; override;
function IsShortCutLinked: 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 SetShortCut(Value: TShortCut); override;
procedure SetVisible(Value: Boolean); override;
procedure SetOnExecute(Value: TNotifyEvent); override;
end;
TSCHeaderColActionLinkClass = class of TSCHeaderColActionLink;
TSCHeaderColStyle = (schsImage, schsImageAndText, schsOwnerDraw, schsText);
TSCHeaderColBevel = (schbNone, schb3D, schb3DX, schbRaised, schbFlat,
schb3DRaised, schbSpace, schbMac, schbMetal, schbWinXP);
TSCHeaderColumn = class(TCollectionItem)
private
FActionLink: TSCHeaderColActionLink;
FAlignment: TAlignment;
FAllowClick: Boolean;
FBorderColor: TColor;
FColor: TColor;
FDown: Boolean;
FEnabled: Boolean;
FEndEllipsis: Boolean;
FImageIndex: TImageIndex;
FIndent: Cardinal;
FMinWidth: Integer;
FMaxWidth: Integer;
FParentColor: Boolean;
FSizable: Boolean;
FStyle: TSCHeaderColStyle;
FText: string;
FVisible: Boolean;
FWidth: Integer;
FXPHotColor: TColor;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnMouseDown: TMouseEvent;
FOnMouseMove: TMouseMoveEvent;
FOnMouseUp: TMouseEvent;
function GetAction: TBasicAction;
procedure SetAction(const Value: TBasicAction);
procedure SetAlignment(Value: TAlignment);
procedure SetBorderColor(Value: TColor);
procedure SetColor(Value: TColor);
procedure SetDown(Value: Boolean);
procedure SetEnabled(const Value: Boolean);
procedure SetEndEllipsis(Value: Boolean);
procedure SetImageIndex(const Value: TImageIndex);
procedure SetIndent(Value : Cardinal);
procedure SetMaxWidth(Value: Integer);
procedure SetMinWidth(Value: Integer);
procedure SetParentColor(Value: Boolean);
procedure SetStyle(Value: TSCHeaderColStyle);
procedure SetText(const Value: string);
procedure SetVisible(Value: Boolean);
procedure SetWidth(Value: Integer);
procedure UpdateColumnDown; virtual;
function GetComponentState: TComponentState;
protected
function GetDisplayName: string; override;
function GetDefaultWidth: Cardinal; virtual;
function GetImages: TCustomImageList;
function GetParentColor: TColor; virtual;
function IsCaptionStored: Boolean;
function IsEnabledStored: Boolean;
function IsImageIndexStored: Boolean;
function IsOnClickStored: Boolean;
function IsVisibleStored: Boolean;
procedure DoActionChange(Sender: TObject);
function GetActionLinkClass: TSCHeaderColActionLinkClass; dynamic;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
property ActionLink: TSCHeaderColActionLink read FActionLink write FActionLink;
property Down: Boolean read FDown write SetDown;
property ComponentState: TComponentState read GetComponentState;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property Action: TBasicAction read GetAction write SetAction;
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property AllowClick: Boolean read FAllowClick write FAllowClick default True;
property BorderColor: TColor read FBorderColor write SetBorderColor default clBtnShadow;
property Color: TColor read FColor write SetColor default clBtnFace;
property Enabled: Boolean read FEnabled write SetEnabled stored IsEnabledStored default True;
property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default True;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
property Indent: Cardinal read FIndent write SetIndent default 0;
property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 10000;
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
property ParentColor: Boolean read FParentColor write SetParentColor default True;
property Sizable: Boolean read FSizable write FSizable default True;
property Style: TSCHeaderColStyle read FStyle write SetStyle default schsText;
property Text: string read FText write SetText;
property Visible: Boolean read FVisible write SetVisible default True;
property Width: Integer read FWidth write SetWidth default 100;
property XPHotColor: TColor read FXPHotColor write FXPHotColor default SC_HottrackColor;
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;
TSCHeaderColumns = class(TCollection)
private
FHeader: TSCCustomHeader;
function GetItem(Index: Integer): TSCHeaderColumn;
procedure SetItem(Index: Integer; Value: TSCHeaderColumn);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
function UniqueColText(Base: String): String;
public
constructor Create(Header: TSCCustomHeader);
function Add: TSCHeaderColumn;
property Items[Index: Integer]: TSCHeaderColumn read GetItem write SetItem; default;
{$IFDEF SC_DELPHI5_AND_EARLY}
property Owner: TSCCustomHeader read FHeader;
{$ENDIF}
end;
TSCDrawColumnEvent = procedure(Header: TSCCustomHeader; Column: TSCHeaderColumn;
ColCanvas: TCanvas; const Rect: TRect) of object;
TSCColumnEvent = procedure(Header: TSCCustomHeader; Column: TSCHeaderColumn) of object;
TSCColumnHitTest = (schtClient, schtColumn, schtColumnLeft, schtColumnRight,
schtNowhere);
TSCHeaderHitInfo = record
X, Y: Integer;
Column: Integer;
HitPos: TSCColumnHitTest;
end;
PHeaderHitInfo = ^TSCHeaderHitInfo;
TSCCustomHeader = class(TSCCustomControl)
private
FArrowColor: TColor;
FArrowBorderColor: TColor;
FClientBevel: TSCHeaderColBevel;
FColumns: TSCHeaderColumns;
FColumnSpace: Cardinal;
FDefaultBevel: TSCHeaderColBevel;
FDefaultColWidth: Cardinal;
FDragImageList: TImageList;
FDragReorder: Boolean;
FFullDrag: Boolean;
FHotTrack: Boolean;
FHotTrackFontColor: TColor;
FLimitClient: Boolean;
FOnColumnClick: TSCColumnEvent;
FOnColumnDblClick: TSCColumnEvent;
FOnColumnResize: TSCColumnEvent;
FOnDrawColumn: TSCDrawColumnEvent;
FHitInfo: TSCHeaderHitInfo;
FHottrackInfo: TSCHeaderHitInfo;
FMouseDownHitInfo: TSCHeaderHitInfo;
FColumnClicked: Boolean;
FColumnDblClicked: Boolean;
FSizing: Boolean;
FDraggedColumn: Integer;
FOldCursor: TCursor;
FMouseIsDown: Boolean;
FDraggedOnColumn: Integer;
procedure SetClientBevel(Value: TSCHeaderColBevel);
function GetColumnDragging: Boolean;
procedure SetColumns(Value: TSCHeaderColumns);
procedure SetColumnSpace(Value: Cardinal);
procedure SetDefaultBevel(Value: TSCHeaderColBevel);
procedure SetFullDrag(Value: Boolean);
procedure SetHotTrack(Value: Boolean);
procedure SetHotTrackFontColor(Value: TColor);
procedure SetLimitClient(Value: Boolean);
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 CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
procedure WMCancelMode(var Message: TMessage); message WM_CANCELMODE;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
protected
procedure Paint; override;
procedure SetAutoSize(Value: Boolean); override;
function GetBlendValue: Word; override;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
procedure InitializeHitTest(AHitInfo: PHeaderHitInfo);
procedure ResetHitInfo;
procedure ResetHotTrackInfo;
procedure AutoSizeChanged; override;
procedure EnabledChanged; override;
procedure SetColumnCursor(AHitType: TSCColumnHitTest);
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure DoDockOver(Source: TDragDockObject; X, Y: Integer; State: TDragState;
var Accept: Boolean); override;
function CalculateImageRect(Column: TSCHeaderColumn; ARect: TRect): TRect; reintroduce; virtual;
procedure DrawSizeLine(ACanvas: TCanvas; X, Y: Integer);
procedure DrawColumn(Column: TSCHeaderColumn; C: TCanvas;
const ARect: TRect; InternalDraw: Boolean);
procedure DrawColumnBorder(Column: TSCHeaderColumn; C: TCanvas;
const ARect: TRect; InternalDraw: Boolean);
procedure DrawClientBevel(C: TCanvas; const ARect: TRect);
procedure DrawImageColumn(Column: TSCHeaderColumn; ColumnCanvas: TCanvas;
const ARect: TRect; InternalDraw: Boolean);
procedure DrawTextColumn(Column: TSCHeaderColumn; ColumnCanvas: TCanvas;
const ARect: TRect; InternalDraw: Boolean);
procedure ColumnSized(Column: TSCHeaderColumn);
procedure UpdateColumnColors(OldColor: TColor);
procedure UpdateColumn(Index: Integer; Repaint: Boolean); dynamic;
procedure UpdateColumns; dynamic;
procedure InitiateColumnDrag(Col: Integer); virtual;
procedure BeginColumnDragging(Col: Integer); virtual;
procedure DoColumnDragMove; dynamic;
procedure DrawDragArrow;
procedure StopDragging;
procedure DoColumnDrag(FromColumn, ToColumn: Integer); dynamic;
property Align default alTop;
property ArrowColor: TColor read FArrowColor write FArrowColor default clLime;
property ArrowBorderColor: TColor read FArrowBorderColor write FArrowBorderColor default clNavy;
property ClientBevel: TSCHeaderColBevel read FClientBevel write SetClientBevel default schbWinXP;
property Color default clBtnFace;
property Columns: TSCHeaderColumns read FColumns write SetColumns;
property ColumnSpace: Cardinal read FColumnSpace write SetColumnSpace default 0;
property DefaultBevel: TSCHeaderColBevel read FDefaultBevel write SetDefaultBevel default schbWinXP;
property DefaultColWidth: Cardinal read FDefaultColWidth write FDefaultColWidth default 100;
property DragReorder: Boolean read FDragReorder write FDragReorder default False;
property FullDrag: Boolean read FFullDrag write SetFullDrag default True;
property HotTrack: Boolean read FHotTrack write SetHotTrack default False;
property HotTrackFontColor: TColor read FHotTrackFontColor write SetHotTrackFontColor default clBlue;
property LimitClient: Boolean read FLimitClient write SetLimitClient default False;
property ParentColor default False;
property ParentFont default False;
property OnColumnClick: TSCColumnEvent read FOnColumnClick write FOnColumnClick;
property OnColumnDblClick: TSCColumnEvent read FOnColumnDblClick write FOnColumnDblClick;
property OnColumnResize: TSCColumnEvent read FOnColumnResize write FOnColumnResize;
property OnDrawColumn: TSCDrawColumnEvent read FOnDrawColumn write FOnDrawColumn;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
function GetClickedColumn: Integer; dynamic;
function ColumnAtPos(P: TPoint): Integer; dynamic;
function ClientToColumn(P: TPoint): TPoint;
function ColumnRect(Column: TSCHeaderColumn): TRect; overload;
function ColumnRect(Index: Integer): TRect; overload;
function GetLastVisible: Integer;
function SpaceRect: TRect;
function GetHitInfo(P: TPoint): TSCHeaderHitInfo; virtual;
function GetHitTypeAt(X, Y: Integer): TSCColumnHitTest;
function IsValidColumn(Col: Integer): Boolean;
property ColumnDragging: Boolean read GetColumnDragging;
property DraggedColumn: Integer read FDraggedColumn;
property Sizing: Boolean read FSizing;
end;
TSCHeader = class(TSCCustomHeader)
published
property Align;
property Anchors;
property ArrowColor;
property ArrowBorderColor;
property AutoSize;
property BlendColor;
property ClientBevel;
property Color;
property Columns;
property ColumnSpace;
property Constraints;
property Cursor;
property DefaultBevel;
property DefaultColWidth;
property DragCursor;
property DragKind;
property DragMode;
property DragReorder;
property Enabled;
property Font;
property FullDrag;
property Hint;
property HotTrack;
property HotTrackFontColor;
property Images;
property LimitClient;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Tag;
property Visible;
property OnCanResize;
property OnClick;
property OnColumnClick;
property OnColumnDblClick;
property OnColumnResize;
property OnConstrainedResize;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnDblClick;
property OnDrawColumn;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
TSCSimpleImageBox = class(TSCCustomControl)
protected
function GetBlendValue: Word; override;
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
published
property BlendColor;
property Border;
property BorderColor;
property Color default clWindow;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property FlatColor;
property ImageIndex;
property Images;
property ParentColor default False;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property UseDockManager default True;
property Visible;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnMouseWheel;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
TSCCustomBevel = class(TSCGraphicControl)
private
FBevel: TSCControlBevel;
FBevelColor: TColor;
FBevelEdges: TSCBorderEdges;
FBevelWidth: TSCBevelWidth;
procedure SetBevel(Value: TSCControlBevel);
procedure SetBevelColor(Value: TColor);
procedure SetBevelEdges(Value: TSCBorderEdges);
procedure SetBevelWidth(Value: TSCBevelWidth);
protected
procedure Paint; override;
procedure AdjustBevelRect(var Rect: TRect); virtual;
function GetBevelSize: Integer;
property Bevel: TSCControlBevel read FBevel write SetBevel default sccbLowered;
property BevelColor: TColor read FBevelColor write SetBevelColor default clNone;
property BevelEdges: TSCBorderEdges read FBevelEdges write SetBevelEdges default SCAllBorderEdges;
property BevelWidth: TSCBevelWidth read FBevelWidth write SetBevelWidth default 0;
public
constructor Create(AOwner: TComponent); override;
procedure Assign(Source: TPersistent); override;
end;
TSCBevel = class(TSCCustomBevel)
published
property Align;
property Anchors;
property Bevel;
property BevelColor;
property BevelEdges;
property BevelWidth;
property Color;
property Constraints;
property Cursor;
property Hint;
property ParentColor;
property ParentShowHint;
property Visible;
property Transparent;
end;
implementation
type
TSCFakeControl = class(TWinControl);
{ TSCHeaderColActionLink }
procedure TSCHeaderColActionLink.AssignClient(AClient: TObject);
begin
FClient := AClient as TSCHeaderColumn;
end;
function TSCHeaderColActionLink.IsCaptionLinked: Boolean;
begin
Result := inherited IsCaptionLinked and
AnsiSameText(FClient.Text, (Action as TCustomAction).Caption);
end;
function TSCHeaderColActionLink.IsEnabledLinked: Boolean;
begin
Result := inherited IsEnabledLinked and
(FClient.Enabled = (Action as TCustomAction).Enabled);
end;
function TSCHeaderColActionLink.IsHintLinked: Boolean;
begin
Result := False;
end;
function TSCHeaderColActionLink.IsImageIndexLinked: Boolean;
begin
Result := inherited IsImageIndexLinked and
(FClient.ImageIndex = (Action as TCustomAction).ImageIndex);
end;
function TSCHeaderColActionLink.IsOnExecuteLinked: Boolean;
begin
Result := inherited IsOnExecuteLinked and
(@FClient.OnClick = @Action.OnExecute);
end;
function TSCHeaderColActionLink.IsShortCutLinked: Boolean;
begin
Result := False;
end;
function TSCHeaderColActionLink.IsVisibleLinked: Boolean;
begin
Result := inherited IsVisibleLinked and
(FClient.Visible = (Action as TCustomAction).Visible);
end;
procedure TSCHeaderColActionLink.SetCaption(const Value: string);
begin
if IsCaptionLinked then FClient.Text := Value;
end;
procedure TSCHeaderColActionLink.SetEnabled(Value: Boolean);
begin
if IsEnabledLinked then FClient.Enabled := Value;
end;
procedure TSCHeaderColActionLink.SetHint(const Value: string);
begin
inherited;
end;
procedure TSCHeaderColActionLink.SetImageIndex(Value: Integer);
begin
if IsImageIndexLinked then FClient.ImageIndex := Value;
end;
procedure TSCHeaderColActionLink.SetOnExecute(Value: TNotifyEvent);
begin
if IsOnExecuteLinked then FClient.OnClick := Value;
end;
procedure TSCHeaderColActionLink.SetShortCut(Value: TShortCut);
begin
inherited;
end;
procedure TSCHeaderColActionLink.SetVisible(Value: Boolean);
begin
if IsVisibleLinked then FClient.Visible := Value;
end;
{ TSCHeaderColumn }
procedure TSCHeaderColumn.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 TSCHeaderColumn.Assign(Source: TPersistent);
begin
if Source is TSCHeaderColumn then
begin
with TSCHeaderColumn(Source) do
begin
Self.Alignment := Alignment;
Self.BorderColor := BorderColor;
Self.Color := Color;
Self.Enabled := Enabled;
Self.EndEllipsis := EndEllipsis;
Self.ImageIndex := ImageIndex;
Self.ParentColor := ParentColor;
Self.Style := Style;
Self.Text := Text;
Self.Visible := Visible;
Self.Width := Width;
end;
end else
inherited Assign(Source);
end;
constructor TSCHeaderColumn.Create(Collection: TCollection);
begin
FMaxWidth := 10000;
FAllowClick := True;
FImageIndex := -1;
inherited Create(Collection);
FWidth := GetDefaultWidth;
FBorderColor := clBtnShadow;
FColor := GetParentColor;
FEnabled := True;
FEndEllipsis := True;
FParentColor := True;
FSizable := True;
FStyle := schsText;
FVisible := True;
FXPHotColor := SC_HottrackColor;
end;
destructor TSCHeaderColumn.Destroy;
begin
FreeAndNil(FActionLink);
inherited Destroy;
end;
procedure TSCHeaderColumn.DoActionChange(Sender: TObject);
begin
if Sender = Action then ActionChange(Sender, False);
end;
function TSCHeaderColumn.GetAction: TBasicAction;
begin
if FActionLink <> nil then
Result := FActionLink.Action else
Result := nil;
end;
function TSCHeaderColumn.GetActionLinkClass: TSCHeaderColActionLinkClass;
begin
Result := TSCHeaderColActionLink;
end;
function TSCHeaderColumn.GetComponentState: TComponentState;
var
AOwner: TPersistent;
begin
Result := [csLoading];
AOwner := TSCHeaderColumns(Collection).Owner;
if AOwner is TComponent then
Result := TComponent(AOwner).ComponentState;
end;
function TSCHeaderColumn.GetDefaultWidth: Cardinal;
var
AOwner: TPersistent;
begin
AOwner := TSCHeaderColumns(Collection).Owner;
if AOwner is TSCCustomHeader then
Result := TSCCustomHeader(AOwner).DefaultColWidth
else
Result := 100;
end;
function TSCHeaderColumn.GetDisplayName: string;
begin
Result := Text;
if Result = '' then Result := inherited GetDisplayName;
end;
function TSCHeaderColumn.GetImages: TCustomImageList;
begin
Result := nil;
if TSCHeaderColumns(Collection).FHeader <> nil then
Result := TSCHeaderColumns(Collection).FHeader.Images;
end;
function TSCHeaderColumn.GetParentColor: TColor;
var
AOwner: TPersistent;
begin
AOwner := TSCHeaderColumns(Collection).Owner;
if AOwner is TSCCustomHeader then
Result := TSCCustomHeader(AOwner).Color
else
Result := clBtnFace;
end;
function TSCHeaderColumn.IsCaptionStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsCaptionLinked;
end;
function TSCHeaderColumn.IsEnabledStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsEnabledLinked;
end;
function TSCHeaderColumn.IsImageIndexStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsImageIndexLinked;
end;
function TSCHeaderColumn.IsOnClickStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsOnExecuteLinked;
end;
function TSCHeaderColumn.IsVisibleStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsVisibleLinked;
end;
procedure TSCHeaderColumn.SetAction(const Value: TBasicAction);
begin
if Value = nil then
begin
FActionLink.Free;
FActionLink := nil;
end
else
begin
if FActionLink = nil then
FActionLink := GetActionLinkClass.Create(Self);
FActionLink.Action := Value;
FActionLink.OnChange := DoActionChange;
ActionChange(Value, csLoading in Value.ComponentState);
end;
end;
procedure TSCHeaderColumn.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetBorderColor(Value: TColor);
begin
if FBorderColor <> Value then
begin
FBorderColor := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetColor(Value: TColor);
begin
if FColor <> Value then
begin
FColor := Value;
if FParentColor and (Value <> GetParentColor) then
FParentColor := False;
Changed(True);
end;
end;
procedure TSCHeaderColumn.SetDown(Value: Boolean);
begin
if not FEnabled and Value then Value := False;
if FDown <> Value then
begin
FDown := Value;
if Value then UpdateColumnDown;
Changed(True);
end;
end;
procedure TSCHeaderColumn.SetEnabled(const Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetEndEllipsis(Value: Boolean);
begin
if FEndEllipsis <> Value then
begin
FEndEllipsis := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetImageIndex(const Value: TImageIndex);
begin
if FImageIndex <> Value then
begin
FImageIndex := Value;
if (Style in [schsImage,
schsImageAndText, schsOwnerDraw]) then
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetIndent(Value: Cardinal);
begin
if FIndent <> Value then
begin
FIndent := Value;
if (Style in [schsText,
schsImageAndText, schsOwnerDraw]) then
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetMaxWidth(Value: Integer);
begin
if Value < FMinWidth then Value := FMinWidth;
if Value > 10000 then Value := 10000;
FMaxWidth := Value;
SetWidth(FWidth);
end;
procedure TSCHeaderColumn.SetMinWidth(Value: Integer);
begin
if Value < 0 then Value := 0;
if Value > FMaxWidth then Value := FMaxWidth;
FMinWidth := Value;
SetWidth(FWidth);
end;
procedure TSCHeaderColumn.SetParentColor(Value: Boolean);
begin
if FParentColor <> Value then
begin
FParentColor := Value;
if FParentColor then
Color := GetParentColor;
end;
end;
procedure TSCHeaderColumn.SetStyle(Value: TSCHeaderColStyle);
begin
if FStyle <> Value then
begin
FStyle := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetText(const Value: string);
begin
if FText <> Value then
begin
FText := Value;
Changed(False);
end;
end;
procedure TSCHeaderColumn.SetVisible(Value: Boolean);
begin
if FVisible <> Value then
begin
FVisible := Value;
Changed(True);
end;
end;
procedure TSCHeaderColumn.SetWidth(Value: Integer);
var
Cs: TComponentState;
begin
if Value < FMinWidth then Value := FMinWidth;
if Value > FMaxWidth then Value := FMaxWidth;
Cs := ComponentState;
if (FWidth <> Value) and (FSizable or (Cs*[csLoading, csDesigning] <> [])) then
begin
FWidth := Value;
if Collection <> nil then
begin
Changed(True);
TSCHeaderColumns(Collection).FHeader.ColumnSized(Self);
end;
end;
end;
procedure TSCHeaderColumn.UpdateColumnDown;
var
I: Integer;
begin
for I := 0 to Collection.Count-1 do
if Collection.Items[I] <> Self then
TSCHeaderColumn(Collection.Items[I]).Down := False;
end;
{ TSCHeaderColumns }
function TSCHeaderColumns.Add: TSCHeaderColumn;
begin
Result := TSCHeaderColumn(inherited Add);
end;
constructor TSCHeaderColumns.Create(Header: TSCCustomHeader);
begin
inherited Create(TSCHeaderColumn);
FHeader := Header;
end;
function TSCHeaderColumns.GetItem(Index: Integer): TSCHeaderColumn;
begin
Result := TSCHeaderColumn(inherited GetItem(Index));
end;
function TSCHeaderColumns.GetOwner: TPersistent;
begin
Result := FHeader;
end;
procedure TSCHeaderColumns.SetItem(Index: Integer;
Value: TSCHeaderColumn);
begin
inherited SetItem(Index, Value);
end;
function TSCHeaderColumns.UniqueColText(Base: String): String;
var
S: String;
I: Integer;
begin
S := Base;
if (S <> '') and SameText(S[1], 'T') then
System.Delete(S, 1, 1);
if S = '' then S := Base;
for I := 1 to Count do
if not SameText(S + IntToStr(I), Items[I-1].Text) then
begin
Result := S + IntToStr(I);
Exit;
end;
Result := S + IntToStr(Count+1);
end;
procedure TSCHeaderColumns.Update(Item: TCollectionItem);
begin
if Item <> nil then
FHeader.UpdateColumn(Item.Index, False) else
FHeader.UpdateColumns;
end;
{ TSCCustomHeader }
procedure TSCCustomHeader.BeginColumnDragging(Col: Integer);
var
W, H: Integer;
P1, P2: TPoint;
begin
if IsValidColumn(Col) and GetCursorPos(P1) then
begin
W := FColumns[Col].Width;
H := ClientHeight;
if (W > 0) and (H > 0) and FColumns[Col].Visible then
begin
P2 := ClientToColumn(ScreenToClient(P1));
InitiateColumnDrag(Col);
FDragImageList.DragCursor := crDefault;
FDragImageList.SetDragImage(0, P2.X, P2.Y);
FDragImageList.BeginDrag(GetDeskTopWindow, P1.X, P1.Y);
Application.CancelHint;
end;
end;
end;
function TSCCustomHeader.CalculateImageRect(Column: TSCHeaderColumn;
ARect: TRect): TRect;
begin
Result := ARect;
if not (Column.Style in [schsImage,
schsImageAndText]) then
begin
Result.Right := Result.Left;
Exit;
end;
case Column.Alignment of
taLeftJustify:
Inc(Result.Left, 1);
taRightJustify:
Dec(Result.Right, 1);
taCenter:
begin
Inc(Result.Left, 1);
Dec(Result.Right, 1);
end;
end;
if Result.Bottom < Result.Top then