home *** CD-ROM | disk | FTP | other *** search
- // ┌───────┐
- // ─────────>│ AVNER │
- // ─────────>│ BEN │──────> Software Engineering Method
- // └───────┘
- // 10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535
-
- // The Screen NAVigator, ver 1.10 April 1990
- // Copyright (c) 1989 by Avner Ben
- // Snav is not, and never was, free software.
- // for conditions for use refer to file "copyrigh.txt"
-
- // The Screen Navigator is an object-oriented device-independent
- // character-graphics driver package, written in the C++ language,
- // distributed in the form of C++ source code.
- // For further information refer to the documentation files.
-
- // this simple example is intended as a template to be extended and modified
- // by the user, provided the above title and copyright notice are unchanged
- // and are not ommitted.
-
- /***************************************************************************/
-
- // demonstration part 2 - header.
- // a simplistic formatted-input driver, implemented with the screen driver
- // of demo part 1. Device-specific assumptions made about function keys.
- // Implemented are only the methods required by the main demo program.
-
- // 28.10.89 avner ben coded.
- /////// snav v1.1
- // 8.3.90-31.3.90 avner ben:
- // * C++ v2.0 upgrade * modified some functions to return by value *
- // removed the main screen area from definition of class char_input *
- // default screen-driver allocation * made class character_input generic *
- // removed char-set dependant tests and other pc-dependant references to
- // driver *
-
- // site history (this copy):
- // __.__.__, _____________: _______________________________.
-
- #ifndef DEMO1_H
- #include "demo1.hpp"
- #endif
-
- enum func_k { // function key pressed
- K_C, // no, character pressed!
- K_RT, // right arrow
- K_UP, // up arrow
- K_LT, // left arrow
- K_DN // down arrow
- // add your own
- };
-
- class character_input
- { // interactive keyboard/console input driver
-
- private:
- boolean private_screen; // tells if delete on exit
-
- protected:
- panel *scr; // specific driver determined by caller
- char cc; // last read char. blank if fkey pressed
- func_k fkey; // last pressed fkey. 0 if char pressed.
-
- public :
- character_input(panel *inscr);
- character_input(const square_pos &window, int driver_num=0);
- ~character_input(void);
- virtual char get_c(void)=0; // implementation dependant
- virtual int charnum(char c)=0; // char-set dependant
- char c(void) { return cc; }
- func_k fk(void) { return fkey; }
-
- boolean get_position(char *prompt, panel *draw_board, boolean hilite=TRUE);
- int get_number(char *prompt, int imax);
- boolean get_boolean(char *prompt);
- weight_d get_wgt(void);
- direction get_dir(void);
- void msg(char *prompt);
- void clear(void) { scr->clear(); }
- void home(void) { scr->home(); }
- void next(void) { scr->next(); }
- void put_s(char *s) { scr->put_s(s); }
- void put_c_stay(char c)
- { scr->put_c(c,NULL,&(direction)nodir); }
- };
-
- class pc_keyboard : public character_input
- {
- public:
- pc_keyboard(panel *inscr) : character_input(inscr) {}
- pc_keyboard(const square_pos &window, int driver_num=0)
- : character_input(window, driver_num) {}
- char get_c(void);
- int charnum(char c) {
- if (c<'0' || c>'9') return 0;
- return (int)(c-'0');
- }
- };
-
- class keyboard_driver_manager
- { // run-time keyboard-implementation selector
-
- private:
- int default_kbd;
-
- public:
- keyboard_driver_manager(int def=0)
- { default_kbd=def; }
- character_input *allocate(panel *scr, int kbd_num=0);
- character_input *allocate(const square_pos &window,
- int scr_num=0, int kbd_num=0);
- int ask_default(void)
- { return default_kbd; }
- void set_default(int def)
- { default_kbd=def; }
- };
-
-
- struct slide_option
- { // linked-list of options in slide-menu
-
- char *s, // option name
- *letter, // option letter in the former
- *hlp; // explanation (in dialog area)
- int num; // option number (serial)
- point_pos pos; // position in menu area
- slide_option *next, *last;
-
- slide_option(char *text, int posopt, char *help);
- ~slide_option(void) { delete s; delete hlp; }
- void off(panel *scr)
- { scr->toggle_attr(VD_HI); scr->put_s(s,&pos); scr->toggle_attr(VD_HI); }
- void on(panel *scr) // pc-specific visual attribute codes used
- { scr->toggle_attr(VD_REV); scr->put_s(s,&pos); scr->toggle_attr(VD_REV); }
- void put_help(panel *explain)
- { explain->clear(); explain->put_s(hlp); }
- };
-
- class slide_menu
- { // slide-menu manager (like pop-up menu system topmost menu)
-
- friend struct slide_option;
-
- private :
- panel *scr, *explain; // the menu area, the help area
- slide_option *stopt, *enopt, *cursor; // ptrs to option list
-
- public :
- slide_menu(panel *parent, panel *help);
- // warning: chops top line off parent screen!
- ~slide_menu(void);
- void append_opt(char *text, int posopt, char *help);
- void next_opt(void);
- void prev_opt(void);
- int select(void);
- void clear(void) { scr->clear(); }
- };
-
- class text_window
- {
- private :
- panel *box;
-
- public:
- text_window(panel *parent, point_pos *start, char *title,
- boolean centered, char *inpline[]);
- ~text_window(void)
- { box->deframe(); delete box; }
- void pause(char *prompt);
- void put_page(char *inpline[]);
- };
-
-