1{
2 ***************************************************************************
3                              groupededit.pas
4                              ---------------
5
6 Provied a base class where a TCustomMaskedit (derived) control is
7 grouped inside a TCustomControl with a TControl derived class.
8
9 The objective of this baseclass is to forward all relevant methods and
10 properties of TCustomMaskEdit.
11 Grouping the controls inside a TCustomControl is done, so that the
12 resulting control will properly align and anchor.
13
14 Initial implementation 2016 by Bart Broersma
15
16
17               Component Library Extended dialogs Controls
18
19
20 ***************************************************************************
21
22 *****************************************************************************
23 *                                                                           *
24 *  This file is part of the Lazarus Component Library (LCL)                 *
25 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
26 *  for details about the copyright.                                         *
27 *                                                                           *
28 *  This program is distributed in the hope that it will be useful,          *
29 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
30 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
31 *                                                                           *
32 *****************************************************************************
33
34
35}
36unit GroupedEdit;
37
38{$mode objfpc}{$H+}
39
40//{$I lcl_defines.inc}
41
42interface
43
44uses
45  Classes, SysUtils, LCLProc, LResources, LCLStrConsts, Types, LCLType, LMessages,
46  Graphics, Controls, Forms, LazFileUtils, Dialogs, StdCtrls, Buttons, Menus,
47  MaskEdit;
48
49type
50
51  { TGEEdit }
52
53  TGEEdit = class(TCustomMaskedit)
54  public
55    function PerformTab(ForwardTab: boolean): boolean; override;
56  end;
57
58  TGEEditClass = class of TGEEdit;
59
60  { TCustomAbstractGroupedEdit }
61
62  TCustomAbstractGroupedEdit = class(TCustomControl)
63  private
64    FAutoSizeHeightIsEditHeight: Boolean;
65    FBuddy: TControl;
66    FDirectInput: Boolean;
67    FEdit: TGEEdit;
68    FFocusOnBuddyClick: Boolean;
69    FInitialColor: TColor;
70    FIsReadOnly: Boolean;
71    FLayout: TLeftRight;
72    FSpacing: Integer;
73    //Forwarded events from FBuddy
74    FOnBuddyClick: TNotifyEvent;
75    //Forwarded events from FEdit
76    FOnEditClick: TNotifyEvent;
77    FOnEditChange: TNotifyEvent;
78    FOnEditContextPopup:TContextPopupEvent;
79    FOnEditDblClick: TNotifyEvent;
80    FOnEditDragDrop: TDragDropEvent;
81    FOnEditDragOver: TDragOverEvent;
82    FOnEditEditingDone: TNotifyEvent;
83    FOnEditEndDrag: TEndDragEvent;
84    FOnEditExit: TNotifyEvent;
85    FOnEditKeyDown: TKeyEvent;
86    FOnEditKeyPress: TKeyPressEvent;
87    FOnEditEnter: TNotifyEvent;
88    FOnEditKeyUp: TKeyEvent;
89    FOnEditMouseDown: TMouseEvent;
90    FOnEditMouseUp: TMouseEvent;
91    FOnEditMouseEnter: TNotifyEvent;
92    FOnEditMouseLeave: TNotifyEvent;
93    FOnEditMouseMove: TMouseMoveEvent;
94    FOnEditMouseWheel: TMouseWheelEvent;
95    FOnEditMouseWheelUp: TMouseWheelUpDownEvent;
96    FOnEditMouseWheelDown: TMouseWheelUpDownEvent;
97    FOnEditStartDrag: TStartDragEvent;
98    FOnEditUtf8KeyPress: TUtf8KeyPressEvent;
99
100    function GetAlignment: TAlignment;
101    function GetAutoSelect: Boolean;
102    function GetAutoSelected: Boolean;
103    function GetCanUndo: Boolean;
104    function GetCaretPos: TPoint;
105    function GetCharCase: TEditCharCase;
106    function GetColor: TColor;
107    function GetDirectInput: Boolean;
108    function GetEchoMode: TEchoMode;
109    function GetEditMask: String;
110    function GetEditText: string;
111    function GetHideSelection: Boolean;
112    function GetIsMasked: Boolean;
113    function GetMaxLength: Integer;
114    function GetModified: Boolean;
115    function GetNumbersOnly: Boolean;
116    function GetParentColor: Boolean;
117    function GetPasswordChar: char;
118    function GetReadOnly: Boolean;
119    function GetSelLength: Integer;
120    function GetSelStart: Integer;
121    function GetSelText: String;
122    function GetTabStop: Boolean;
123    function GetTextHint: TTranslateString;
124
125    procedure InternalOnBuddyClick(Sender: TObject);
126    procedure InternalOnEditClick(Sender: TObject);
127    procedure InternalOnEditDblClick(Sender: TObject);
128    procedure InternalOnEditChange(Sender: TObject);
129    procedure InternalOnEditContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
130    procedure InternalOnEditDragDrop(Sender, Source: TObject; X,Y: Integer);
131    procedure InternalOnEditDragOver(Sender, Source: TObject; X,Y: Integer; State: TDragState; var Accept: Boolean);
132    procedure InternalOnEditEditingDone(Sender: TObject);
133    procedure InternalOnEditEnter(Sender: TObject);
134    procedure InternalOnEditExit(Sender: TObject);
135    procedure InternalOnEditEndDrag(Sender, Target: TObject; X,Y: Integer);
136    procedure InternalOnEditKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
137    procedure InternalOnEditKeyPress(Sender: TObject; var Key: char);
138    procedure InternalOnEditKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
139    procedure InternalOnEditMouseDown(Sender: TObject; Button: TMouseButton;
140      Shift: TShiftState; X, Y: Integer);
141    procedure InternalOnEditMouseUp(Sender: TObject; Button: TMouseButton;
142      Shift: TShiftState; X, Y: Integer);
143    procedure InternalOnEditMouseEnter(Sender: TObject);
144    procedure InternalOnEditMouseLeave(Sender: TObject);
145    procedure InternalOnEditMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
146    procedure InternalOnEditMouseWheel(Sender: TObject; Shift: TShiftState;
147         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
148    procedure InternalOnEditMouseWheelUp(Sender: TObject;
149          Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
150    procedure InternalOnEditMouseWheelDown(Sender: TObject;
151          Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
152    procedure InternalOnEditUtf8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
153    procedure InternalOnEditStartDrag(Sender: TObject; var DragObject: TDragObject);
154
155    procedure SetAlignment(AValue: TAlignment);
156    procedure SetAutoSelect(AValue: Boolean);
157    procedure SetAutoSelected(AValue: Boolean);
158    procedure SetCaretPos(AValue: TPoint);
159    procedure SetCharCase(AValue: TEditCharCase);
160    procedure SetEchoMode(AValue: TEchoMode);
161    procedure SetEditMask(AValue: String);
162    procedure SetEditText(AValue: string);
163    procedure SetHideSelection(AValue: Boolean);
164    procedure SetLayout(AValue: TLeftRight);
165    procedure SetMaxLength(AValue: Integer);
166    procedure SetModified(AValue: Boolean);
167    procedure SetNumbersOnly(AValue: Boolean);
168    procedure SetParentColor(AValue: Boolean);
169    procedure SetPasswordChar(AValue: char);
170    procedure SetPopupMenu(AValue: TPopupMenu);
171    procedure SetReadOnly(AValue: Boolean);
172    procedure SetSelLength(AValue: Integer);
173    procedure SetSelStart(AValue: Integer);
174    procedure SetSelText(AValue: String);
175    procedure SetSpacing(const Value: integer);
176    procedure SetTabStop(AValue: Boolean);
177    procedure SetTextHint(AValue: TTranslateString);
178  protected
179    procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
180                WithThemeSpace: Boolean); override;
181    function CreateBuddy: TControl; virtual;
182    function CreateEditor: TGEEdit; virtual;
183
184    procedure FocusAndMaybeSelectAll;
185    function GetEditorClassType: TGEEditClass; virtual;
186    function GetBuddyClassType: TControlClass; virtual; abstract;
187    class function GetControlClassDefaultSize: TSize; override;
188    procedure SetDirectInput(AValue: Boolean); virtual;
189    function RealGetText: TCaption; override;
190    procedure RealSetText(const AValue: TCaption); override;
191
192    function GetEditPopupMenu: TPopupMenu;
193    function GetBuddyCaption: TCaption;
194    function GetBuddyCursor: TCursor;
195    function GetBuddyHint: TTranslateString;
196    function GetBuddyWidth: Integer;
197    function GetBuddyVisible: Boolean;
198    procedure SetBuddyCaption(AValue: TCaption);
199    procedure SetBuddyCursor(AValue: TCursor);
200    procedure SetBuddyHint(AValue: TTranslateString);
201    procedure SetBuddyWidth(AValue: Integer);
202    procedure SetBuddyVisible(AValue: Boolean);
203
204    procedure BuddyClick; virtual;
205
206    procedure DoEnter; override;
207
208    procedure EditChange; virtual;
209    procedure EditClick; virtual;
210    procedure EditContextPopup(MousePos: TPoint; var Handled: Boolean); virtual;
211    procedure EditDblClick; virtual;
212    procedure EditDragDrop(Source: TObject; X,Y: Integer);  virtual;
213    procedure EditDragOver(Source: TObject; X,Y: Integer; State: TDragState; var Accept: Boolean); virtual;
214    procedure EditEditingDone; virtual;
215    procedure EditEndDrag(Target: TObject; X,Y: Integer); virtual;
216    procedure EditEnter; virtual;
217    procedure EditExit; virtual;
218    procedure EditKeyDown(var Key: word; Shift: TShiftState); virtual;
219    procedure EditKeyPress( var Key: char); virtual;
220    procedure EditKeyUp(var Key: word; Shift: TShiftState); virtual;
221    procedure EditMouseDown(Button: TMouseButton;
222      Shift: TShiftState; X, Y: Integer); virtual;
223    procedure EditMouseUp(Button: TMouseButton;
224      Shift: TShiftState; X, Y: Integer); virtual;
225    procedure EditMouseEnter; virtual;
226    procedure EditMouseLeave; virtual;
227    procedure EditMouseMove(Shift: TShiftState; X, Y: Integer); virtual;
228    procedure EditMouseWheel(Shift: TShiftState;
229         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
230    procedure EditMouseWheelUp(Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); virtual;
231    procedure EditMouseWheelDown(Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); virtual;
232    procedure EditUtf8KeyPress(var UTF8Key: TUTF8Char); virtual;
233    procedure EditStartDrag(var DragObject: TDragObject); virtual;
234
235    procedure UpdateSpacing;
236    procedure CheckCursor;
237    procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED;
238    function  EditCanModify: Boolean; virtual;
239    procedure GetSel(out _SelStart: Integer; out _SelStop: Integer);
240    function GetSpacing: Integer; virtual;
241    procedure SetSel(const _SelStart: Integer; _SelStop: Integer);
242    procedure Loaded; override;
243    procedure Reset; virtual;
244    procedure SetAutoSize(AValue: Boolean); override;
245    procedure SetColor(AValue: TColor); reintroduce;
246    procedure SetCursor(AValue: TCursor); override;
247    procedure ShouldAutoAdjust(var AWidth, AHeight: Boolean); override;
248
249    property AutoSelect: Boolean read GetAutoSelect write SetAutoSelect default True;
250    property AutoSelected: Boolean read GetAutoSelected write SetAutoSelected;
251    property Buddy: TControl read FBuddy;
252    property BuddyCaption: TCaption read GetBuddyCaption write SetBuddyCaption;
253    property BuddyCursor: TCursor read GetBuddyCursor write SetBuddyCursor default crDefault;
254    property BuddyHint: TTranslateString read GetBuddyHint write SetBuddyHint;
255    property BuddyWidth: Integer read GetBuddyWidth write SetBuddyWidth;
256    property DirectInput : Boolean read GetDirectInput write SetDirectInput default True;
257    property BaseEditor: TGEEdit read FEdit;
258    property EditMask: String read GetEditMask write SetEditMask;
259    property EditText: string read GetEditText write SetEditText;
260    property FocusOnBuddyClick: Boolean read FFocusOnBuddyClick write FFocusOnBuddyClick default False;
261    property IsMasked: Boolean read GetIsMasked;
262    property Layout: TLeftRight read FLayout write SetLayout default taLeftJustify;
263    property Spacing: Integer read GetSpacing write SetSpacing default 0;
264
265    //Derived classes should implement there own (readonly) Edit property, so that it will have the correct classtype
266    //Derived classes should implement a (readonly) property that returns the buddy with the correct classtype (e.g. TSpeedButton)
267
268    property OnBuddyClick: TNotifyEvent read FOnBuddyClick write FOnBuddyClick;
269  public
270    constructor Create(AOwner: TComponent); override;
271    destructor Destroy; override;
272
273    procedure SetFocus; override;
274    function Focused: Boolean; override;
275    procedure Clear;
276    procedure ClearSelection; virtual;
277    procedure CopyToClipboard; virtual;
278    procedure CutToClipboard; virtual;
279    procedure PasteFromClipboard; virtual;
280    procedure SelectAll;
281    procedure Undo; virtual;
282    procedure ValidateEdit; virtual;
283
284    property Autosize default True;
285    property AutoSizeHeightIsEditHeight: Boolean read FAutoSizeHeightIsEditHeight write FAutoSizeHeightIsEditHeight default True;
286    property Alignment: TAlignment read GetAlignment write SetAlignment default taLeftJustify;
287    property CanUndo: Boolean read GetCanUndo;
288    property CaretPos: TPoint read GetCaretPos write SetCaretPos;
289    property CharCase: TEditCharCase read GetCharCase write SetCharCase default ecNormal;
290    property Color: TColor read GetColor write SetColor stored True default {$ifdef UseCLDefault}clDefault{$else}clWindow{$endif};
291    property ParentColor: Boolean read GetParentColor write SetParentColor default False;
292    property EchoMode: TEchoMode read GetEchoMode write SetEchoMode default emNormal;
293    property HideSelection: Boolean read GetHideSelection write SetHideSelection default False;
294    property MaxLength: Integer read GetMaxLength write SetMaxLength;
295    property Modified: Boolean read GetModified write SetModified;
296    property NumbersOnly: Boolean read GetNumbersOnly write SetNumbersOnly default False;
297    property PasswordChar: char read GetPasswordChar write SetPasswordChar;
298    property PopupMenu: TPopupMenu read GetEditPopupMenu write SetPopupMenu;
299    property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
300    property SelLength: Integer read GetSelLength write SetSelLength;
301    property SelStart: Integer read GetSelStart write SetSelStart;
302    property SelText: String read GetSelText write SetSelText;
303    property TabStop: Boolean read GetTabStop write SetTabStop default True;
304    property Text;
305    property TextHint: TTranslateString read GetTextHint write SetTextHint;
306
307    property OnChange: TNotifyEvent read FOnEditChange write FOnEditChange;
308    property OnClick: TNotifyEvent read FOnEditClick write FOnEditClick;
309    property OnContextPopup: TContextPopupEvent read FOnEditContextPopup write FOnEditContextPopup;
310    property OnDblClick: TNotifyEvent read FOnEditDblClick write FOnEditDblClick;
311    property OnDragDrop: TDragDropEvent read FOnEditDragDrop write FOnEditDragDrop;
312    property OnDragOver: TDragOverEvent read FOnEditDragOver write FOnEditDragOver;
313    property OnEditingDone: TNotifyEvent read FOnEditEditingDone write FOnEditEditingDone;
314    property OnEndDrag: TEndDragEvent read FOnEditEndDrag write FOnEditEndDrag;
315    property OnEnter: TNotifyEvent read FOnEditEnter write FOnEditEnter;
316    property OnExit: TNotifyEvent read FOnEditExit write FOnEditExit;
317    property OnMouseDown: TMouseEvent read FOnEditMouseDown write FOnEditMouseDown;
318    property OnKeyPress: TKeyPressEvent read FOnEditKeyPress write FOnEditKeyPress;
319    property OnKeyDown: TKeyEvent read FOnEditKeyDown write FOnEditKeyDown;
320    property OnKeyUp: TKeyEvent read FOnEditKeyUp write FOnEditKeyUp;
321    property OnMouseEnter: TNotifyEvent read FOnEditMouseEnter write FOnEditMouseEnter;
322    property OnMouseLeave: TNotifyEvent read FOnEditMouseLeave write FOnEditMouseLeave;
323    property OnMouseMove: TMouseMoveEvent read FOnEditMouseMove write FOnEditMouseMove;
324    property OnMouseWheel: TMouseWheelEvent read FOnEditMouseWheel write FOnEditMouseWheel;
325    property OnMouseWheelUp: TMouseWheelUpDownEvent read FOnEditMouseWheelUp write FOnEditMouseWheelUp;
326    property OnMouseWheelDown: TMouseWheelUpDownEvent read FOnEditMouseWheelDown write FOnEditMouseWheelDown;
327    property OnMouseUp: TMouseEvent read FOnEditMouseUp write FOnEditMouseUp;
328    property OnStartDrag: TStartDragEvent read FOnEditStartDrag write FOnEditStartDrag;
329    property OnUtf8KeyPress: TUtf8KeyPressEvent read FOnEditUtf8KeyPress write FOnEditUtf8KeyPress;
330
331  end;
332
333 { TAbstractGroupedEdit }
334
335  TAbstractGroupedEdit = class(TCustomAbstractGroupedEdit)
336  public
337    property AutoSelected;
338  published
339    property NumbersOnly;
340    property Action;
341    property AutoSelect;
342    property AutoSizeHeightIsEditHeight;
343    property AutoSize default True;
344    property Align;
345    property Alignment;
346    property Anchors;
347    property BiDiMode;
348    property BorderSpacing;
349    property BorderStyle default bsNone;
350    property BuddyCaption;
351    property BuddyCursor;
352    property BuddyHint;
353    property BuddyWidth;
354    property CharCase;
355    property Color;
356    property Constraints;
357    property Cursor;
358    property DirectInput;
359    property EchoMode;
360    property Enabled;
361    property FocusOnBuddyClick;
362    property Font;
363//    property HideSelection;
364    property Hint;
365    property Layout;
366    property MaxLength;
367    //property OnBuddyClick;
368    property OnChange;
369    property OnClick;
370    property OnDblClick;
371    property OnDragDrop;
372    property OnDragOver;
373    property OnContextPopup;
374    property OnEditingDone;
375    property OnEndDrag;
376    property OnEnter;
377    property OnExit;
378    property OnKeyDown;
379    property OnKeyPress;
380    property OnKeyUp;
381    property OnMouseDown;
382    property OnMouseEnter;
383    property OnMouseLeave;
384    property OnMouseMove;
385    property OnMouseUp;
386    property OnMouseWheel;
387    property OnMouseWheelDown;
388    property OnMouseWheelUp;
389    property OnStartDrag;
390    property OnUTF8KeyPress;
391    property ParentBiDiMode;
392    property ParentColor;
393    property ParentFont;
394    property ParentShowHint;
395    property PasswordChar;
396    property PopupMenu;
397    property ReadOnly;
398    property ShowHint;
399    property Spacing;
400    property TabOrder;
401    property TabStop;
402    property Text;
403    property TextHint;
404    property Visible;
405  end;
406
407
408implementation
409
410
411{ TGEEdit }
412
413
414function TGEEdit.PerformTab(ForwardTab: boolean): boolean;
415begin
416  //if not Forward then inherited PerFormTab will set focus to the owning
417  //TCustomAbstractGroupedEdit, which immediately transfers the focus back to the TGEEdit
418  //so let TCustomAbstractGroupedEdit do the Performtab in this case
419  if ForwardTab then
420    Result := inherited PerformTab(ForwardTab)
421  else
422  begin
423    if Owner is TCustomAbstractGroupedEdit then
424      Result :=  TCustomAbstractGroupedEdit(Owner).PerformTab(ForwardTab)
425    else
426      Result := False;
427  end;
428end;
429
430{ TCustomAbstractGroupedEdit }
431
432procedure TCustomAbstractGroupedEdit.InternalOnBuddyClick(Sender: TObject);
433begin
434  BuddyClick;
435end;
436
437procedure TCustomAbstractGroupedEdit.InternalOnEditChange(Sender: TObject);
438begin
439  if not (csLoading in ComponentState) then
440    EditChange;
441end;
442
443procedure TCustomAbstractGroupedEdit.InternalOnEditContextPopup(
444  Sender: TObject; MousePos: TPoint; var Handled: Boolean);
445begin
446  EditContextPopup(MousePos, Handled);
447end;
448
449procedure TCustomAbstractGroupedEdit.InternalOnEditClick(Sender: TObject);
450begin
451  EditClick;
452end;
453
454procedure TCustomAbstractGroupedEdit.InternalOnEditDblClick(Sender: TObject);
455begin
456  EditDblClick;
457end;
458
459procedure TCustomAbstractGroupedEdit.InternalOnEditDragDrop(Sender, Source: TObject; X, Y: Integer);
460begin
461  EditDragDrop(Source, X, Y);
462end;
463
464procedure TCustomAbstractGroupedEdit.InternalOnEditDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
465begin
466  EditDragOver(Source, X, Y, State, Accept);
467end;
468
469procedure TCustomAbstractGroupedEdit.InternalOnEditEditingDone(Sender: TObject);
470begin
471  EditEditingDone;
472end;
473
474procedure TCustomAbstractGroupedEdit.InternalOnEditEndDrag(Sender, Target: TObject; X, Y: Integer);
475begin
476  EditEndDrag(Target, X, Y);
477end;
478
479procedure TCustomAbstractGroupedEdit.InternalOnEditEnter(Sender: TObject);
480begin
481  EditEnter;
482end;
483
484procedure TCustomAbstractGroupedEdit.InternalOnEditExit(Sender: TObject);
485begin
486  EditExit;
487end;
488
489procedure TCustomAbstractGroupedEdit.InternalOnEditKeyDown(Sender: TObject; var Key: word;
490  Shift: TShiftState);
491begin
492  EditKeyDown(Key, Shift);
493end;
494
495procedure TCustomAbstractGroupedEdit.InternalOnEditKeyPress(Sender: TObject; var Key: char);
496begin
497  EditKeyPress(Key);
498end;
499
500procedure TCustomAbstractGroupedEdit.InternalOnEditKeyUp(Sender: TObject; var Key: word;
501  Shift: TShiftState);
502begin
503  EditKeyUp(Key, Shift);
504end;
505
506procedure TCustomAbstractGroupedEdit.InternalOnEditMouseDown(Sender: TObject;
507  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
508begin
509  EditMouseDown(Button, Shift, X, Y);
510end;
511
512procedure TCustomAbstractGroupedEdit.InternalOnEditMouseUp(Sender: TObject;
513  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
514begin
515  EditMouseUp(Button, Shift, X, Y);
516end;
517
518procedure TCustomAbstractGroupedEdit.InternalOnEditMouseEnter(Sender: TObject);
519begin
520  EditMouseEnter;
521end;
522
523procedure TCustomAbstractGroupedEdit.InternalOnEditMouseLeave(Sender: TObject);
524begin
525  EditMouseLeave;
526end;
527
528procedure TCustomAbstractGroupedEdit.InternalOnEditMouseMove(Sender: TObject;
529  Shift: TShiftState; X, Y: Integer);
530begin
531  EditMouseMove(Shift, X, Y);
532end;
533
534procedure TCustomAbstractGroupedEdit.InternalOnEditMouseWheel(Sender: TObject;
535  Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
536  var Handled: Boolean);
537begin
538  EditMouseWheel(Shift, WheelDelta, MousePos, Handled);
539end;
540
541procedure TCustomAbstractGroupedEdit.InternalOnEditMouseWheelUp(Sender: TObject;
542  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
543begin
544  EditMouseWheelUp(Shift, MousePos, Handled);
545end;
546
547procedure TCustomAbstractGroupedEdit.InternalOnEditMouseWheelDown(Sender: TObject;
548  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
549begin
550  EditMouseWheelDown(Shift, MousePos, Handled);
551end;
552
553procedure TCustomAbstractGroupedEdit.InternalOnEditUtf8KeyPress(Sender: TObject;
554  var UTF8Key: TUTF8Char);
555begin
556  EditUtf8KeyPress(UTF8Key);
557end;
558
559procedure TCustomAbstractGroupedEdit.InternalOnEditStartDrag(Sender: TObject; var DragObject: TDragObject);
560begin
561  EditStartDrag(DragObject);
562end;
563
564function TCustomAbstractGroupedEdit.GetCanUndo: Boolean;
565begin
566  Result := FEdit.CanUndo;
567end;
568
569function TCustomAbstractGroupedEdit.GetCaretPos: TPoint;
570begin
571  Result := FEdit.CaretPos;
572end;
573
574function TCustomAbstractGroupedEdit.GetEditPopupMenu: TPopupMenu;
575begin
576  Result := FEdit.PopupMenu;
577end;
578
579procedure TCustomAbstractGroupedEdit.CalculatePreferredSize(var PreferredWidth,
580  PreferredHeight: integer; WithThemeSpace: Boolean);
581var
582  EditPreferredHeight: integer;
583begin
584  EditPreferredHeight := 0;
585  inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, WithThemeSpace);
586  FEdit.CalculatePreferredSize(PreferredWidth, EditPreferredHeight, WithThemeSpace);
587
588  if FAutoSizeHeightIsEditHeight then
589    PreferredHeight := EditPreferredHeight;
590  PreferredWidth := 0;
591end;
592
593function TCustomAbstractGroupedEdit.GetReadOnly: Boolean;
594begin
595  Result := FIsReadOnly;
596end;
597
598function TCustomAbstractGroupedEdit.GetSelLength: Integer;
599begin
600  Result := FEdit.SelLength;
601end;
602
603function TCustomAbstractGroupedEdit.GetSelStart: Integer;
604begin
605  Result := FEdit.SelStart;
606end;
607
608function TCustomAbstractGroupedEdit.GetSelText: String;
609begin
610  Result := FEdit.SelText;
611end;
612
613function TCustomAbstractGroupedEdit.GetSpacing: Integer;
614begin
615  Result := FSpacing;
616end;
617
618function TCustomAbstractGroupedEdit.GetTabStop: Boolean;
619begin
620  Result := FEdit.TabStop;
621end;
622
623function TCustomAbstractGroupedEdit.RealGetText: TCaption;
624begin
625  Result := FEdit.Text;
626end;
627
628function TCustomAbstractGroupedEdit.GetTextHint: TTranslateString;
629begin
630  Result := FEdit.TextHint;
631end;
632
633procedure TCustomAbstractGroupedEdit.FocusAndMaybeSelectAll;
634begin
635  FEdit.SetFocus;
636  if AutoSelect then
637    FEdit.SelectAll
638  else
639    FEdit.SelStart := MaxInt;
640end;
641
642function TCustomAbstractGroupedEdit.GetAlignment: TAlignment;
643begin
644  Result := FEdit.Alignment;
645end;
646
647function TCustomAbstractGroupedEdit.GetAutoSelect: Boolean;
648begin
649  Result := FEdit.AutoSelect;
650end;
651
652function TCustomAbstractGroupedEdit.GetAutoSelected: Boolean;
653begin
654  Result := FEdit.AutoSelected;
655end;
656
657function TCustomAbstractGroupedEdit.GetBuddyCaption: TCaption;
658begin
659  Result := FBuddy.Caption;
660end;
661
662function TCustomAbstractGroupedEdit.GetBuddyCursor: TCursor;
663begin
664  Result := FBuddy.Cursor;
665end;
666
667function TCustomAbstractGroupedEdit.GetBuddyHint: TTranslateString;
668begin
669  Result := FBuddy.Hint;
670end;
671
672function TCustomAbstractGroupedEdit.GetBuddyWidth: Integer;
673begin
674  Result := FBuddy.Width;
675end;
676
677function TCustomAbstractGroupedEdit.GetBuddyVisible: Boolean;
678begin
679  Result := FBuddy.Visible;
680end;
681
682procedure TCustomAbstractGroupedEdit.SetBuddyHint(AValue: TTranslateString);
683begin
684  FBuddy.Hint := AValue;
685end;
686
687procedure TCustomAbstractGroupedEdit.SetBuddyWidth(AValue: Integer);
688begin
689  FBuddy.Width := AValue;
690end;
691
692procedure TCustomAbstractGroupedEdit.SetBuddyVisible(AValue: Boolean);
693begin
694  FBuddy.Visible := AValue;
695end;
696
697procedure TCustomAbstractGroupedEdit.SetCaretPos(AValue: TPoint);
698begin
699  FEdit.CaretPos := AValue;
700end;
701
702function TCustomAbstractGroupedEdit.GetCharCase: TEditCharCase;
703begin
704  Result := FEdit.CharCase;
705end;
706
707function TCustomAbstractGroupedEdit.GetDirectInput: Boolean;
708begin
709  Result := FDirectInput;
710end;
711
712function TCustomAbstractGroupedEdit.GetEchoMode: TEchoMode;
713begin
714  Result := FEdit.EchoMode;
715end;
716
717function TCustomAbstractGroupedEdit.GetEditMask: String;
718begin
719  Result := FEdit.EditMask
720end;
721
722function TCustomAbstractGroupedEdit.GetEditText: string;
723begin
724  Result := FEdit.EditText;
725end;
726
727function TCustomAbstractGroupedEdit.GetColor: TColor;
728begin
729  Result := FEdit.Color;
730end;
731
732function TCustomAbstractGroupedEdit.GetHideSelection: Boolean;
733begin
734  Result := FEdit.HideSelection;
735end;
736
737function TCustomAbstractGroupedEdit.GetIsMasked: Boolean;
738begin
739  Result := FEdit.IsMasked;
740end;
741
742function TCustomAbstractGroupedEdit.GetMaxLength: Integer;
743begin
744  Result := FEdit.MaxLength;
745end;
746
747function TCustomAbstractGroupedEdit.GetModified: Boolean;
748begin
749  Result := FEdit.Modified;
750end;
751
752function TCustomAbstractGroupedEdit.GetNumbersOnly: Boolean;
753begin
754  Result := FEdit.NumbersOnly;
755end;
756
757function TCustomAbstractGroupedEdit.GetParentColor: Boolean;
758begin
759  Result := FEdit.ParentColor;
760end;
761
762function TCustomAbstractGroupedEdit.GetPasswordChar: char;
763begin
764  Result := FEdit.PasswordChar;
765end;
766
767procedure TCustomAbstractGroupedEdit.SetAlignment(AValue: TAlignment);
768begin
769  FEdit.Alignment := AValue;
770end;
771
772procedure TCustomAbstractGroupedEdit.SetAutoSelect(AValue: Boolean);
773begin
774  FEdit.AutoSelect := AValue;
775end;
776
777procedure TCustomAbstractGroupedEdit.SetAutoSelected(AValue: Boolean);
778begin
779  FEdit.AutoSelected := AValue;
780end;
781
782procedure TCustomAbstractGroupedEdit.SetAutoSize(AValue: Boolean);
783begin
784  if AutoSize = AValue then
785    Exit;
786  inherited SetAutosize(AValue);
787  //FButton.AutoSize := AValue;
788  FEdit.AutoSize := AValue;
789end;
790
791procedure TCustomAbstractGroupedEdit.SetBuddyCaption(AValue: TCaption);
792begin
793  FBuddy.Caption := AValue;
794end;
795
796procedure TCustomAbstractGroupedEdit.SetBuddyCursor(AValue: TCursor);
797begin
798  FBuddy.Cursor := AValue;
799end;
800
801class function TCustomAbstractGroupedEdit.GetControlClassDefaultSize: TSize;
802begin
803  Result.CX := 80 + 23; //as TCustomEdit + TCustomSpeedButton
804  Result.CY := 23;  //as TCustomEdit
805end;
806
807procedure TCustomAbstractGroupedEdit.SetCharCase(AValue: TEditCharCase);
808begin
809  FEdit.CharCase := AValue;
810end;
811
812procedure TCustomAbstractGroupedEdit.SetDirectInput(AValue: Boolean);
813begin
814  FDirectInput := AValue;
815  FEdit.ReadOnly := ((not FDirectInput) or (FIsReadOnly));
816end;
817
818procedure TCustomAbstractGroupedEdit.SetEchoMode(AValue: TEchoMode);
819begin
820  FEdit.EchoMode := AValue;
821end;
822
823procedure TCustomAbstractGroupedEdit.SetEditMask(AValue: String);
824begin
825  FEdit.EditMask := AValue;
826end;
827
828procedure TCustomAbstractGroupedEdit.SetEditText(AValue: string);
829begin
830  FEdit.EditText := AValue;
831end;
832
833procedure TCustomAbstractGroupedEdit.SetColor(AValue: TColor);
834begin
835  if (csLoading in ComponentState) then
836    FInitialColor := AValue
837  else
838    FEdit.Color := AValue;
839end;
840
841procedure TCustomAbstractGroupedEdit.SetCursor(AValue: TCursor);
842begin
843  if Cursor = AValue then
844    Exit;
845  inherited SetCursor(AValue);
846  FEdit.Cursor := AValue;
847end;
848
849procedure TCustomAbstractGroupedEdit.ShouldAutoAdjust(var AWidth,
850  AHeight: Boolean);
851begin
852  AWidth := True;
853  AHeight := not AutoSize;
854end;
855
856procedure TCustomAbstractGroupedEdit.SetFocus;
857begin
858  FEdit.SetFocus;
859end;
860
861procedure TCustomAbstractGroupedEdit.SetHideSelection(AValue: Boolean);
862begin
863  FEdit.HideSelection := AValue;
864end;
865
866procedure TCustomAbstractGroupedEdit.SetLayout(AValue: TLeftRight);
867begin
868  if (FLayout = AValue) then
869    Exit;
870  FLayout := AValue;
871  DisableAlign;
872  UpdateSpacing;
873  case FLayout of
874    taLeftJustify : FBuddy.Align := alRight;
875    taRightJustify: FBuddy.Align := alLeft;
876  end;
877  EnableAlign;
878end;
879
880procedure TCustomAbstractGroupedEdit.SetMaxLength(AValue: Integer);
881begin
882  FEdit.MaxLength := AValue;
883end;
884
885procedure TCustomAbstractGroupedEdit.SetModified(AValue: Boolean);
886begin
887  FEdit.Modified := AValue;
888end;
889
890procedure TCustomAbstractGroupedEdit.SetNumbersOnly(AValue: Boolean);
891begin
892  FEdit.NumbersOnly := AValue;
893end;
894
895procedure TCustomAbstractGroupedEdit.SetParentColor(AValue: Boolean);
896begin
897  FEdit.ParentColor := AValue;
898end;
899
900procedure TCustomAbstractGroupedEdit.SetPasswordChar(AValue: char);
901begin
902  FEdit.PasswordChar := AValue;
903end;
904
905procedure TCustomAbstractGroupedEdit.SetPopupMenu(AValue: TPopupMenu);
906begin
907  FEdit.PopupMenu := AValue;
908end;
909
910procedure TCustomAbstractGroupedEdit.RealSetText(const AValue: TCaption);
911begin
912  FEdit.Text := AValue;
913end;
914
915
916procedure TCustomAbstractGroupedEdit.BuddyClick;
917begin
918  //debugln(['TCustomAbstractGroupedEdit.BuddyClick: Assigned(FOnBuddyClick)=',Assigned(FOnBuddyClick)]);
919  if ReadOnly then
920    Exit;
921  if Assigned(FOnBuddyClick) then
922    FOnBuddyClick(Self);
923  //derived controls that override BuddyClick typically run a dialog after calling inherited,
924  //in that case selecting the text now does not make sense at all (and looks silly)
925  //it's up to the derived control to implement this focus and select if wanted
926  if TMethod(@Self.BuddyClick).Code = Pointer(@TCustomAbstractGroupedEdit.BuddyClick) then
927  begin
928    if FocusOnBuddyClick then FocusAndMaybeSelectAll;
929  end;
930end;
931
932procedure TCustomAbstractGroupedEdit.DoEnter;
933begin
934  inherited DoEnter;
935  if not (csDesigning in ComponentState) then
936    FEdit.SetFocus;
937end;
938
939procedure TCustomAbstractGroupedEdit.EditChange;
940begin
941  if Assigned(FOnEditChange) then FOnEditChange(Self);
942end;
943
944procedure TCustomAbstractGroupedEdit.EditClick;
945begin
946  if Assigned(FOnEditClick) then FOnEditClick(Self);
947end;
948
949procedure TCustomAbstractGroupedEdit.EditContextPopup(MousePos: TPoint; var Handled: Boolean);
950begin
951  if Assigned(FOnEditContextPopup) then FOnEditContextPopup(Self, MousePos, Handled);
952end;
953
954procedure TCustomAbstractGroupedEdit.EditDblClick;
955begin
956  if Assigned(FOnEditDblClick) then FOnEditDblClick(Self);
957end;
958
959procedure TCustomAbstractGroupedEdit.EditDragDrop(Source: TObject; X, Y: Integer);
960begin
961  if Assigned(FOnEditDragDrop) then FOnEditDragDrop(Self, Source, X, Y);
962end;
963
964procedure TCustomAbstractGroupedEdit.EditDragOver(Source: TObject; X, Y: Integer;
965  State: TDragState; var Accept: Boolean);
966begin
967  Accept:=Assigned(FOnEditDragOver);
968  if Accept then
969    FOnEditDragOver(Self, Source, X, Y, State, Accept);
970end;
971
972procedure TCustomAbstractGroupedEdit.EditEditingDone;
973begin
974  if Assigned(FOnEditEditingDone) then FOnEditEditingDone(Self);
975end;
976
977procedure TCustomAbstractGroupedEdit.EditEndDrag(Target: TObject; X, Y: Integer);
978begin
979  if Assigned(FOnEditEndDrag) then FOnEditEndDrag(Self, Target, X, Y);
980end;
981
982procedure TCustomAbstractGroupedEdit.EditEnter;
983begin
984  if Assigned(FOnEditEnter) then FOnEditEnter(Self);
985end;
986
987procedure TCustomAbstractGroupedEdit.EditExit;
988begin
989  if Assigned(FOnEditExit) then FOnEditExit(Self);
990end;
991
992procedure TCustomAbstractGroupedEdit.EditKeyDown(var Key: word; Shift: TShiftState);
993begin
994  if Assigned(FOnEditKeyDown) then FOnEditKeyDown(Self, Key, Shift);
995end;
996
997procedure TCustomAbstractGroupedEdit.EditKeyPress(var Key: char);
998begin
999  if Assigned(FOnEditKeyPress) then FOnEditKeyPress(Self, Key);
1000end;
1001
1002procedure TCustomAbstractGroupedEdit.EditKeyUp(var Key: word; Shift: TShiftState);
1003begin
1004  if Assigned(FOnEditKeyUp) then FOnEditKeyUp(Self, Key, Shift);
1005end;
1006
1007procedure TCustomAbstractGroupedEdit.EditMouseDown(Button: TMouseButton;
1008  Shift: TShiftState; X, Y: Integer);
1009begin
1010  if Assigned(FOnEditMouseDown) then FOnEditMouseDown(Self, Button, Shift, X, Y);
1011end;
1012
1013procedure TCustomAbstractGroupedEdit.EditMouseUp(Button: TMouseButton;
1014  Shift: TShiftState; X, Y: Integer);
1015begin
1016  if Assigned(FOnEditMouseUp) then FOnEditMouseUp(Self, Button, Shift, X, Y);
1017end;
1018
1019procedure TCustomAbstractGroupedEdit.EditMouseEnter;
1020begin
1021  if Assigned(FOnEditMouseEnter) then FOnEditMouseEnter(Self);
1022end;
1023
1024procedure TCustomAbstractGroupedEdit.EditMouseLeave;
1025begin
1026  if Assigned(FOnEditMouseLeave) then FOnEditMouseLeave(Self);
1027end;
1028
1029procedure TCustomAbstractGroupedEdit.EditMouseMove(Shift: TShiftState; X, Y: Integer);
1030begin
1031  if Assigned(FOnEditMouseMove) then FOnEditMouseMove(Self, Shift, X, Y);
1032end;
1033
1034procedure TCustomAbstractGroupedEdit.EditMouseWheel(Shift: TShiftState;
1035  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
1036begin
1037  if Assigned(FOnEditMouseWheel) then FOnEditMouseWheel(Self, Shift, WheelDelta, MousePos, Handled);
1038end;
1039
1040procedure TCustomAbstractGroupedEdit.EditMouseWheelUp(Shift: TShiftState;
1041  MousePos: TPoint; var Handled: Boolean);
1042begin
1043  if Assigned(FOnEditMouseWheelUp) then FOnEditMouseWheelUp(Self, Shift, MousePos, Handled);
1044end;
1045
1046procedure TCustomAbstractGroupedEdit.EditMouseWheelDown(Shift: TShiftState;
1047  MousePos: TPoint; var Handled: Boolean);
1048begin
1049  if Assigned(FOnEditMouseWheelDown) then FOnEditMouseWheelDown(Self, Shift, MousePos, Handled);
1050end;
1051
1052procedure TCustomAbstractGroupedEdit.EditUtf8KeyPress(var UTF8Key: TUTF8Char);
1053begin
1054  if Assigned(FOnEditUtf8KeyPress) then FOnEditUtf8KeyPress(Self, Utf8Key);
1055end;
1056
1057procedure TCustomAbstractGroupedEdit.EditStartDrag(var DragObject: TDragObject);
1058begin
1059  if Assigned(FOnEditStartDrag) then FOnEditStartDrag(Self, DragObject);
1060end;
1061
1062procedure TCustomAbstractGroupedEdit.CheckCursor;
1063begin
1064  FEdit.CheckCursor;
1065end;
1066
1067procedure TCustomAbstractGroupedEdit.CMParentColorChanged(var Message: TLMessage);
1068begin
1069  if inherited ParentColor then
1070  begin
1071    inherited SetColor(Parent.Color);
1072    inherited ParentColor := True;
1073  end;
1074end;
1075
1076function TCustomAbstractGroupedEdit.EditCanModify: Boolean;
1077begin
1078  Result := FEdit.EditCanModify;
1079end;
1080
1081procedure TCustomAbstractGroupedEdit.GetSel(out _SelStart: Integer; out _SelStop: Integer);
1082begin
1083  FEdit.GetSel(_SelStart, _SelStop);
1084end;
1085
1086procedure TCustomAbstractGroupedEdit.SetSel(const _SelStart: Integer; _SelStop: Integer);
1087begin
1088  FEdit.SetSel(_SelStart, _SelStop);
1089end;
1090
1091procedure TCustomAbstractGroupedEdit.Loaded;
1092begin
1093  inherited Loaded;
1094  {
1095    inherited Loaded sends a CM_PARENTFONTCHANGED message, which then
1096    also sets FEdit's color, which is undesired.
1097  }
1098  UpdateSpacing;
1099  if GetColor <> FInitialColor then SetColor(FInitialColor);
1100end;
1101
1102
1103procedure TCustomAbstractGroupedEdit.Reset;
1104begin
1105  FEdit.Reset;
1106end;
1107
1108
1109procedure TCustomAbstractGroupedEdit.SetReadOnly(AValue: Boolean);
1110begin
1111  FIsReadOnly := AValue;
1112  FEdit.ReadOnly := AValue or (not DirectInput);
1113  FBuddy.Enabled := not FIsReadOnly and Enabled;
1114end;
1115
1116procedure TCustomAbstractGroupedEdit.SetSelLength(AValue: Integer);
1117begin
1118  FEdit.SelLength := AValue;
1119end;
1120
1121procedure TCustomAbstractGroupedEdit.SetSelStart(AValue: Integer);
1122begin
1123  FEdit.SelStart := AValue;
1124end;
1125
1126procedure TCustomAbstractGroupedEdit.SetSelText(AValue: String);
1127begin
1128  FEdit.SelText := AValue;
1129end;
1130
1131procedure TCustomAbstractGroupedEdit.SetSpacing(const Value: integer);
1132begin
1133  if (Value = FSpacing) then Exit;
1134  FSpacing := Value;
1135  if not (csLoading in ComponentState) then UpdateSpacing;
1136end;
1137
1138procedure TCustomAbstractGroupedEdit.SetTabStop(AValue: Boolean);
1139begin
1140  FEdit.TabStop := AValue;
1141end;
1142
1143procedure TCustomAbstractGroupedEdit.SetTextHint(AValue: TTranslateString);
1144begin
1145  FEdit.TextHint := AValue;
1146end;
1147
1148procedure TCustomAbstractGroupedEdit.UpdateSpacing;
1149begin
1150  if (FBuddy=nil) or not FBuddy.Visible then
1151  begin
1152    FEdit.BorderSpacing.Right := 0;
1153    FEdit.BorderSpacing.Left := 0;
1154  end
1155  else
1156  if (FLayout = taLeftJustify) then
1157  begin
1158    FEdit.BorderSpacing.Right := FSpacing;
1159    FEdit.BorderSpacing.Left := 0;
1160  end
1161  else
1162  begin
1163    FEdit.BorderSpacing.Right := 0;
1164    FEdit.BorderSpacing.Left := FSpacing;
1165  end;
1166end;
1167
1168
1169function TCustomAbstractGroupedEdit.CreateBuddy: TControl;
1170begin
1171  Result := GetBuddyClassType.Create(Self);
1172end;
1173
1174function TCustomAbstractGroupedEdit.CreateEditor: TGEEdit;
1175begin
1176  Result := GetEditorClassType.Create(Self);
1177end;
1178
1179function TCustomAbstractGroupedEdit.GetEditorClassType: TGEEditClass;
1180begin
1181  Result := TGEEdit;
1182end;
1183
1184constructor TCustomAbstractGroupedEdit.Create(AOwner: TComponent);
1185var
1186  B: TBitmap;
1187begin
1188  AutoSizeHeightIsEditHeight := True;
1189  FEdit := CreateEditor;
1190  FBuddy := CreateBuddy;
1191  inherited Create(AOwner);
1192  ControlStyle := ControlStyle + [csNoFocus];
1193  FEdit.ParentColor := False;
1194  FInitialColor := {$ifdef UseCLDefault}clDefault{$else}clWindow{$endif};
1195  BorderStyle := bsNone;
1196  FLayout := taLeftjustify;
1197  FDirectInput := True;
1198  FIsReadOnly := False;
1199  TabStop := True;
1200  inherited TabStop := False;
1201  FocusOnBuddyClick := False;
1202  FSpacing := 0;
1203  SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
1204
1205  FBuddy.Align := alRight;
1206  FBuddy.OnClick := @InternalOnBuddyClick;
1207  FBuddy.Parent := Self;
1208
1209  with FEdit do
1210  begin
1211    Align := alClient;
1212    ParentColor := False;
1213    ParentFont := True;
1214
1215    AutoSelect := True;
1216    Alignment := taLeftJustify;
1217    ReadOnly := False;
1218
1219    OnChange := @InternalOnEditChange;
1220    OnClick := @InternalOnEditClick;
1221    OnContextPopup := @InternalOnEditContextPopup;
1222    OnDblClick := @InternalOnEditDblClick;
1223    OnDragDrop := @InternalOnEditDragDrop;
1224    OnDragOver := @InternalOnEditDragOver;
1225    OnEditingDone := @InternalOnEditEditingDone;
1226    OnEndDrag := @InternalOnEditEndDrag;
1227    OnExit := @InternalOnEditExit;
1228    OnEnter := @InternalOnEditEnter;
1229    OnKeyDown := @InternalOnEditKeyDown;
1230    OnKeyPress := @InternalOnEditKeyPress;
1231    OnKeyUp := @InternalOnEditKeyUp;
1232    OnMouseDown := @InternalOnEditMouseDown;
1233    OnMouseUp := @InternalOnEditMouseUp;
1234    OnMouseEnter := @InternalOnEditMouseEnter;
1235    OnMouseLeave := @InternalOnEditMouseLeave;
1236    OnMouseMove := @InternalOnEditMouseMove;
1237    OnMouseWheel := @InternalOnEditMouseWheel;
1238    OnMouseWheelUp := @InternalOnEditMouseWheelUp;
1239    OnMouseWheelDown := @InternalOnEditMouseWheelDown;
1240    OnStartDrag := @InternalOnEditStartDrag;
1241    OnUtf8KeyPress := @InternalOnEditUtf8KeyPress;
1242  end;
1243  FEdit.Parent := Self;
1244  AutoSize := True;
1245  Color := {$ifdef UseCLDefault}clDefault{$else}clWindow{$endif};
1246  inherited ParentColor := True; //don't want to see the container if Parent's color changes
1247end;
1248
1249destructor TCustomAbstractGroupedEdit.Destroy;
1250begin
1251  inherited Destroy;
1252end;
1253
1254function TCustomAbstractGroupedEdit.Focused: Boolean;
1255begin
1256  Result := FEdit.Focused;
1257end;
1258
1259procedure TCustomAbstractGroupedEdit.Clear;
1260begin
1261  FEdit.Clear;
1262end;
1263
1264procedure TCustomAbstractGroupedEdit.ClearSelection;
1265begin
1266  FEdit.ClearSelection;
1267end;
1268
1269procedure TCustomAbstractGroupedEdit.CopyToClipboard;
1270begin
1271  FEdit.CopyToClipboard;
1272end;
1273
1274procedure TCustomAbstractGroupedEdit.CutToClipboard;
1275begin
1276  FEdit.CutToClipBoard;
1277end;
1278
1279procedure TCustomAbstractGroupedEdit.PasteFromClipboard;
1280begin
1281  FEdit.PasteFromClipBoard;
1282end;
1283
1284procedure TCustomAbstractGroupedEdit.SelectAll;
1285begin
1286  FEdit.SelectAll;
1287end;
1288
1289
1290procedure TCustomAbstractGroupedEdit.Undo;
1291begin
1292  FEdit.Undo;
1293end;
1294
1295procedure TCustomAbstractGroupedEdit.ValidateEdit;
1296begin
1297  FEdit.ValidateEdit;
1298end;
1299
1300initialization
1301  RegisterPropertyToSkip(TCustomAbstractGroupedEdit, 'TextHintFontColor','Used in a previous version of Lazarus','');
1302  RegisterPropertyToSkip(TCustomAbstractGroupedEdit, 'TextHintFontStyle','Used in a previous version of Lazarus','');
1303end.
1304