forked from dim-s/soulengine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dsStdCtrl.pas
1079 lines (908 loc) · 25.4 KB
/
dsStdCtrl.pas
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
unit dsStdCtrl;
{$I 'sDef.inc'}
interface
uses Forms, Dialogs, SysUtils, Windows, Types, UITypes, TypInfo, Classes, Controls, Buttons,
Messages, StdCtrls, Graphics, ExtCtrls, ShellAPI, ComCtrls,
DragDrop, DropTarget, DragDropFile;
{$M+}
{$TypeInfo On}
type
TComponentLabel = class(TCustomControl)
private
FCaption: string;
FPanel: TCustomControl;
procedure SetCaption(const Value: string);
protected
procedure Paint; override;
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Caption: string read FCaption write SetCaption;
end;
type
__TNoVisual = class(TCustomControl)
private
FGlyph: TBitmap;
FLabel: TComponentLabel;
FfileName: string;
FrealHeight: integer;
FrealWidth: integer;
FCaption: string;
FTop, FLeft: integer;
fc: TNOTifyEvent;
FLabelDblClick: TNotifyEvent;
fa: TComponent;
// FLabelClick: TNotifyEvent;
procedure SetfileName(const Value: string);
procedure SetrealHeight(const Value: integer);
procedure SetrealWidth(const Value: integer);
procedure FSetLEft(const Value: integer);
procedure FSetFTop(const Value: integer);
procedure SetCaption(const Value: string);
protected
procedure SetName(const Value: TComponentName); override;
procedure Paint; override;
procedure initLabel;
procedure WMMove(var Msg: TWMMove); message WM_MOVE;
{ ïðîöåäóðà äëÿ îáðàáîòêè ñîîáùåíèÿ Wm_move, ÷òîáû ìåòêà ïåðåìåùàëàñü âìåñòå ñ êíîïêîé }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure loadFromFile(fileName: string);
published
property Assoc: TComponent read fa write fa;
property __iconName: string read FfileName write SetfileName;
property realWidth: integer read FrealWidth write SetrealWidth default 24;
property realHeight: integer read FrealHeight write SetrealHeight
default 24;
property Left: integer read FLeft write FSetlEft;
property Top: integer read fTop write FSetFtop;
property onMove:TNOTifyEvent read fc write fc;
property Caption: string read FCaption write SetCaption;
property OnDblClick: TNotifyEvent read FLabelDblClick write FLabelDblClick;
property Font;
property Cursor;
property Visible;
end;
type
TDropFilesEvent = procedure(Sender: TObject; Files: TUnicodeStrings; X: integer;
Y: integer) of object;
TDropFilesTarget = class(TDropFileTarget)
private
FOnDropFiles: TDropFilesEvent; // Notification handler
published
procedure hOnDrop(Sender: TObject; ShiftState: TShiftState;
APoint: TPoint; var Effect: Longint);
procedure setOnDropFiles(AEvent: TDropFilesEvent);
constructor Create(AOwner: TComponent); override;
property OnDropFiles: TDropFilesEvent read FOnDropFiles write SetOnDropFiles;
end;
type
TWMScrollEvent = procedure(Sender: TObject; ScrollCode: integer; var ScrollPos: integer) of object;
TScrollBox=Class(Forms.TScrollBox)
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
private
FOnScrollVert: TWMScrollEvent;
FOnScrollHorz: TWMScrollEvent;
published
Property OnScrollVert:TWMScrollEvent read FOnScrollVert Write FonScrollVert;
Property OnScrollHorz:TWMScrollEvent read FOnScrollHorz Write FonScrollHorz;
End;
type
TEdit = class(StdCtrls.TEdit)
private
FInitDraw: boolean;
FOldBackColor: TColor;
FOldFontColor: TColor;
FColorOnEnter: TColor;
FFontColorOnEnter: TColor;
FAlignment: TAlignment;
FTabOnEnter: boolean;
FTextHint: string;
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
FMarginLeft: integer;
FMarginRight: integer;
procedure SetAlignment(Value: TAlignment);
procedure SetMarginLeft(const Value: integer);
procedure SetMarginRight(const Value: integer);
protected
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure UpdateMargins;
public
constructor Create(AOwner: TComponent); override;
published
property TextHint: string read FTextHint write FTextHint;
property Alignment: TAlignment read FAlignment write SetAlignment;
property ColorOnEnter: TColor read FColorOnEnter write FColorOnEnter;
property FontColorOnEnter: TColor read FFontColorOnEnter
write FFontColorOnEnter;
property TabOnEnter: boolean read FTabOnEnter write FTabOnEnter;
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
property MarginLeft: integer read FMarginLeft write SetMarginLeft;
property MarginRight: integer read FMarginRight write SetMarginRight;
end;
type
TCVisibleEvent = procedure (Sender: TObject; var Value: Boolean) of object;
TDockVisibleEvent = procedure (Sender: TObject; Control: TObject; Value: Boolean) of object;
TDSPanel = class(TPanel)
private
FOnViSet: TCVisibleEvent;
FOnShow: TNotifyEvent;
FOnHide: TNotifyEvent;
FDKViSet: TDockVisibleEvent;
procedure CMVisibleChanged(var Message: TMessage); message CM_VISIBLECHANGED;
public
property DockManager;
published
property OnVisibilityChanged: TCVisibleEvent read FOnViSet write FOnViSet;
property OnDockedVisibilityChanged: TDockVisibleEvent read FDKViSet write FDKViSet;
property OnShow: TNotifyEvent read fOnShow write fOnShow;
property OnHide: TNotifyEvent read fOnHide write fOnHide;
end;
type
TMemo = class(StdCtrls.TMemo)
private
FAlignment: TAlignment;
FTabOnEnter: boolean;
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
procedure SetAlignment(Value: TAlignment);
protected
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
published
property Alignment: TAlignment read FAlignment write SetAlignment;
property TabOnEnter: boolean read FTabOnEnter write FTabOnEnter;
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
end;
type
TBitBtn = class(Buttons.TBitBtn)
private
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
protected
procedure DoEnter; override;
procedure DoExit; override;
published
constructor Create(AOwner: TComponent); override;
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
end;
type
TListBox = class(StdCtrls.TListBox)
private
FAlignment: TAlignment;
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
FTwoColor: TColor;
FTwoFontColor: TColor;
FMarginLeft: integer;
FBorderSelected: boolean;
FReadOnly: boolean;
FFonts: TList;
FColors: TList;
procedure SetTwoColor(const Value: TColor);
procedure SetTwoFontColor(const Value: TColor);
procedure SetMarginLeft(const Value: integer);
procedure SetBorderSelected(const Value: boolean);
procedure SetAlignment(const Value: TAlignment);
procedure SetReadOnly(const Value: boolean);
protected
procedure DoEnter; override;
procedure DoExit; override;
procedure DrawItem(Index: integer; Rect: TRect;
State: TOwnerDrawState); override;
published
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetColor(Index: integer; Color: TColor);
function GetColor(Index: integer): TColor;
procedure ClearColor(Index: integer);
function GetFont(Index: integer): TFont;
procedure ClearFont(Index: integer);
property Alignment: TAlignment read FAlignment write SetAlignment;
property BorderSelected: boolean read FBorderSelected
write SetBorderSelected;
property TwoColor: TColor read FTwoColor write SetTwoColor;
property TwoFontColor: TColor read FTwoFontColor write SetTwoFontColor;
property MarginLeft: integer read FMarginLeft write SetMarginLeft;
property ReadOnly: boolean read FReadOnly write SetReadOnly;
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
end;
type
TCheckBox = class(StdCtrls.TCheckBox)
private
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
protected
procedure DoEnter; override;
procedure DoExit; override;
public
constructor Create(AOwner: TComponent); override;
published
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
end;
type
TComboBox = class(StdCtrls.TComboBox)
private
FOnFocus: TNotifyEvent;
FOnBlur: TNotifyEvent;
protected
procedure DoEnter; override;
procedure DoExit; override;
public
constructor Create(AOwner: TComponent); override;
published
property OnFocus: TNotifyEvent read FOnFocus write FOnFocus;
property OnBlur: TNotifyEvent read FOnBlur write FOnBlur;
end;
implementation
{ TEdit }
constructor TEdit.Create(AOwner: TComponent);
begin
inherited;
FColorOnEnter := clNone;
FFontColorOnEnter := clNone;
FTextHint := '';
Alignment := taLeftJustify;
if (TextHint <> '') and (Text = '') then
Text := TextHint;
FInitDraw := False;
end; (* Create *)
procedure TEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array [TAlignment] of longword = (ES_Left, ES_Right, ES_Center);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or Alignments[FAlignment];
if (TextHint <> '') and (Text = '') then
Text := TextHint;
end;
procedure TEdit.DoEnter;
begin
FOldBackColor := Color;
FOldFontColor := Font.Color;
if FColorOnEnter <> clNone then
Color := FColorOnEnter;
if FFontColorOnEnter <> clNone then
Font.Color := FFontColorOnEnter;
if (TextHint <> '') and (TextHint = Text) then
Text := '';
if Assigned(FOnFocus) then
FOnFocus(Self);
UpdateMargins;
inherited;
end; (* DoEnter *)
procedure TEdit.DoExit;
begin
Color := FOldBackColor;
Font.Color := FOldFontColor;
if (TextHint <> '') and (Text = '') then
Text := TextHint;
if Assigned(FOnBlur) then
FOnBlur(Self);
UpdateMargins;
inherited;
end; (* DoExit *)
procedure TEdit.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
UpdateMargins;
end;
end;
procedure TEdit.SetMarginLeft(const Value: integer);
begin
FMarginLeft := Value;
UpdateMargins;
end;
procedure TEdit.SetMarginRight(const Value: integer);
begin
FMarginRight := Value;
UpdateMargins;
end;
procedure TEdit.UpdateMargins;
begin
SendMessage(Handle, EM_SETMARGINS, EC_LEFTMARGIN, LPARAM(FMarginLeft));
SendMessage(Handle, EM_SETMARGINS, EC_RIGHTMARGIN, FMarginRight shl 16);
end;
procedure TEdit.WMPaint(var Message: TWMPaint);
begin
inherited;
if (TextHint <> '') and (Text = '') then
Text := TextHint;
if not FInitDraw then
begin
FInitDraw := True;
UpdateMargins;
end;
end;
procedure TEdit.KeyPress(var Key: char);
begin
inherited KeyPress(Key);
// UpdateMargins;
if FTabOnEnter and (Owner is TWinControl) then
begin
if Key = Char(VK_RETURN) then
begin
if HiWord(GetKeyState(VK_SHIFT)) <> 0 then
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 1, 0)
else
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 0, 0);
Key := #0;
end;
end;
end; (* KeyPress *)
{ TScrollBoxEx }
procedure TScrollBox.WMHScroll(var Message: TWMHScroll);
var x_pos: integer;
begin
inherited;
if Assigned(FOnScrollHorz) then
begin
x_pos := Self.HorzScrollBar.Position;
FOnScrollHorz(Self, integer(Message.ScrollCode), x_pos);
Self.HorzScrollBar.Position := x_pos;
end;
end;
procedure TScrollBox.WMVScroll(var Message: TWMVScroll);
var y_pos: integer;
begin
inherited;
if Assigned(FOnScrollVert) then begin
y_pos := Self.VertScrollBar.Position;
FOnScrollVert(Self, integer(Message.ScrollCode), y_pos);
Self.VertScrollBar.Position := SmallInt( y_pos );
end;
end;
{ TMemo }
constructor TMemo.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TMemo.CreateParams(var Params: TCreateParams);
const
Alignments: array [TAlignment] of longword = (ES_Left, ES_Right, ES_Center);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or Alignments[FAlignment];
end;
procedure TMemo.DoEnter;
begin
if Assigned(FOnFocus) then
FOnFocus(Self);
inherited;
end;
procedure TMemo.DoExit;
begin
if Assigned(FOnBlur) then
FOnBlur(Self);
inherited;
end;
procedure TMemo.KeyPress(var Key: char);
begin
inherited KeyPress(Key);
if FTabOnEnter and (Owner is TWinControl) then
begin
if Key = Char(VK_RETURN) then
begin
if HiWord(GetKeyState(VK_SHIFT)) <> 0 then
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 1, 0)
else
PostMessage((Owner as TWinControl).Handle, WM_NEXTDLGCTL, 0, 0);
Key := #0;
end;
end;
end;
procedure TMemo.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
{ TBitBtn }
constructor TBitBtn.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TBitBtn.DoEnter;
begin
if Assigned(FOnFocus) then
FOnFocus(Self);
inherited;
end;
procedure TBitBtn.DoExit;
begin
if Assigned(FOnBlur) then
FOnBlur(Self);
inherited;
end;
{ TListBox }
constructor TListBox.Create(AOwner: TComponent);
begin
inherited;
FTwoColor := clNone;
FTwoFontColor := clNone;
FMarginLeft := 2;
FFonts := TList.Create;
FColors := TList.Create;
Style := lbOwnerDrawFixed;
BorderSelected := True;
FReadOnly := False;
end;
destructor TListBox.Destroy;
var
i: integer;
begin
for i := 0 to FFonts.Count - 1 do
if FFonts[i] <> nil then
TFont(FFonts[i]).Free;
FFonts.Free;
FColors.Free;
inherited;
end;
procedure TListBox.DoEnter;
begin
if Assigned(FOnFocus) then
FOnFocus(Self);
inherited;
end;
procedure TListBox.DoExit;
begin
if Assigned(FOnBlur) then
FOnBlur(Self);
inherited;
end;
procedure TListBox.DrawItem(Index: integer; Rect: TRect;
State: TOwnerDrawState);
var
MyColor, MyFontColor: TColor;
H: integer;
ItemHeight: integer;
begin
if (not BorderSelected) and (odFocused in State) then
begin
DrawFocusRect(Canvas.Handle, Rect);
exit;
end;
if FReadOnly then
begin
MyColor := Color;
MyFontColor := Font.Color;
end
else
begin
MyColor := Canvas.Brush.Color;
MyFontColor := Canvas.Font.Color;
end;
if not(odSelected in State) or FReadOnly then
begin
if (Index + 1) mod 2 = 0 then
begin
if (FTwoColor <> clNone) then
MyColor := TwoColor;
if (FTwoFontColor <> clNone) then
MyFontColor := TwoFontColor;
end;
if (FColors.Count > Index) and (TColor(FColors[Index]) <> clNone) then
begin
MyColor := TColor(FColors[Index]);
end;
end;
Canvas.Pen.Style := psClear;
Canvas.Brush.Color := MyColor;
Canvas.FillRect(Rect);
if (FFonts.Count > Index) and (FFonts[Index] <> nil) then
begin
MyFontColor := Canvas.Font.Color;
Canvas.Font.Assign(TFont(FFonts[Index]));
if (odSelected in State) and not FReadOnly then
Canvas.Font.Color := MyFontColor;
end
else
Canvas.Font.Color := MyFontColor;
if Self.ItemHeight > 0 then
ItemHeight := Self.ItemHeight
else
ItemHeight := Canvas.TextHeight(Items[Index]);
H := Rect.Top + ItemHeight div 2 - Canvas.TextHeight(Items[Index]) div 2;
case FAlignment of
taLeftJustify:
Canvas.TextOut(Rect.Left + MarginLeft, H, Items[Index]);
taRightJustify:
Canvas.TextOut(Rect.Right - MarginLeft - Canvas.TextWidth(Items[Index]),
H, Items[Index]);
taCenter:
Canvas.TextOut(Rect.Left + ((Rect.Right - Rect.Left) div 2) -
(Canvas.TextWidth(Items[Index]) div 2), H, Items[Index]);
end;
end;
procedure TListBox.ClearColor(Index: integer);
begin
if (FColors.Count > Index) and (Index > -1) then
FColors[Index] := Pointer(clNone);
end;
procedure TListBox.ClearFont(Index: integer);
begin
if (Index > Items.Count - 1) or (Index < 0) or (Index > FFonts.Count - 1) then
exit;
if (FFonts[Index] <> nil) then
TFont(FFonts[Index]).Free;
FFonts[Index] := nil;
Invalidate;
end;
function TListBox.GetColor(Index: integer): TColor;
begin
if (FColors.Count > Index) and (Index > -1) then
Result := TColor(FColors[Index])
else
Result := clNone;
end;
function TListBox.GetFont(Index: integer): TFont;
var
Font: TFont;
i: integer;
begin
if Items.Count < FFonts.Count then
begin
for i := FFonts.Count - 1 downto Items.Count do
begin
if FFonts[i] <> nil then
TFont(FFonts[i]).Free;
FFonts.Delete(i);
end;
end;
if (Index > Items.Count - 1) or (Index < 0) then
begin
Result := nil;
exit;
end;
if Index > FFonts.Count - 1 then
begin
Font := TFont.Create;
Font.Assign(Self.Font);
for i := FFonts.Count to Index - 1 do
begin
FFonts.Add(nil);
end;
FFonts.Add(Font);
Result := Font;
exit;
end;
if FFonts[Index] = nil then
begin
Font := TFont.Create;
Font.Assign(Self.Font);
FFonts[Index] := Font;
Result := Font;
end
else
Result := FFonts[Index];
end;
procedure TListBox.SetMarginLeft(const Value: integer);
begin
FMarginLeft := Value;
Invalidate;
end;
procedure TListBox.SetReadOnly(const Value: boolean);
begin
FReadOnly := Value;
ItemIndex := -1;
end;
procedure TListBox.SetAlignment(const Value: TAlignment);
begin
FAlignment := Value;
Invalidate;
end;
procedure TListBox.SetBorderSelected(const Value: boolean);
begin
FBorderSelected := Value;
Invalidate;
end;
procedure TListBox.SetColor(Index: integer; Color: TColor);
var
i: integer;
begin
if (Index < 0) or (Index > Items.Count - 1) then
exit;
for i := FColors.Count to Items.Count - 1 do
FColors.Add(Pointer(clNone));
FColors[Index] := Pointer(Color);
Invalidate;
end;
procedure TListBox.SetTwoColor(const Value: TColor);
begin
FTwoColor := Value;
Invalidate;
end;
procedure TListBox.SetTwoFontColor(const Value: TColor);
begin
FTwoFontColor := Value;
Invalidate;
end;
{ TCheckBox }
constructor TCheckBox.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TCheckBox.DoEnter;
begin
if Assigned(FOnFocus) then
FOnFocus(Self);
inherited;
end;
procedure TCheckBox.DoExit;
begin
if Assigned(FOnBlur) then
FOnBlur(Self);
inherited;
end;
{ TComboBox }
constructor TComboBox.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TComboBox.DoEnter;
begin
if Assigned(FOnFocus) then
FOnFocus(Self);
inherited;
end;
procedure TComboBox.DoExit;
begin
if Assigned(FOnBlur) then
FOnBlur(Self);
inherited;
end;
{ TDSPanel }
procedure TDSPanel.CMVisibleChanged(var Message: TMessage);
var Value: Boolean;
begin
Value := Boolean(Message.WParam);
if Value then
begin
if Assigned(fOnShow) then
fOnShow((Self as TObject));
end
else
begin
if Assigned(fOnHide) then
fOnHide((Self as TObject));
end;
if Assigned(FDKViSet) then begin
FDKViSet((Self as TObject), (Self.HostDockSite as TObject), Value);
end;
if Assigned(FOnViSet) then begin
FOnViSet((Self as TObject), Value);
if Boolean(Message.WParam) <> Value then
Exit;
end;
inherited;
end;
{ TDropFilesInfo }
{
constructor TDropFilesInfo.Create;
begin
inherited;
FFiles := TStringList.Create;
end;
destructor TDropFilesInfo.Destroy;
begin
FreeAndNil(FFiles);
inherited;
end;
procedure TDropFilesInfo.Assign(Source: TPersistent);
begin
if Source is TDropFilesInfo then
begin
FControl := TDropFilesInfo(Source).Control;
FStamp := TDropFilesInfo(Source).Stamp;
FPoint := TDropFilesInfo(Source).Point;
FFiles.Assign(TDropFilesInfo(Source).Files);
end
else
inherited Assign(Source);
end;
{ TDropFilesTarget }
constructor TDropFilesTarget.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Self.OnDrop := Self.hOnDrop;
Self.DragTypes := [dtMove, dtCopy];
Self.Target := TWinControl( AOwner );
end;
procedure TDropFilesTarget.setOnDropFiles(AEvent: TDropFilesEvent);
begin
FOnDropFiles := AEvent;
end;
procedure TDropFilesTarget.hOnDrop(Sender: TObject; ShiftState: TShiftState;
APoint: TPoint; var Effect: Longint);
Begin
if Assigned(FOnDropFiles) then
begin
FOnDropFiles(Sender, Files, APoint.X, APoint.Y);
end;
End;
{ TComponentLabel }
constructor TComponentLabel.Create(AOwner: TComponent);
begin
inherited;
Width := 1;
Height := 1;
end;
procedure TComponentLabel.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_NOPARENTNOTIFY;
end;
destructor TComponentLabel.Destroy;
begin
inherited;
end;
procedure TComponentLabel.Paint;
begin
// inherited;
Visible := FPanel.Visible;
if not Visible then
exit;
Width := Canvas.TextWidth(Caption) + 2;
Height := Canvas.TextHeight(Caption) + 2;
Canvas.Pen.Style := psClear;
Canvas.Pen.Width := 0;
Canvas.Brush.Color := Color;
Canvas.Rectangle(0, 0, Width, Height);
Canvas.TextOut(1, 1, Caption);
end;
procedure TComponentLabel.SetCaption(const Value: string);
begin
FCaption := Value;
end;
{ __TNoVisual }
constructor __TNoVisual.Create(AOwner: TComponent);
begin
inherited;
FGlyph := TBitmap.Create;
FLabel := TComponentLabel.Create(Self);
FGlyph.Transparent := True;
FGlyph.TransparentMode := tmAuto;
realWidth := 24;
realHeight := 24;
Color := clWindow;
Parent := TWinControl(AOwner);
end;
destructor __TNoVisual.Destroy;
begin
// FLabel.Free;
FGlyph.Free;
inherited;
end;
procedure __TNoVisual.initLabel;
begin
if Parent = nil then
exit;
FLabel.Parent := Self.Parent;
FLabel.Font.Assign(Self.Font);
FLabel.Color := Color;
FLabel.Caption := Name;
FLabel.FPanel := Self;
FLabel.BringToFront;
FLabel.Left := Round(Left + (realWidth / 2) - (FLabel.Canvas.TextWidth(Name)
/ 2) - 1);
FLabel.Top := Top + Height + 3;
FLabel.OnDblClick := OnDblClick;
FLabel.OnClick := OnClick;
end;
procedure __TNoVisual.loadFromFile(fileName: string);
begin
FfileName := fileName;
FGlyph.loadFromFile(fileName);
end;
procedure __TNoVisual.Paint;
var stext: string;
begin
// if not Visible then exit;
inherited;
if Parent = nil then
exit;
Canvas.Pen.Style := psAlternate;
Canvas.Pen.Width := 1;
Canvas.Brush.Color := Color;
Canvas.Rectangle(0, 0, Width, Height);
if FLabel <> nil then
begin
if Assoc <> nil then
stext := Assoc.Name
else
stext := Name;
FLabel.Caption := stext;
FLabel.Left := Round(Left + (realWidth / 2) -
(Canvas.TextWidth(stext) / 2) - 1);