Repository navigation
Expand file tree
/
Copy pathSCGraphicButton.pas
More file actions
2761 lines (2277 loc) · 69.6 KB
/
Copy pathSCGraphicButton.pas
File metadata and controls
2761 lines (2277 loc) · 69.6 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 SCGraphicButton;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, StdActns, ActnList, Menus, SCConsts, SCCommon, SCControl;
type
TSCGraphicButtonBorderProps = class(TSCGraphicBorderProps)
published
property Border;
property Color;
property ExDraw;
property FlatColor;
property FlatInnerColor;
property InnerBorder;
property Width;
end;
TSCGraphicButtonBase = class(TSCGraphicControl)
private
FDblClicked: Boolean;
FEndEllipsis: Boolean;
FTimerEnabled: Boolean;
FInterval: Integer;
FWindowHandle: HWND;
procedure DoTimer;
procedure UpdateTimer;
procedure SetInterval(Value: Integer);
procedure SetEndEllipsis(Value: Boolean);
protected
procedure WndProc(var Message: TMessage); override;
procedure StartTimer;
procedure StopTimer;
function GetInterval: Integer; virtual;
procedure Timer; virtual;
procedure DoMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure DoMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
function GetBorderPropsClass: TSCGraphicBorderPropsClass; override;
property DblClicked: Boolean read FDblClicked;
property EndEllipsis: Boolean read FEndEllipsis write SetEndEllipsis default True;
property Transparent default False;
property WindowHandle: HWND read FWindowHandle;
property Interval: Integer read GetInterval write SetInterval default 50;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
end;
TSCCustomGraphicButton = class(TSCGraphicButtonBase)
private
FAllowAllUp: Boolean;
FArrowColor: TColor;
FCancel: Boolean;
FCenter: Boolean;
FDown: Boolean;
FDropdownMenu: TPopupMenu;
FGradient: TSCButtonGradient;
FGroupIndex: Integer;
FHighlightColor: TColor;
FHottrackColor: TColor;
FLayout: TSCButtonLayout;
FPopupArrow: Boolean;
FRepeatClick: Boolean;
FRepeatInterval: Integer;
FRoundColor: TColor;
FRounded: Boolean;
FRoundWithParentColor: Boolean;
FShowCaption: Boolean;
FStyle: TSCButtonStyle;
FModalResult: TModalResult;
FMultiline: Boolean;
FFontColor: TColor;
FPopArrowColor: TColor;
FInnerRect: TRect;
FImgOffset: TPoint;
FTxtOffset: TPoint;
FPopOffset: TPoint;
FMousePressed: Boolean;
FOnStateChange: TNotifyEvent;
procedure SetAllowAllUp(Value: Boolean);
procedure SetArrowColor(Value: TColor);
procedure SetCenter(Value: Boolean);
procedure SetDown(Value: Boolean);
procedure SetDropdownMenu(Value: TPopupMenu);
procedure SetGradient(Value: TSCButtonGradient);
procedure SetGroupIndex(Value: Integer);
procedure SetHighlightColor(Value: TColor);
procedure SetHottrackColor(Value: TColor);
procedure SetLayout(Value: TSCButtonLayout);
procedure SetPopupArrow(Value: Boolean);
procedure SetRepeatClick(Value: Boolean);
procedure SetRepeatInterval(Value: Integer);
procedure SetRoundColor(Value: TColor);
procedure SetRounded(Value: Boolean);
procedure SetRoundWithParentColor(Value: Boolean);
procedure SetShowCaption(Value: Boolean);
procedure SetStyle(Value: TSCButtonStyle);
procedure SetMultiline(Value: Boolean);
procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMButtonPressed(var Message: TMessage); message CM_BUTTONPRESSED;
procedure CNCommand(var Message: TWMCommand); message CN_COMMAND;
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
function CanDoUp: Boolean;
procedure UpdateGroupDown;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Paint; override;
procedure Timer; override;
function IsTransparent: Boolean; override;
function PopupDropdownMenu: Boolean;
function CheckMenuDropdown: Boolean;
procedure StopTracking; override;
procedure MouseInControlChanged; override;
procedure SpacingChanged; override;
procedure EnabledChanged; override;
procedure StartRepeat;
procedure StopRepeat;
function CanRepeat: Boolean;
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 MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure DrawPopupArrow(R: TRect; AColor: TColor = clNone);
procedure DrawImageAndText(var R: TRect; FontColor: TColor = clNone);
procedure DoDrawCorel;
procedure DoDrawFlatMacSpeed;
procedure DoDrawHower;
procedure DoDrawMacSpeed;
procedure DoDrawNew;
procedure DoDrawOfficeXP;
procedure DoDrawRaisedShadow;
procedure DoDrawSpeed;
procedure DoDrawWin2k;
procedure DoDrawXP;
procedure DoDrawOffice12;
procedure DoDrawOffice2003;
procedure DoDrawDarkling;
procedure DoDrawMetal;
property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default False;
property ArrowColor: TColor read FArrowColor write SetArrowColor default clBtnText;
property Cancel: Boolean read FCancel write FCancel default False;
property Center: Boolean read FCenter write SetCenter default True;
property Color default clBtnFace;
property Gradient: TSCButtonGradient read FGradient write SetGradient default scbgTopToBottom;
property GroupIndex: Integer read FGroupIndex write SetGroupIndex default 0;
property Down: Boolean read FDown write SetDown default False;
property DropdownMenu: TPopupMenu read FDropdownMenu write SetDropdownMenu;
property HighlightColor: TColor read FHighlightColor write SetHighlightColor default SC_HighlightColor;
property HottrackColor: TColor read FHottrackColor write SetHottrackColor default SC_HottrackColor;
property Layout: TSCButtonLayout read FLayout write SetLayout default scblLeft;
property ModalResult: TModalResult read FModalResult write FModalResult default 0;
property Multiline: Boolean read FMultiline write SetMultiline default False;
property ParentColor default False;
property PopupArrow: Boolean read FPopupArrow write SetPopupArrow default False;
property RepeatClick: Boolean read FRepeatClick write SetRepeatClick default False;
property RepeatInterval: Integer read FRepeatInterval write SetRepeatInterval default 50;
property RoundColor: TColor read FRoundColor write SetRoundColor default clBtnFace;
property Rounded: Boolean read FRounded write SetRounded default True;
property RoundWithParentColor: Boolean read FRoundWithParentColor write SetRoundWithParentColor default True;
property ShowCaption: Boolean read FShowCaption write SetShowCaption default True;
property Style: TSCButtonStyle read FStyle write SetStyle default scbsWin2k;
property OnStateChange: TNotifyEvent read FOnStateChange write FOnStateChange;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure Click; override;
function UseRightToLeftAlignment: Boolean; override;
end;
TSCSpeedButton = class(TSCCustomGraphicButton)
published
property Align;
property AllowAllUp;
property Anchors;
property ArrowColor;
property BiDiMode;
property Cancel;
property Caption;
property Center;
property Color;
property Constraints;
property Cursor;
property DragCursor;
property DragKind;
property DragMode;
property DropdownMenu;
property Enabled;
property EndEllipsis;
property Font;
property Gradient;
property GroupIndex;
property Down;
property HighlightColor;
property HottrackColor;
property Images;
property ImageIndex;
property Indent;
property Layout;
property ModalResult;
property Multiline;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupArrow;
property RepeatClick;
property RepeatInterval;
property RoundColor;
property Rounded;
property RoundWithParentColor;
property ShowCaption;
property ShowHint;
property Spacing;
property Style;
property Transparent;
property Visible;
property OnCanResize;
property OnClick;
{$IFDEF SC_DELPHI5_UP}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnStateChange;
end;
implementation
type
TColoredControl = class(TControl);
{ TSCGraphicButtonBase }
procedure TSCGraphicButtonBase.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TSCGraphicButtonBase then
begin
with TSCGraphicButtonBase(Source) do
begin
Self.EndEllipsis := EndEllipsis;
Self.Interval := Interval;
end;
end;
end;
constructor TSCGraphicButtonBase.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEndEllipsis := True;
FInterval := 50;
{$IFDEF SC_DELPHI6_UP}
{$WARN SYMBOL_DEPRECATED OFF}
{$ENDIF}
FWindowHandle := AllocateHWnd(WndProc);
{$IFDEF SC_DELPHI6_UP}
{$WARN SYMBOL_DEPRECATED ON}
{$ENDIF}
Transparent := False;
end;
destructor TSCGraphicButtonBase.Destroy;
begin
{$IFDEF SC_DELPHI6_UP}
{$WARN SYMBOL_DEPRECATED OFF}
{$ENDIF}
DeallocateHWnd(FWindowHandle);
{$IFDEF SC_DELPHI6_UP}
{$WARN SYMBOL_DEPRECATED ON}
{$ENDIF}
FWindowHandle := 0;
inherited Destroy;
end;
procedure TSCGraphicButtonBase.DoMouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
FDblClicked := ssDouble in Shift;
inherited DoMouseDown(Button, Shift, X, Y);
end;
procedure TSCGraphicButtonBase.DoMouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
if FDblClicked then
begin
FDblClicked := False;
Click;
end;
inherited DoMouseUp(Button, Shift, X, Y);
end;
procedure TSCGraphicButtonBase.DoTimer;
begin
if Enabled and FTimerEnabled and not IsDesigning then
Timer;
end;
function TSCGraphicButtonBase.GetBorderPropsClass: TSCGraphicBorderPropsClass;
begin
Result := TSCGraphicButtonBorderProps;
end;
function TSCGraphicButtonBase.GetInterval: Integer;
begin
Result := FInterval;
end;
procedure TSCGraphicButtonBase.SetEndEllipsis(Value: Boolean);
begin
if FEndEllipsis <> Value then
begin
FEndEllipsis := Value;
Invalidate;
end;
end;
function TSCCustomGraphicButton.CanDoUp: Boolean;
var
I: Integer;
Control: TControl;
begin
Result := FAllowAllUp or (FGroupIndex = 0);
if not Result and (Parent <> nil) then
with Parent do
for I := 0 to ControlCount - 1 do
begin
Control := Controls[I];
if (Control <> Self) and (Control is TSCCustomGraphicButton) then
with TSCCustomGraphicButton(Control) do
if FGroupIndex = Self.FGroupIndex then
begin
Result := Down;
if Result then Exit;
end;
end;
end;
procedure TSCCustomGraphicButton.Click;
var
Form: TCustomForm;
begin
if Parent <> nil then
begin
Form := GetParentForm(Self);
if Form <> nil then
Form.ModalResult := ModalResult;
end;
inherited Click;
end;
procedure TSCCustomGraphicButton.CMButtonPressed(var Message: TMessage);
var
Sender: TSCCustomGraphicButton;
begin
if Message.WParam = FGroupIndex then
begin
Sender := TSCCustomGraphicButton(Message.LParam);
if Sender <> Self then
begin
if Sender.Down and FDown then
begin
FDown := False;
Invalidate;
end;
FAllowAllUp := Sender.AllowAllUp;
end;
end;
end;
procedure TSCCustomGraphicButton.CMDialogChar(var Message: TCMDialogChar);
begin
with Message do
if IsAccel(CharCode, Caption) then
begin
Click;
Result := 1;
end else
inherited;
end;
procedure TSCCustomGraphicButton.CMDialogKey(var Message: TCMDialogKey);
begin
with Message do
if (CharCode = VK_ESCAPE) and FCancel and
(KeyDataToShiftState(Message.KeyData) = []) then
begin
Click;
Result := 1;
end else
inherited;
end;
procedure TSCCustomGraphicButton.CMParentColorChanged(var Message: TMessage);
begin
inherited;
if FRoundWithParentColor then
begin
if Message.wParam <> 0 then
SetRoundColor(TColor(Message.lParam)) else
SetRoundColor(TColoredControl(Parent).Color);
FRoundWithParentColor := True;
end;
end;
constructor TSCCustomGraphicButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csSetCaption, csOpaque, csDoubleClicks];
SetBounds(Left, Top, 72, 25);
DoubleBuffered := True;
ParentColor := False;
Color := clBtnFace;
FAllowAllUp := False;
FArrowColor := clBtnText;
FCenter := True;
FDown := False;
FGradient := scbgTopToBottom;
FGroupIndex := 0;
FHighlightColor := SC_HighlightColor;
FHottrackColor := SC_HottrackColor;
FLayout := scblLeft;
FPopupArrow := False;
FRepeatInterval := 50;
FRoundColor := clBtnFace;
FRounded := True;
FRoundWithParentColor := True;
FShowCaption := True;
FStyle := scbsWin2k;
end;
procedure TSCCustomGraphicButton.DoDrawCorel;
var
CR, R: TRect;
TopColor, BtmColor: TColor;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
R := CR;
if not Transparent then
with Canvas do
begin
Brush.Style := bsSolid;
if not FDown then
Brush.Color := Self.Color
else begin
if IsColorLight(Self.Color) then
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, False)
else
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, True);
end;
FillRect(R);
end;
FInnerRect := CR;
InflateRect(FInnerRect, -3, -3);
if Enabled and not FDown and (FGroupIndex = 0) and FMousePressed then
InflateRect(FInnerRect, -1, -1);
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
FImgOffset := Point(1, 1);
FTxtOffset := Point(1, 1);
FPopOffset := Point(1, 1);
end;
R := CR;
if Enabled and ((FDown and (FMousePressed or MouseInControl)) or
(FMousePressed and MouseInControl)) then
begin
if not FDown and (FGroupIndex = 0) and FMousePressed then
begin
TopColor := Get3DDkShadowOf(Self.Color);
BtmColor := TopColor;
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
TopColor := GetBtnShadowOf(Self.Color);
BtmColor := GetBtnHighlightOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end else
begin
TopColor := GetBtnShadowOf(Self.Color);
BtmColor := GetBtnHighlightOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
TopColor := Get3DDkShadowOf(Self.Color);
BtmColor := BlendedColor(Self.Color, 16, 16, 16, True);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end;
end else
if FDown and (not Enabled or not (FMousePressed or MouseInControl)) then
begin
TopColor := GetBtnShadowOf(Self.Color);
BtmColor := GetBtnHighlightOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end else
begin
if Enabled and (FGroupIndex = 0) and FMousePressed then
begin
TopColor := Get3DDkShadowOf(Self.Color);
BtmColor := TopColor;
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end;
if Enabled and ((FMousePressed and not MouseInControl) or
(not FMousePressed and MouseInControl)) then
begin
TopColor := GetBtnHighlightOf(Self.Color);
BtmColor := Get3DDkShadowOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
TopColor := BlendedColor(Self.Color, 16, 16, 16, True);
BtmColor := GetBtnShadowOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end else
begin
TopColor := GetBtnHighlightOf(Self.Color);
BtmColor := GetBtnShadowOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, 0);
end;
end;
end;
procedure TSCCustomGraphicButton.DoDrawFlatMacSpeed;
var
CR, R: TRect;
RoundBy: Integer;
TopColor: TColor;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
R := CR;
if not Transparent then
with Canvas do
begin
Brush.Style := bsSolid;
if FDown then
begin
if not (Enabled and FMousePressed and MouseInControl) then
Brush.Color := Self.Color
else
if IsColorLight(Self.Color) then
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, False)
else
Brush.Color := BlendedColor(Self.Color, 96, 96, 96, True);
end else
begin
if IsColorLight(Self.Color) then
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, False)
else
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, True);
end;
FillRect(R);
end;
FInnerRect := CR;
InflateRect(FInnerRect, -3, -3);
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
FImgOffset := Point(1, 1);
FTxtOffset := Point(1, 1);
FPopOffset := Point(1, 1);
end;
RoundBy := 0;
if FRounded then RoundBy := 4;
if IsDesigning or FDown or (Enabled and
(FMousePressed or MouseInControl)) then
begin
R := CR;
TopColor := GetBtnShadowOf(Self.Color);
scFrame3D(Canvas, R, TopColor, TopColor, 1, RoundBy);
end;
if FRounded and not Transparent then
begin
R := CR;
SCFillCorners(Canvas, R, FRoundColor, RoundBy);
end;
end;
procedure TSCCustomGraphicButton.DoDrawHower;
var
CR, R: TRect;
FC, C: TColor;
Rd, I: Integer;
RoundBy: Integer;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
FInnerRect := CR;
InflateRect(FInnerRect, -6, -6);
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
FImgOffset := Point(1, 1);
FTxtOffset := Point(1, 1);
FPopOffset := Point(1, 1);
end;
C := Self.Color;
if Enabled and not FMousePressed and MouseInControl then
C := FHottrackColor
else
if Enabled and FMousePressed and not MouseInControl then
C := FHighlightColor;
if FDown then
begin
if IsColorLight(Self.Color) then
C := BlendedColor(C, 24, 24, 24, False)
else
C := BlendedColor(C, 24, 24, 24, True);
end;
R := CR;
if Transparent then
InflateRect(R, -4, -4)
else begin
with Canvas do
begin
Brush.Style := bsSolid;
if FRounded and not Transparent then
begin
Brush.Color := FRoundColor;
FillRect(R);
end;
InflateRect(R, -4, -4);
Brush.Color := C;
FillRect(R);
end;
end;
RoundBy := 0; Rd := 0;
if FRounded then
begin
RoundBy := 2;
Rd := RoundBy + 2;
end;
FC := BlendedColor(C, 16, 16, 16, True);
for I := 0 to 3 do
begin
R := CR;
InflateRect(R, I - 3, I - 3);
scFrame3D(Canvas, R, FC, FC, 1, Rd);
if FRounded then
begin
InflateRect(R, 1, 1);
scFrame3D(Canvas, R, FC, FC, 1, Rd + 2);
end;
FC := BlendedColor(FC, 12, 12, 12, True);
end;
R := CR;
InflateRect(R, -4, -4);
FC := BlendedColor(C, 64, 64, 64, False);
scFrame3D(Canvas, R, FC, FC, 1, RoundBy);
end;
procedure TSCCustomGraphicButton.DoDrawMacSpeed;
var
CR, R: TRect;
RoundBy: Integer;
TopColor, BtmColor: TColor;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
R := CR;
if not Transparent then
with Canvas do
begin
Brush.Style := bsSolid;
if FDown then
begin
if not (Enabled and FMousePressed and MouseInControl) then
Brush.Color := Self.Color
else
if IsColorLight(Self.Color) then
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, False)
else
Brush.Color := BlendedColor(Self.Color, 96, 96, 96, True);
end else
begin
if IsColorLight(Self.Color) then
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, False)
else
Brush.Color := BlendedColor(Self.Color, 24, 24, 24, True);
end;
FillRect(R);
end;
FInnerRect := CR;
InflateRect(FInnerRect, -3, -3);
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
FImgOffset := Point(1, 1);
FTxtOffset := Point(1, 1);
FPopOffset := Point(1, 1);
end;
RoundBy := 0;
if FRounded then RoundBy := 4;
R := CR;
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
TopColor := GetBtnShadowOf(Self.Color);
BtmColor := GetBtnHighlightOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, RoundBy);
end else
begin
TopColor := GetBtnHighlightOf(Self.Color);
BtmColor := GetBtnShadowOf(Self.Color);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, RoundBy);
end;
if FRounded and not Transparent then
begin
R := CR;
SCFillCorners(Canvas, R, FRoundColor, RoundBy);
end;
end;
procedure TSCCustomGraphicButton.DoDrawNew;
var
CR, R: TRect;
Round1, Round2, Round3: Integer;
DownState, Track: Boolean;
BtmColor, TopColor,
FrameColor, FaceColor: TColor;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
R := CR;
FInnerRect := CR;
InflateRect(FInnerRect, -5, -5);
if FDown or (Enabled and FMousePressed and MouseInControl) then
begin
FImgOffset := Point(1, 1);
FTxtOffset := Point(1, 1);
FPopOffset := Point(1, 1);
end;
Round1 := 0; Round2 := 0; Round3 := 0;
if FRounded then
begin
Round1 := 4;
Round2 := 2;
Round3 := 0;
end;
// face
FaceColor := Self.Color;
if FDown then
FaceColor := BlendedColor(Self.Color, 24, 24, 24, True)
else
if Enabled and FMousePressed and MouseInControl then
FaceColor := BlendedColor(Self.Color, 8, 8, 8, False);
if not Transparent then
with Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := FaceColor;
FillRect(R);
end;
// outter sunken frame
TopColor := BlendedColor(clBtnFace, 16, 16, 16, False);
BtmColor := BlendedColor(clBtnFace, 48, 48, 48, True);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round1);
// outter frame
TopColor := BlendedColor(Self.Color, 144, 144, 144, False);
BtmColor := BlendedColor(TopColor, 16, 16, 16, True);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round1);
// highligh or hottrack frame
Track := False;
FrameColor := Self.Color;
if Enabled and not FMousePressed and MouseInControl then
begin
Track := True;
FrameColor := FHottrackColor;
end else
if Enabled and FMousePressed then
begin
Track := True;
FrameColor := FHighlightColor;
end;
DownState := FDown or (Enabled and not FDown and
FMousePressed and MouseInControl);
TopColor := BlendedColor(FrameColor, 16, 16, 16, True);
if DownState and Track then
BtmColor := TopColor
else
BtmColor := BlendedColor(FrameColor, 40, 40, 40, False);
if Track then
begin
TopColor := BlendedColor(TopColor, 32, 32, 32, True);
BtmColor := BlendedColor(BtmColor, 32, 32, 32, True);
end;
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round2);
if Track then
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round3)
else
if not DownState then
begin
TopColor := BlendedColor(TopColor, 4, 4, 4, False);
BtmColor := BlendedColor(BtmColor, 12, 12, 12, True);
InflateRect(R, 1, 0);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round3);
TopColor := BlendedColor(TopColor, 4, 4, 4, False);
BtmColor := BlendedColor(BtmColor, 12, 12, 12, True);
InflateRect(R, 1, 0);
scFrame3D(Canvas, R, TopColor, BtmColor, 1, Round3);
end;
if FRounded and not Transparent then
begin
R := CR;
SCFillCorners(Canvas, R, FRoundColor, Round1);
end;
end;
procedure TSCCustomGraphicButton.DoDrawOfficeXP;
var
CR, R: TRect;
IsDefaultColor: Boolean;
begin
if (Canvas = nil) or not CanGetClientRect then
Exit;
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
FFontColor := clBtnText;
FPopArrowColor := clBtnText;
IsDefaultColor := False;
R := CR;
with Canvas do
begin
Brush.Style := bsSolid;
if FDown then
begin
if Enabled and (FMousePressed or MouseInControl) then
begin
Brush.Color := GetOfficeXPDownedSelColor;
FFontColor := clHighlightText;
FPopArrowColor := clHighlightText;
end else
Brush.Color := GetOfficeXPDownedColor;
end else
if Enabled and FMousePressed and MouseInControl then
begin
Brush.Color := GetOfficeXPDownedSelColor;
FFontColor := clHighlightText;
FPopArrowColor := clHighlightText;
end else
if Enabled and (FMousePressed or MouseInControl) then
Brush.Color := GetOfficeXPSelColor
else begin
Brush.Color := GetOfficeXPBtnColor;
IsDefaultColor := True;
end;
if not (Transparent and IsDefaultColor) then
FillRect(R);
end;
FInnerRect := CR;
InflateRect(FInnerRect, -3, -3);