home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / cxl-1.zip / CXLWIN.H < prev    next >
C/C++ Source or Header  |  1989-03-27  |  21KB  |  417 lines

  1. /*
  2.    ┌──────────────────────────────────────────────────────────────────────────┐
  3.    │                                                                          │
  4.    │  CXLWIN.H  -  CXL is Copyright (c) 1987-1989 by Mike Smedley.            │
  5.    │                                                                          │
  6.    │  This header file contains function prototypes and definitions for       │
  7.    │  windowing functions.                                                    │
  8.    │                                                                          │
  9.    └──────────────────────────────────────────────────────────────────────────┘
  10. */
  11.  
  12. #if defined(__TURBOC__)                     /* Turbo C */
  13.     #if __STDC__
  14.         #define _Cdecl
  15.     #else
  16.         #define _Cdecl  cdecl
  17.     #endif
  18.     #define _Near
  19. #elif defined(__ZTC__)                      /* Zortech C++ */
  20.     #define _Cdecl
  21.     #define _Near
  22. #elif defined(M_I86) && !defined(__ZTC__)   /* Microsoft C/QuickC */
  23.     #if !defined(NO_EXT_KEYS)
  24.         #define _Cdecl  cdecl
  25.         #define _Near   near
  26.     #else
  27.         #define _Cdecl
  28.         #define _Near
  29.     #endif
  30. #elif defined(__POWERC__)                   /* Power C */
  31.     #define _Cdecl
  32.     #define _Near
  33. #endif
  34.  
  35.  
  36. /*------------------------------[ WINDOW type ]------------------------------*/
  37.  
  38. typedef int     WINDOW;
  39.  
  40. /*---------------------------[ function prototypes ]-------------------------*/
  41.  
  42. int      _Cdecl wactiv(WINDOW whandle);
  43. int      _Cdecl wborder(int btype);
  44. int      _Cdecl wbox(int wsrow,int wscol,int werow,int wecol,int btype
  45.                 ,int attr);
  46. int      _Cdecl wcclear(int attr);
  47. int      _Cdecl wcenters(int wrow,int attr,char *str);
  48. int      _Cdecl wchgattr(int battr,int wattr);
  49. int      _Cdecl wchkbox(int wsrow,int wscol,int werow,int wecol);
  50. int      _Cdecl wchkcol(int wcol);
  51. int      _Cdecl wchkcoord(int wrow,int wcol);
  52. int      _Cdecl wchkrow(int wrow);
  53. int      _Cdecl wclose(void);
  54. int      _Cdecl wcloseall(void);
  55. int      _Cdecl wclreol(void);
  56. int      _Cdecl wclreos(void);
  57. WINDOW   _Cdecl wcopy(int nsrow,int nscol);
  58. int      _Cdecl wdelline(int wrow,int direc);
  59. int      _Cdecl wdump(void);
  60. int      _Cdecl wdupc(int ch,int count);
  61. int      _Cdecl wdups(char *str,int count);
  62. char    *_Cdecl werrmsg(void);
  63. int      _Cdecl wfill(int wsrow,int wscol,int werow,int wecol,int ch,int attr);
  64. struct   _wrec_t *_Cdecl wfindrec(WINDOW whandle);
  65. int      _Cdecl wgetc(void);
  66. int      _Cdecl wgetchf(char *valid,int defchar);
  67. int      _Cdecl wgetns(char *str,int maxchars);
  68. int      _Cdecl wgets(char *str);
  69. int      _Cdecl wgotoxy(int wrow,int wcol);
  70. WINDOW   _Cdecl whandle(void);
  71. int      _Cdecl whelpcat(int cat);
  72. int      _Cdecl whelpclr(void);
  73. int      _Cdecl whelpdef(char *file,unsigned key,int winattr,int textattr,
  74.                          int selattr,int barattr,void (_Cdecl *open)(void));
  75. int      _Cdecl whelpop(void);
  76. int      _Cdecl whelpopc(void);
  77. int      _Cdecl whelpush(void);
  78. int      _Cdecl whelpushc(int cat);
  79. int      _Cdecl whide(void);
  80. int      _Cdecl whline(int wsrow,int wscol,int count,int btype,int attr);
  81. WINDOW   _Cdecl windowat(int row,int col);
  82. int      _Cdecl winpbeg(int fieldattr,int textattr);
  83. int      _Cdecl winpdef(int wrow,int wcol,char *str,char *format,int fconv,
  84.                         int mode,int (_Cdecl *validate) (char *),int help);
  85. int      _Cdecl winpfba(void (_Cdecl *before)(void),
  86.                         void (_Cdecl *after)(void));
  87. struct _field_t *_Cdecl winpffind(int wrow,int wcol);
  88. int      _Cdecl winpread(void);
  89. int      _Cdecl winputsf(char *str,char *fmt);
  90. int      _Cdecl winsline(int wrow,int direc);
  91. int      _Cdecl wmenubeg(int srow,int scol,int erow,int ecol,int btype,
  92.                          int battr,int wattr,void (_Cdecl *open)(void));
  93. int      _Cdecl wmenubegc(void);
  94. int      _Cdecl wmenuend(int taginit,int menutype,int barwidth,int textpos,
  95.                          int textattr,int scharattr,int noselattr,int barattr);
  96. int      _Cdecl wmenuget(void);
  97. int      _Cdecl wmenuiba(void (_Cdecl *before)(void),
  98.                          void (_Cdecl *after)(void));
  99. struct   _item_t *_Cdecl wmenuifind(int tagid);
  100. int      _Cdecl wmenuitem(int wrow,int wcol,char *str,int schar,int tagid,
  101.                           int fmask,void (_Cdecl *select)(void),
  102.                           unsigned hotkey,int help);
  103. int      _Cdecl wmenuitxt(int wrow,int wcol,int attr,char *str);
  104. int      _Cdecl wmessage(char *str,int border,int leftofs,int attr);
  105. int      _Cdecl wmove(int nsrow,int nscol);
  106. WINDOW   _Cdecl wopen(int srow,int scol,int erow,int ecol,int btype,int battr,
  107.                       int wattr);
  108. int      _Cdecl wperror(char *message);
  109. int      _Cdecl wpgotoxy(int wrow,int wcol);
  110. char    *_Cdecl wpickfile(int srow,int scol,int erow,int ecol,int btype,
  111.                           int bordattr,int winattr,int barattr,int title,
  112.                           char *filespec,void (_Cdecl *open)(void));
  113. int      _Cdecl wpickstr(int srow,int scol,int erow,int ecol,int btype,
  114.                          int bordattr,int winattr,int barattr,char *strarr[],
  115.                          void (_Cdecl *open)(void));
  116. int      _Cdecl wprintc(int wrow,int wcol,int attr,int ch);
  117. int      _Cdecl wprintf(const char *format,...);
  118. int      _Cdecl wprints(int wrow,int wcol,int attr,char *str);
  119. int      _Cdecl wprintsf(int wrow,int wcol,int attr,char *format,char *str);
  120. int      _Cdecl wputc(int ch);
  121. int      _Cdecl wputns(char *str,int width);
  122. int      _Cdecl wputs(char *str);
  123. int      _Cdecl wputsw(char *str);
  124. int      _Cdecl wreadcur(int *wrow,int *wcol);
  125. void     _Cdecl wrestore(int *wbuf);
  126. int      _Cdecl wrjusts(int wrow,int wjcol,int attr,char *str);
  127. int     *_Cdecl wsave(int srow,int scol,int erow,int ecol);
  128. int      _Cdecl wscanf(const char *format,...);
  129. int      _Cdecl wscroll(int count,int direc);
  130. int      _Cdecl wscrollbox(int wsrow,int wscol,int werow,int wecol,int count,
  131.                            int direction);
  132. int      _Cdecl wselstr(int wrow,int wcol,int attr,char *strarr[]);
  133. int      _Cdecl wshadoff(void);
  134. int      _Cdecl wshadow(int attr);
  135. int      _Cdecl wsize(int nerow,int necol);
  136. int      _Cdecl wtextattr(int attr);
  137. int      _Cdecl wtitle(char *str,int tpos,int tattr);
  138. int      _Cdecl wunhide(WINDOW whandle);
  139. int      _Cdecl wvline(int wsrow,int wscol,int count,int btype,int attr);
  140. int      _Cdecl wwprints(WINDOW whandle,int wrow,int wcol,int attr,char *str);
  141.  
  142. /*-------------[ error codes returned from windowing functions ]-------------*/
  143.  
  144. #define W_NOERROR   0       /* no error                          */
  145. #define W_ESCPRESS  1       /* Escape key was pressed            */
  146. #define W_ALLOCERR  2       /* memory allocation error           */
  147. #define W_NOTFOUND  3       /* record not found                  */
  148. #define W_NOACTIVE  4       /* no active window                  */
  149. #define W_INVCOORD  5       /* invalid coordinates               */
  150. #define W_INVFORMT  6       /* invalid format string             */
  151. #define W_NOINPDEF  7       /* no input fields defined           */
  152. #define W_STRLONG   8       /* string too long for window        */
  153. #define W_INVBTYPE  9       /* invalid box type                  */
  154. #define W_NOBORDER  10      /* no window border                  */
  155. #define W_NOHIDDEN  11      /* no hidden windows                 */
  156. #define W_NOTHIDD   12      /* window is not hidden              */
  157. #define W_NOSELECT  13      /* no selectable menu items          */
  158. #define W_NOITMDEF  14      /* no menu items defined             */
  159. #define W_NOMNUEND  15      /* no end of menu specified          */
  160. #define W_NOMNUDEF  16      /* no menu defined                   */
  161. #define W_NOMNUBEG  17      /* no begin of menu specified        */
  162. #define W_NOFRMDEF  18      /* no form defined                   */
  163. #define W_NOFRMBEG  19      /* no begin of form specified        */
  164. #define W_NOHLPDEF  20      /* no help record defined            */
  165. #define W_HLPSTKOV  21      /* help stack overflow               */
  166. #define W_HLPSTKUN  22      /* help stack underflow              */
  167. #define W_DOSERROR  23      /* DOS error                         */
  168. #define W_NOMATCH   24      /* no files matched input filespec   */
  169.                                            
  170. /*---------------[ direction codes for scrolling functions ]----------------*/
  171.  
  172. #define SDOWN   0   /* scroll down */
  173. #define SUP     1   /* scroll up   */
  174.  
  175. /*----------------------[ menu item record definition ]----------------------*/
  176.  
  177. struct _item_t {
  178.     struct _item_t *prev;   /* pointer to previous record      */
  179.     struct _item_t *next;   /* pointer to next record          */
  180.     void *child;            /* pointer to submenu's record     */
  181.     char *str;              /* address of selection string     */
  182.     char *desc;             /* text description of menu option */
  183.     void (*select) (void);  /* address of selection function   */
  184.     void (*before) (void);  /* address of "before" function    */
  185.     void (*after)  (void);  /* address of "after"  function    */
  186.     int tagid;              /* tag identifier                  */
  187.     int help;               /* help category number            */
  188.     unsigned hotkey;        /* hot key to select function      */
  189.     unsigned char schar;    /* quick selection character       */
  190.     unsigned char wrow;     /* start of text - window row      */
  191.     unsigned char wcol;     /* start of text - window column   */
  192.     unsigned char fmask;    /* special feature mask            */
  193.     unsigned char dwrow;    /* description window row          */
  194.     unsigned char dwcol;    /* description window column       */
  195.     unsigned char dattr;    /* description attribute           */
  196.     unsigned char redisp;   /* redisplay flag                  */
  197. };
  198.  
  199. /*--------------------[ window menu record definition ]----------------------*/
  200.  
  201. struct _menu_t {
  202.     struct _menu_t *prev;       /* pointer to prev menu structure   */
  203.     struct _menu_t *next;       /* pointer to next menu structure   */
  204.     struct _menu_t *parent;     /* pointer to parent menu           */
  205.     struct _item_t *item;       /* pointer to head menu item        */
  206.     struct _item_t *citem;      /* pointer to current menu item     */
  207.     void (*open) (void);        /* address of post-opening function */
  208.     int tagcurr;                /* tag ID of item selection bar on  */
  209.     unsigned char usecurr;      /* will menu use current window?    */
  210.     unsigned char srow;         /* starting row of menu window      */
  211.     unsigned char scol;         /* starting column of menu window   */
  212.     unsigned char erow;         /* ending row of menu window        */
  213.     unsigned char ecol;         /* ending column of menu window     */
  214.     unsigned char btype;        /* menu window border type          */
  215.     unsigned char battr;        /* menu window border attribute     */
  216.     unsigned char wattr;        /* menu window attribute            */
  217.     unsigned char menutype;     /* menu type mask                   */
  218.     unsigned char barwidth;     /* width of menu bar or zero        */
  219.     unsigned char textpos;      /* offset of text from start of bar */
  220.     unsigned char textattr;     /* attribute of menu text           */
  221.     unsigned char scharattr;    /* attribute of selection character */
  222.     unsigned char noselattr;    /* non-selectable text attribute    */
  223.     unsigned char barattr;      /* attribute of selection bar       */
  224. };
  225.  
  226. /*-----------------------[ window information record ]-----------------------*/
  227.  
  228. struct _winfo_t {
  229.     struct _wrec_t  *active;    /* pointer to active window         */
  230.     struct _wrec_t  *hidden;    /* pointer to head hidden window    */
  231.     struct _menu_t  *menu;      /* pointer to head menu record      */
  232.     struct _menu_t  *cmenu;     /* pointer to current menu record   */
  233.     WINDOW handle;              /* last handle given to a window    */
  234.     int help;                   /* current help category            */
  235.     int errno;                  /* error num from last window func  */
  236.     int total;                  /* total number of open windows     */
  237.     int mlevel,ilevel;          /* system variables used in menus   */
  238.     unsigned char esc;          /* check for Esc in input funcions? */
  239.     unsigned char tabwidth;     /* window TTY output tab width      */
  240.     char fillch;                /* character to fill windows with   */
  241. };
  242.  
  243. extern struct _winfo_t _Near _Cdecl _winfo;
  244.  
  245. /*-------------------[ fmask definitions for wmenuitem() ]-------------------*/
  246.  
  247. #define M_HASPD     1   /* has pull-down menu attached   */
  248. #define M_NOSEL     2   /* is not selectable             */
  249. #define M_CLOSE     4   /* close this menu when selected */
  250. #define M_CLALL     8   /* close all menus when selected */
  251.  
  252. /*------------------[ menutype definitions for wmenuend() ]------------------*/
  253.  
  254. #define M_HORZ      1       /* horizontal menu         */
  255. #define M_VERT      2       /* vertical menu           */
  256. #define M_OMNI      7       /* omnidirectional menu    */
  257. #define M_PD        8       /* pull-down menu          */
  258. #define M_NOQS      16      /* disable quick selection */
  259. #define M_SAVE      32      /* save last bar position  */
  260.  
  261. /*------------------[ special return codes from wmenuget() ]-----------------*/
  262.  
  263. #define M_EXIT      32764   /* exit menu               */
  264. #define M_EXITALL   32765   /* exit all menus          */
  265. #define M_PREVPD    32766   /* previous pull-down menu */
  266. #define M_NEXTPD    32767   /* next pull-down menu     */
  267.  
  268. /*---------------------[ window input field definition ]---------------------*/
  269.  
  270. struct _field_t {
  271.     struct _field_t *prev;      /* pointer to previous field       */
  272.     struct _field_t *next;      /* pointer to next field           */
  273.     char *str;                  /* address of receiving string     */
  274.     char *buf;                  /* address of temp receive string  */
  275.     char *format;               /* input field format string       */
  276.     int (*validate) (char *);   /* address of validation function  */
  277.     void (*before) (void);      /* address of "before" function    */
  278.     void (*after)  (void);      /* address of "after"  function    */
  279.     int help;                   /* help category number            */
  280.     int lenbuf;                 /* length of buffer                */
  281.     int lenfld;                 /* length of screen input field    */
  282.     int lenfmt;                 /* length of format string         */
  283.     unsigned char wrow;         /* start of input - window row     */
  284.     unsigned char wcol;         /* start of input - window column  */
  285.     unsigned char mode;         /* 0=init, 1=update, 2=cond update */
  286.     unsigned char decpos;       /* decimal position (numeric)      */
  287.     unsigned char redisp;       /* redisplay flag                  */
  288.     char fconv;                 /* field conversion character      */
  289. };
  290.                                  
  291. /*-------------------[ window data entry form definition ]-------------------*/
  292.  
  293. struct _form_t {
  294.     struct _form_t  *prev;      /* pointer to previous form record */
  295.     struct _form_t  *next;      /* pointer to next form record     */
  296.     struct _field_t *field;     /* pointer to head field record    */
  297.     struct _field_t *cfield;    /* pointer to current field record */
  298.     char *pformat;              /* format string pointer           */
  299.     char *pbuf;                 /* buffer string pointer           */
  300.     unsigned char cwrow;        /* current window row              */
  301.     unsigned char cwcol;        /* current window column           */
  302.     unsigned char decimal;      /* decimal field flag              */
  303.     unsigned char insert;       /* insert mode flag                */
  304.     unsigned char fieldattr;    /* field attribute                 */
  305.     unsigned char textattr;     /* text attribute                  */
  306. };
  307.  
  308. /*----------------------[ structure of window records ]----------------------*/
  309.  
  310. struct _wrec_t {
  311.     struct _wrec_t *prev;   /* pointer to previous window record */
  312.     struct _wrec_t *next;   /* pointer to next window record     */
  313.     struct _form_t *form;   /* pointer to head form record       */
  314.     int *wbuf;              /* address of window's buffer        */
  315.     int *wsbuf;             /* address of window shadow's buffer */
  316.     char *title;            /* address of window's title string  */
  317.     WINDOW whandle;         /* window's handle                   */
  318.     int help;               /* help category number              */
  319.     unsigned char srow;     /* start row of window               */
  320.     unsigned char scol;     /* start column of window            */
  321.     unsigned char erow;     /* end row of window                 */
  322.     unsigned char ecol;     /* end column of window              */
  323.     unsigned char btype;    /* window's box type                 */
  324.     unsigned char wattr;    /* window's initial text attribute   */
  325.     unsigned char battr;    /* atrribute of window's border      */
  326.     unsigned char border;   /* has border?  0 = no, 1 = yes      */
  327.     unsigned char row;      /* window's current cursor row       */
  328.     unsigned char column;   /* window's current cursor column    */
  329.     unsigned char attr;     /* window's current text attribute   */
  330.     unsigned char tpos;     /* position of window's title        */
  331.     unsigned char tattr;    /* attribute of window's title       */
  332.     unsigned char wsattr;   /* attribute of window's shadow      */
  333. };                                 
  334.  
  335. /*------------[ window title position definitions for wtitle() ]-------------*/
  336.  
  337. #define TLEFT       1   /* left justified  */
  338. #define TCENTER     2   /* centered        */
  339. #define TRIGHT      3   /* right justified */
  340.  
  341. /*------------------------[ definition of NULL ]-----------------------------*/
  342.  
  343. #if !defined(NULL)
  344.     #if defined(__TURBOC__)                     /* Turbo C */
  345.         #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  346.             #define NULL    0
  347.         #else
  348.             #define NULL    0L
  349.         #endif
  350.     #elif defined(__ZTC__)                      /* Zortech C++ */
  351.         #ifdef LPTR
  352.             #define NULL    0L
  353.         #else
  354.             #define NULL    0
  355.         #endif
  356.     #elif defined(M_I86) && !defined(__ZTC__)   /* Microsoft C/QuickC */
  357.         #if defined(M_I86SM) || defined(M_I86MM)
  358.             #define NULL    0
  359.         #else
  360.             #define NULL    0L
  361.         #endif
  362.     #elif defined(__POWERC__)                   /* Power C */
  363.         #define NULL    0
  364.     #endif
  365. #endif
  366.  
  367. /*--------------[ attribute codes for functions that use them ]--------------*/
  368.  
  369. #if     !defined(BLACK)     /* foreground colors */
  370. #define BLACK       0                   
  371. #define BLUE        1
  372. #define GREEN       2
  373. #define CYAN        3
  374. #define RED         4
  375. #define MAGENTA     5
  376. #define BROWN       6
  377. #define YELLOW      14
  378. #define WHITE       15
  379. #endif
  380. #if     !defined(LGREY)
  381. #define LGREY       7       /* CXL abbreviates LIGHT as L    */
  382. #define DGREY       8       /* and DARK as D for ease of use */
  383. #define LBLUE       9
  384. #define LGREEN      10
  385. #define LCYAN       11
  386. #define LRED        12
  387. #define LMAGENTA    13
  388.  
  389. #define _BLACK      0       /* background colors */
  390. #define _BLUE       16
  391. #define _GREEN      32
  392. #define _CYAN       48
  393. #define _RED        64
  394. #define _MAGENTA    80
  395. #define _BROWN      96
  396. #define _LGREY      112
  397. #endif
  398.  
  399. #if     !defined(BLINK)
  400. #define BLINK       128     /* blink attribute */
  401. #endif
  402.  
  403. /*----------------------------[ macro functions ]----------------------------*/
  404.  
  405. #if !defined(MK_FP)
  406. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  407.                             (unsigned)(ofs)))
  408. #endif
  409. #define wclear()            wcclear(_winfo.active->wattr)
  410. #define wfillch(a)          (_winfo.fillch=a)
  411. #define winpfcurr()         (_winfo.active->form->cfield)
  412. #define wisactiv(a)         ((a==_winfo.active->whandle)?1:0)
  413. #define wmenumcurr()        (_winfo.cmenu)
  414. #define wmenuicurr()        (wmenumcurr()->citem)
  415. #define wsetesc(a)          (_winfo.esc=a)
  416. #define wtabwidth(a)        (_winfo.tabwidth=((a==0)?1:a))
  417.