home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ALSTSR.ZIP / TWINDOW.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-26  |  6.1 KB  |  199 lines

  1. /* ------------------- twindow.h ----------------------- */
  2.  
  3. /*      Uncomment this for stacked windows
  4.  *      rather than layered windows.
  5.  *
  6.  * #define FASTWINDOWS
  7.  *
  8.  */
  9.  
  10. /* ------ window colors ---------- */
  11.  
  12. #ifdef WHITE    /* For conflict with conio.h    */
  13.  
  14. #undef WHITE
  15. #undef YELLOW
  16. #undef MAGENTA
  17.  
  18. #endif
  19.  
  20. #define RED   4
  21. #define GREEN 2
  22. #define BLUE  1
  23. #define AQUA (GREEN+BLUE)
  24. #define WHITE (RED+GREEN+BLUE)
  25. #define YELLOW (RED+GREEN)
  26. #define MAGENTA (RED+BLUE)
  27. #define BLACK 0
  28.  
  29. #define BRIGHT 8
  30. #define DIM 0
  31. #define BORDER 0
  32. #define TITLE 1
  33. #define ACCENT 2
  34. #define NORMAL 3
  35. #define ALL 4
  36.  
  37. #define TRUE 1
  38. #define FALSE 0
  39. #define ERROR -1
  40. #define OK 0
  41. /*page*/
  42. /* ------------- window controller structures ----------- */
  43. typedef struct field {    /* data entry field description    */
  44.     char *fmask;        /* field data entry mask        */
  45.     char *fprot;        /* field protection                */
  46.     char *fbuff;        /* field buffer                    */
  47.     int ftype;            /* field type                    */
  48.     int frow;            /* field row                    */
  49.     int fcol;            /* field column                    */
  50.     void (*fhelp)();    /* field help function            */
  51.     char *fhwin;        /* field help window            */
  52.     int flx, fly;        /* help window location            */
  53.     int (*fvalid)();    /* field validation function    */
  54.     struct field *fnxt;    /* next field on template         */
  55.     struct field *fprv;    /* previous field on template     */
  56. } FIELD;
  57. typedef struct _wnd {
  58.     int _wv;          /* true if window is visible     */
  59.     int _hd;          /* true if window was hidden     */
  60.     char *_ws;          /* points to window save block   */
  61.     char *_tl;          /* points to window title           */
  62.     int _wx;          /* nw x coordinate               */
  63.     int _wy;          /* nw y coordinate               */
  64.     int _ww;          /* window width                   */
  65.     int _wh;          /* window height                   */
  66.     int _wsp;          /* scroll pointer                   */
  67.     int _sp;          /* selection pointer               */
  68.     int _cr;          /* cursor x location               */
  69.     int btype;          /* border type                   */
  70.     int wcolor[4];      /* colors for window                */
  71.     int _pn;          /* previous normal color           */
  72.     int oldcx;          /* previous cursor x coordinate    */
  73.     int oldcy;          /* previous cursor y coordinate    */
  74.     struct _wnd *_nx; /* points to next window         */
  75.     struct _wnd *_pv; /* points to previous window     */
  76.     FIELD *_fh;          /* points to 1st data entry fld  */    
  77.     FIELD *_ft;          /* points to last data entry fld */    
  78. } WINDOW;
  79. typedef struct w_menu {
  80.     char *mname;
  81.     char **mselcs;
  82.     void (**func)();
  83. } MENU;
  84.  
  85. #define SAV     (wnd->_ws)
  86. #define WTITLE  (wnd->_tl)
  87. #define COL     (wnd->_wx)
  88. #define ROW     (wnd->_wy)
  89. #define WIDTH     (wnd->_ww)
  90. #define HEIGHT     (wnd->_wh)
  91. #define SCROLL  (wnd->_wsp)
  92. #define SELECT  (wnd->_sp)
  93. #define WCURS   (wnd->_cr)
  94. #define WBORDER    (wnd->wcolor[BORDER])
  95. #define WTITLEC    (wnd->wcolor[TITLE])
  96. #define WACCENT    (wnd->wcolor[ACCENT])
  97. #define WNORMAL    (wnd->wcolor[NORMAL])
  98. #define PNORMAL (wnd->_pn)
  99. #define BTYPE    (wnd->btype)
  100. #define NEXT    (wnd->_nx)
  101. #define PREV    (wnd->_pv)
  102. #define WCOLOR  (wnd->wcolor)
  103. #define VISIBLE (wnd->_wv)
  104. #define HIDDEN  (wnd->_hd)
  105. #define FHEAD    (wnd->_fh)
  106. #define FTAIL   (wnd->_ft)
  107.  
  108. #define NW       (wcs[wnd->btype].nw)
  109. #define NE       (wcs[wnd->btype].ne)
  110. #define SE       (wcs[wnd->btype].se)
  111. #define SW       (wcs[wnd->btype].sw)
  112. #define SIDE     (wcs[wnd->btype].side)
  113. #define LINE     (wcs[wnd->btype].line)
  114. /*page*/
  115. /* -------- function prototypes and macros -------- */
  116.  
  117. /* ------ general-purpose functions and macros ----- */
  118. void clear_screen(void);
  119. int vmode(void);
  120. void cursor(int, int);
  121. void curr_cursor(int *, int *);
  122. int cursor_type(void);
  123. void set_cursor_type(int);
  124. int get_char(void);
  125. int scroll_lock(void);
  126. #define vpoke(vseg, adr, chr) poke(vseg, adr, chr)
  127. #define vpeek(vseg, adr) peek(vseg, adr)
  128.  
  129. /* ----- window functions and macros ------- */
  130. WINDOW *establish_window(int, int, int, int);
  131. void set_border(WINDOW *, int);
  132. void set_colors(WINDOW *, int, int, int, int);
  133. void set_intensity(WINDOW *, int);
  134. void set_title(WINDOW *, char *);
  135. void display_window(WINDOW *);
  136. void delete_window(WINDOW *);
  137. void clear_window(WINDOW *);
  138. void hide_window(WINDOW *);
  139. void _Cdecl wprintf(WINDOW *, char *, ...);
  140. void wputchar(WINDOW *, int);
  141. void close_all(void);
  142. void wcursor(WINDOW *, int x, int y);
  143. void error_message(char *);
  144. void clear_message(void);
  145. int get_selection(WINDOW *, int, char *);
  146.  
  147. #define reverse_video(wnd) wnd->wcolor[3]=wnd->wcolor[2]
  148. #define normal_video(wnd) wnd->wcolor[3]=wnd->_pn
  149. #define rmove_window(wnd,x,y) repos_wnd(wnd, x, y, 0)
  150. #define move_window(wnd,x,y) repos_wnd(wnd, COL-x, ROW-y, 0)
  151. #define forefront(wnd) repos_wnd(wnd, 0, 0, 1)
  152. #define rear_window(wnd) repos_wnd(wnd, 0, 0, -1)
  153. /*page*/
  154. /* ----- internal to window processes ----- */
  155. void accent(WINDOW *);
  156. void deaccent(WINDOW *);
  157. void scroll(WINDOW *, int);
  158. void repos_wnd(WINDOW *, int, int, int);
  159. void acline(WINDOW *, int);
  160. #define accent(wnd)    acline(wnd, WACCENT)
  161. #define deaccent(wnd) acline(wnd, WNORMAL)
  162. #define clr(bg,fg,in) ((fg)|(bg<<4)|(in))
  163. #define vad(x,y) ((y)*160+(x)*2)
  164. #ifdef FASTWINDOWS
  165. #define cht(ch,at) ((ch&255)|(at<<8))
  166. #define displ(w,x,y,c,a) vpoke(VSG,vad(x+COL,y+ROW),cht((c),(a)))
  167. #define dget(w,x,y) vpeek(VSG,vad(x+COL,y+ROW))
  168. #define verify_wnd(w) ((*(w)==listtail)&&(*(w)!=0))
  169. #else
  170. void displ(WINDOW *wnd, int x, int y, int ch, int at);
  171. #endif
  172. /* ------ editor function ------- */
  173. void text_editor(WINDOW *, char *, int);
  174. /* -------- menu function ------- */
  175. void menu_select(char *name, MENU *mn);
  176. /* ----- help functions ------- */
  177. void load_help(char *);
  178. void set_help(char *, int, int);
  179. void retrieve_help(int *, int *, int *);
  180. void reset_help(int, int, int);
  181. extern void (*helpfunc)();
  182. extern void help();
  183. extern int helpkey;
  184. /* ----- data entry functions ---- */
  185. void init_template(WINDOW *);
  186. FIELD *establish_field(WINDOW *,int,int,char *,char *,int);
  187. void clear_template(WINDOW *);
  188. void field_tally(WINDOW *);
  189. int data_entry(WINDOW *);
  190. void wprompt(WINDOW *, int, int, char *);
  191. void error_message(char *);
  192. void clear_notice(void);
  193. void field_window(FIELD *, char *, int, int);
  194. #define field_protect(f,s)  f->fprot=s
  195. #define field_help(f,h)     f->fhelp=h
  196. #define field_validate(f,v) f->fvalid=v
  197. void preadjust_date(WINDOW *);
  198. void postadjust_date(WINDOW *);
  199.