-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controls.pas
10968 lines (10043 loc) · 314 KB
/
Controls.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
{*******************************************************}
{ }
{ Borland Delphi Visual Component Library }
{ }
{ Copyright (c) 1995-2002 Borland Software Corporation }
{ }
{*******************************************************}
unit Controls;
{$P+,S-,W-,R-,T-,H+,X+}
{ WARN SYMBOL_PLATFORM OFF}
{$C PRELOAD}
interface
{$R Controls.res}
{ CommCtrl.hpp is not required in Controls.hpp }
(*$NOINCLUDE CommCtrl *)
uses
{$IFDEF LINUX}
Messages, WinUtils, Windows, Classes, Sysutils,
Graphics, MultiMon, Menus, CommCtrl, Imm, ImgList, ActnList;
{$ENDIF}
{$IFDEF MSWINDOWS}
Messages, Windows, MultiMon, Classes, SysUtils, Graphics, Menus, CommCtrl,
Imm, ImgList, ActnList;
{$ENDIF}
{ VCL control message IDs }
const
CM_BASE = $B000;
CM_ACTIVATE = CM_BASE + 0;
CM_DEACTIVATE = CM_BASE + 1;
CM_GOTFOCUS = CM_BASE + 2;
CM_LOSTFOCUS = CM_BASE + 3;
CM_CANCELMODE = CM_BASE + 4;
CM_DIALOGKEY = CM_BASE + 5;
CM_DIALOGCHAR = CM_BASE + 6;
CM_FOCUSCHANGED = CM_BASE + 7;
CM_PARENTFONTCHANGED = CM_BASE + 8;
CM_PARENTCOLORCHANGED = CM_BASE + 9;
CM_HITTEST = CM_BASE + 10;
CM_VISIBLECHANGED = CM_BASE + 11;
CM_ENABLEDCHANGED = CM_BASE + 12;
CM_COLORCHANGED = CM_BASE + 13;
CM_FONTCHANGED = CM_BASE + 14;
CM_CURSORCHANGED = CM_BASE + 15;
CM_CTL3DCHANGED = CM_BASE + 16;
CM_PARENTCTL3DCHANGED = CM_BASE + 17;
CM_TEXTCHANGED = CM_BASE + 18;
CM_MOUSEENTER = CM_BASE + 19;
CM_MOUSELEAVE = CM_BASE + 20;
CM_MENUCHANGED = CM_BASE + 21;
CM_APPKEYDOWN = CM_BASE + 22;
CM_APPSYSCOMMAND = CM_BASE + 23;
CM_BUTTONPRESSED = CM_BASE + 24;
CM_SHOWINGCHANGED = CM_BASE + 25;
CM_ENTER = CM_BASE + 26;
CM_EXIT = CM_BASE + 27;
CM_DESIGNHITTEST = CM_BASE + 28;
CM_ICONCHANGED = CM_BASE + 29;
CM_WANTSPECIALKEY = CM_BASE + 30;
CM_INVOKEHELP = CM_BASE + 31;
CM_WINDOWHOOK = CM_BASE + 32;
CM_RELEASE = CM_BASE + 33;
CM_SHOWHINTCHANGED = CM_BASE + 34;
CM_PARENTSHOWHINTCHANGED = CM_BASE + 35;
CM_SYSCOLORCHANGE = CM_BASE + 36;
CM_WININICHANGE = CM_BASE + 37;
CM_FONTCHANGE = CM_BASE + 38;
CM_TIMECHANGE = CM_BASE + 39;
CM_TABSTOPCHANGED = CM_BASE + 40;
CM_UIACTIVATE = CM_BASE + 41;
CM_UIDEACTIVATE = CM_BASE + 42;
CM_DOCWINDOWACTIVATE = CM_BASE + 43;
CM_CONTROLLISTCHANGE = CM_BASE + 44;
CM_GETDATALINK = CM_BASE + 45;
CM_CHILDKEY = CM_BASE + 46;
CM_DRAG = CM_BASE + 47;
CM_HINTSHOW = CM_BASE + 48;
CM_DIALOGHANDLE = CM_BASE + 49;
CM_ISTOOLCONTROL = CM_BASE + 50;
CM_RECREATEWND = CM_BASE + 51;
CM_INVALIDATE = CM_BASE + 52;
CM_SYSFONTCHANGED = CM_BASE + 53;
CM_CONTROLCHANGE = CM_BASE + 54;
CM_CHANGED = CM_BASE + 55;
CM_DOCKCLIENT = CM_BASE + 56;
CM_UNDOCKCLIENT = CM_BASE + 57;
CM_FLOAT = CM_BASE + 58;
CM_BORDERCHANGED = CM_BASE + 59;
CM_BIDIMODECHANGED = CM_BASE + 60;
CM_PARENTBIDIMODECHANGED = CM_BASE + 61;
CM_ALLCHILDRENFLIPPED = CM_BASE + 62;
CM_ACTIONUPDATE = CM_BASE + 63;
CM_ACTIONEXECUTE = CM_BASE + 64;
CM_HINTSHOWPAUSE = CM_BASE + 65;
CM_DOCKNOTIFICATION = CM_BASE + 66;
CM_MOUSEWHEEL = CM_BASE + 67;
CM_ISSHORTCUT = CM_BASE + 68;
{$IFDEF LINUX}
CM_RAWX11EVENT = CM_BASE + 69;
{$ENDIF}
{ VCL control notification IDs }
const
CN_BASE = $BC00;
CN_CHARTOITEM = CN_BASE + WM_CHARTOITEM;
CN_COMMAND = CN_BASE + WM_COMMAND;
CN_COMPAREITEM = CN_BASE + WM_COMPAREITEM;
CN_CTLCOLORBTN = CN_BASE + WM_CTLCOLORBTN;
CN_CTLCOLORDLG = CN_BASE + WM_CTLCOLORDLG;
CN_CTLCOLOREDIT = CN_BASE + WM_CTLCOLOREDIT;
CN_CTLCOLORLISTBOX = CN_BASE + WM_CTLCOLORLISTBOX;
CN_CTLCOLORMSGBOX = CN_BASE + WM_CTLCOLORMSGBOX;
CN_CTLCOLORSCROLLBAR = CN_BASE + WM_CTLCOLORSCROLLBAR;
CN_CTLCOLORSTATIC = CN_BASE + WM_CTLCOLORSTATIC;
CN_DELETEITEM = CN_BASE + WM_DELETEITEM;
CN_DRAWITEM = CN_BASE + WM_DRAWITEM;
CN_HSCROLL = CN_BASE + WM_HSCROLL;
CN_MEASUREITEM = CN_BASE + WM_MEASUREITEM;
CN_PARENTNOTIFY = CN_BASE + WM_PARENTNOTIFY;
CN_VKEYTOITEM = CN_BASE + WM_VKEYTOITEM;
CN_VSCROLL = CN_BASE + WM_VSCROLL;
CN_KEYDOWN = CN_BASE + WM_KEYDOWN;
CN_KEYUP = CN_BASE + WM_KEYUP;
CN_CHAR = CN_BASE + WM_CHAR;
CN_SYSKEYDOWN = CN_BASE + WM_SYSKEYDOWN;
CN_SYSCHAR = CN_BASE + WM_SYSCHAR;
CN_NOTIFY = CN_BASE + WM_NOTIFY;
{ TModalResult values }
const
mrNone = 0;
mrOk = idOk;
mrCancel = idCancel;
mrAbort = idAbort;
mrRetry = idRetry;
mrIgnore = idIgnore;
mrYes = idYes;
mrNo = idNo;
mrAll = mrNo + 1;
mrNoToAll = mrAll + 1;
mrYesToAll = mrNoToAll + 1;
type
TModalResult = Low(Integer)..High(Integer);
function IsPositiveResult(const AModalResult: TModalResult): Boolean;
function IsNegativeResult(const AModalResult: TModalResult): Boolean;
function IsAbortResult(const AModalResult: TModalResult): Boolean;
function IsAnAllResult(const AModalResult: TModalResult): Boolean;
function StripAllFromResult(const AModalResult: TModalResult): TModalResult;
{ Cursor identifiers }
type
TCursor = -32768..32767;
{$NODEFINE TCursor}
(*$HPPEMIT 'namespace Controls'}*)
(*$HPPEMIT '{'}*)
(*$HPPEMIT '#pragma option -b-'*)
(*$HPPEMIT ' enum TCursor {crMin=-32768, crMax=32767};'}*)
(*$HPPEMIT '#pragma option -b.'*)
(*$HPPEMIT '}'*)
const
crDefault = TCursor(0);
crNone = TCursor(-1);
crArrow = TCursor(-2);
crCross = TCursor(-3);
crIBeam = TCursor(-4);
crSize = TCursor(-22);
crSizeNESW = TCursor(-6);
crSizeNS = TCursor(-7);
crSizeNWSE = TCursor(-8);
crSizeWE = TCursor(-9);
crUpArrow = TCursor(-10);
crHourGlass = TCursor(-11);
crDrag = TCursor(-12);
crNoDrop = TCursor(-13);
crHSplit = TCursor(-14);
crVSplit = TCursor(-15);
crMultiDrag = TCursor(-16);
crSQLWait = TCursor(-17);
crNo = TCursor(-18);
crAppStart = TCursor(-19);
crHelp = TCursor(-20);
crHandPoint = TCursor(-21);
crSizeAll = TCursor(-22);
type
{ Forward declarations }
TDragObject = class;
TControl = class;
TWinControl = class;
TDragImageList = class;
TWinControlClass = class of TWinControl;
{ VCL control message records }
TCMActivate = TWMNoParams;
TCMDeactivate = TWMNoParams;
TCMGotFocus = TWMNoParams;
TCMLostFocus = TWMNoParams;
TCMDialogKey = TWMKey;
TCMDialogChar = TWMKey;
TCMHitTest = TWMNCHitTest;
TCMEnter = TWMNoParams;
TCMExit = TWMNoParams;
TCMDesignHitTest = TWMMouse;
TCMWantSpecialKey = TWMKey;
TCMMouseWheel = record
Msg: Cardinal;
ShiftState: TShiftState;
Unused: Byte;
WheelDelta: SmallInt;
case Integer of
0: (
XPos: Smallint;
YPos: Smallint);
1: (
Pos: TSmallPoint;
Result: Longint);
end;
TCMCancelMode = record
Msg: Cardinal;
Unused: Integer;
Sender: TControl;
Result: Longint;
end;
TCMFocusChanged = record
Msg: Cardinal;
Unused: Integer;
Sender: TWinControl;
Result: Longint;
end;
TCMControlListChange = record
Msg: Cardinal;
Control: TControl;
Inserting: LongBool;
Result: Longint;
end;
TCMChildKey = record
Msg: Cardinal;
CharCode: Word;
Unused: Word;
Sender: TWinControl;
Result: Longint;
end;
TCMControlChange = record
Msg: Cardinal;
Control: TControl;
Inserting: LongBool;
Result: Longint;
end;
TCMChanged = record
Msg: Cardinal;
Unused: Longint;
Child: TControl;
Result: Longint;
end;
TDragMessage = (dmDragEnter, dmDragLeave, dmDragMove, dmDragDrop, dmDragCancel,
dmFindTarget);
PDragRec = ^TDragRec;
TDragRec = record
Pos: TPoint;
Source: TDragObject;
Target: Pointer;
Docking: Boolean;
end;
TCMDrag = packed record
Msg: Cardinal;
DragMessage: TDragMessage;
Reserved1: Byte;
Reserved2: Word;
DragRec: PDragRec;
Result: Longint;
end;
TDragDockObject = class;
TCMDockClient = packed record
Msg: Cardinal;
DockSource: TDragDockObject;
MousePos: TSmallPoint;
Result: Integer;
end;
TCMUnDockClient = packed record
Msg: Cardinal;
NewTarget: TControl;
Client: TControl;
Result: Integer;
end;
TCMFloat = packed record
Msg: Cardinal;
Reserved: Integer;
DockSource: TDragDockObject;
Result: Integer;
end;
PDockNotifyRec = ^TDockNotifyRec;
TDockNotifyRec = record
ClientMsg: Cardinal;
MsgWParam: Integer;
MsgLParam: Integer;
end;
TCMDockNotification = packed record
Msg: Cardinal;
Client: TControl;
NotifyRec: PDockNotifyRec;
Result: Integer;
end;
TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom);
TAlignSet = set of TAlign;
{ Dragging objects }
TDragObject = class(TObject)
private
FDragTarget: Pointer;
FDragHandle: HWND;
FDragPos: TPoint;
FDragTargetPos: TPoint;
FDropped: Boolean;
FMouseDeltaX: Double;
FMouseDeltaY: Double;
FCancelling: Boolean;
function Capture: HWND;
procedure ReleaseCapture(Handle: HWND);
protected
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); virtual;
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; virtual;
function GetDragImages: TDragImageList; virtual;
procedure WndProc(var Msg: TMessage); virtual;
procedure MainWndProc(var Message: TMessage);
public
procedure AfterConstruction; override;
procedure Assign(Source: TDragObject); virtual;
procedure BeforeDestruction; override;
function GetName: string; virtual;
procedure HideDragImage; virtual;
function Instance: THandle; virtual;
procedure ShowDragImage; virtual;
property Cancelling: Boolean read FCancelling write FCancelling;
property DragHandle: HWND read FDragHandle write FDragHandle;
property DragPos: TPoint read FDragPos write FDragPos;
property DragTargetPos: TPoint read FDragTargetPos write FDragTargetPos;
property DragTarget: Pointer read FDragTarget write FDragTarget;
property Dropped: Boolean read FDropped;
property MouseDeltaX: Double read FMouseDeltaX;
property MouseDeltaY: Double read FMouseDeltaY;
end;
TDragObjectClass = class of TDragObject;
TDragObjectEx = class(TDragObject)
public
procedure BeforeDestruction; override;
end;
TBaseDragControlObject = class(TDragObject)
private
FControl: TControl;
protected
procedure EndDrag(Target: TObject; X, Y: Integer); virtual;
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
public
constructor Create(AControl: TControl); virtual;
procedure Assign(Source: TDragObject); override;
property Control: TControl read FControl write FControl;
end;
TDragControlObject = class(TBaseDragControlObject)
protected
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
function GetDragImages: TDragImageList; override;
public
procedure HideDragImage; override;
procedure ShowDragImage; override;
end;
TDragControlObjectEx = class(TDragControlObject)
public
procedure BeforeDestruction; override;
end;
TDragDockObject = class(TBaseDragControlObject)
private
FBrush: TBrush;
FDockRect: TRect;
FDropAlign: TAlign;
FDropOnControl: TControl;
FEraseDockRect: TRect;
FFloating: Boolean;
procedure SetBrush(Value: TBrush);
protected
procedure AdjustDockRect(ARect: TRect); virtual;
procedure DrawDragDockImage; virtual;
procedure EndDrag(Target: TObject; X, Y: Integer); override;
procedure EraseDragDockImage; virtual;
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
function GetFrameWidth: Integer; virtual;
public
constructor Create(AControl: TControl); override;
destructor Destroy; override;
procedure Assign(Source: TDragObject); override;
property Brush: TBrush read FBrush write SetBrush;
property DockRect: TRect read FDockRect write FDockRect;
property DropAlign: TAlign read FDropAlign;
property DropOnControl: TControl read FDropOnControl;
property Floating: Boolean read FFloating write FFloating;
property FrameWidth: Integer read GetFrameWidth;
end;
TDragDockObjectEx = class(TDragDockObject)
public
procedure BeforeDestruction; override;
end;
{ Controls }
TControlCanvas = class(TCanvas)
private
FControl: TControl;
FDeviceContext: HDC;
FWindowHandle: HWnd;
procedure SetControl(AControl: TControl);
protected
procedure CreateHandle; override;
public
destructor Destroy; override;
procedure FreeHandle;
procedure UpdateTextFlags;
property Control: TControl read FControl write SetControl;
end;
{ TControlActionLink }
TControlActionLink = class(TActionLink)
protected
FClient: TControl;
procedure AssignClient(AClient: TObject); override;
function IsCaptionLinked: Boolean; override;
function IsEnabledLinked: Boolean; override;
function IsHelpLinked: Boolean; override;
function IsHintLinked: Boolean; override;
function IsVisibleLinked: Boolean; override;
function IsOnExecuteLinked: Boolean; override;
function DoShowHint(var HintStr: string): Boolean; virtual;
procedure SetCaption(const Value: string); override;
procedure SetEnabled(Value: Boolean); override;
procedure SetHint(const Value: string); override;
procedure SetHelpContext(Value: THelpContext); override;
procedure SetHelpKeyword(const Value: string); override;
procedure SetHelpType(Value: THelpType); override;
procedure SetVisible(Value: Boolean); override;
procedure SetOnExecute(Value: TNotifyEvent); override;
end;
TControlActionLinkClass = class of TControlActionLink;
{ TControl }
TControlState = set of (csLButtonDown, csClicked, csPalette,
csReadingState, csAlignmentNeeded, csFocusing, csCreating,
csPaintCopy, csCustomPaint, csDestroyingHandle, csDocking);
{ New TControlStyles: csNeedsBorderPaint and csParentBackground.
These two ControlStyles are only applicable when Themes are Enabled
in applications on Windows XP. csNeedsBorderPaint causes the
ThemeServices to paint the border of a control with the current theme.
csParentBackground causes the parent to draw its background into the
Control's background; this is useful for controls which need to show their
parent's theme elements, such as a TPanel or TFrame that appear on a
TPageControl. TWinControl introduces a protected ParentBackground
property which includes/excludes the csParentBackground control style.
}
TControlStyle = set of (csAcceptsControls, csCaptureMouse,
csDesignInteractive, csClickEvents, csFramed, csSetCaption, csOpaque,
csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible,
csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector,
csActionClient, csMenuEvents, csNeedsBorderPaint, csParentBackground);
TMouseButton = (mbLeft, mbRight, mbMiddle);
TDragMode = (dmManual, dmAutomatic);
TDragState = (dsDragEnter, dsDragLeave, dsDragMove);
TDragKind = (dkDrag, dkDock);
TTabOrder = -1..32767;
TCaption = type string;
TDate = type TDateTime;
TTime = type TDateTime;
{$EXTERNALSYM TDate}
{$EXTERNALSYM TTime}
(*$HPPEMIT 'namespace Controls'*)
(*$HPPEMIT '{'*)
(*$HPPEMIT ' typedef System::TDateTime TDate;'*)
(*$HPPEMIT ' typedef System::TDateTime TTime;'*)
(*$HPPEMIT '}'*)
TScalingFlags = set of (sfLeft, sfTop, sfWidth, sfHeight, sfFont,
sfDesignSize);
TAnchorKind = (akLeft, akTop, akRight, akBottom);
TAnchors = set of TAnchorKind;
TConstraintSize = 0..MaxInt;
TSizeConstraints = class(TPersistent)
private
FControl: TControl;
FMaxHeight: TConstraintSize;
FMaxWidth: TConstraintSize;
FMinHeight: TConstraintSize;
FMinWidth: TConstraintSize;
FOnChange: TNotifyEvent;
procedure SetConstraints(Index: Integer; Value: TConstraintSize);
protected
procedure Change; virtual;
procedure AssignTo(Dest: TPersistent); override;
property Control: TControl read FControl;
public
constructor Create(Control: TControl); virtual;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
published
property MaxHeight: TConstraintSize index 0 read FMaxHeight write SetConstraints default 0;
property MaxWidth: TConstraintSize index 1 read FMaxWidth write SetConstraints default 0;
property MinHeight: TConstraintSize index 2 read FMinHeight write SetConstraints default 0;
property MinWidth: TConstraintSize index 3 read FMinWidth write SetConstraints default 0;
end;
TMouseEvent = procedure(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer) of object;
TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState;
X, Y: Integer) of object;
TKeyEvent = procedure(Sender: TObject; var Key: Word;
Shift: TShiftState) of object;
TKeyPressEvent = procedure(Sender: TObject; var Key: Char) of object;
TDragOverEvent = procedure(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean) of object;
TDragDropEvent = procedure(Sender, Source: TObject;
X, Y: Integer) of object;
TStartDragEvent = procedure(Sender: TObject;
var DragObject: TDragObject) of object;
TEndDragEvent = procedure(Sender, Target: TObject;
X, Y: Integer) of object;
TDockDropEvent = procedure(Sender: TObject; Source: TDragDockObject;
X, Y: Integer) of object;
TDockOverEvent = procedure(Sender: TObject; Source: TDragDockObject;
X, Y: Integer; State: TDragState; var Accept: Boolean) of object;
TUnDockEvent = procedure(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean) of object;
TStartDockEvent = procedure(Sender: TObject;
var DragObject: TDragDockObject) of object;
TGetSiteInfoEvent = procedure(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean) of object;
TCanResizeEvent = procedure(Sender: TObject; var NewWidth, NewHeight: Integer;
var Resize: Boolean) of object;
TConstrainedResizeEvent = procedure(Sender: TObject; var MinWidth, MinHeight,
MaxWidth, MaxHeight: Integer) of object;
TMouseWheelEvent = procedure(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean) of object;
TMouseWheelUpDownEvent = procedure(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean) of object;
TContextPopupEvent = procedure(Sender: TObject; MousePos: TPoint; var Handled: Boolean) of object;
{$IFDEF LINUX}
TWndMethod = WinUtils.TWndMethod;
{$ENDIF}
{$IFDEF MSWINDOWS}
TWndMethod = Classes.TWndMethod;
{$ENDIF}
{$EXTERNALSYM TWndMethod}
// TDockOrientation indicates how a zone's child zones are arranged.
// doNoOrient means a zone contains a TControl and not child zones.
// doHorizontal means a zone's children are stacked top-to-bottom.
// doVertical means a zone's children are arranged left-to-right.
TDockOrientation = (doNoOrient, doHorizontal, doVertical);
TControl = class(TComponent)
private
FParent: TWinControl;
FWindowProc: TWndMethod;
FLeft: Integer;
FTop: Integer;
FWidth: Integer;
FHeight: Integer;
FControlStyle: TControlStyle;
FControlState: TControlState;
FDesktopFont: Boolean;
FVisible: Boolean;
FEnabled: Boolean;
FParentFont: Boolean;
FParentColor: Boolean;
FAlign: TAlign;
FAutoSize: Boolean;
FDragMode: TDragMode;
FIsControl: Boolean;
FBiDiMode: TBiDiMode;
FParentBiDiMode: Boolean;
FAnchors: TAnchors;
FAnchorMove: Boolean;
FText: PChar;
FFont: TFont;
FActionLink: TControlActionLink;
FColor: TColor;
FConstraints: TSizeConstraints;
FCursor: TCursor;
FDragCursor: TCursor;
FPopupMenu: TPopupMenu;
FHint: string;
FFontHeight: Integer;
FAnchorRules: TPoint;
FOriginalParentSize: TPoint;
FScalingFlags: TScalingFlags;
FShowHint: Boolean;
FParentShowHint: Boolean;
FDragKind: TDragKind;
FDockOrientation: TDockOrientation;
FHostDockSite: TWinControl;
FWheelAccumulator: Integer;
FUndockWidth: Integer;
FUndockHeight: Integer;
FLRDockWidth: Integer;
FTBDockHeight: Integer;
FFloatingDockSiteClass: TWinControlClass;
FOnCanResize: TCanResizeEvent;
FOnConstrainedResize: TConstrainedResizeEvent;
FOnMouseDown: TMouseEvent;
FOnMouseMove: TMouseMoveEvent;
FOnMouseUp: TMouseEvent;
FOnDragDrop: TDragDropEvent;
FOnDragOver: TDragOverEvent;
FOnResize: TNotifyEvent;
FOnStartDock: TStartDockEvent;
FOnEndDock: TEndDragEvent;
FOnStartDrag: TStartDragEvent;
FOnEndDrag: TEndDragEvent;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnContextPopup: TContextPopupEvent;
FOnMouseWheel: TMouseWheelEvent;
FOnMouseWheelDown: TMouseWheelUpDownEvent;
FOnMouseWheelUp: TMouseWheelUpDownEvent;
FHelpType: THelpType;
FHelpKeyword: String;
FHelpContext: THelpContext;
procedure CalcDockSizes;
function CheckNewSize(var NewWidth, NewHeight: Integer): Boolean;
function CreateFloatingDockSite(Bounds: TRect): TWinControl;
procedure DoActionChange(Sender: TObject);
function DoCanAutoSize(var NewWidth, NewHeight: Integer): Boolean;
function DoCanResize(var NewWidth, NewHeight: Integer): Boolean;
procedure DoConstraintsChange(Sender: TObject);
procedure DoConstrainedResize(var NewWidth, NewHeight: Integer);
procedure DoDragMsg(var DragMsg: TCMDrag);
procedure DoMouseDown(var Message: TWMMouse; Button: TMouseButton;
Shift: TShiftState);
procedure DoMouseUp(var Message: TWMMouse; Button: TMouseButton);
procedure FontChanged(Sender: TObject);
function GetBoundsRect: TRect;
function GetClientHeight: Integer;
function GetClientWidth: Integer;
function GetLRDockWidth: Integer;
function GetMouseCapture: Boolean;
function GetText: TCaption;
function GetTBDockHeight: Integer;
function GetUndockWidth: Integer;
function GetUndockHeight: Integer;
procedure InvalidateControl(IsVisible, IsOpaque: Boolean);
function IsAnchorsStored: Boolean;
function IsBiDiModeStored: Boolean;
function IsCaptionStored: Boolean;
function IsColorStored: Boolean;
function IsEnabledStored: Boolean;
function IsFontStored: Boolean;
function IsHintStored: Boolean;
function IsHelpContextStored: Boolean;
function IsOnClickStored: Boolean;
function IsShowHintStored: Boolean;
function IsVisibleStored: Boolean;
procedure ReadIsControl(Reader: TReader);
procedure SetAnchors(Value: TAnchors);
procedure SetAction(Value: TBasicAction);
procedure SetAlign(Value: TAlign);
procedure SetBoundsRect(const Rect: TRect);
procedure SetClientHeight(Value: Integer);
procedure SetClientSize(Value: TPoint);
procedure SetClientWidth(Value: Integer);
procedure SetColor(Value: TColor);
procedure SetCursor(Value: TCursor);
procedure SetDesktopFont(Value: Boolean);
procedure SetFont(Value: TFont);
procedure SetHeight(Value: Integer);
procedure SetHelpContext(const Value: THelpContext);
procedure SetHelpKeyword(const Value: String);
procedure SetHostDockSite(Value: TWinControl);
procedure SetLeft(Value: Integer);
procedure SetMouseCapture(Value: Boolean);
procedure SetParentColor(Value: Boolean);
procedure SetParentFont(Value: Boolean);
procedure SetShowHint(Value: Boolean);
procedure SetParentShowHint(Value: Boolean);
procedure SetPopupMenu(Value: TPopupMenu);
procedure SetText(const Value: TCaption);
procedure SetTop(Value: Integer);
procedure SetVisible(Value: Boolean);
procedure SetWidth(Value: Integer);
procedure SetZOrderPosition(Position: Integer);
procedure UpdateAnchorRules;
procedure WriteIsControl(Writer: TWriter);
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMNCLButtonDown(var Message: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
procedure WMMButtonDown(var Message: TWMMButtonDown); message WM_MBUTTONDOWN;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
procedure WMRButtonDblClk(var Message: TWMRButtonDblClk); message WM_RBUTTONDBLCLK;
procedure WMMButtonDblClk(var Message: TWMMButtonDblClk); message WM_MBUTTONDBLCLK;
procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
procedure WMMButtonUp(var Message: TWMMButtonUp); message WM_MBUTTONUP;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE;
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
procedure CMVisibleChanged(var Message: TMessage); message CM_VISIBLECHANGED;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
procedure CMSysFontChanged(var Message: TMessage); message CM_SYSFONTCHANGED;
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
procedure CMParentShowHintChanged(var Message: TMessage); message CM_PARENTSHOWHINTCHANGED;
procedure CMHintShow(var Message: TMessage); message CM_HINTSHOW;
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
procedure CMFloat(var Message: TCMFloat); message CM_FLOAT;
procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED;
procedure CMParentBiDiModeChanged(var Message: TMessage); message CM_PARENTBIDIMODECHANGED;
procedure CMMouseWheel(var Message: TCMMouseWheel); message CM_MOUSEWHEEL;
procedure WMContextMenu(var Message: TWMContextMenu); message WM_CONTEXTMENU;
procedure SetConstraints(const Value: TSizeConstraints);
protected
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
procedure AdjustSize; dynamic;
procedure AssignTo(Dest: TPersistent); override;
procedure BeginAutoDrag; dynamic;
function CanResize(var NewWidth, NewHeight: Integer): Boolean; virtual;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; virtual;
procedure Changed;
procedure ChangeScale(M, D: Integer); dynamic;
procedure Click; dynamic;
procedure ConstrainedResize(var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer); virtual;
function CalcCursorPos: TPoint;
function DesignWndProc(var Message: TMessage): Boolean; dynamic;
procedure DblClick; dynamic;
procedure DefaultDockImage(DragDockObject: TDragDockObject; Erase: Boolean); dynamic;
procedure DefineProperties(Filer: TFiler); override;
procedure DockTrackNoTarget(Source: TDragDockObject; X, Y: Integer); dynamic;
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); dynamic;
procedure DoEndDock(Target: TObject; X, Y: Integer); dynamic;
procedure DoDock(NewDockSite: TWinControl; var ARect: TRect); dynamic;
procedure DoStartDock(var DragObject: TDragObject); dynamic;
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint): Boolean; dynamic;
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; dynamic;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; dynamic;
procedure DragCanceled; dynamic;
procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
var Accept: Boolean); dynamic;
procedure DoEndDrag(Target: TObject; X, Y: Integer); dynamic;
procedure DoStartDrag(var DragObject: TDragObject); dynamic;
procedure DrawDragDockImage(DragDockObject: TDragDockObject); dynamic;
procedure EraseDragDockImage(DragDockObject: TDragDockObject); dynamic;
function GetAction: TBasicAction; virtual;
function GetActionLinkClass: TControlActionLinkClass; dynamic;
function GetClientOrigin: TPoint; virtual;
function GetClientRect: TRect; virtual;
function GetDeviceContext(var WindowHandle: HWnd): HDC; virtual;
function GetDockEdge(MousePos: TPoint): TAlign; dynamic;
function GetDragImages: TDragImageList; virtual;
function GetEnabled: Boolean; virtual;
function GetFloating: Boolean; virtual;
function GetFloatingDockSiteClass: TWinControlClass; virtual;
function GetPalette: HPALETTE; dynamic;
function GetPopupMenu: TPopupMenu; dynamic;
procedure Loaded; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); dynamic;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); dynamic;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); dynamic;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure PositionDockRect(DragDockObject: TDragDockObject); dynamic;
function PaletteChanged(Foreground: Boolean): Boolean; dynamic;
procedure ReadState(Reader: TReader); override;
procedure RequestAlign; dynamic;
procedure Resize; dynamic;
procedure SendCancelMode(Sender: TControl);
procedure SendDockNotification(Msg: Cardinal; WParam, LParam: Integer);
procedure SetAutoSize(Value: Boolean); virtual;
procedure SetDragMode(Value: TDragMode); virtual;
procedure SetEnabled(Value: Boolean); virtual;
procedure SetName(const Value: TComponentName); override;
procedure SetParent(AParent: TWinControl); virtual;
procedure SetParentComponent(Value: TComponent); override;
procedure SetParentBiDiMode(Value: Boolean); virtual;
procedure SetBiDiMode(Value: TBiDiMode); virtual;
procedure SetZOrder(TopMost: Boolean); dynamic;
procedure UpdateBoundsRect(const R: TRect);
procedure VisibleChanging; dynamic;
procedure WndProc(var Message: TMessage); virtual;
property ActionLink: TControlActionLink read FActionLink write FActionLink;
property AutoSize: Boolean read FAutoSize write SetAutoSize default False;
property Caption: TCaption read GetText write SetText stored IsCaptionStored;
property Color: TColor read FColor write SetColor stored IsColorStored default clWindow;
property DesktopFont: Boolean read FDesktopFont write SetDesktopFont default False;
property DragKind: TDragKind read FDragKind write FDragKind default dkDrag;
property DragCursor: TCursor read FDragCursor write FDragCursor default crDrag;
property DragMode: TDragMode read FDragMode write SetDragMode default dmManual;
property Font: TFont read FFont write SetFont stored IsFontStored;
property IsControl: Boolean read FIsControl write FIsControl;
property MouseCapture: Boolean read GetMouseCapture write SetMouseCapture;
property ParentBiDiMode: Boolean read FParentBiDiMode write SetParentBiDiMode default True;
property ParentColor: Boolean read FParentColor write SetParentColor default True;
property ParentFont: Boolean read FParentFont write SetParentFont default True;
property ParentShowHint: Boolean read FParentShowHint write SetParentShowHint default True;
property PopupMenu: TPopupMenu read FPopupMenu write SetPopupMenu;
property ScalingFlags: TScalingFlags read FScalingFlags write FScalingFlags;
property Text: TCaption read GetText write SetText;
property WheelAccumulator: Integer read FWheelAccumulator write FWheelAccumulator;
property WindowText: PChar read FText write FText;
property OnCanResize: TCanResizeEvent read FOnCanResize write FOnCanResize;
property OnClick: TNotifyEvent read FOnClick write FOnClick stored IsOnClickStored;
property OnConstrainedResize: TConstrainedResizeEvent read FOnConstrainedResize write FOnConstrainedResize;
property OnContextPopup: TContextPopupEvent read FOnContextPopup write FOnContextPopup;
property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
property OnDragDrop: TDragDropEvent read FOnDragDrop write FOnDragDrop;
property OnDragOver: TDragOverEvent read FOnDragOver write FOnDragOver;
property OnEndDock: TEndDragEvent read FOnEndDock write FOnEndDock;
property OnEndDrag: TEndDragEvent read FOnEndDrag write FOnEndDrag;
property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown;
property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove;
property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp;
property OnMouseWheel: TMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
property OnMouseWheelDown: TMouseWheelUpDownEvent read FOnMouseWheelDown
write FOnMouseWheelDown;
property OnMouseWheelUp: TMouseWheelUpDownEvent read FOnMouseWheelUp write
FOnMouseWheelUp;
property OnResize: TNotifyEvent read FOnResize write FOnResize;
property OnStartDock: TStartDockEvent read FOnStartDock write FOnStartDock;
property OnStartDrag: TStartDragEvent read FOnStartDrag write FOnStartDrag;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure BeginDrag(Immediate: Boolean; Threshold: Integer = -1);
procedure BringToFront;
function ClientToScreen(const Point: TPoint): TPoint;
function ClientToParent(const Point: TPoint; AParent: TWinControl = nil): TPoint;
procedure Dock(NewDockSite: TWinControl; ARect: TRect); dynamic;
procedure DefaultHandler(var Message); override;
function Dragging: Boolean;
procedure DragDrop(Source: TObject; X, Y: Integer); dynamic;
function DrawTextBiDiModeFlags(Flags: Longint): Longint;
function DrawTextBiDiModeFlagsReadingOnly: Longint;
property Enabled: Boolean read GetEnabled write SetEnabled stored IsEnabledStored default True;
procedure EndDrag(Drop: Boolean);
function GetControlsAlignment: TAlignment; dynamic;
function GetParentComponent: TComponent; override;
function GetTextBuf(Buffer: PChar; BufSize: Integer): Integer;
function GetTextLen: Integer;
function HasParent: Boolean; override;
procedure Hide;
procedure InitiateAction; virtual;
procedure Invalidate; virtual;
procedure MouseWheelHandler(var Message: TMessage); dynamic;
function IsRightToLeft: Boolean;
function ManualDock(NewDockSite: TWinControl; DropControl: TControl = nil;
ControlSide: TAlign = alNone): Boolean;
function ManualFloat(ScreenPos: TRect): Boolean;
function Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
procedure Refresh;
procedure Repaint; virtual;
function ReplaceDockedControl(Control: TControl; NewDockSite: TWinControl;
DropControl: TControl; ControlSide: TAlign): Boolean;
function ScreenToClient(const Point: TPoint): TPoint;
function ParentToClient(const Point: TPoint; AParent: TWinControl = nil): TPoint;
procedure SendToBack;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); virtual;
procedure SetTextBuf(Buffer: PChar);
procedure Show;
procedure Update; virtual;
function UseRightToLeftAlignment: Boolean; dynamic;
function UseRightToLeftReading: Boolean;
function UseRightToLeftScrollBar: Boolean;
property Action: TBasicAction read GetAction write SetAction;
property Align: TAlign read FAlign write SetAlign default alNone;
property Anchors: TAnchors read FAnchors write SetAnchors stored IsAnchorsStored default [akLeft, akTop];
property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode stored IsBiDiModeStored;
property BoundsRect: TRect read GetBoundsRect write SetBoundsRect;
property ClientHeight: Integer read GetClientHeight write SetClientHeight stored False;
property ClientOrigin: TPoint read GetClientOrigin;
property ClientRect: TRect read GetClientRect;
property ClientWidth: Integer read GetClientWidth write SetClientWidth stored False;
property Constraints: TSizeConstraints read FConstraints write SetConstraints;
property ControlState: TControlState read FControlState write FControlState;
property ControlStyle: TControlStyle read FControlStyle write FControlStyle;
property DockOrientation: TDockOrientation read FDockOrientation write FDockOrientation;
property Floating: Boolean read GetFloating;
property FloatingDockSiteClass: TWinControlClass read GetFloatingDockSiteClass write FFloatingDockSiteClass;
property HostDockSite: TWinControl read FHostDockSite write SetHostDockSite;
property LRDockWidth: Integer read GetLRDockWidth write FLRDockWidth;
property Parent: TWinControl read FParent write SetParent;
property ShowHint: Boolean read FShowHint write SetShowHint stored IsShowHintStored;
property TBDockHeight: Integer read GetTBDockHeight write FTBDockHeight;
property UndockHeight: Integer read GetUndockHeight write FUndockHeight;
property UndockWidth: Integer read GetUndockWidth write FUndockWidth;
property Visible: Boolean read FVisible write SetVisible stored IsVisibleStored default True;
property WindowProc: TWndMethod read FWindowProc write FWindowProc;
published
property Left: Integer read FLeft write SetLeft;
property Top: Integer read FTop write SetTop;
property Width: Integer read FWidth write SetWidth;
property Height: Integer read FHeight write SetHeight;
property Cursor: TCursor read FCursor write SetCursor default crDefault;
property Hint: string read FHint write FHint stored IsHintStored;
property HelpType: THelpType read FHelpType write FHelpType default htContext;
property HelpKeyword: String read FHelpKeyword write SetHelpKeyword stored IsHelpContextStored;
property HelpContext: THelpContext read FHelpContext write SetHelpContext stored IsHelpContextStored default 0;
end;
TControlClass = class of TControl;
TCreateParams = record
Caption: PChar;
Style: DWORD;
ExStyle: DWORD;
X, Y: Integer;
Width, Height: Integer;
WndParent: HWnd;
Param: Pointer;
WindowClass: TWndClass;
WinClassName: array[0..63] of Char;
end;
{ TWinControlActionLink }
TWinControlActionLink = class(TControlActionLink)
protected
FClient: TWinControl;
procedure AssignClient(AClient: TObject); override;
function IsHelpContextLinked: Boolean; override;
procedure SetHelpContext(Value: THelpContext); override;
end;
TWinControlActionLinkClass = class of TWinControlActionLink;
{ TWinControl }
TImeMode = (imDisable, imClose, imOpen, imDontCare,
imSAlpha, imAlpha, imHira, imSKata, imKata,