Reference TCustomSlideEdit
Declared in Codebot.Controls.Edits.pas on line 57
TCustomSlideEdit is an edit for a number between Min and Max with a spin button on its right. Pressing the button pops up a slide bar under the mouse, and dragging while the button is held moves the slide bar. The up and down arrow keys change the value by Step. Text typed in the edit is converted to a number, and the text is formatted when the edit loses focus.
TCustomSlideEdit = class(TSurfaceCustomControl)
protected
{ Return the text of the inner edit }
function RealGetText: TCaption; override;
{ Set the text of the inner edit }
procedure RealSetText(const Value: TCaption); override;
procedure CreateWnd; override;
procedure FontChanged(Sender: TObject); override;
procedure Loaded; override;
procedure Resize; override;
{ The height the inner edit needs to show its text }
function EditHeight: Integer;
{ Extra height reserved below the inner edit by descendants }
function ExtraHeight: Integer; virtual;
{ The bounds of the spin button }
function GetButtonRect: TRectI; virtual;
{ The bounds of the inner edit }
function GetEditRect: TRectI; virtual;
{ Position the inner edit inside the edit rect }
procedure AdjustEdit; virtual;
{ Set the height to fit the font when AutoHeight is true }
procedure AdjustHeight; virtual;
{ Pop up the slide bar under the mouse }
procedure DoButtonPress; virtual;
{ Convert the text typed by the user to a position }
procedure DoChange; virtual;
{ Return the text shown for a position, invoking OnFormat }
function DoFormat(const Value: Double): string; virtual;
{ Invoke OnValueChange }
procedure DoValueChange; virtual;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseLeave; override;
procedure Draw; override;
{ The edit where text is typed }
property InnerEdit: TEdit read FEdit;
{ The popup holding the slide bar }
property Popup: TPopupSlideForm read FPopup;
{ Popped is true while the slide bar is shown }
property Popped: Boolean read FPopped;
{ ButtonDown is true while the spin button is pressed }
property ButtonDown: Boolean read FButtonDown;
{ ButtonHot is true while the mouse is over the spin button }
property ButtonHot: Boolean read FButtonHot;
{ When true the height follows the font }
property AutoHeight: Boolean read FAutoHeight write SetAutoHeight default True;
{ The smallest value }
property Min: Double read GetMin write SetMin;
{ The largest value }
property Max: Double read GetMax write SetMax;
{ The current value }
property Position: Double read GetPosition write SetPosition;
{ The amount the arrow keys change the value, and when greater than zero the
value snaps to multiples of step }
property Step: Double read GetStep write SetStep;
{ OnDrawBackground allows custom drawing of the popup slide bar track }
property OnDrawBackground: TDrawStateEvent read GetOnDrawBackground write SetOnDrawBackground;
{ OnDrawThumb allows custom drawing of the popup slide bar thumb }
property OnDrawThumb: TDrawStateEvent read GetOnDrawThumb write SetOnDrawThumb;
{ OnFormat allows the text shown for a value to be changed }
property OnFormat: TFormatTextEvent read FOnFormat write FOnFormat;
{ OnValueChange is invoked when the position changes }
property OnValueChange: TNotifyEvent read FOnValueChange write FOnValueChange;
public
{ Create a new slide edit }
constructor Create(AOwner: TComponent); override;
{ The text in the edit }
property Text;
end;See also
TDrawStateEvent in Codebot.Graphics.pas
TFormatTextEvent in Codebot.Controls.Sliders.pas
TRectI in Codebot.Graphics.Types.pas
TSurfaceCustomControl in Codebot.Controls.pas