1. TNumIO
const
{$IFDEF PAIDVERS}
SDLVersionInfo = 'numio_r900_full';
IsLightEd = false;
{$ELSE}
SDLVersionInfo = 'numio_r900_lighted';
IsLightEd = true;
{$ENDIF}
Release = 900;
type
TInFormat =(itExp,itFloat,itFixPoint,itInt,itHex,itOct,itBin,itDynamic);
TNumIO = class(TCustomEdit)
private
FInFormat : TInFormat; { type of display: dec, hex,... }
FFixPDecPl : integer;
FOldText : String; {caches the input string to handle errors}
FInternalChg : boolean;
FBeep : boolean; { beep on illegal inputs? }
FMinimum : double; { minimum allowed value }
FMaximum : double; { maximum allowed value }
FDecPSep : TDecPSep;
procedure SetInputFormat (value: TInFormat);
procedure SetRangeLow (value: double);
procedure SetRangeHigh (value: double);
procedure SetLabValue (x: double);
function GetLabValue: double;
procedure SetDecPSep (Value: TDecPSep);
procedure SetFixPDecPl (value: integer);
procedure SetEditText (txt: string);
protected
procedure AssignTo (Dest: TPersistent); override;
function ConvertNumString (Instring: String;
var DReslt: double): boolean;
procedure Change; override;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign (Source: TPersistent); override;
property Value: double read GetLabValue write SetLabValue;
published
{$IFNDEF VER110} // CBuilder 3.0 does not know about anchors
{$IFNDEF VER100} // Delphi 3.0 does not know about anchors
property Anchors;
{$ENDIF}
{$ENDIF}
property Align;
property AutoSelect;
property AutoSize;
property Beep: boolean read FBeep write FBeep;
property BorderStyle;
property Color;
{$IFNDEF ISCLX}
property Ctl3D;
property ParentCtl3D;
{$ENDIF}
property Cursor;
property DecPlaceSep: TDecPSep read FDecPSep write SetDecPSep;
property Enabled;
property FixPointDecPlaces: integer
read FFixPDecPl write SetFixPDecPl;
property Font;
property Height;
property HelpContext;
property HideSelection;
property Hint;
property InputFormat: TInFormat read FInFormat write SetInputFormat;
property Left;
property RangeHigh: double
read FMaximum write SetRangeHigh stored TRUE;
property RangeLow: double
read FMinimum write SetRangeLow stored TRUE;
property ReadOnly;
property Name;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Tag;
property Text;
property Top;
property Visible;
property Width;
property OnChange;
property OnClick;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
2. TNumIO2
const
defLeftSpace = 35; // default left space
defFixP = 2; // number of decimal places
defTextBoxWidth = 80; // default width of input text box
type
ESDLNumIO2Error = class(ESDLError); // exception type to indicate errors
TNumIO2 = class (TCustomControl)
private
FLeftSpace : integer; // space for text left to the input box
FTextBoxWidth : integer; // width of numeric field
FDecP : integer; // no. of dec, places - fixed point
FEnabled : boolean; // TRUE: control is enabled
FCaretTimerH : HWND; // handle for caret blinking timer
FInBuffer : string; // input buffer
FCaretPos : integer; // caret position
FCaretVisib : boolean; // visibility state of caret
FLeftText : string; // text at left of the input box
FRightText : string; // text at right of the input box
FFrameStyle : TFrameStyle; // style of frame
FAlignment : TAlignment; // alignment of num. input text
FLTAlignment : TAlignment; // alignment of left text
FRTAlignment : TAlignment; // alignment of right text
FMouseAreaCode : integer; // mouse pos. - area code
FColorBoxBG : TColor; // color of text box background
FColorBoxText : TColor; // color of text box
FColorOutBG : TColor; // color of outer background
FColorOutText : TColor; // color of outer text
FColBlackLine : TColor; // colors to draw the frame
FColGrayLine : TColor; // -"-
FColWhiteLine : TColor; // -"-
FColorWarnBG : TColor; // range over/underflow warning color
FColorWarnTxt : TColor; // range over/underflow warning color
FColorScheme : TColorScheme; // color scheme of frames
FSelBegin : integer; // begin of selection range
FSelEnd : integer; // end of selection range
FDecPSep : TDecPSep; // decimal place separator
FInputFormat : TInFormat; // type of display: dec., hex,...
FKeyShifted : boolean; // key state (shift)
FKeyCntrl : boolean; // key state (control)
FHideSel : boolean; // hide selection when no focus
FMaximum : double; // lower border of allowed range
FMinimum : double; // upper border of allowed range
FOnlineCheck : boolean; // perform online check of borders
FBeep : boolean; // sound if invalid input
FReadOnly : boolean; // no input possible
FAutoSize : boolean; // adjust height automatically
FOnChange : TNotifyEvent; // OnChange event
procedure SetLeftSpace (Value: integer);
procedure SetColorBoxBG (Value: TColor);
procedure SetColorBoxText (Value: TColor);
procedure SetColorOutBG (Value: TColor);
procedure SetColorOutText (Value: TColor);
procedure SetColorScheme (Value: TColorScheme);
procedure SetFrameStyle (value: TFrameStyle);
procedure SetAlignment (value: TAlignment);
procedure SetLTAlignment (value: TAlignment);
procedure SetRTAlignment (value: TAlignment);
procedure SetTextBoxWidth (value: integer);
procedure SetNioText (value: string);
procedure SetNioValue (value: double);
function GetNioValue: double;
procedure SetReadonly (value: boolean);
procedure SetAutoSize (value: boolean);
procedure SetHideSel (value: boolean);
procedure SetDecP (value: integer);
procedure SetDecSep (value: TDecPSep);
procedure SetSelBegin (value: integer);
procedure SetSelEnd (value: integer);
procedure SetLeftText (value: string);
procedure SetRightText (value: string);
procedure SetInFormatType (value: TInFormat);
procedure SetColorWarnBG (value: TColor);
procedure SetColorWarnBoxText (value: TColor);
procedure SetRangeLow (value: double);
procedure SetRangeHigh (value: double);
procedure CNKeyDown(var Message: TWMKeyDown); message CN_KEYDOWN;
procedure CNKeyUp(var Message: TWMKeyUp); message CN_KEYUP;
procedure UpdateTimer;
function XCoordsToCharPos (X: integer): integer;
function CharPosToXCoords (cp: integer): integer;
protected
procedure AssignTo (Dest: TPersistent); override;
procedure MouseMove (Shift: TShiftState; X,Y: integer); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure Paint; override;
procedure Click; override;
procedure CaretTimerEvent(Sender: TObject);
procedure SetEnabled (value: boolean); override;
procedure WndProc(var Msg: TMessage); // virtual method of base class
// is hidden deliberately
public
procedure Assign(Source: TPersistent); override;
procedure Changed;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CheckValidity (Instring: string): boolean;
property MouseAreaCode: integer read FMouseAreaCode;
property SelBegin: integer read FSelBegin write SetSelBegin;
property SelEnd: integer read FSelEnd write SetSelEnd;
published
property Align;
property Alignment: TAlignMent read FAlignment write SetALignment;
property Anchors;
property AutoSize: boolean read FAutoSize write SetAutoSize;
property Beep: boolean read FBeep write FBeep;
property ColorBoxBG: TColor
read FColorBoxBG write SetColorBoxBG;
property ColorBoxText: TColor
read FColorBoxText write SetColorBoxText;
property ColorOutBG: TColor
read FColorOutBG write SetColorOutBG;
property ColorOutText: TColor
read FColorOutText write SetColorOutText;
property ColorScheme: TColorScheme
read FColorScheme write SetColorScheme;
property ColorWarnBG: TColor
read FColorWarnBG write SetColorWarnBG;
property ColorWarnText: TColor
read FColorWarnTxt write SetColorWarnBoxText;
property Cursor;
property DecPlaceSep: TDecPSep read FDecPSep write SetDecSep;
property Enabled: boolean read FEnabled write SetEnabled;
property FixPointDecPlaces: integer read FDecP write SetDecP;
property Font;
property FrameStyle: TFrameStyle
read FFrameStyle write SetFrameStyle;
property Height;
property HelpContext;
property HideSelection: boolean read FHideSel write SetHideSel;
property Hint;
property InputFormat: TInFormat
read FInputFormat write SetInFormatType;
property Left;
property LeftSpace: integer read FLeftSpace write SetLeftSpace;
property LeftText: string read FLeftText write SetLefttext;
property LeftTextAlignment: TAlignMent
read FLTAlignment write SetLTAlignment;
property Name;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property RangeHigh: double
read FMaximum write SetRangeHigh stored TRUE;
property RangeLow: double
read FMinimum write SetRangeLow stored TRUE;
property ReadOnly: boolean read FReadOnly write SetReadOnly;
property RightText: string read FRightText write SetRightText;
property RightTextAlignment: TAlignment
read FRTAlignment write SetRTAlignment;
property ShowHint;
property TabOrder;
property TabStop;
property Tag;
property Text: string read FInBuffer write SetNioText;
property TextBoxWidth: integer read FTextBoxWidth write SetTextBoxWidth;
property Top;
property Value: double read GetNioValue write SetNioValue;
property Visible;
property Width;
property OnClick;
property OnDblClick;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnKeyPress;
property OnKeyUp;
property OnKeyDown;
property OnEnter;
property OnExit;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
|