home *** CD-ROM | disk | FTP | other *** search
- {$X+,R-,S-,N+,E+,D-,L-,O+,F+,A+,G-,B-,V-}
- UNIT tvinp101;
-
- INTERFACE
-
- USES drivers, dialogs, msgbox, objects, views;
-
- TYPE
-
- pinputnumber = ^tinputnumber;
-
- {------------------------------------------------------------------------}
- { Tinputnumber is a base class for all of the other numeric input classes}
- { It is not intended to ever be instantiated }
- {------------------------------------------------------------------------}
- tinputnumber = OBJECT (tinputline)
- { 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; { Flag to indicate which constructor was called }
- 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.
- Minimum and maximum are the min/max values that the input line will
- accept. Valu is the initial value the input will take. }
-
- 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
- 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
- );
-
- { Procedure to call RegisterType() for all of the provided input types }
- PROCEDURE registernumerics;
-
- IMPLEMENTATION
-
- { Object methods and support routines }
- BEGIN
- { Note the automatic initialize of these two type pstring variables }
- NEW (limits [1]^);
- NEW (limits [2]^);
- END.
-
-
-