home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
t
/
tvinp102.zip
/
TVINP102.INT
< prev
next >
Wrap
Text File
|
1992-08-21
|
8KB
|
254 lines
{ $X+,R-,S-,N+,E+,D-,L-,O+,A+,G-,B-,V- }
unit tvinp101;
interface
uses drivers,dialogs,msgbox,objects,views;
type
{--------------------------------------------------------------------------}
{ TinputAncestor is a base class for all of the other numeric input classes}
{ It is not intended to ever be instantiated }
{--------------------------------------------------------------------------}
PInputAncestor = ^TinputAncestor;
TInputAncestor = object(TInputLine)
procedure SetState(AState : word; Enable : Boolean); virtual;
procedure BadNumber; virtual;
end;
{--------------------------------------------------------------------------}
{ TInputNumerals is nothing more glorified than a TInputLine that only }
{ accepts the numbers 0..9. None of the numerical inputs are derived from }
{ it, but I have found it useful in the past }
{--------------------------------------------------------------------------}
PInputNumerals = ^TInputNumerals;
TInputNumerals = object(TInputAncestor)
procedure HandleEvent(var Event : TEvent); virtual;
end;
Pinputnumber = ^Tinputnumber;
{------------------------------------------------------------------------}
{ Tinputnumber is also base class for all of the other numeric input }
{ classes except TInputNumerals. It is not intended to ever be }
{ instantiated either. }
{------------------------------------------------------------------------}
Tinputnumber = object(TInputAncestor)
{ Methods }
{ For loading from streams }
constructor load(var s : TStream);
{ For storing to streams }
procedure store(var s : TStream); virtual;
{ Returns the byte count of the data stored. Not the length of the
string used for editing, but the actual binary number }
function datasize : word; virtual;
{ Overridden methods for data transfer with dialog boxes }
procedure getdata(var rec); virtual;
procedure setdata(var rec); virtual;
{ Handler for keyboard events to strip unwanted characters and validate
input for numbers when the focus changes }
procedure handleevent(var event : Tevent); virtual;
{ Numeric validation routine. Checks that a number is within the programmer
selected boundaries }
function valid(command:word) : boolean; virtual;
destructor done; virtual;
private
{ These variables/methods are not available for direct manipulation }
defaulted : boolean;
default_value : pointer; { Default value
initialized during construction }
storagesize : word; { This is the number returned by datasize() }
value,min,max : pointer; { Actual value storage locations }
lngth,decs : byte; { String formatting information for display }
{ The TinputNumber constructor is private to guarantee that a instance
of TinputNumber is never formally created }
constructor init(var bounds : Trect; Amaxlen : byte;
var minimum,maximum,valu; mysize : word; length,decimals : byte);
end;
Pinputint = ^Tinputint;
{ Integer dialog box input }
Tinputint = object(Tinputnumber)
{ Constructor to allow program control over allowed data values. The first
two parameters are self explanatory if you're familiar with Turbo Vision }
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : integer);
{ Creates a default integer, which allows inputs for all numbers between
-32768..32767 }
constructor default(var bounds : Trect; Amaxlen : byte);
{ Handleevent strips off all non numeric input when a TinputInt is focused }
procedure handleevent(var event : Tevent); virtual;
{ Valid checks that the integer entered is within the prescibed range }
function valid(command:word) : boolean; virtual;
end;
PInputLong = ^TInputlong;
{ Long integer input object. Methods identical to TinputInt }
TInputlong = object(TInputnumber)
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : longint);
constructor default(var bounds : Trect; Amaxlen : byte);
procedure handleevent(var event : Tevent); virtual;
function valid(command:word) : boolean; virtual;
end;
PInputReal = ^TInputReal;
{ Software real input object }
TInputReal = object(TInputnumber)
{ The TinputReal object adds the length and decimals parameters to
the constructor to allow string formatting. Use these parameters
as you would in a call to writeln(x:length:decimals) }
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : real; length,decimals : byte);
{ Provides a default real input that takes any value within the valid
range of real numbers as defined in the TP documentation }
constructor default(var bounds : Trect; Amaxlen : byte);
{ Valid for TinputReal allows entry of exponents as well as numbers and
optional sign }
function valid(command:word) : boolean; virtual;
end;
PInputSingle = ^TInputSingle;
{ Single type input object. Refer to TinputReal }
TInputSingle = object(TInputnumber)
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : single; length,decimals : byte);
constructor default(var bounds : Trect; Amaxlen : byte);
function valid(command:word) : boolean; virtual;
end;
PInputDouble = ^TInputDouble;
{ Double type input object. Refer to TinputReal }
TInputDouble = object(TInputnumber)
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : double; length,decimals : byte);
constructor default(var bounds : Trect; Amaxlen : byte);
function valid(command:word) : boolean; virtual;
end;
PInputExtended = ^TInputExtended;
{ Extended type input object. Refer to TinputReal }
TInputExtended = object(TInputnumber)
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : extended; length,decimals : byte);
constructor default(var bounds : Trect; Amaxlen : byte);
function valid(command:word) : boolean; virtual;
end;
PInputComp = ^TInputComp;
{ Comp type input object }
TInputComp = object(TInputnumber)
{ The TinputComp constructor adds a length parameter, but no decimals
parameter since comp types are whole numbers }
constructor init(var bounds : Trect; Amaxlen : byte;
minimum,maximum,valu : comp; length,decimals: byte);
constructor default(var bounds : Trect; Amaxlen : byte);
function valid(command:word) : boolean; virtual;
end;
{ These are the stream registration records for use with the above
objects. You must register each individual object with Turbo Vision
before any reading or writing to/from streams can take place.
A procedure called RegisterNumerics is provided to register all of
the provided objects }
const
Immediate_Checking : Boolean = True;
Rinputint : Tstreamrec = (
objtype : 700;
vmtlink : ofs(typeof(Tinputint)^);
load : @Tinputint.load;
store : @Tinputint.store
);
Rinputlong : Tstreamrec = (
objtype : 701;
vmtlink : ofs(typeof(Tinputlong)^);
load : @Tinputlong.load;
store : @Tinputlong.store
);
Rinputreal : Tstreamrec = (
objtype : 702;
vmtlink : ofs(typeof(Tinputreal)^);
load : @Tinputreal.load;
store : @Tinputreal.store
);
Rinputsingle : Tstreamrec = (
objtype : 703;
vmtlink : ofs(typeof(Tinputsingle)^);
load : @Tinputsingle.load;
store : @Tinputsingle.store
);
Rinputdouble : Tstreamrec = (
objtype : 704;
vmtlink : ofs(typeof(Tinputdouble)^);
load : @Tinputdouble.load;
store : @Tinputdouble.store
);
Rinputextended : Tstreamrec = (
objtype : 705;
vmtlink : ofs(typeof(Tinputextended)^);
load : @Tinputextended.load;
store : @Tinputextended.store
);
Rinputcomp : Tstreamrec = (
objtype : 706;
vmtlink : ofs(typeof(Tinputcomp)^);
load : @Tinputcomp.load;
store : @Tinputcomp.store
);
Rinputnumerals : Tstreamrec = (
objtype : 707;
vmtlink : ofs(typeof(Tinputnumerals)^);
load : @Tinputnumerals.load;
store : @Tinputnumerals.store
);
{ Procedure to call RegisterType() for all of the provided input types }
procedure RegisterNumerics;
implementation
begin
new(limits[1]);
new(limits[2]);
end.