Provides the base class for grouped edit controls

Provides a base class where a TCustomMaskEdit (derived) control is grouped inside a TCustomControl with another TControl derived class. The objective of this base class is to forward all relevant methods and properties of TCustomMaskEdit. Grouping the controls inside a TCustomControl is done, so that the resulting control can be aligned and anchored.

Initial implementation 2016 by Bart Broersma

Implements the edit control used in TCustomAbstractGroupedEdit

TGEEdit is a TCustomMaskedit descendant which implements the edit control used in TCustomAbstractGroupedEdit. TGEEdit provides an overridden method to handle Tab keys. The key can be frowarded to the control that owns the class instance, to the ancestor class, or simply discarded.

TGEEdit is the type used to implement the BaseEditor property in TCustomAbstractGroupedEdit.

Handles Tab key presses for the control True when the Tab key has been handled True forwards the key to the ancestor class Class type used to create instances of TGEEdit Implements a grouped edit control

TCustomAbstractGroupedEdit is a TCustomControl descendant which implements a grouped edit control. TCustomAbstractGroupedEdit is composed of a TGEEdit control that provides an editor for the control value, and a related TControl descendant.

TCustomAbstractGroupedEdit basically acts as a container for the grouped controls, and ensures that Aligment and Anchoring are performed. TCustomAbstractGroupedEdit forwards relevant methods and properties to the BaseEditor or Buddy members, and receives event notifications from both.

Derived classes should implement their own BaseEditor and Buddy properties so that they will have the correct class types.

Gets the value for the Alignment property Value for the property Gets the value for the AutoSelect property Value for the property Gets the value for the AutoSelected property Value for the property Gets the value for the CanUndo property Value for the property Gets the value for the CaretPos property Value for the property Gets the value for the CharCase property Value for the property Gets the value for the Color property Value for the property Gets the value for the DirectInput property Value for the property Gets the value for the EchoMode property Value for the property Gets the value for the EditMask property Value for the property Gets the value for the EditText property Value for the property Gets the value for the HideSelection property Value for the property Gets the value for the IsMasked property Value for the property Gets the value for the MaxLength property Value for the property Gets the value for the Modified property Value for the property Gets the value for the NumbersOnly property Value for the property Gets the value for the ParentColor property Value for the property Gets the value for the PasswordChar property Read access for the the value is redirected to the PasswordChar property in BaseEditor. Value for the property Gets the value for the ReadOnly property Value for the property Gets the value for the SelLength property Read access to the property value is redirected to BaseEditor. Value for the property Gets the value for the SelStart property Read access to the property value is redirected to BaseEditor. Value for the property Gets the value for the SelText property Read access to the property value is redirected to BaseEditor. Value for the property Gets the value for the TabStop property Read access to the property value is redirected to BaseEditor. Value for the property Gets the value for the TextHint property Read access to the property value is redirected to BaseEditor. Value for the property Executes the click event handler for the Buddy control Object instance for the event notification Executes the click event handler for the BaseEditor control Object instance for the event notification Executes the double click event handler for the BaseEditor control Object instance for the event notification Executes the OnChange event handler for the BaseEditor control Object instance for the event notification Executes the OnEditDragDrop event handler for the control Object instance for the event notification Executes the OnEditDragOver event handler for the control Object instance for the event notification Executes the OnEditingDone event handler for the control Object instance for the event notification Executes the OnEditEnter event handler for the control Object instance for the event notification Executes the OnEditExit event handler for the control Object instance for the event notification Executes the OnEditEndDrag event handler for the control Object instance for the event notification Executes the OnEditKeyDown event handler for the control Object instance for the event notification Executes the OnEditKeyPress event handler for the control Object instance for the event notification Executes the OnEditKeyUp event handler for the control Object instance for the event notification Executes the OnEditMouseDown event handler for the control Object instance for the event notification Executes the OnEditMouseUp event handler for the control Object instance for the event notification Sets the value for the Alignment property Write access for the property value is redirected to the Alignment property in BaseEditor. New value for the property Sets the value for the AutoSelect property Write access for the property value is redirected to BaseEditor. New value for the property Sets the value for the AutoSelected property Write access to the property value is redirected to BaseEditor. New value for the property Sets the value for the CaretPos property Write access to the property value is redirected to BaseEditor. New value for the property Sets the value for the CharCase property

Write access to the property value is redirected to BaseEditor.

New value for the property Sets the value for the EchoMode property Write access to the property value is redirected to BaseEditor. New value for the property Sets the value for the EditMask property Write access to the property value is redirected to BaseEditor. New value for the property Sets the value for the EditText property Write access to the property value is redirected to BaseEditor. New value for the property Sets the value for the HideSelection property

Read and write access for the property value is redirected to BaseEditor.

New value for the property Sets the value for the Layout property New value for the property Sets the value for the MaxLength property New value for the property Sets the value for the Modified property New value for the property Sets the value for the NumbersOnly property New value for the property Sets the value for the ParentColor property New value for the property Sets the value for the PasswordChar property New value for the property Sets the value for the PopupMenu property New value for the property Sets the value for the ReadOnly property New value for the property Sets the value for the SelLength property New value for the property Sets the value for the SelStart property New value for the property Sets the value for the SelText property New value for the property Sets the value for the Spacing property New value for the property Sets the value for the TabStop property New value for the property Sets the value for the TextHint property New value for the property Registers the widget set class used to create new instances of the grouped edit

Calls the inherited method, and registers the following properties to be skipped during LCL component streaming:

TextHintFontColor
Used in a previous version of Lazarus
TextHintFontStyle
Used in a previous version of Lazarus
Calculates the preferred size for the control with optional space reserved by theme services

CalculatePreferredSize is an overridden procedure used to calculate the dimensions for the control. The calculated values are returned in PreferredWidth and PreferredHeight.

CalculatePreferredSize calls the inherited method, and forwards the method call to the BaseEditor control. When AutoSizeHeightIsEditHeight is set to True, the value calculated as the control height in BaseEditor is used as the value in the PreferredHeight argument. The value in PreferredWidth is always set to zero (0).

Width for the control; always zero in the method Height for the control Indicates if additional space needed for theme services is reserved Creates the TControl instance assigned to the Buddy property

CreateBuddy is a TControl function used to create the TControl instance assigned to the Buddy property. CreateBuddy calls GetBuddyClassType to get the class reference used to create new instances of the control, and calls its Create method using the current class instance as the owner for the TControl instance.

CreateBuddy is used the Create constructor.

TControl instance created in the method Creates the TGEEdit instance used in the BaseEditor property TGEEdit instance created in the method Gives focus to the control, and optionally selects text in its editor

FocusAndMaybeSelectAll is a procedure used to give focus to the control, and to optionally select text in its editor. FocusAndMaybeSelectAll calls the SetFocus method in BaseEditor to ensure that the editor portion of the grouped edit control has focus.

The value in AutoSelect is used to determine the selected text in the BaseEditor control. When AutoSelect is set to True, the SelectAll method in BaseEditor is called to select all of the content in the control. When False, the SelStart method in BaseEditor is set to the maximum value for an Integer, ensuring that the caret position is located at the end of the control value.

FocusAndMaybeSelectAll is used in the implementation of the BuddyClick method.

Gets the class reference used to create the BaseEditor for the control Class reference used to create the BaseEditor for the control Gets the class reference used to create the Buddy for the control Class reference sed to create the Buddy for the control Gets the default size for new instances of the control Default size for new class instances Sets the value for the DirectInput property New value for the property Gets the value for the text in the control Value for the text in the control Sets the value for the text in the control New value for the text in the control Gets the popup menu for the BaseEditor in the control The popup menu for the BaseEditor in the control Gets the Caption used in the Buddy property Caption used in the Buddy property Gets the value for the BuddyCursor property Value for the property Gets the value for the BuddyHint property Value for the property Gets the value for the BuddyWidth property Value for the property Sets the Caption used in the Buddy property Value assigned as the Caption in the Buddy property Sets the cursor shape used in the Buddy property Value assigned as the Cursor in the Buddy property Sets the Hint displayed for the Buddy property Value assigned as the Hint in the Buddy property Sets the Width used for the Buddy property Value assigned as the Width in the Buddy property Performs actions needed when the Buddy control is clicked

Used in internal methods to redirect events from the Buddy control to the container class (the current class instance).

BuddyClick uses the value in ReadOnly to determine if the grouped edit control should respond to a Click event from the Buddy control. When ReadOnly is True, no actions are performed in the method.

BuddyClick signals the OnBuddyEvent handler (when assigned). When the BuddyClick code points to this method (and not an overridden one in a descendant), the FocusOnBuddyClick method is called to determine if focus and selection changes are handled by the current class instance.

Derived controls may override BuddyClick to run a dialog after calling the inherited method. In this scenario, selecting the text in this method is most likely premature. It is the responsibility of the derived control to implement focus changes and selection as needed.

Performs actions needed when the control is entered

DoEnter is an overridden procedure used to perform actions needed when the control is entered using keyboard navigation. DoEnter calls the inherited DoEnter method to signal the OnEnter event handler, and calls the SetFocus method in BaseEditor at run-time. The focus change is not performed at design-time.

Signals the OnEditChange event handler, when assigned

EditChange is a procedure used to signals the OnEditChange event handler, when assigned. EditChange is used in the implementation of the InternalOnEditChange method, which is assigned as the OnChange event handler in the BaseEditor property.

Signals the OnEditClick event handler, when assigned Forwards a CheckCursor method call to the BaseEditor for the control Handles the control message received when the ParentColor property is changed Gets the offsets for the current text selection in the control Starting position for the text selection in the control Ending position for the text selection in the control Gets the value for the Spacing property Value for the property Sets the current text selection in the control Initial position selected in the control Final position selected in the control Performs actions when the control has finished loading in the LCL streaming mechanism Forwards a Reset method call to the BaseEditor in the control Sets the value for the AutoSize property New value for the property Sets the value for the Color property New value for the property Sets the value for the Cursor property New value for the property Indicates if the text in the control is automatically selected when focus is received Indicates if the current text selection was performed automatically Represents the associated TControl instance in the grouped edit control

Buddy normally contains a TSpeedButton, TUpDown or similar control. Derived classes may implement a different class type for the control using the GetBuddyClassType method.

Caption used for the Buddy control Cursor shape used for the Buddy control Hint displayed for the Buddy control Width for the Buddy control Indicates if text can be entered directly into the BaseEditor control Represents the control used as the editor for the value in the grouped edit control Contains the masking characters used in the editor for the control

EditMask is a String property that contains the masking characters used in the editor for the control. EditMask redirects read and write access for the property to the TGEEdit instance in the BaseEditor property.

Contains the value entered in the control including masking characters

EditText is a String property which contains the value entered in the control including masking characters. Read and write access to the property value are redirected to the BaseEditor control.

Use the Text property to access the actual characters in the control value, excluding any characters introduced by an edit mask.

Determines if the control receives focus when the Buddy conrol is clicked

FocusOnBuddyClick is a Boolean property which determines if the control receives focus (and a potential change to the text selection in the editor) when the Buddy control is clicked. The default value for the property is False.

FocusOnBuddyClick is used in the implementation of the BuddyClick method.

Indicates if an edit mask is in use in the BaseEditor in the grouped edit control

Layout is a TLeftRight property that determines the setting for the Align property in the BaseEditor and the Buddy controls. The default value for the property is taLeftJustify.

Changing the value in Layout cause the Align properties in the grouped controls to be set to the appropriate values. For example:

taLeftJustify
Causes the Buddy control to be right aligned (opposite of the editor control).
taRightJustify
Causes the Buddy control to be left aligned (opposite of the editor control).
Spacing used between the BaseEditor and the Buddy controls

Spacing is an Integer property that contains the spacing used between the BaseEditor and the Buddy controls.

Event handler signalled when the Buddy control is clicked Constructor for the class instance

Create is the overridden constructor for the class instance. Create allocates resources needed for the BaseEditor and Buddy properties prior to calling the inherited constructor. The default values for properties and event handlers are assigned in the constructor, including those needed in the BaseEditor and Buddy properties.

The Buddy control is aligned to the right edge of the current class instance.

BaseEditor is aligned to the remaining client area in the control. Event handlers in BaseEditor are set to the internal methods used to redirect mouse and keyboard events for the current class instance.

Both Buddy and BaseEditor use the current class instance in their Parent properties.

Owner of the class instance Destructor for the class instance

Destroy is the overridden destructor for the class instance. Destroy calls the inherited destructor.

Please note: Resources allocated for BaseEditor and Buddy in the constructor are not explicitly freed in the destructor; that action is performed using the Notification that occurs when this class instance (which is the owner for those resources) is freed.
Sets the focus to the editor in the control

SetFocus is an overridden procedure which gives focus to the grouped edit control. SetFocus redirects the method call to the SetFocus method in the BaseEditor for the control.

Performs actions needed when the control receives focus

Focused is an overridden Boolean function used to perform actions needed when the control receives focus. Focused calls the Focused method in the BaseEditor for the control.

True when the control has focus Removes the text content in the control

Clear is a procedure used to remove the text content in the control. Clear class the Clear method in BaseEditor.

Clears the content for the current selection in the control Copies content in the control to the clipboard Copies content in the control to the clipboard, and removes it from the control Pastes content into the control from the clipboard Selects all of the content in the control Reverses the last edit performed on the control value Performs actions needed to validate the value for the control

ValidateEdit is a procedure used to perform actions needed to validate the value for the control. The method calls the ValidateEdit method in the BaseEditor member to validate its Text against the edit mask assigned to the property.

Indicates if the height for BaseEditor is used as the height for the control when autosizing

AutoSizeHeightIsEditHeight is a Boolean property which indicates if the height for BaseEditor is used as the height for the control when autosizing is enabled. The default value for the property is True.

AutoSizeHeightIsEditHeight is used in the implementation of the CalculatePreferredSize method called when CanAutoSize is True.

Indicates the text alignment used for the control value

Alignment is a TAlignment property which indicates the text alignment used for the control value in the BaseEditor control. Read and write access for the property value are redirected to the BaseEditor control.

The default value for the property is taLeftJustify.

Indicates if the Undo method can used to revert changes to the control value Position of the editing caret in the control Controls the case conversion used for a value entered in the control

CharCase is a TEditCharCase property that controls the case conversion used (if any) for a value entered in the control. The default value for the property is ecNormal, and indicates that no case conversion is used. See for more information about the enumeration values supported for the type.

Read and write access to the property value are redirected to the BaseEditor control.

Please note: The value in CharCase can automatically be changed to ecNormal when an edit mask is assigned to the control.
Indicates if the color in the Parent control is used

ParentColor is a Boolean property which indicates if the Color from the Parent control is used instead the value assigned to the control. When this property is True, all changes to Color in the parent will also be applied to the Color in the control, ensuring that they both contain the same value. If the Color of the control is changed by the application, then ParentColor will be automatically set to False.

Read and write access to the property value are redirected to the BaseEditor control. The defaul value for the property is False.

Using ParentColor when the Color value is clDefault can cause problems in resolving the actual color value. To obtain the Color property of a control while taking into account clDefault and ParentColor, use the GetColorResolvingParent method. This method might return a non-RGB color, but will never return clDefault. To obtain a purely RGB result use the GetRGBColorResolvingParent method.

Indicates if characters entered in the control value are hidden, displayed, or obscured Hides the current text selection in the control Maximum number of characters allowed in the editor for the control Indicates if the content in the control has been changed Indicates that only numbers can be enetered in the control value Contains the character displayed when entering a password value PopupMenu for the control Indicates if value in the control cannot be changed Number of characters in the current selection for the control Starting position for the current selection in the control Returns the selected text in the control

GetSelText is a String function used to get the selected text in the grouped edit control. Read and write access to the property are redirected to the BaseEdit property.

TabStop is a Boolean property which indicates if the control can be accessed using Tab or Shift+Tab keyboard navigation. Read and write access to the property value is redirected to the BaseEditor property.

Contains the hint text displayed for the grouped edit control

TextHint is a TTranslateString property which contains the hint text displayed for the grouped edit control. Read and write access to the property value are redirected to the BaseEditor property.

Event handler signalled when the value for the control is changed

OnChange is a TNotifyEvent property that contains the event handler signalled when the value for the control is changed. OnChange is triggered from the EditChange method called when the BaseEditor control has modified its value.

OnUTF8KeyPress uses the InternalOnEditUtf8KeyPress method as the default event handler for the control, as assigned in the Create constructor.