home *** CD-ROM | disk | FTP | other *** search
- // INFINITY used for infinite loops -- while(!INFINITY)...
-
- #define INFINITY 0
-
- // Keystroke -- A key class for C++. Stores a key scan code with
- // KEYSTROKE::GETKEY(). Special will be 1 if alt is hit or one of the
- // other "special" keys are pressed.
-
- #define HOMEKEY 71
- #define UPARROW 72
- #define LEFTARROW 75
- #define RIGHTARROW 77
- #define ENDKEY 79
- #define DOWNARROW 80
- #define INSERTKEY 82
- #define DELETEKEY 83
-
- // Not so special keys
- #define BACKSPACE 8
- #define RETURN 13
- #define ESCAPE 27
-
- class KEYSTROKE
- {
- protected:
- union SCAN
- {
- int c;
- char ch[2];
- };
-
- void GETKEY();
-
- public:
- char lastkey; // Last key hit
- char special; // 1 if last key hit is special
- };
-
- // Derive various classes from ED. We can do less with ED itself than
- // we can with GETKEY.
-
- class ED
- {
- int row, col;
- public:
- ED(); // Edits a variable at current cursor position
- ED(int, // Edits a variable at row,
- int); // Col
- virtual void *get() = 0;
- int startrow() { return row; }
- int startcol() { return col; }
- };
-
- // EDSTR edits a simple string of a certian length at a screen position --
- // does not check to see if you went off the screen with your length
- // because I want to keep this moderately compatable with display
- // adapters that go over 80 columns.
-
- class EDSTR : public ED, public KEYSTROKE
- {
- protected:
- int datalen;
- char *data; // String to use
- int curx, // Current cursor X position
- cury; // Current cursor Y position
- int loc; // Current position in data
- virtual int RIGHT(); // Moves cursor 1 space right
- virtual int LEFT(); // Moves cursor 1 space left
- virtual int DEL(); // Deletes 1 character -- Moves everthing right 1 space
- virtual int BKSP(); // LEFT + DEL
- virtual int INS(); // Inserts a space at the cursor
- virtual int HOME(); // Home key -- moves to beginning of field
- virtual int END(); // End key -- moves to end of field
- virtual int NORMAL(); // Normal keypress -- insert in data
- public:
- EDSTR(char *, // Edit a string at the current row, col of
- int); // n length.
- EDSTR(int, // Edit a string at row, col of n length
- int, // Col
- char *, // String to edit
- int); // length
-
- void *get(); // Overrides get in ED
- };
-
- // EDFANCY - Edits a string -- Alows a mask such as " / / ". EDFANCY
- // will automagically skip over anything in that mask that is not a space.
- // The mask will be displayed before the string is edited.
- //
- // EDFANCY also does not check for bounds as some adapters may go more
- // than 80 columns. Also NORMAL still allows control chars.
-
- class EDFANCY : public EDSTR
- {
- protected:
- int ERR;
- char *mask;
- int INS();
- int DEL();
- int NORMAL();
- virtual int ISKNOWN(int);
- virtual int ISKNOWN();
- // Returns a 1 if loc (or whatever) is ' '
- virtual int onmask(); // Returns a 1 if loc is on a mask char
- virtual int onmask(int); // Returns a 1 if int is on a mask char
- public:
- EDFANCY(int, // Row
- int, // Column
- char *, // Mask
- char *, // Data
- int); // Length
- ~EDFANCY();
-
- virtual void DISPLAY(); // Displays mask before editing.
- void *get(); // Check this out down the file a ways
- };
-
- // This is the good one...
-
- // EDPIC allows the user to force input into a given picture.
- // Ex. A mask of "##/##/##" is supplied. If the user tries to enter
- // Alpha data, the data will not be accepted. The #'s will not show,
- // and the user will be able to type numbers over them.
- //
- // # - Numeric Data (0-9 and .)
- // (space) - Any data
- // A - Uppercase alpha
- // a - lowercase alpha
- // + - Extended numeric (Numeric and +,-,/,*,^,,)
- // X - Alphanumeric (No control characters)
- // H - Hex number characters 0-9 A-F
-
- class EDPIC : public EDFANCY
- {
- protected:
- int NORMAL();
- int ISKNOWN();
- int ISKNOWN(int);
- virtual int ISGOOD(int);
- virtual int ISGOOD();
- // Returns a 1 if lastkey is an acceptable character --
- // compares it to mask. Characters forced into areas
- // where they should not be with DEL and INS will go
- // away.
- public:
-
- EDPIC(int, // Row
- int, // Column
- char *, // Mask
- char *, // Data
- int); // Length
- };
-