home *** CD-ROM | disk | FTP | other *** search
- {*
- * TvInput.pas
- *
- * Enhancements to Turbo Vision TInputLine.
- *
- * Copyright 1992 by Richard W. Hansen
- *
- *}
-
- (*
- THERE ARE CHANGES NEEDED TO VIEWS.PAS!!!!!!
-
- <<<< AT LINE 260 MAKE Select a virtual method >>>>
- procedure Select; virtual;
- *)
-
-
-
-
- UNIT TvInput;
- {$V-}
- {$X+}
-
- {$I TVDEFS.INC}
-
- INTERFACE
-
-
- USES
- Dialogs, Drivers, Objects, Views, MsgBox,
- {$IFDEF USE_TVSCROLL}
- TvScroll,
- {$ENDIF}
- TvConst, TvString, TvType;
-
-
-
- CONST
- HideChar : Char = '*'; { character used for passwords }
-
- DecimalPt = '.';
- CommaChar = ',';
- Left = True;
- Right = False;
-
- { 3D InputLine Palette }
- { 1 = Inputline active }
- { 2 = Inputline passive }
- { 3 = Inputline selected text }
- { 4 = Inputline arrow }
- C3DInputLine = #45#45#46#47;
-
-
- TYPE
- P3DInputLine = ^T3DInputLine;
- T3DInputLine = Object(TInputLine)
- Constructor Init(var Bounds : TRect;
- AMaxLen: Integer);
- Function GetPalette: PPalette; Virtual;
- end;
-
-
- { This is the base input line for all the new data entry line objects.
- When you pass an edit mask the MaxLen is calculated automatically.
- Only the characters in the set associated with a particular edit
- mask will be accepted.
- }
- PEditLine = ^TEditLine; {$IFDEF USE_TVSCROLL}
- TEditLine = Object(TScrollInputLine){$ELSE}
- TEditLine = Object(TInputLine) {$ENDIF}
- PadChar : Char; { blank place holder char }
- XPos : Byte; { insert position }
- First : Byte; { first editable position }
- Mask : PString;{ edit mask }
- ID : Word;
- LLabel : PView;
- PostEdit : Pointer;
- EditFlags : Word;
-
- Constructor Init(var Bounds : TRect;
- EditMask : String);
- (*
- Constructor Load(var S: TStream);
- Procedure Store(var S: TStream);
- *)
- Destructor Done; Virtual;
- Procedure Merge(var St : String;
- Justify : Boolean); Virtual;
- Function Remove(St : String): String;
- Function CanScroll(ScrollLeft : Boolean): Boolean;
- Procedure Draw; Virtual;
- Procedure SelectAll(Enable : Boolean);
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
- Function NextPos(Pos : Integer): Integer; Virtual;
- Function PrevPos(Pos : Integer): Integer; Virtual;
- Function HomePos: Integer; Virtual;
- Procedure SetData(var Rec); Virtual;
- Procedure GetData(var Rec); Virtual;
- Function DataSize: Word; Virtual;
- Function EditToMaskPos(Pos : Integer): Integer;
- Function MaskToEditPos(Pos : Integer): Integer;
- Procedure DeleteMarked;
- Procedure InsertChar(Ch : Char); Virtual;
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Function Valid(Command : Word): Boolean; Virtual;
-
- Procedure SetPostEdit(P : Pointer);
- Function Empty: Boolean; Virtual;
- Procedure SetEditFlag(AFlag : Word;
- Enable: Boolean);
- Procedure AddLabel(ALabel : PView);
- Procedure Lock;
- Procedure UnLock;
- Procedure SetID(AFieldID : Word);
- Function GetID: Word;
- {$IFDEF HAVE_RTL}
- Procedure Select; Virtual;
- {$ENDIF}
- end;
-
-
- { This is the base object for all numeric edit line objects. }
- PNumericEdit = ^TNumericEdit;
- TNumericEdit = Object(TEditLine)
- ErrCode : Integer; { string to numeric conversion error }
-
- Procedure HandleEvent(var Event: TEvent); Virtual;
- Function Valid(Command : Word): Boolean; Virtual;
- Function OutOfRange: Boolean; Virtual;
- Function OutOfRangeMsg: String; Virtual;
- end;
-
-
- { TLongEdit is the base object for all integer edit lines. AMin and
- AMax define the valid range of values for the field. If AMin and
- AMax are both zero any valid number may be entered. All the types
- defined below vary only in the range of numbers that are valid and
- in the data type returned and expected by SetData and GetData.
- }
- PLongEdit = ^TLongEdit;
- TLongEdit = Object(TNumericEdit)
- Min : LongInt; { smallest acceptable value }
- Max : LongInt; { largest acceptable value }
-
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : LongInt;
- AMax : LongInt);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- Function OutOfRange: Boolean; Virtual;
- Function OutOfRangeMsg: String; Virtual;
- end;
-
-
- PIntegerEdit = ^TIntegerEdit;
- TIntegerEdit = Object(TLongEdit)
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : Integer;
- AMax : Integer);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- end;
-
-
- PWordEdit = ^TWordEdit;
- TWordEdit = Object(TLongEdit)
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : Word;
- AMax : Word);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- end;
-
-
- PByteEdit = ^TByteEdit;
- TByteEdit = Object(TLongEdit)
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : Byte;
- AMax : Byte);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- end;
-
- { THexEdit accepts long integers in hexadecimal format. }
- PHexEdit = ^THexEdit;
- THexEdit = Object(TLongEdit)
- Procedure SetData(var Rec); Virtual;
- Function OutOfRangeMsg: String; Virtual;
- end;
-
-
- { TFloatEdit is the base object for all floating point input. You may
- include a decimal point in the edit mask for floating point numbers.
- The user may only enter as many digits after the deciml point as are
- specified in the eidt mask. AMin and AMax define the valid range of
- values for the field. If AMin and AMax are both zero any valid number
- may be entered. All the floaing point types defined below vary only
- in the range of numbers that are valid and the data type returned by
- and expected by SetData and GetData.
- }
-
- PFloatEdit = ^TFloatEdit;
- TFloatEdit = Object(TNumericEdit)
- DP : Byte; { number of decimal places }
-
- Constructor Init(var Bounds : TRect;
- EditMask : String);
- Procedure HandleEvent(var Event: TEvent); Virtual;
- Procedure Merge(var St : String;
- Justify : Boolean); Virtual;
- end;
-
- {$IFOPT N+}
- PDoubleEdit = ^TDoubleEdit;
- TDoubleEdit = Object(TFloatEdit)
- Min : Double; { smallest acceptable value }
- Max : Double; { largest acceptable value }
-
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : Double;
- AMax : Double);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- Function OutOfRange: Boolean; Virtual;
- Function OutOfRangeMsg: String; Virtual;
- end;
- {$ENDIF}
-
-
- PRealEdit = ^TRealEdit;
- TRealEdit = Object(TFloatEdit)
- Min : Real; { smallest acceptable value }
- Max : Real; { largest acceptable value }
-
- Constructor Init(var Bounds : TRect;
- EditMask : String;
- AMin : Real;
- AMax : Real);
- Function DataSize: Word; Virtual;
- Procedure GetData(var Rec); Virtual;
- Procedure SetData(var Rec); Virtual;
- Function OutOfRange: Boolean; Virtual;
- Function OutOfRangeMsg: String; Virtual;
- end;
-
-
- { This descendant of TDialog has mehods for locking/unlocking fields
- on the fly. It also contains some the logic for required fields.
- If you assign an ID number to the entry fields you can later pass
- that ID to LockField to later lock or unlock a field.
- }
- PEntryDialog = ^TEntryDialog; {$IFDEF USE_TVSCROLL}
- TEntryDialog = Object(TScrollDialog) {$ELSE}
- TEntryDialog = Object(TDialog) {$ENDIF}
- Constructor Init(var Bounds : TRect;
- ATitle : TTitleStr);
- Function FindField(ID : Word): Pointer;
- Procedure LockField(ID : Word;
- Enable : Boolean);
- Procedure HandleEvent(var Event : TEvent); Virtual;
- {$IFDEF USE_TVSCROLL}
- Procedure Insert(P : PView);
- {$ENDIF}
- end;
-
-
- PNewCheckBoxes = ^TNewCheckBoxes;
- TNewCheckBoxes = Object(TCheckBoxes)
- PostEdit : Pointer;
- ID : Word;
- LLabel : PView;
- EditFlags : Word;
-
- Constructor Init(var Bounds : TRect;
- AStrings: PSItem);
- Procedure SetPostEdit(P : Pointer);
- Function Empty: Boolean; Virtual;
- Procedure SetEditFlag(AFlag : Word;
- Enable: Boolean);
- Procedure AddLabel(ALabel : PView);
- Procedure Lock;
- Procedure UnLock;
- Procedure SetID(AFieldID : Word);
- Function GetID: Word;
- {$IFDEF HAVE_RTL}
- Procedure Select; Virtual;
- {$ENDIF}
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Function Valid(Command: Word): Boolean; Virtual;
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
-
- end;
-
-
- PNewRadioButtons = ^TNewRadioButtons;
- TNewRadioButtons = Object(TRadioButtons)
- PostEdit : Pointer;
- ID : Word;
- LLabel : PView;
- EditFlags : Word;
-
- Constructor Init(var Bounds : TRect;
- AStrings: PSItem);
- Procedure SetPostEdit(P : Pointer);
- Function Empty: Boolean; Virtual;
- Procedure SetEditFlag(AFlag : Word;
- Enable: Boolean);
- Procedure AddLabel(ALabel : PView);
- Procedure Lock;
- Procedure UnLock;
- Procedure SetID(AFieldID : Word);
- Function GetID: Word;
- {$IFDEF HAVE_RTL}
- Procedure Select; Virtual;
- {$ENDIF}
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Function Valid(Command: Word): Boolean; Virtual;
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
-
- end;
-
-
- CONST
- AnyChar = 'X'; { any character }
- ForceUp = 'U'; { any character, force upper case }
- ForceLo = 'L'; { any character, force lower case }
- AlphaOnly = 'a'; { alpha numeric only }
- UpperAlpha = 'u'; { alpha numeric only, force upper case }
- LowerAlpha = 'l'; { alpha numeric only, force lower case }
- NumberOnly = '#'; { numbers, minus, period }
- DigitOnly = '9'; { numbers only }
- HexOnly = '&'; { hexadecimal numbers }
-
-
- EditMaskChars : TCharSet = [AnyChar, ForceUp, ForceLo, AlphaOnly,
- UpperAlpha, LowerAlpha, NumberOnly,
- DigitOnly, HexOnly];
-
- AnyCharSet : TCharSet = [#32..#255];
- AlphaOnlySet : TCharSet = ['0'..'9', 'A'..'Z', 'a'..'z', ' '];
- DigitOnlySet : TCharSet = ['0'..'9'];
- NumberOnlySet : TCharSet = ['0'..'9', '-'];
- HexOnlySet : TCharSet = ['0'..'9', 'A'..'F', 'a'..'f', '$'];
-
-
- DateMaskSet : TCharSet = ['m','M', 'd','D', 'y','Y', DateSlash];
-
-
-
-