Repository navigation
Expand file tree
/
Copy pathSCImageBox.pas
More file actions
4831 lines (4062 loc) · 119 KB
/
Copy pathSCImageBox.pas
File metadata and controls
4831 lines (4062 loc) · 119 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 SCImageBox;
{$I SweetControls.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Clipbrd, SCConsts, SCCommon, SCControl;
type
TSCImageBorderProps = class(TSCBorderProps)
public
constructor Create(AOwner: TSCCustomControl); override;
published
property Border default sccb3DLowered;
end;
TSCImageBoxScrollbar = class(TSCControlScrollbar)
published
property Background;
property ButtonColors;
property Icons;
property SlideLine;
property Thumb;
end;
TSCImageBoxScrollbars = class(TSCControlScrollbars)
private
function GetVisible: Boolean;
procedure SetVisible(Value: Boolean);
public
procedure Assign(Source: TPersistent); override;
published
property Visible: Boolean read GetVisible write SetVisible default True;
end;
TSCZoomRatio = 1..5000;
TSCImageZoomMode = (sczmNone, sczmStretch, sczmStretchKeepingRatio, sczmZoom);
TSCCustomImageBox = class(TSCCustomScrollControl)
private
FCenter: Boolean;
FShowScrollbars: Boolean;
FHideFocusRect: Boolean;
FHorizontalPos: Integer;
FVerticalPos: Integer;
FZoomRatio: TSCZoomRatio;
FZoomMode: TSCImageZoomMode;
FDrawing: Integer;
FQuickDraw: Boolean;
FCreatingWnd: Integer;
FScrollPosChanging: Integer;
FScrollbarChanging: Integer;
FTile: Boolean;
FPictureTransparent: Boolean;
procedure SetCenter(Value: Boolean);
procedure SetHorizontalPos(Value: Integer);
procedure SetVerticalPos(Value: Integer);
procedure SetHideFocusRect(Value: Boolean);
procedure SetShowScrollbars(Value: Boolean);
procedure SetTile(Value: Boolean);
procedure SetZoomRatio(Value: TSCZoomRatio);
procedure SetZoomMode(Value: TSCImageZoomMode);
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMCut(var Message: TMessage); message WM_CUT;
procedure WMCopy(var Message: TMessage); message WM_COPY;
procedure WMPaste(var Message: TMessage); message WM_PASTE;
protected
procedure CreateWnd; override;
procedure Loaded; override;
procedure Paint; override;
procedure AdjustBounds; override;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
function GetPalette: HPALETTE; override;
function GetGraphic: TGraphic; virtual;
function GetBorderPropsClass: TSCControlBorderPropsClass; override;
procedure EnsureHorizontalPos(var P: Integer);
procedure EnsureVerticalPos(var P: Integer);
function UpdateHorzScrollBar: Boolean;
function UpdateVertScrollBar: Boolean;
procedure UpdateScrollbars(Horz, Vert: Boolean); dynamic;
procedure DoScrollerPositionChanged(Kind: TSCScrollbarKind); override;
function GetControlScrollbarsClass: TSCControlCustomScrollbarsClass; override;
function GetScrollbarClass: TSCCustomControlScrollbarClass; override;
function HasGraphic(G: TGraphic): Boolean;
function HasPicture(P: TPicture): Boolean; override;
function CanDrawGraphic(G: TGraphic): Boolean;
function GetPictureRect(P: TPicture): TRect; override;
procedure PaintPicture(P: TPicture);
procedure DoDrawPicture(G: TGraphic); virtual;
procedure DoPictureChanged; override;
function CanDrawCaption: Boolean; virtual;
function GetPictureCaption: String; virtual;
function CanCopy: Boolean; dynamic;
function CanCut: Boolean; dynamic;
function CanPaste: Boolean; dynamic;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
property Border default sccb3DLowered;
property Center: Boolean read FCenter write SetCenter default False;
property Color default clWindow;
property HideFocusRect: Boolean read FHideFocusRect write SetHideFocusRect default False;
property ShowScrollbars: Boolean read FShowScrollbars write SetShowScrollbars default True;
property ParentColor default False;
property QuickDraw: Boolean read FQuickDraw write FQuickDraw default False;
property HorizontalPos: Integer read FHorizontalPos write SetHorizontalPos default 0;
property Tile: Boolean read FTile write SetTile default False;
property VerticalPos: Integer read FVerticalPos write SetVerticalPos default 0;
property ZoomRatio: TSCZoomRatio read FZoomRatio write SetZoomRatio default 100;
property ZoomMode: TSCImageZoomMode read FZoomMode write SetZoomMode default sczmNone;
public
constructor Create(AOwner: TComponent); override;
procedure Assign(Source: TPersistent); override;
procedure CopyToClipboard; dynamic;
procedure CutToClipboard; dynamic;
procedure PasteFromClipboard; dynamic;
end;
TSCImageBox = class(TSCCustomImageBox)
public
property HorizontalPos;
property VerticalPos;
published
property Align;
property Anchors;
property AutoSize;
property BiDiMode;
property BorderProps;
property Caption;
property Center;
property ClickFocus;
property Color;
property Constraints;
property Cursor;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HideFocusRect;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property Picture;
property PictureTransparent;
property QuickDraw;
property Scrollbars;
property ShowHint;
property ShowPicture;
property ShowSizeGrip;
property ShowStatusbar;
property StatusbarAlignment;
property StatusbarColor;
property StatusbarText;
property TabOrder;
property TabStop;
property Tile;
property Transparent;
property Visible;
property ZoomRatio;
property ZoomMode;
property OnCanResize;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
TSCPictureListerFrame = (scpfBumped, scpfEtched, scpfSingle, scpfDouble,
scpfLowered, scpf3DLowered, scpfRaised, scpf3DRaised, scpfRoundedDouble,
scpfNone, scpfMetal);
TSCPictureListerOption = (scpoAllowSelection, scpoHideSelection, scpoHottrack,
scpoHottrackUnderline, scpoShowCaption, scpoShowDescription);
TSCPictureListerOptions = set of TSCPictureListerOption;
const
SCDefaultPictureListerOptions = [scpoAllowSelection, scpoHideSelection,
scpoHottrack, scpoShowCaption, scpoShowDescription];
type
TSCCustomPictureLister = class;
TSCPictureListerScrollbar = class(TSCControlScrollbar)
published
property Background;
property ButtonColors;
property Icons;
property SlideLine;
property Thumb;
end;
TSCPictureListerScrollbars = class(TSCControlScrollbars)
private
function GetVisible: Boolean;
procedure SetVisible(Value: Boolean);
public
procedure Assign(Source: TPersistent); override;
published
property Visible: Boolean read GetVisible write SetVisible default True;
end;
TSCPictureListerColors = class(TPersistent)
private
FOwner: TSCCustomPictureLister;
FBackground: TColor;
FCaption: TColor;
FDefault: TColor;
FDescription: TColor;
FFrame: TColor;
FHideSelection: TColor;
FHideSelectionText: TColor;
FHighlight: TColor;
FHighlightText: TColor;
FHottrack: TColor;
FHottrackText: TColor;
procedure SetBackground(Value: TColor);
procedure SetCaption(Value: TColor);
procedure SetDefault(Value: TColor);
procedure SetDescription(Value: TColor);
procedure SetFrame(Value: TColor);
procedure SetHideSelection(Value: TColor);
procedure SetHideSelectionText(Value: TColor);
procedure SetHighlight(Value: TColor);
procedure SetHighlightText(Value: TColor);
procedure SetHottrack(Value: TColor);
procedure SetHottrackText(Value: TColor);
protected
function GetOwner: TPersistent; override;
procedure DoChange;
public
constructor Create(AOwner: TSCCustomPictureLister); virtual;
procedure Assign(Source: TPersistent); override;
published
property Background: TColor read FBackground write SetBackground default clWindow;
property Caption: TColor read FCaption write SetCaption default clNone;
property Default: TColor read FDefault write SetDefault default clBtnFace;
property Description: TColor read FDescription write SetDescription default clNone;
property Frame: TColor read FFrame write SetFrame default clNone;
property HideSelection: TColor read FHideSelection write SetHideSelection default clBtnShadow;
property HideSelectionText: TColor read FHideSelectionText write SetHideSelectionText default clHighlightText;
property Highlight: TColor read FHighlight write SetHighlight default clHighlight;
property HighlightText: TColor read FHighlightText write SetHighlightText default clHighlightText;
property Hottrack: TColor read FHottrack write SetHottrack default clPurple;
property HottrackText: TColor read FHottrackText write SetHottrackText default clWhite;
end;
TSCCustomPictureLister = class(TSCCustomScrollControl)
private
FAlignment: TAlignment;
FCaptionFont: TFont;
FCaptionHeight: Integer;
FColors: TSCPictureListerColors;
FColumns: Integer;
FDescriptionHeight: Integer;
FDescriptions: Integer;
FFrame: TSCPictureListerFrame;
FFrameSize: Integer;
FOptions: TSCPictureListerOptions;
FHotIndex: Integer;
FSelectedIndex: Integer;
FPictureHeight: Integer;
FPictureWidth: Integer;
FSpaceHorz: Integer;
FSpaceVert: Integer;
FHorizontalPos: Integer;
FVerticalPos: Integer;
FShowScrollbars: Boolean;
FOnHottrack: TNotifyEvent;
FDrawing: Integer;
FCreatingWnd: Integer;
FScrollPosChanging: Integer;
FScrollbarChanging: Integer;
FMouseDownIndex: Integer;
procedure SetAlignment(Value: TAlignment);
procedure SetCaptionFont(Value: TFont);
procedure SetColors(Value: TSCPictureListerColors);
procedure SetColumns(Value: Integer);
procedure SetDescriptions(Value: Integer);
procedure SetFrame(Value: TSCPictureListerFrame);
procedure SetFrameSize(Value: Integer);
procedure SetOptions(Value: TSCPictureListerOptions);
procedure SetPictureHeight(Value: Integer);
procedure SetPictureWidth(Value: Integer);
procedure SetSpaceHorz(Value: Integer);
procedure SetSpaceVert(Value: Integer);
procedure SetSelectedIndex(Value: Integer);
procedure SetShowScrollbars(Value: Boolean);
procedure SetHorizontalPos(Value: Integer);
procedure SetVerticalPos(Value: Integer);
function GetCount: Integer;
procedure ColorsChanged(Sender: TObject);
procedure CaptionFontChanged(Sender: TObject);
procedure DoHottrack;
procedure UpdateHottrack(Draw: Boolean = True);
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
protected
procedure CreateWnd; override;
procedure Loaded; override;
procedure Paint; override;
function GetColumns: Integer;
function GetDrawRect: TRect;
function GetFrameSize: Integer;
function GetCaptionHeight: Integer;
function GetDescriptionHeight: Integer;
function GetBoxHeight: Integer;
function GetBoxWidth: Integer;
procedure SetIndent(Value: Integer); override;
procedure IndentChanged; override;
procedure SpacingChanged; override;
procedure StopTracking; override;
procedure EnabledChanged; override;
procedure MouseInControlChanged; override;
procedure DoPictureListChanged; override;
function GetPicture: TPicture; override;
procedure UpdateList;
procedure DrawBox(C: TCanvas; Index, X, Y: Integer);
procedure EnsureHorizontalPos(var P: Integer);
procedure EnsureVerticalPos(var P: Integer);
function UpdateHorzScrollBar: Boolean;
function UpdateVertScrollBar: Boolean;
procedure UpdateScrollbars(Horz, Vert: Boolean); dynamic;
procedure DoScrollerPositionChanged(Kind: TSCScrollbarKind); override;
function GetControlScrollbarsClass: TSCControlCustomScrollbarsClass; override;
function GetScrollbarClass: TSCCustomControlScrollbarClass; override;
function GetBorderPropsClass: TSCControlBorderPropsClass; override;
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 KeyDown(var Key: Word; Shift: TShiftState); override;
property HotIndex: Integer read FHotIndex;
property Alignment: TAlignment read FAlignment write SetAlignment default taCenter;
property Border default sccb3DLowered;
property CaptionFont: TFont read FCaptionFont write SetCaptionFont;
property Color default clWindow;
property Colors: TSCPictureListerColors read FColors write SetColors;
property Columns: Integer read FColumns write SetColumns default 0;
property Descriptions: Integer read FDescriptions write SetDescriptions default 1;
property Frame: TSCPictureListerFrame read FFrame write SetFrame default scpfSingle;
property FrameSize: Integer read FFrameSize write SetFrameSize default 0;
property Indent default 8;
property HorizontalPos: Integer read FHorizontalPos write SetHorizontalPos default 0;
property VerticalPos: Integer read FVerticalPos write SetVerticalPos default 0;
property Options: TSCPictureListerOptions read FOptions write SetOptions default SCDefaultPictureListerOptions;
property ParentColor default False;
property PictureHeight: Integer read FPictureHeight write SetPictureHeight default 80;
property PictureWidth: Integer read FPictureWidth write SetPictureWidth default 80;
property SelectedIndex: Integer read FSelectedIndex write SetSelectedIndex default -1;
property ShowScrollbars: Boolean read FShowScrollbars write SetShowScrollbars default True;
property SpaceHorz: Integer read FSpaceHorz write SetSpaceHorz default 0;
property SpaceVert: Integer read FSpaceVert write SetSpaceVert default 0;
property Spacing default 8;
property OnHottrack: TNotifyEvent read FOnHottrack write FOnHottrack;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetPictureRect(Index: Integer): TRect;
function GetPictureAtPos(X, Y: Integer): Integer;
procedure MakeVisible(Index: Integer);
function InView(Index: Integer; PartitialAllowed: Boolean = True): Boolean;
property Count: Integer read GetCount;
end;
TSCPictureLister = class(TSCCustomPictureLister)
public
property HotIndex;
property SelectedIndex;
published
property Align;
property Alignment;
property Anchors;
property BorderProps;
property CaptionFont;
property Color;
property Colors;
property Columns;
property Constraints;
property Descriptions;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Frame;
property FrameSize;
property Indent;
property Options;
property ParentColor;
property ParentFont;
property Picture;
property PictureList;
property PictureHeight;
property PictureWidth;
property PopupMenu;
property Scrollbars;
property SpaceHorz;
property SpaceVert;
property Spacing;
property TabOrder;
property TabStop;
property Transparent;
property Visible;
property OnCanResize;
property OnChange;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnHottrack;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
TSCImageListerFrame = (scifBumped, scifEtched, scifSingle, scifDouble,
scifLowered, scif3DLowered, scifRaised, scif3DRaised, scifRoundedDouble,
scifNone, scifMetal);
TSCImageListerOption = (scioAllowSelection, scioHideSelection, scioHottrack,
scioHottrackUnderline, scioShowNumbers);
TSCImageListerOptions = set of TSCImageListerOption;
const
SCDefaultImageListerOptions = [scioAllowSelection, scioHideSelection,
scioHottrack, scioShowNumbers];
type
TSCCustomImageLister = class;
TSCImageListerScrollbar = class(TSCControlScrollbar)
published
property Background;
property ButtonColors;
property Icons;
property SlideLine;
property Thumb;
end;
TSCImageListerScrollbars = class(TSCControlScrollbars)
private
function GetVisible: Boolean;
procedure SetVisible(Value: Boolean);
public
procedure Assign(Source: TPersistent); override;
published
property Visible: Boolean read GetVisible write SetVisible default True;
end;
TSCImageListerColors = class(TPersistent)
private
FOwner: TSCCustomImageLister;
FBackground: TColor;
FCaption: TColor;
FDefault: TColor;
FFrame: TColor;
FHideSelection: TColor;
FHideSelectionText: TColor;
FHighlight: TColor;
FHighlightText: TColor;
FHottrack: TColor;
FHottrackText: TColor;
procedure SetBackground(Value: TColor);
procedure SetCaption(Value: TColor);
procedure SetDefault(Value: TColor);
procedure SetFrame(Value: TColor);
procedure SetHideSelection(Value: TColor);
procedure SetHideSelectionText(Value: TColor);
procedure SetHighlight(Value: TColor);
procedure SetHighlightText(Value: TColor);
procedure SetHottrack(Value: TColor);
procedure SetHottrackText(Value: TColor);
protected
function GetOwner: TPersistent; override;
procedure DoChange;
public
constructor Create(AOwner: TSCCustomImageLister); virtual;
procedure Assign(Source: TPersistent); override;
published
property Background: TColor read FBackground write SetBackground default clNone;
property Caption: TColor read FCaption write SetCaption default clNone;
property Default: TColor read FDefault write SetDefault default clNone;
property Frame: TColor read FFrame write SetFrame default clNone;
property HideSelection: TColor read FHideSelection write SetHideSelection default clBtnShadow;
property HideSelectionText: TColor read FHideSelectionText write SetHideSelectionText default clHighlightText;
property Highlight: TColor read FHighlight write SetHighlight default clHighlight;
property HighlightText: TColor read FHighlightText write SetHighlightText default clHighlightText;
property Hottrack: TColor read FHottrack write SetHottrack default clPurple;
property HottrackText: TColor read FHottrackText write SetHottrackText default clWhite;
end;
TSCCustomImageLister = class(TSCCustomScrollControl)
private
FAlignment: TAlignment;
FCaptionHeight: Integer;
FColors: TSCImageListerColors;
FColumns: Integer;
FFrame: TSCImageListerFrame;
FFrameSize: Integer;
FOptions: TSCImageListerOptions;
FHotIndex: Integer;
FSelectedIndex: Integer;
FPictureHeight: Integer;
FPictureWidth: Integer;
FSpaceHorz: Integer;
FSpaceVert: Integer;
FHorizontalPos: Integer;
FVerticalPos: Integer;
FShowScrollbars: Boolean;
FOnHottrack: TNotifyEvent;
FDrawing: Integer;
FCreatingWnd: Integer;
FScrollPosChanging: Integer;
FScrollbarChanging: Integer;
FMouseDownIndex: Integer;
procedure SetAlignment(Value: TAlignment);
procedure SetColors(Value: TSCImageListerColors);
procedure SetColumns(Value: Integer);
procedure SetFrame(Value: TSCImageListerFrame);
procedure SetFrameSize(Value: Integer);
procedure SetOptions(Value: TSCImageListerOptions);
procedure SetSpaceHorz(Value: Integer);
procedure SetSpaceVert(Value: Integer);
procedure SetSelectedIndex(Value: Integer);
procedure SetShowScrollbars(Value: Boolean);
procedure SetHorizontalPos(Value: Integer);
procedure SetVerticalPos(Value: Integer);
function GetCount: Integer;
procedure ColorsChanged(Sender: TObject);
procedure DoHottrack;
procedure UpdateHottrack(Draw: Boolean = True);
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
protected
procedure CreateWnd; override;
procedure Loaded; override;
procedure Paint; override;
function GetColumns: Integer;
function GetDrawRect: TRect;
function GetFrameSize: Integer;
function GetCaptionHeight: Integer;
function GetImageHeight: Integer;
function GetImageWidth: Integer;
function GetBoxHeight: Integer;
function GetBoxWidth: Integer;
procedure SetIndent(Value: Integer); override;
procedure IndentChanged; override;
procedure SpacingChanged; override;
procedure StopTracking; override;
procedure EnabledChanged; override;
procedure MouseInControlChanged; override;
procedure ImageListChange(Sender: TObject); override;
procedure UpdateList;
procedure DrawBox(C: TCanvas; Index, X, Y: Integer);
procedure EnsureHorizontalPos(var P: Integer);
procedure EnsureVerticalPos(var P: Integer);
function UpdateHorzScrollBar: Boolean;
function UpdateVertScrollBar: Boolean;
procedure UpdateScrollbars(Horz, Vert: Boolean); dynamic;
procedure DoScrollerPositionChanged(Kind: TSCScrollbarKind); override;
function GetControlScrollbarsClass: TSCControlCustomScrollbarsClass; override;
function GetScrollbarClass: TSCCustomControlScrollbarClass; override;
function GetBorderPropsClass: TSCControlBorderPropsClass; override;
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 KeyDown(var Key: Word; Shift: TShiftState); override;
property HotIndex: Integer read FHotIndex;
property Alignment: TAlignment read FAlignment write SetAlignment default taCenter;
property Border default sccb3DLowered;
property Color default clWindow;
property Colors: TSCImageListerColors read FColors write SetColors;
property Columns: Integer read FColumns write SetColumns default 0;
property Frame: TSCImageListerFrame read FFrame write SetFrame default scifNone;
property FrameSize: Integer read FFrameSize write SetFrameSize default 0;
property Indent default 8;
property HorizontalPos: Integer read FHorizontalPos write SetHorizontalPos default 0;
property VerticalPos: Integer read FVerticalPos write SetVerticalPos default 0;
property Options: TSCImageListerOptions read FOptions write SetOptions default SCDefaultImageListerOptions;
property ParentColor default False;
property SelectedIndex: Integer read FSelectedIndex write SetSelectedIndex default -1;
property ShowScrollbars: Boolean read FShowScrollbars write SetShowScrollbars default True;
property SpaceHorz: Integer read FSpaceHorz write SetSpaceHorz default 0;
property SpaceVert: Integer read FSpaceVert write SetSpaceVert default 0;
property Spacing default 8;
property OnHottrack: TNotifyEvent read FOnHottrack write FOnHottrack;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetPictureRect(Index: Integer): TRect;
function GetPictureAtPos(X, Y: Integer): Integer;
procedure MakeVisible(Index: Integer);
function InView(Index: Integer; PartitialAllowed: Boolean = True): Boolean;
property Count: Integer read GetCount;
end;
TSCImageLister = class(TSCCustomImageLister)
public
property HotIndex;
property SelectedIndex;
published
property Align;
property Alignment;
property Anchors;
property BorderProps;
property Color;
property Colors;
property Columns;
property Constraints;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Frame;
property FrameSize;
property Images;
property Indent;
property Options;
property ParentColor;
property ParentFont;
property Picture;
property PictureProps;
property PopupMenu;
property Scrollbars;
property SpaceHorz;
property SpaceVert;
property Spacing;
property TabOrder;
property TabStop;
property Transparent;
property Visible;
property OnCanResize;
property OnChange;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnHottrack;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
implementation
{ TSCCustomImageBox }
procedure TSCCustomImageBox.AdjustBounds;
begin
AdjustSize;
end;
function TSCCustomImageBox.CanAutoSize(var NewWidth, NewHeight: Integer): Boolean;
var
P: TPicture;
begin
Result := True;
P := Picture;
if (P.Width > 0) and (P.Height > 0) then
begin
if Align in [alNone, alLeft, alRight] then
NewWidth := P.Width;
if Align in [alNone, alTop, alBottom] then
NewHeight := P.Height;
end;
end;
constructor TSCCustomImageBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csSetCaption, csOpaque, csDoubleClicks];
ParentColor := False;
Color := clWindow;
Border := sccb3DLowered;
SetBounds(Left, Top, 140, 100);
FQuickDraw := False;
FShowScrollbars := True;
FHorizontalPos := 0;
FVerticalPos := 0;
FZoomRatio := 100;
FZoomMode := sczmNone;
end;
procedure TSCCustomImageBox.DoDrawPicture(G: TGraphic);
var
DrawPict: TPicture;
begin
if CanDrawGraphic(G) then
begin
Inc(FDrawing);
try
DrawPict := TPicture.Create;
try
DrawPict.Assign(G);
PaintPicture(DrawPict);
finally
DrawPict.Free;
end;
finally
Dec(FDrawing);
end;
end;
end;
procedure TSCCustomImageBox.EnsureHorizontalPos(var P: Integer);
var
Mx: Integer;
CR, R: TRect;
begin
if (P < 0) or IsDesigning or not ((FZoomMode = sczmZoom) or
((FZoomMode = sczmNone) and not (AutoSize or Center))) then
P := 0
else begin
R := GetPictureRect(Picture);
OffsetRect(R, -R.Left, -R.Top);
if IsRectEmpty(R) then
begin
P := 0;
Exit;
end;
CR := GetClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
if IsRectEmpty(CR) then
begin
P := 0;
Exit;
end;
Mx := R.Right - CR.Right;
if (Mx > 0) and (P > Mx) then
P := Mx;
end;
end;
procedure TSCCustomImageBox.EnsureVerticalPos(var P: Integer);
var
Mx: Integer;
CR, R: TRect;
begin
if (P < 0) or IsDesigning or not ((FZoomMode = sczmZoom) or
((FZoomMode = sczmNone) and not (AutoSize or Center))) then
P := 0
else begin
R := GetPictureRect(Picture);
OffsetRect(R, -R.Left, -R.Top);
if IsRectEmpty(R) then
begin
P := 0;
Exit;
end;
CR := GetClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
if IsRectEmpty(CR) then
begin
P := 0;
Exit;
end;
Mx := R.Bottom - CR.Bottom;
if (Mx > 0) and (P > Mx) then
P := Mx;
end;
end;
function TSCCustomImageBox.GetBorderPropsClass: TSCControlBorderPropsClass;
begin
Result := TSCImageBorderProps;
end;
function TSCCustomImageBox.GetPictureRect(P: TPicture): TRect;
var
R: TRect;
L, T: Integer;
Ratio, Hr: Double;
begin
Result := Rect(0, 0, 0, 0);
if ShowPicture then
begin
R := GetClientRect;
OffsetRect(R, -R.Left, -R.Top);
if not IsRectEmpty(R) then
begin
if (P <> nil) and (P.Graphic <> nil) and
not P.Graphic.Empty and (P.Height > 0) and (P.Width > 0) then
begin
Result := Rect(0, 0, P.Width, P.Height);
case FZoomMode of
sczmStretch:
begin
Result := R;
end;
sczmStretchKeepingRatio:
begin
Ratio := R.Right / P.Width;
Hr := R.Bottom / P.Height;
if Hr < Ratio then Ratio := Hr;
Result := Rect(0, 0, Round(Ratio * P.Width), Round(Ratio * P.Height));
end;
sczmZoom:
begin
Ratio := FZoomRatio / 100;
Result := Rect(0, 0, Round(Ratio * P.Width), Round(Ratio * P.Height));
end;
sczmNone:
begin
if FCenter and not AutoSize then
begin
L := (R.Right - P.Width) div 2;
T := (R.Bottom - P.Height) div 2;
Result := Rect(L, T, L + P.Width, T + P.Height);
end;
end;
end;
end;
end;
end;
end;
function TSCCustomImageBox.HasGraphic(G: TGraphic): Boolean;
begin
Result := (G <> nil) and not G.Empty and (G.Height > 0) and (G.Width > 0);
end;
procedure TSCCustomImageBox.Paint;
var
CR: TRect;
Cl: TColor;
Text: String;
begin
if not HandleAllocated then
Exit;
Inc(FDrawing);
try
CR := ClientRect;
OffsetRect(CR, -CR.Left, -CR.Top);
if IsRectEmpty(CR) then
Exit;
Cl := Self.Color;
if Cl = clNone then Cl := clWindow;
with Canvas do
begin
Brush.Color := Cl;
FillRect(CR);
if Transparent then
PaintParentOn(Canvas);
end;
DoDrawPicture(GetGraphic);
if CanDrawCaption then
begin
Text := GetPictureCaption;
with Canvas do
begin
Font := Self.Font;
Brush.Style := bsClear;
DrawText(Handle, PChar(Text), Length(Text), CR,
DT_SINGLELINE or DT_NOPREFIX or DT_CENTER or DT_VCENTER);
end;
end;
if not IsDesigning and not FHideFocusRect and Focused then
begin