Repository navigation
Expand file tree
/
Copy pathSCTrackbar.pas
More file actions
2703 lines (2310 loc) · 74.3 KB
/
Copy pathSCTrackbar.pas
File metadata and controls
2703 lines (2310 loc) · 74.3 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 SCTrackbar;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
SCCommon, SCConsts, SCControl;
type
TSCCustomTrackbar = class;
TSCOrientation = (sctoHorizontal, sctoVertical);
TSCTrackStyle = (scthImage, scthMac, scthMetal, scthNew, scthPS,
scthPSNew, scthWindows);
TSCTrackAlign = (sctaLeftToRight, sctaRightToLeft);
TSCTrackLinePosition = (sclpBottomRight, sclpTopLeft, sclpBoth);
TSCTrackProgressStyle = (sctp3D, sctpClassic, sctpGradient3D,
sctpGradientFull, sctpGradientComplementary, sctpMetal, sctpOffice12,
sctpRaised, sctpSliced, sctpSlicedGradient, sctpXP);
TSCTrackbarPaintEvent = procedure(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; var Handled: Boolean) of object;
TSCTrackbarProgress = class(TPersistent)
private
FOwner: TSCCustomTrackbar;
function GetBkColor: TColor;
procedure SetBkColor(Value: TColor);
function GetBorder: TSCControlBorder;
procedure SetBorder(Value: TSCControlBorder);
function GetBorderColor: TColor;
procedure SetBorderColor(Value: TColor);
function GetColor: TColor;
procedure SetColor(Value: TColor);
function GetEndColor: TColor;
procedure SetEndColor(Value: TColor);
function GetHeight: Integer;
procedure SetHeight(Value: Integer);
function GetSlice: Integer;
procedure SetSlice(Value: Integer);
function GetStyle: TSCTrackProgressStyle;
procedure SetStyle(Value: TSCTrackProgressStyle);
public
constructor Create(AOwner: TSCCustomTrackbar); virtual;
procedure Assign(Source: TPersistent); override;
published
property BkColor: TColor read GetBkColor write SetBkColor default clWindow;
property Border: TSCControlBorder read GetBorder write SetBorder default sccb3DLowered;
property BorderColor: TColor read GetBorderColor write SetBorderColor default cl3DDkShadow;
property Color: TColor read GetColor write SetColor default clHighlight;
property EndColor: TColor read GetEndColor write SetEndColor default clAqua;
property Height: Integer read GetHeight write SetHeight default 12;
property Slice: Integer read GetSlice write SetSlice default 10;
property Style: TSCTrackProgressStyle read GetStyle write SetStyle default sctpClassic;
end;
TSCTrackbarSlider = class(TPersistent)
private
FOwner: TSCCustomTrackbar;
function GetColor: TColor;
procedure SetColor(Value: TColor);
function GetFocusColor: TColor;
procedure SetFocusColor(Value: TColor);
function GetFrameColor: TColor;
procedure SetFrameColor(Value: TColor);
function GetHottracks: Boolean;
procedure SetHottracks(Value: Boolean);
function GetHotColor: TColor;
procedure SetHotColor(Value: TColor);
function GetOffset: Integer;
procedure SetOffset(Value: Integer);
function GetSize: Integer;
procedure SetSize(Value: Integer);
function GetStyle: TSCTrackStyle;
procedure SetStyle(Value: TSCTrackStyle);
public
constructor Create(AOwner: TSCCustomTrackbar); virtual;
procedure Assign(Source: TPersistent); override;
published
property Color: TColor read GetColor write SetColor default clBtnFace;
property FocusColor: TColor read GetFocusColor write SetFocusColor default clHighlight;
property FrameColor: TColor read GetFrameColor write SetFrameColor default clGreen;
property Hottracks: Boolean read GetHottracks write SetHottracks default True;
property HotColor: TColor read GetHotColor write SetHotColor default clBlue;
property Offset: Integer read GetOffset write SetOffset default 0;
property Size: Integer read GetSize write SetSize default 4;
property Style: TSCTrackStyle read GetStyle write SetStyle default scthWindows;
end;
TSCSliderStyle = TSCThumbStyle;
TSCCustomTrackbar = class(TSCCustomControl)
private
FAlignment: TSCTrackAlign;
FFrequency: Integer;
FLineColor: TColor;
FLinePosition: TSCTrackLinePosition;
FLineSize: Integer;
FMax: Integer;
FMin: Integer;
FOrientation: TSCOrientation;
FPageSize: Integer;
FPosition: Integer;
FProgress: TSCTrackbarProgress;
FProgressBkColor: TColor;
FProgressBorder: TSCControlBorder;
FProgressBorderColor: TColor;
FProgressColor: TColor;
FProgressEndColor: TColor;
FProgressSlice: Integer;
FProgressStyle: TSCTrackProgressStyle;
FProgressHeight: Integer;
FShowFocusRect: Boolean;
FShowLines: Boolean;
FShowProgress: Boolean;
FShowSlider: Boolean;
FSlider: TSCTrackbarSlider;
FSliderColor: TColor;
FSliderFocusColor: TColor;
FSliderFrameColor: TColor;
FSliderHottracks: Boolean;
FSliderHotColor: TColor;
FSliderOffset: Integer;
FSliderSize: Integer;
FSliderStyle: TSCTrackStyle;
FLeftClicked: Boolean;
FSliderClicked: Boolean;
FSliderIsHot: Boolean;
FOnCustomDrawBack: TSCTrackbarPaintEvent;
FOnCustomDrawLines: TSCTrackbarPaintEvent;
FOnCustomDrawProgress: TSCTrackbarPaintEvent;
FOnCustomDrawSlider: TSCTrackbarPaintEvent;
procedure SetAlignment(Value: TSCTrackAlign);
procedure SetFrequency(Value: Integer);
procedure SetLineColor(Value: TColor);
procedure SetLinePosition(Value: TSCTrackLinePosition);
procedure SetMax(Value: Integer);
procedure SetMin(Value: Integer);
procedure SetOrientation(Value: TSCOrientation);
procedure SetProgress(Value: TSCTrackbarProgress);
procedure SetProgressBkColor(Value: TColor);
procedure SetProgressBorder(Value: TSCControlBorder);
procedure SetProgressBorderColor(Value: TColor);
procedure SetProgressColor(Value: TColor);
procedure SetProgressEndColor(Value: TColor);
procedure SetProgressHeight(Value: Integer);
procedure SetProgressSlice(Value: Integer);
procedure SetProgressStyle(Value: TSCTrackProgressStyle);
procedure SetShowFocusRect(Value: Boolean);
procedure SetShowLines(Value: Boolean);
procedure SetShowProgress(Value: Boolean);
procedure SetShowSlider(Value: Boolean);
procedure SetSlider(Value: TSCTrackbarSlider);
procedure SetSliderColor(Value: TColor);
procedure SetSliderFocusColor(Value: TColor);
procedure SetSliderFrameColor(Value: TColor);
procedure SetSliderHottracks(Value: Boolean);
procedure SetSliderHotColor(Value: TColor);
procedure SetSliderOffset(Value: Integer);
procedure SetSliderSize(Value: Integer);
procedure SetSliderStyle(Value: TSCTrackStyle);
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
protected
procedure Paint; override;
procedure Loaded; override;
function NormalizePosition(Value: Integer): Integer;
function GetPosition: Integer; virtual;
procedure SetPosition(Value: Integer); virtual;
procedure DoChange; override;
function CanSetValue(var Value: LongInt): Boolean; virtual;
function CanSetUserValue(var Value: LongInt): Boolean; virtual;
procedure ImageListChange(Sender: TObject); override;
function GetSliderSize: Integer;
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 ProcessTrackKey(Key: Word);
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
function GetProgressBorderSize: Integer;
function GetProgressRect: TRect; dynamic;
function GetSliderRect: TRect; dynamic;
function GetGradientShadow(AColor: TColor): TColor;
function GetGradientDark(AColor: TColor): TColor;
function GetGradientLight(AColor: TColor): TColor;
function GetGradientExDark(AColor: TColor): TColor;
function GetGradientExLight(AColor: TColor): TColor;
function GetGradientPeal(AColor: TColor): TColor;
function GetGradientPreDark(AColor: TColor): TColor;
function GetGradientPreLight(AColor: TColor): TColor;
function GetGradientHighLight(AColor: TColor): TColor;
procedure DoDrawLines(ACanvas: TCanvas); virtual;
procedure DoDrawSlider(ACanvas: TCanvas); virtual;
procedure DoDrawProgress(ACanvas: TCanvas); virtual;
procedure DoDraw(ACanvas: TCanvas); virtual;
property Alignment: TSCTrackAlign read FAlignment write SetAlignment default sctaLeftToRight;
property BlendColor default False;
property Color default clBtnFace;
property Frequency: Integer read FFrequency write SetFrequency default 1;
property LineColor: TColor read FLineColor write SetLineColor default clBtnText;
property LinePosition: TSCTrackLinePosition read FLinePosition write SetLinePosition default sclpBottomRight;
property LineSize: Integer read FLineSize write FLineSize default 1;
property Max: Integer read FMax write SetMax default 10;
property Min: Integer read FMin write SetMin default 0;
property Orientation: TSCOrientation read FOrientation write SetOrientation default sctoHorizontal;
property PageSize: Integer read FPageSize write FPageSize default 2;
property ParentColor default False;
property Position: Integer read GetPosition write SetPosition default 0;
property ProgressBkColor: TColor read FProgressBkColor write SetProgressBkColor default clWindow;
property ProgressBorder: TSCControlBorder read FProgressBorder write SetProgressBorder default sccb3DLowered;
property ProgressBorderColor: TColor read FProgressBorderColor write SetProgressBorderColor default cl3DDkShadow;
property ProgressColor: TColor read FProgressColor write SetProgressColor default clHighlight;
property ProgressEndColor: TColor read FProgressEndColor write SetProgressEndColor default clAqua;
property ProgressSlice: Integer read FProgressSlice write SetProgressSlice default 10;
property ProgressStyle: TSCTrackProgressStyle read FProgressStyle write SetProgressStyle default sctpClassic;
property ProgressHeight: Integer read FProgressHeight write SetProgressHeight default 12;
property Progress: TSCTrackbarProgress read FProgress write SetProgress;
property ShowFocusRect: Boolean read FShowFocusRect write SetShowFocusRect default True;
property ShowLines: Boolean read FShowLines write SetShowLines default True;
property ShowProgress: Boolean read FShowProgress write SetShowProgress default True;
property ShowSlider: Boolean read FShowSlider write SetShowSlider default True;
property SliderColor: TColor read FSliderColor write SetSliderColor default clBtnFace;
property SliderFocusColor: TColor read FSliderFocusColor write SetSliderFocusColor default clHighlight;
property SliderFrameColor: TColor read FSliderFrameColor write SetSliderFrameColor default clGreen;
property SliderHottracks: Boolean read FSliderHottracks write SetSliderHottracks default True;
property SliderHotColor: TColor read FSliderHotColor write SetSliderHotColor default clBlue;
property SliderOffset: Integer read FSliderOffset write SetSliderOffset default 0;
property SliderSize: Integer read FSliderSize write SetSliderSize default 4;
property SliderStyle: TSCTrackStyle read FSliderStyle write SetSliderStyle default scthWindows;
property Slider: TSCTrackbarSlider read FSlider write SetSlider;
property Spacing default 0;
property TabStop default True;
property OnCustomDrawBack: TSCTrackbarPaintEvent read FOnCustomDrawBack
write FOnCustomDrawBack;
property OnCustomDrawLines: TSCTrackbarPaintEvent read FOnCustomDrawLines
write FOnCustomDrawLines;
property OnCustomDrawProgress: TSCTrackbarPaintEvent read FOnCustomDrawProgress
write FOnCustomDrawProgress;
property OnCustomDrawSlider: TSCTrackbarPaintEvent read FOnCustomDrawSlider
write FOnCustomDrawSlider;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function PtOnSlider(P: TPoint): Boolean;
function PositionAtPos(P: TPoint): Integer;
end;
TSCTrackbar = class(TSCCustomTrackbar)
published
property Align;
property Alignment;
property Anchors;
property BlendColor;
property BorderProps;
property Color;
property Constraints;
property Cursor;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Frequency;
property Hint;
property Images;
property ImageIndex;
property Indent;
property LineColor;
property LinePosition;
property LineSize;
property Max;
property Min;
property Orientation;
property PageSize;
property ParentColor;
property ParentShowHint;
property Picture;
property PictureProps;
property PopupMenu;
property Position;
property Progress;
property ShowHint;
property ShowFocusRect;
property ShowLines;
property ShowProgress;
property ShowSlider;
property Slider;
property Spacing;
property TabOrder;
property TabStop;
property Transparent;
property Tag;
property OnChange;
property OnClick;
property OnCanResize;
property OnConstrainedResize;
property OnContextPopup;
property OnCustomDrawBack;
property OnCustomDrawLines;
property OnCustomDrawProgress;
property OnCustomDrawSlider;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnDblClick;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
implementation
{ TSCCustomTrackbar }
procedure TSCCustomTrackbar.CMMouseEnter(var Message: TMessage);
var
P: TPoint;
Hot: Boolean;
begin
if not IsDesigning then
begin
GetCursorPos(P);
P := ScreenToClient(P);
Hot := FSliderIsHot;
FSliderIsHot := PtOnSlider(P);
if (FSliderStyle <> scthImage) and
FSliderHottracks and (Hot <> FSliderIsHot) then
Invalidate;
end;
inherited;
end;
procedure TSCCustomTrackbar.CMMouseLeave(var Message: TMessage);
var
Hot: Boolean;
begin
if not IsDesigning then
begin
Hot := FSliderIsHot;
FSliderIsHot := False;
if (FSliderStyle <> scthImage) and
FSliderHottracks and (Hot <> FSliderIsHot) then
Invalidate;
end;
inherited;
end;
constructor TSCCustomTrackbar.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
SetBounds(Left, Top, 150, 45);
DoubleBuffered := True;
ClickFocus := True;
Color := clBtnFace;
ParentColor := False;
TabStop := True;
BlendColor := False;
Spacing := 0;
FAlignment := sctaLeftToRight;
FFrequency := 1;
FLineColor := clBtnText;
FLinePosition := sclpBottomRight;
FLineSize := 1;
FMax := 10;
FMin := 0;
FOrientation := sctoHorizontal;
FPageSize := 2;
FPosition := 0;
FProgressBkColor := clWindow;
FProgressBorder := sccb3DLowered;
FProgressBorderColor := cl3DDkShadow;
FProgressColor := clHighlight;
FProgressEndColor := clAqua;
FProgressHeight := 12;
FProgressSlice := 10;
FProgressStyle := sctpClassic;
FShowFocusRect := True;
FShowLines := True;
FShowProgress := True;
FShowSlider := True;
FSliderColor := clBtnFace;
FSliderFocusColor := clHighlight;
FSliderFrameColor := clGreen;
FSliderHottracks := True;
FSliderHotColor := clBlue;
FSliderOffset := 0;
FSliderSize := 4;
FSliderStyle := scthWindows;
FProgress := TSCTrackbarProgress.Create(Self);
FSlider := TSCTrackbarSlider.Create(Self);
end;
procedure TSCCustomTrackbar.DoChange;
begin
Invalidate;
end;
procedure TSCCustomTrackbar.DoDrawLines(ACanvas: TCanvas);
var
C: TColor;
Handled: Boolean;
PR, R, CR: TRect;
Cnt, P, Frq, ThS, I, W, H: Integer;
begin
if (ACanvas = nil) or not (FShowLines and CanGetClientRect) then
Exit;
Cnt := FMax - FMin;
if Cnt > 0 then
begin
PR := GetProgressRect;
Handled := False;
if Assigned(FOnCustomDrawLines) then
begin
R := PR;
CR := GetClientRect;
if FOrientation = sctoHorizontal then
begin
R.Top := CR.Top;
R.Bottom := CR.Bottom;
end else
begin
R.Left := CR.Left;
R.Right := CR.Right;
end;
FOnCustomDrawLines(Self, Canvas, R, Handled);
end;
if Handled then
Exit;
P := GetProgressBorderSize;
InflateRect(PR, -P, -P);
if FOrientation = sctoHorizontal then
W := PR.Right - PR.Left
else
W := PR.Bottom - PR.Top;
if W <= 0 then Exit;
ThS := GetSliderSize;
R := PR;
if FOrientation = sctoHorizontal then
begin
if FSliderStyle <> scthImage then
InflateRect(R, 0, ThS + FSliderOffset + 4)
else begin
InflateRect(R, 0, 6);
if (Images <> nil) and (FProgressHeight < Images.Height) then
InflateRect(R, 0, (Images.Height - FProgressHeight) div 2);
end;
Dec(R.Top);
if not FShowSlider then
InflateRect(R, 0, 2);
end else
begin
if FSliderStyle <> scthImage then
InflateRect(R, ThS + FSliderOffset + 4, 0)
else begin
InflateRect(R, 6, 0);
if (Images <> nil) and (FProgressHeight < Images.Width) then
InflateRect(R, (Images.Width - FProgressHeight) div 2, 0);
end;
Dec(R.Left);
if not FShowSlider then
InflateRect(R, 2, 0);
end;
C := FLineColor;
if C = clNone then C := clWindowText;
with ACanvas do
begin
Pen.Mode := pmCopy;
Pen.Style := psSolid;
Pen.Width := 1;
Pen.Color := C;
Frq := FFrequency;
if Frq < 1 then Frq := 1;
for I := 0 to Cnt do
if (Frq = 1) or (I = 0) or
(I = Cnt) or ((I mod Frq) = 0) then
begin
P := MulDiv(I, W, Cnt);
H := 4;
if (I > 0) and (I < Cnt) then
H := 3;
if FOrientation = sctoHorizontal then
begin
if FLinePosition in [sclpBottomRight, sclpBoth] then
begin
MoveTo(R.Left + P, R.Bottom);
LineTo(R.Left + P, R.Bottom + H);
end;
if FLinePosition in [sclpTopLeft, sclpBoth] then
begin
MoveTo(R.Left + P, R.Top);
LineTo(R.Left + P, R.Top - H);
end;
end else
begin
if FLinePosition in [sclpBottomRight, sclpBoth] then
begin
MoveTo(R.Right, R.Top + P);
LineTo(R.Right + H, R.Top + P);
end;
if FLinePosition in [sclpTopLeft, sclpBoth] then
begin
MoveTo(R.Left, R.Top + P);
LineTo(R.Left - H, R.Top + P);
end;
end;
end;
end;
end;
end;
procedure TSCCustomTrackbar.DoDrawProgress(ACanvas: TCanvas);
var
DoSlicing, Handled: Boolean;
CR, R, R2, R3, R4: TRect;
I, St, W, P, Ps, Pb: Integer;
C, C1, C2, C3, C4, ClStart, ClEnd: TColor;
begin
if (ACanvas = nil) or not CanGetClientRect then
Exit;
CR := GetProgressRect;
IntersectRect(R, CR, ClientRect);
if not (IsRectEmpty(CR) or IsRectEmpty(R)) then
begin
Handled := False;
if Assigned(FOnCustomDrawProgress) then
FOnCustomDrawProgress(Self, Canvas, CR, Handled);
if Handled then
Exit;
C := FProgressBkColor;
if (C = clNone) and (FProgressStyle in [sctpGradientComplementary,
sctpSliced, sctpSlicedGradient, sctpXP, sctpMetal]) then
begin
C := Self.Color;
if C = clNone then C := clBtnFace;
end;
if C <> clNone then
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C;
R := CR;
FillRect(R);
end;
if FShowProgress then
begin
R := CR;
Pb := GetProgressBorderSize;
InflateRect(R, -(Pb + Spacing), -(Pb + Spacing));
if not IsRectEmpty(R) then
begin
Ps := NormalizePosition(Position);
P := 0;
if FMax - FMin > 0 then
begin
if FOrientation = sctoHorizontal then
W := R.Right - R.Left
else
W := R.Bottom - R.Top;
if W > 0 then
begin
P := Ps - FMin;
P := Round(P * (W / (FMax - FMin)));
end;
end;
if P > 0 then
begin
C := FProgressBkColor;
if C = clNone then C := Self.Color;
C1 := FProgressColor;
if C1 = clNone then C1 := C;
C2 := FProgressEndColor;
if C2 = clNone then C2 := C;
R2 := R;
if FOrientation = sctoHorizontal then
begin
if FAlignment = sctaLeftToRight then
R2.Right := R2.Left + P
else
R2.Left := R2.Right - P;
end else
begin
if FAlignment = sctaLeftToRight then
R2.Bottom := R2.Top + P
else
R2.Top := R2.Bottom - P;
end;
if not IsRectEmpty(R2) then
case FProgressStyle of
sctpRaised, sctpClassic:
begin
if C1 <> C then
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C1;
FillRect(R2);
end;
if FProgressStyle = sctpRaised then
begin
C3 := SCCommon.scBlendColor(C1, 64);
C4 := SCCommon.scBlendColor(C1, -64);
scFrame3D(ACanvas, R2, C3, C4, 1, 0);
end;
end;
sctpOffice12:
begin
InflateRect(R2, -1, -1);
if not IsRectEmpty(R) then
begin
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C1;
FillRect(R2);
end;
ClEnd := C1;
ClStart := GetGradientPreLight(C1);
if FOrientation = sctoHorizontal then
begin
R3 := R2;
Dec(R3.Bottom, Round((R3.Bottom - R3.Top)/4));
scDrawGradient(ACanvas, R3, scgTopToBottom, ClStart, ClEnd);
end else
begin
R3 := R2;
Dec(R3.Right, Round((R3.Right - R3.Left)/4));
scDrawGradient(ACanvas, R3, scgLeftToRight, ClStart, ClEnd);
end;
ClStart := GetGradientDark(C1);
ClEnd := GetGradientLight(C1);
if FOrientation = sctoHorizontal then
begin
R3 := R2;
Inc(R3.Top, (R3.Bottom - R3.Top) div 2);
if not IsRectEmpty(R3) then
scDrawGradient(ACanvas, R3, scgTopToBottom, ClStart, ClEnd);
end else
begin
R3 := R2;
Inc(R3.Left, (R3.Right - R3.Left) div 2);
if not IsRectEmpty(R3) then
scDrawGradient(ACanvas, R3, scgLeftToRight, ClStart, ClEnd);
end;
R3 := R2;
InflateRect(R3, -1, -1);
ClStart := GetGradientPreLight(C1);
scFrame3D(ACanvas, R3, ClStart, ClStart, 1, 0);
R3 := R2;
ClStart := GetGradientPreDark(C1);
scFrame3D(ACanvas, R3, ClStart, ClStart, 1, 0);
end;
end;
sctp3D, sctpGradient3D:
begin
if C1 <> C then
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C1;
FillRect(R2);
end;
R3 := R2;
if FOrientation = sctoHorizontal then
R3.Bottom := R3.Top + ((R3.Bottom - R3.Top) div 2)
else
R3.Right := R3.Left + ((R3.Right - R3.Left) div 2);
if not IsRectEmpty(R2) then
begin
C3 := SCCommon.scBlendColor(C1, 64);
if FOrientation = sctoHorizontal then
scDrawGradient(ACanvas, R3, scgTopToBottom, C3, C1)
else
scDrawGradient(ACanvas, R3, scgLeftToRight, C3, C1);
R3 := R2;
if FOrientation = sctoHorizontal then
R3.Top := R3.Bottom - ((R3.Bottom - R3.Top) div 2)
else
R3.Left := R3.Right - ((R3.Right - R3.Left) div 2);
C4 := SCCommon.scBlendColor(C1, -64);
if FOrientation = sctoHorizontal then
scDrawGradient(ACanvas, R3, scgTopToBottom, C1, C4)
else
scDrawGradient(ACanvas, R3, scgLeftToRight, C1, C4);
if FProgressStyle = sctp3D then
begin
R3 := R2;
scFrame3D(ACanvas, R3, C3, C4, 1, 0);
C3 := SCCommon.scBlendColor(C1, 48);
C4 := SCCommon.scBlendColor(C1, -48);
scFrame3D(ACanvas, R3, C3, C4, 1, 0);
end;
end;
end;
sctpSliced, sctpSlicedGradient,
sctpXP, sctpMetal:
begin
InflateRect(R2, -1, -1);
if not IsRectEmpty(R2) and ((FProgressStyle in [sctpXP, sctpMetal]) or
((C1 <> C) and (FProgressStyle = sctpSliced)) or
(((C1 <> C) or (C2 <> C)) and (FProgressStyle = sctpSlicedGradient))) then
begin
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C1;
FillRect(R2);
end;
if FProgressStyle in [sctpXP, sctpMetal] then
begin
R3 := R2;
if FOrientation = sctoHorizontal then
R3.Bottom := R3.Top + ((R3.Bottom - R3.Top) div 2)
else
R3.Right := R3.Left + ((R3.Right - R3.Left) div 2);
if not IsRectEmpty(R2) then
begin
C3 := SCCommon.scBlendColor(C1, 128);
if FOrientation = sctoHorizontal then
begin
scDrawGradient(ACanvas, R3, scgTopToBottom, C3, C1);
R3 := R2;
R3.Top := R3.Bottom - ((R3.Bottom - R3.Top) div 2);
scDrawGradient(ACanvas, R3, scgTopToBottom, C1, C3)
end else
begin
scDrawGradient(ACanvas, R3, scgLeftToRight, C3, C1);
R3 := R2;
R3.Left := R3.Right - ((R3.Right - R3.Left) div 2);
scDrawGradient(ACanvas, R3, scgLeftToRight, C1, C3);
end;
end;
end else
if FProgressStyle = sctpSlicedGradient then
begin
R3 := R;
InflateRect(R3, -1, -1);
if FOrientation = sctoHorizontal then
scDrawGradient(ACanvas, R3, scgLeftToRight, C1, C2)
else
scDrawGradient(ACanvas, R3, scgTopToBottom, C1, C2);
R3 := R2;
if FOrientation = sctoHorizontal then
begin
if FAlignment = sctaLeftToRight then
begin
R3.Left := R3.Right;
R3.Right := R.Right - 1;
end else
begin
R3.Right := R3.Left;
R3.Left := R.Left + 1;
end;
end else
begin
if FAlignment = sctaLeftToRight then
begin
R3.Top := R3.Bottom;
R3.Bottom := R.Top + 1;
end else
begin
R3.Bottom := R3.Top;
R3.Top := R.Bottom - 1;
end;
end;
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C;
FillRect(R3);
end;
end;
DoSlicing := (FProgressSlice > 0) and (Ps > FMin) and
(FProgressSlice < P);
if DoSlicing then
begin
with ACanvas do
begin
Brush.Style := bsSolid;
Brush.Color := C;
Pen.Width := 1;
Pen.Style := psSolid;
Pen.Mode := pmCopy;
Pen.Color := C1;
end;
St := Round((P-2) / (FProgressSlice + 2));
if FOrientation = sctoHorizontal then
begin
if FAlignment = sctaLeftToRight then
begin
R3 := R2;
R3.Right := R3.Left + 2;
R4 := R2;
R4.Right := R4.Left + FProgressSlice;
for I := 0 to St-1 do
begin
OffsetRect(R3, FProgressSlice, 0);
with ACanvas do
begin
Brush.Style := bsSolid;
FillRect(R3);
end;
OffsetRect(R3, R3.Right - R3.Left, 0);
if (FProgressStyle = sctpMetal) and not IsRectEmpty(R4) then
begin
with ACanvas do
begin
Brush.Style := bsClear;
Rectangle(R4.Left, R4.Top, R4.Right, R4.Bottom);
end;
OffsetRect(R4, FProgressSlice + 2, 0);
end;
end;
end else
begin
R3 := R2;
R3.Left := R3.Right - 2;
R4 := R2;
R4.Left := R4.Right - FProgressSlice;
for I := 0 to St-1 do
begin
OffsetRect(R3, -FProgressSlice, 0);
with ACanvas do
begin
Brush.Style := bsSolid;
FillRect(R3);
end;
OffsetRect(R3, -(R3.Right - R3.Left), 0);
if (FProgressStyle = sctpMetal) and not IsRectEmpty(R4) then
begin
with ACanvas do
begin
Brush.Style := bsClear;
Rectangle(R4.Left, R4.Top, R4.Right, R4.Bottom);
end;
OffsetRect(R4, -(FProgressSlice + 2), 0);
end;
end;
end;
end else
begin
if FAlignment = sctaLeftToRight then
begin
R3 := R2;
R3.Bottom := R3.Top + 2;
R4 := R2;
R4.Bottom := R4.Top + FProgressSlice;
for I := 0 to St-1 do
begin
OffsetRect(R3, 0, FProgressSlice);
with ACanvas do
begin
Brush.Style := bsSolid;
FillRect(R3);
end;
OffsetRect(R3, 0, R3.Bottom - R3.Top);
if (FProgressStyle = sctpMetal) and not IsRectEmpty(R4) then
begin
with ACanvas do
begin