home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_01 / define.doc < prev    next >
Text File  |  1991-03-01  |  28KB  |  1,023 lines

  1. /*
  2. HEADER:        Documentation file
  3. TITLE:        DEFINE.DOC
  4. VERSION:    1.0
  5. DATE:        5/1/90
  6.  
  7. DESCRIPTION:    documentation for #defines, structures, typedefs, etc 
  8.             used by the windows programs.
  9.  
  10. KEYWORDS:    windows, keyboard, mouse, text, graphics, expanded memory, menus;
  11. SYSTEM:        MS-DOS v3.0, probably works with v2.0 but untested;
  12. FILENAME:    DEFINE.DOC
  13.  
  14. WARNINGS:    
  15.  
  16. SEE-ALSO:    files on this disk named *.doc, demo*.c
  17.                 wtwg.doc  - more detailed introduction to concepts, 
  18.                               covers main features briefly,
  19.                               instructions for installation and use of routines
  20.                               compiler-specific suggestions
  21.                               list of files for this system with brief desc.
  22.                 defines.doc - this file
  23.                 funcs.doc   - documentation of specific function calls.
  24.                 
  25.                 demo*.c     - demo programs showing main features.
  26.                 
  27. AUTHOR:    David Blum
  28. COMPILERS:    Turbo C v2.0, Microsoft C v5.1
  29. */
  30.  
  31.  
  32.  
  33.  
  34. /* DATADEF.DOC     documentation for data definitions, structures, typedefs
  35.  *                for the WT/WG programs. 
  36.  *
  37.  *    Organization: 
  38.  *        SCREEN ATTRIBUTES
  39.  *        KEYBOARD definitions
  40.  *        STRUCTURES & typedefs
  41.  *                (for flags defined as part of structures,
  42.  *                 the corresponding #define statements are given here)
  43.  *            specific structures:
  44.  *            BOX    - line and border drawing characters.
  45.  *            BUTTON - onscreen mouse-selectable buttons and scrollbars
  46.  *            HEAP   - virtual memory, expanded memory, etc.
  47.  *            WINDOW - windows
  48.  *            LOCATION - data for auto-locating windows.
  49.  *            FORMS  - table layout for data entry forms. associated macros.
  50.  *            MENUS  - table layout for pulldown menus.
  51.  *            MOUSE  - global data describing recent mouse activity.
  52.  *            OBJECT_D_ART - data for mouse-driven drawing. (TurboC only)
  53.  *            MACRO NAMES table.
  54.  *
  55.  *    GLOBAL DATA ITEMS.
  56.  *
  57.  *                    @ David Blum, 1986, 1989, 1990
  58.  */
  59.  
  60.  
  61. /* some 'standard' definitions for improving readability.
  62.  */
  63.     #define ON     1
  64.     #define OFF    0
  65.     #define    TRUE    1
  66.     #define FALSE     0
  67.  
  68. /* VIDEO COLORS
  69.  *        (note that these over-ride the enum COLORS found in 
  70.  *       GRAPHICS.H and conflict with those found in CONIO.H)
  71.  */
  72. #define BLACK                 0
  73. #define BLUE                1
  74. #define GREEN               2    
  75. #define CYAN                   3 
  76. #define RED                 4
  77. #define MAGENTA                5
  78. #define BROWN               6
  79. #define LIGHTGRAY           7
  80. #define DARKGRAY            8
  81. #define LIGHTBLUE           9
  82. #define LIGHTGREEN          10
  83. #define LIGHTCYAN           11
  84. #define LIGHTRED            12
  85. #define LIGHTMAGENTA        13
  86. #define YELLOW              14
  87. #define WHITE                15
  88.  
  89. /* these allow spelling mistakes.
  90.  */
  91. #define LIGHTGREY LIGHTGRAY
  92. #define DARKGREY  DARKGRAY
  93.  
  94.  
  95. #define BLINK      0x80  /* in text mode only - blinking characters. */
  96.  
  97. #define BRIGHT  0x08  /* add this to other colors to get bright video.  */
  98.  
  99.  
  100.  
  101. /* HERCULES monochrome attributes 
  102.  *  Note that in graphics modes, 
  103.  *         any pixels with GREEN or BLUE bits ON will be ON
  104.  *        So, RED, DARKGRAY, LIGHTRED all will be BLACK onscreen
  105.  *        and BLUE, GREEN, CYAN, MAGENTA, BROWN, YELLOW, etc will be white.
  106.  *     
  107.  */
  108. #define WHITE_ON_BLACK 0x02  /*green*/
  109. #define BLACK_ON_WHITE 0x70
  110. #define UNDERLINE      0x01  /*blue */   /*red =x04 */
  111. #define BOLDFACE       0x0A  /* = 0x08 + green */
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. /*----------------------  KEYBOARD  ----------------------------------*/
  120.  
  121. /* keyboard symbolic definitions
  122.  *    routines that access the keyboard return a single 'int' speicifying
  123.  *    which key was pressed. This includes the MOUSE.
  124.  *
  125.  *    this scheme maps all the keys and  mouse into a single int
  126.  *    so the keycode/scancode arrangement can be ignored (simplified!!!)
  127.  *    wgetc() does all the mapping, behind the scenes.
  128.  *
  129.  *    if the mouse left or center button was used since the last call,
  130.  *    the returned key will be MOUSE.
  131.  *    The caller should then check the structure wmouse
  132.  *If the MOUSE right key was pressed, that code will be converted to ESCAPE
  133.  *
  134.  */
  135.  
  136.  
  137. #define CTRL(L)        (L - 0x40)  /* L must be uppercase */
  138.  
  139.     /* Function keys
  140.      * on a standard PC keyboard, only FKEY(1) thru FKEY(10) are avail
  141.      *    (also theier SHIFT_ ALT_ and CTRL_ combos)
  142.      *
  143.      * even if using an AT, FKEY_11 and FKEY_2 cannot be referenced
  144.      *    using the FKEY() etc macros used for FKEY(1) thru FKEY(10)
  145.      * because their key values are not contiguous with FKEY(10).
  146.      */
  147.  
  148. #define FKEY(x)        (128+ 58 +(x))
  149. #define SHIFT_FKEY(x)    (128+ 83 +(x))
  150. #define SHIFTFKEY(x)    (128+ 83 +(x))
  151. #define CTRL_FKEY(x)    (128+ 94 +(x))
  152. #define CTRLFKEY(n)    (128+ 94 +(n))
  153.  
  154.  
  155. #define EXTENDED_KEY       00
  156. #define BACKSPACE    (0x08)
  157. #define CTRL_BACKSPACE  127
  158. #define SHIFT_BACKSPACE   8
  159.  
  160.  
  161. #define ENTER        (0x0d)
  162. #define RETURN        (0x0d)
  163. #define CTRL_ENTER    (0x0a)
  164. #define ESCAPE         (0x1b)
  165. #define CTRL_LEFTBRACKET 0x1b
  166. #define CTRL_RIGHTBRACKET 0x1c
  167. #define END         (128+ 79)
  168. #define CTRL_END    (128+ 117)
  169. #define HOME        (128+ 71)
  170. #define CTRL_HOME     (128+ 119)
  171. #define PAGE_DOWN    (128+ 81)
  172. #define PAGE_DN        (128+ 81)
  173. #define    CTRL_PgDn    (128+ 118)
  174. #define    CTRL_PAGE_DN    (128+ 118)
  175. #define    CTRL_PAGE_DOWN  (128+ 118)
  176. #define PAGE_UP         (128+ 73)
  177. #define UP_ARROW     (128+ 72)
  178. #define DOWN_ARROW    (128+ 80)
  179. #define  DN_ARROW    (128+ 80)
  180. #define LEFT_ARROW    (128+ 75)
  181. #define LT_ARROW    (128+ 75)
  182. #define CTRL_LT_ARROW    (128+ 115)
  183. #define CTRL_LEFT_ARROW (128+ 115)
  184. #define RIGHT_ARROW     (128+ 77)
  185. #define  RT_ARROW    (128+ 77)
  186. #define CTRL_RT_ARROW   (128+ 116)
  187. #define CTRL_RIGHT_ARROW (128+ 116)
  188. #define INSERT        (128+ 82)
  189. #define DELETE        (128+ 83)
  190. #define TAB        (9)
  191. #define    SHIFT_TAB    (128+ 15)
  192. #define    BACKTAB        (128+ 15)
  193. #define CTRL_PRTSCRN    (128+ 114)
  194. #define CTRL_MINUS    31
  195. #define CTRL_BACKSLASH  28
  196.  
  197.  
  198.  
  199.  
  200. #define MOUSE        128
  201.  
  202.  
  203.  
  204.  
  205.  
  206. /*! ALT key functions.
  207.  *
  208.  * the extended key codes for the ALT-letter strokes
  209.  * mimic the keyboard layout, but with breaks of 5 between rows 1-2
  210.  * and a break of 6 between rows 2-3. Don't ask me why.
  211.  *
  212.  *
  213.  * ALT(val)   returns the ALT-letter value of val, which must be caps.
  214.  *
  215.  * isALT(val) returns 1 or 0
  216.  *            (only picks up ALT-letters)
  217.  *                      if (isALT(keypress)).....
  218.  *
  219.  *  unALT(val) returns 0 if cannot convert, returns letter equivalent if can
  220.  *            if ( 0 != ( 'X' == unALT(keypress)  ) ...
  221.  *                ALT-X was pressed
  222.  *            else    wasn't pressed
  223.  *        (note unALT requires capital letter)
  224.  *
  225.  * ALTFKEY(n) returns the ALT value of the function key
  226.  */
  227. int ALT     (int val);
  228. int unALT     (int keypress);
  229.  
  230. #define     ALTFKEY(n)    (128 +103+ (n))
  231. #define        ALT_FKEY(n)    (128 +103+ (n))
  232.  
  233.  
  234.  
  235. #define  isALT(xx)   ( (xx) >= 0x10+128  && (xx) <= 0x32+128 )
  236.  
  237.  
  238.  
  239. #define ALT_A  (0x1E+128)
  240. #define ALT_B  (0x30+128)
  241. #define ALT_C  (0x2E+128)
  242. #define ALT_D  (0x20+128)
  243. #define ALT_E  (0x12+128)
  244. #define ALT_F  (0x21+128)
  245. #define ALT_G  (0x22+128)
  246. #define ALT_H  (0x23+128)
  247. #define ALT_I  (0x17+128)
  248. #define ALT_J  (0x24+128)
  249. #define ALT_K  (0x25+128)
  250. #define ALT_L  (0x26+128)
  251. #define ALT_M  (0x32+128)
  252. #define ALT_N  (0x31+128)
  253. #define ALT_O  (0x18+128)
  254. #define ALT_P  (0x19+128)
  255. #define ALT_Q  (0x10+128)
  256. #define ALT_R  (0x13+128)
  257. #define ALT_S  (0x1F+128)
  258. #define ALT_T  (0x14+128)
  259. #define ALT_U  (0x16+128)
  260. #define ALT_V  (0x2F+128)
  261. #define ALT_W  (0x11+128)
  262. #define ALT_X  (0x2d+128)
  263. #define ALT_Y  (0x15+128)
  264. #define ALT_Z  (0x2C+128)
  265.  
  266.  
  267.  
  268.  
  269. #define ALT_1  (128+120)
  270. #define ALT_2  (128+121)
  271. #define ALT_3  (128+122)
  272. #define ALT_4  (128+123)
  273. #define ALT_5  (128+124)
  274. #define ALT_6  (128+125)
  275. #define ALT_7  (128+126)
  276. #define ALT_8  (128+127)
  277. #define ALT_9  (128+128)
  278. #define ALT_0  (128+129)
  279.  
  280.  
  281.  
  282. #define ALT_MINUS    (128+130)
  283.  
  284. #define ALT_EQ        (128+131)
  285. #define ALT_EQUAL    (128+131)
  286.  
  287. #define CTRL_PgUp    (128+132)
  288. #define CTRL_PAGE_UP    (128+132)
  289.  
  290.  
  291.  
  292. /* the following keys are available only on AT keyboards.
  293.  */
  294. #define ALT_ESCAPE     (128+1  )
  295. #define ALT_BKSPACE    (128+14 )
  296. #define ALT_LT_BRACKET    (128+26 )
  297. #define ALT_RT_BRACKET    (128+27 )
  298. #define ALT_ENTER       (128+28 )
  299. #define ALT_SEMICOLON    (128+39 )
  300. #define ALT_QUOTE    (128+40 )
  301. #define ALT_ACCENT    (128+41 )
  302. #define ALT_BKSLASH    (128+48 )
  303. #define ALT_COMMA    (128+51 )
  304. #define ALT_PERIOD    (128+52 )
  305. #define ALT_SLASH    (128+53 )
  306. #define CTRL_UP_ARROW   (128+141)
  307. #define CTRL_DN_ARROW   (128+145)
  308. #define ALT_HOME        (128+151)
  309. #define ALT_UP_ARROW    (128+152)
  310. #define ALT_PGUP        (128+153)
  311. #define ALT_LT_ARROW    (128+155)
  312. #define ALT_RT_ARROW    (128+157)
  313. #define ALT_END         (128+159)
  314. #define ALT_DN_ARROW    (128+160)
  315. #define ALT_PGDN        (128+161)
  316. #define ALT_INSERT    (128+162)
  317. #define ALT_DEL         (128+163)
  318. #define ALT_TAB         (128+165)
  319.  
  320.  
  321.     /* NOTE that FKEY 11 and 12 cannot be referenced
  322.      *    using the FKEY() etc macros used for FKEY(1) thru FKEY(10)
  323.      */
  324. #define FKEY_11        (128+133)
  325. #define FKEY_12        (128+134)
  326. #define SHIFT_FKEY_11    (128+135)
  327. #define SHIFT_FKEY_12    (128+136)
  328. #define CTRL_FKEY_11    (128+137)
  329. #define CTRL_FKEY_12    (128+138)
  330. #define ALT_FKEY_11    (128+139)
  331. #define ALT_FKEY_12    (128+140)
  332.  
  333.  
  334. /*--------------------------- DATA STRUCTURES ------------------------*/
  335.  
  336.  
  337. /* structure for line-drawing characters.
  338.  * the actual values are held in the global variable wbox[].
  339.  *
  340.  *        for example, wbox[SINGLE_BORDER].nw  gives the upper left corner
  341.  *                                                    of a single line box.
  342.  *    
  343.  */
  344. struct  WBOX_PATTERN
  345.         {
  346.         unsigned char nw, horiz, ne, sw, vert, se ;
  347.         };
  348.  
  349.  
  350.  
  351.     /* box styles - array indices for wbox[]. see above.
  352.      */
  353. #define NO_BORDER        0
  354. #define SINGLE_BORDER         1
  355. #define DOUBLE_BORDER        2
  356. #define SPECKLE_BORDER      3
  357. #define SOLID_BORDER        4
  358. #define MIXED2H1V_BORDER    5
  359. #define MIXED1H2V_BORDER    6
  360. #define HANGING_BORDER        7
  361. #define STANDUP_BORDER        8
  362.  
  363.  
  364.  
  365.  
  366. /* following button flags reserved for internal use.
  367.  */
  368.     #define WBTN_ACTIVE     0x02
  369.     #define WBTN_SCROLL        0x04
  370.     #define WBTN_BUTTON     0x08
  371.  
  372.  
  373. /* WHEAP
  374.  *        This structure is used by the memory management routines.
  375.  *        (Allow use of expnaded memory and/or disk virtual memory)
  376.  *
  377.  *        On calls to wheap_alloc(), this structure is created
  378.  *        and a pointer to it is returned. 
  379.  *        Use that pointer for all further accessions to that heap element.
  380.  *        example (more details in FUNCS.DOC):
  381.  *            WHEAP *h_ptr;
  382.  *            char far *data_ptr;            
  383.  *            h_ptr  = wheap_alloc ( ... );
  384.  *            data_ptr = wheap_access ( h_ptr, ... );
  385.  *                data block associated with by h_ptr is now in RAM
  386.  *            wheap_deaccess ( h_ptr );
  387.  *                data block is now swapped out to expanded memory or disk
  388.  *            wheap_free ( h_ptr );
  389.  *                data block is now free.
  390.  *        
  391.  */
  392. struct WHEAP_STRUCT
  393.     {
  394.     struct WHEAP_STRUCT     *whp_next;    /* linked lists of heap */
  395.     struct WHEAP_STRUCT     *whp_prev;
  396.  
  397.     size_t                     whp_nb;      /* number of bytes */
  398.  
  399.     char                      whp_flag;    /* type of heap element */
  400.     unsigned char             whp_priority;    /* priority        */
  401.  
  402.     /*---------- end of common part ---------- */
  403.  
  404.     void far                 *whp_ram;    /* where stored or accessed*/
  405.  
  406.     /* double linked lists  of disk blocks,
  407.      * so we can find 'holes' for new allocations
  408.      */
  409.     struct WHEAP_STRUCT     *whp_dskhi;    /* ptrs to lo/hi blocks */
  410.     struct WHEAP_STRUCT     *whp_dsklo;
  411.  
  412.     unsigned long              whp_position;    /* position in disk */
  413.  
  414.     int                         whp_handle;    /* XMS handle */
  415.     int                         whp_npages;    /* XMS number of pages */
  416.  
  417.     /* for disk type storage: append (new block), update (old block),
  418.      *    or create (new file)
  419.      */
  420.     char                      whp_typewrite;
  421.  
  422.     char                      whp_filler;    /* alignment */
  423.  
  424.  
  425.     };
  426.  
  427. typedef struct WHEAP_STRUCT  WHEAP;
  428.  
  429.  
  430.  
  431.  
  432.     /* flag values for whx_flag...tells how this blobk is stored
  433.      */
  434. #define WHP_XMS        0x01        /* expanded memory         */
  435. #define WHP_RAM        0x02        /* DOS heap ( void far * )    */
  436. #define WHP_DSK        0x04        /* disk file             */
  437.  
  438.  
  439.     /* maximum allowable allocation by heap manager
  440.      *    this is 64k -16 bytes for DOS memory mgt info.
  441.      */
  442. #define WHEAP_MAX    (65520u)
  443.  
  444.  
  445.     /* priority for window save areas
  446.      * any other data may be saved with higher priority -
  447.      * if out of RAM, the window area will be swapped to disk
  448.      */
  449. #define WIN_HP_PRIORITY     1
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456. struct _WINDOW
  457.     {
  458.     struct     _WINDOW *winchain;    /* pointer to previous window   */
  459.  
  460.     WHEAP           *winsave;    /* restore screen contents area */
  461.  
  462.     WBUTTON         *winbutton;    /* pointer to buttons, if any   */
  463.  
  464.     int        winpxmax;    /* size of window in pixels     */
  465.     int        winpymax;    /*      hihgest VALID pixel #s  */
  466.     int         winpx;      /* last graphics pos. from wopen*/
  467.     int         winpy;          /*    in window-viewport co-ords*/
  468.  
  469.     unsigned char     winpage;    /* video page # =  0...wlastpage*/
  470.     unsigned char   winputstyle;    /* FLAGS see below        */
  471.     unsigned char   winleft;          /* current window positon      */
  472.     unsigned char   wintop;
  473.     unsigned char   winxmax;    /* highest valid column        */
  474.     unsigned char   winymax;        /* highest valid row           */
  475.     unsigned char   winattr;        /* text attribute           */
  476.     unsigned char   winx;        /* current text postion        */
  477.     unsigned char   winy;         /*     range 0...winymax    */
  478.     unsigned char   winbox;            /* style of border         */
  479.     unsigned char   winboxcolor;      /* color of border         */
  480.     unsigned char     winflag;    /* internal flag         */
  481.     };
  482.  
  483.  
  484. typedef struct _WINDOW WINDOW;
  485.  
  486.  
  487.  
  488.  
  489.  
  490. /* put styles - flag values for winputstyle
  491.  *        These my be set at any time to change future performance of wputc()
  492.  *
  493.  */
  494. #define WPUTANSI    0x80    /* ON = use ANSI format codes
  495.                  * OFF= put IBM graphic chars instead
  496.                  */
  497. #define WPUTWRAP    0x40    /* ON = wrap text to next line at End Of Line
  498.                  * OFF= truncate text, stop output
  499.                  */
  500. #define WPUTSCROLL    0x20    /* ON = scroll window up one line
  501.                  *     when text ouptut reaches bottom
  502.                  * OFF= halt text output at lower right char.
  503.                  */
  504. #define WPUTN2RN    0x10    /* ON = translate \n into \r\n. (like ANSI C)
  505.                  * OFF= no carriage return. like TurboC cputs
  506.                  */
  507. #define WPUTALARM    0x08    /* ON = sound alarm for \a.
  508.                  * OFF= no alarm.  NOTE: ON is not implemented at present. 
  509.                  */
  510. #define    WPUTATTR    0x04    /* ON = char. following \a is an attribute
  511.                  * OFF= char following \a is an ordinary char
  512.                  * ONLY enabled if WPUTALARM is OFF
  513.                  */
  514.  
  515.  
  516.     /* definition for winflag.
  517.      */
  518. #define WFL_CURSOR    0x80    /* ON = (text mode only) cursor is on.
  519.                  * OFF= cursor is off.
  520.                  * ONLY set by wcursor() routine.
  521.                  * DO NOT set this yourself.
  522.                  */
  523.  
  524.  
  525. /* flags to govern function of wgets()
  526.  *    these are described in funcs.doc
  527.  */
  528.     #define WGETS_FORM    0x80    /* used internally by wscanform */
  529.     #define WGETS_INT    0x40    /* accept integer input only, +- signs OK */
  530.     #define WGETS_DEC    0x60    /* accept integers and a single decimal pt*/
  531.     #define WGETS_SKIP    0x10    /* auto return when buffer is filled */
  532.  
  533.  
  534.  
  535.  
  536. /* WLOCATION  structure:
  537.  *    this structure contains info for helping to locate a window
  538.  *    if values are placed here they affect the location of windows
  539.  *  The macro wsetlocation() simplifies use.
  540.  *    openned by wpromptc(), wprompts(), wpicklist(), wscanform()
  541.  *         or any other function that uses wlocate() to set its position.
  542.  *    values in this structure are reset after each call to wlocate()
  543.  *
  544.  *    EXAMPLES: 
  545.  *        wsetlocation ( WLOC_ATWIN, 3,4 )
  546.  *        wpromptc (...)        ...prompt box located column 3 row 4 of curr win.
  547.  *
  548.  *        wsetlocation ( WLOC_CENTER, 0, -5 )
  549.  *        wlocate ( &l, &t, xmax, ymax );
  550.  *        wopen (l, t, xmax, ymax.....);  window set 5 rows above screen center
  551.  *    
  552.  *        wsetlocation ( WLOC_ATXY, 0, 0 );
  553.  *        n= wpicklist (...);    ... picklist displayed at current text location
  554.  */
  555. struct WLOCATION
  556.     {
  557.     int  wloc_x;        /* x,y offsets from above location      */
  558.     int  wloc_y;
  559.     char wloc_type;     /* type of location desired - see defines */
  560.     char wloc_reserved;    /* mainains word alignment */
  561.     };
  562.  
  563.  
  564.     #define WLOC_CENTER     0    /* center next window onscreen */
  565.     #define WLOC_ATXY       1    /* place left/top at given position */
  566.     #define WLOC_ATWIN        2    /* place left/top relative to curr. window */
  567.     #define WLOC_ATCUR        3     /* place left/top relative to curr position */
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  /*! MENUS
  581.   *  This is the table giving the layout of the main menus.
  582.   *  the text of the menu line is the first entry,
  583.   *  followed by a function to call, ptr to help text, and a nested menu
  584.   *
  585.   */
  586. struct _WMENU
  587.     {
  588.     char             *mu_entry;      /*text for menu line */
  589.     void             (*mu_func)(void);
  590.     char             *mu_help;       /*help              */
  591.     struct     _WMENU     *mu_menu;       /*nested menu        */
  592.     unsigned char     *mu_enable;    /*0=disable this entry*/
  593.     int               mu_highlight;   /*which letter (0-n) to highlight */
  594.     int                mu_key;        /*keypress to select this one     */
  595.     };
  596.  
  597. typedef struct _WMENU  WMENU;
  598.  
  599.  
  600.  
  601.  
  602.  
  603. /* FORMS
  604.  *    data input routine, driven by a table - 
  605.  *    see the function wscanform() for more info.
  606.  *    see DEMOFORM.C for examples.
  607.  *  
  608.  */
  609. struct _WFORM
  610.     {
  611.  
  612.     char         *wflabel;    /* identifying text */
  613.     void         *wfuser;    /* pointer to user data area */
  614.     char         **wfpick;    /* optional - pointer to picklist */
  615.  
  616.     char         *wformat;    /* % format for printf/scanf
  617.                               */
  618.  
  619.                      /* the next entry is a user-supplied
  620.                       * field validation function
  621.                       */
  622.     int         (*wfvalidate)(struct _WFORM *, char *);
  623.  
  624.     unsigned char     wflen;        /* number of bytes incl. term. null*/
  625.     unsigned char   wfspecial;    /* internal use */
  626.  
  627.     unsigned char     wfx;        /* x,y co-ords of start of data item */
  628.     unsigned char     wfy;
  629.  
  630.  
  631.     };
  632.  
  633. typedef struct _WFORM WFORM;
  634.  
  635.  
  636.  
  637.     /* automatic generation of entries for string, int, float data
  638.      * assuming no user validation or pickllist functions
  639.      * and default lengths for numeric data
  640.      *
  641.      * all that's left to specify is x,y
  642.      */
  643. #define  WFORMENTRY_S(xx)  #xx,  xx, NULL, "%s", NULL, sizeof(xx), 0
  644. #define  WFORMENTRY_I(xx)  #xx, &xx, NULL, "%i", NULL, 6,          0
  645. #define  WFORMENTRY_F(xx)  #xx, &xx, NULL, "%f", NULL, 12,         0
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655. /*! wmouse - structure contains info about where the mouse was
  656.  *         at the time of the last call to wgetc()
  657.  *        wms_left & right tell how many times the buttons were hit
  658.  *           since the last call to wgetc().
  659.  *
  660.  *    If the mouse was used, wgetc() returns key == MOUSE, then check this.
  661.  */
  662. typedef struct _WMOUSE
  663.     {
  664.     int     wms_xmickey,            /*mouse position in mickeys (internal use)*/
  665.             wms_ymickey;
  666.  
  667.     int     wms_px, wms_py;            /* pixel coords relative to window */
  668.  
  669.     int     wms_pxabs, wms_pyabs;    /* pixels in abs.screen coords*/
  670.  
  671.     int        wms_x, wms_y;            /* text-based position in window */
  672.  
  673.     int     wms_xabs, wms_yabs;      /* text-based absolute  coords*/
  674.  
  675.     /* mouse flags -- zero if false, non-zero if true.
  676.      *
  677.      *    note:
  678.      *        wms_present: if non-zero, tells number of mouse buttons
  679.      *      wms_used: see defines below to tell how mouse was used
  680.      *            but you'll never see WMS_RIGHT because it's
  681.      *            changed to ESCAPE automatically.
  682.      *
  683.      *
  684.      */
  685.     unsigned char     wms_present,    /* was a mouse detected            */
  686.                     wms_used,    /* was mouse used since last call  */
  687.                     wms_inwindow,    /* is mouse in current window      */
  688.                     wms_internal;    /* internal use */
  689.     } WMOUSE;
  690.  
  691.  
  692.  
  693.  
  694.  
  695.     /* defined values for wmouse.wms_used
  696.      *     these are valid only after call to wgetc() (or wreadc())
  697.      *    they are reset after each call.
  698.      *
  699.      * NOTE wgetc 'maps' the right mouse button to the ESCAPE key
  700.      *    so calling programs should not test for WMS_RIGHT_BUTTON
  701.      */
  702.  
  703.  
  704.     /* defined values for wmouse.wms_used
  705.      */
  706.  
  707.         /*------- recent button release ------*/
  708.  
  709.     #define    WMS_LEFT_RLS    0x01
  710.  
  711.     #define WMS_CENTER_RLS    0x02
  712.  
  713.         /*------ mouse mvt with Left or Center button held down --------*/
  714.  
  715.     #define WMS_MOVED         0x04
  716.  
  717.         /*------ recent button press --------*/
  718.  
  719.     #define WMS_LEFT_PRS    0x08
  720.  
  721.     #define WMS_CENTER_PRS     0x10
  722.  
  723.     #define WMS_RIGHT_PRS     0x20        /* mostly internal use only */
  724.  
  725.     #define WMS_RIGHT_RLS    0x80        /* mapped to key==ESCAPE by wgetc()
  726.                                          * only seen if use wmouse_location()
  727.                                          * directly
  728.                                          */
  729.  
  730.  
  731. /* WOBJECT_D_ART  - data for control of mouse drawing
  732.  * Only available in Turbo C
  733.  * This structure is allocated once in each call to wdraw()
  734.  * contains description of object that was drawn by mouse.
  735.  */
  736.  
  737. typedef struct
  738.     {
  739.     char    wdr_type;            /* see defines listed below */
  740.     char     wdr_filler;
  741.     int     wdr_linestyle;
  742.     int     wdr_thickness;
  743.     int     wdr_color;
  744.     int        wdr_x1, wdr_y1;        /* start or center co-ords (@button press)*/
  745.     int         wdr_x2, wdr_y2;        /* end co-ords               (@button release)*/
  746.     }
  747.     WOBJECT_D_ART;
  748.  
  749.     /* definitions apply to wdr_type.
  750.      */
  751.     #define WDR_LINE        'l'
  752.     #define WDR_RECT        'r'
  753.     #define WDR_XHAIR       'x'
  754.     #define WDR_VERT         'v'
  755.     #define WDR_HORZ        'h'
  756.     #define WDR_SQUIGGLE     's'
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. /* definition of macro names table
  764.  * see wmacro_ functions for use.
  765.  * and DEMOMACR for example.
  766.  */
  767. typedef char WMACRO_NAMES[10][9];
  768.  
  769.  
  770.  
  771. /*---------------------- global variables. -------------------------*
  772.  *
  773.  *  these are declared extern unless WINDOW_GLOBALS is defined
  774.  *
  775.  *  NOTE: defined in order of alignment precedence.
  776.  *      so it doesn't matter if you compile with -a on or off
  777.  *
  778.  *------------------------------------------------------------------*/
  779.  
  780.  
  781.     /* pointer to currently active window
  782.      * and to original, fullscreen window openned by winit()
  783.      * EXAMPLE     w0-> winxmax gives last valid x value in current window
  784.      *            w0-> winattr  = BLUE  sets new text attribute
  785.      *            w0-> winleft  gives screen co-ord of left edge of window
  786.      *
  787.      * wfullscreen is a fullscreen window. The system will never remove it
  788.      *            calls to wclose() referencing this are ignored.
  789.      *     EXAMPLE:
  790.      *        ... say a 4x5 window is now open.
  791.      *        wreopen (wfullscreen);
  792.      *        wgoto (0,0);
  793.      *        wputs ("text will appear on top line of screen");
  794.      *        wbury ();        ...place wfullscreen on bottom of stack
  795.      *        ... the 4x5 window is again the current window.
  796.      */
  797.     extern     WINDOW      *(w0);                /* current (most recent) window */
  798.  
  799.     extern  WINDOW        *(wfullscreen);        /* first window = fullscreen */
  800.  
  801.  
  802.     /* global ptr to current help string.
  803.      *    change this to a help string when the topic changes.
  804.      *    These changes are handled by wpulldown() and wscanform()
  805.      *    The 'help string' is the key to the helpfile.
  806.      *    See winstall_help() or DEMOMENU.C for example.
  807.      */
  808.     extern  char         *whelp_ptr;
  809.  
  810.  
  811.  
  812.  
  813.     /* tab width (default is 8, user may change at any time)
  814.      */
  815.     extern  int             wtabwidth;
  816.     
  817.     
  818.     /* wcurscanln - cursor scan lines. 
  819.      *  Controls size of text-mode cursor. Lines numbered 0=top, 13=bottom.
  820.      *
  821.      *     high order byte is top line of cursor (0 to character size)
  822.      *    low byte is final line of cursor.
  823.      *
  824.      *     for CGA, automatically is set by winit('T') to 0x0607
  825.      *    for EGA/VGA/HERC/MDA, defaults to 0x0C0D (lines 12 to 13)
  826.      *    to change cursor to a block, reset this to 0x000D (EGA/VGA/HERC/MDA)
  827.      *             or 0x0007 (CGA)
  828.      *    Other combinations can be used, to get 'half-cell' cursors etc...
  829.      *    
  830.      *  For 43 or 50 line modes, cursor size is automatically changed
  831.      *        ( to 0x0607 )
  832.      *  and changed back again when returning to 25-line mode (and at exit)
  833.      * 
  834.      *  Changing this global variable only takes effect 
  835.      *    the next time cursor is turned ON using wcursor (ON).
  836.      *  
  837.      */
  838.     extern unsigned int wcurscanln;
  839.  
  840.  
  841.  
  842.     /* screen size, in characters co=ords (even in graphics modes
  843.      * the number of the first row/column is 0/0
  844.      * the number of the last row/column  is wyabsmax /wxabsmax
  845.      * loop control logic should be like this:
  846.      *    for (row=0; row <= wyabsmax; ++row) {process each row}
  847.      * the actual screen size if wxabsmax+1 by wyabsmax+1.
  848.      * 
  849.      * set by system, do not change.
  850.      */
  851.     extern  int         wxabsmax, wyabsmax;
  852.  
  853.  
  854.  
  855.     /* graphics- specific values -- not used in text-mode functions.
  856.      *    these values give number of pixels-1 in a screen
  857.      *    (start count at 0....n-1.)
  858.      */
  859.     extern  int         wpxabsmax, wpyabsmax;
  860.  
  861.  
  862.  
  863.  
  864.     /* wlocate - data for auto-locating windows
  865.      */
  866.     extern struct  WLOCATION wlocation;
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.     /* mouse
  874.      */
  875.     extern WMOUSE wmouse;
  876.  
  877.  
  878.  
  879.     /* graphics
  880.      *     wpath_BGI = path name for BGI interface.
  881.      *           default is "C:\\TC"
  882.      *           If needed, change before calling winit()
  883.      *     wpxchar, wpychar = pixels per character in x,y directions
  884.      */
  885.     extern  char        *wpath_BGI;    /* path to BGI drivers */
  886.     #define wpxchar        8
  887.     #define wpychar        8
  888.  
  889.  
  890.     /*  whome_dir = 
  891.      *         pointer to a 'home directory'
  892.      *        The online help system looks here for help files.
  893.      *        Default is current directory.
  894.      *        The max length of this string is WDIRLEN bytes (=40)
  895.      */
  896.     #define WDIRLEN 40
  897.     extern char *whome_dir = "\0";        /* Null for home directory = current */
  898.  
  899.  
  900.  
  901.     /* video mode and type of monitor
  902.      *    Note these 'simplified' definitions
  903.      *    wmode is either 'T' for text or 'G' for graphics
  904.      *    wmonitor is 'H' for hercules, 'E' for EGA, etc...
  905.      *
  906.      */
  907.     extern     char          wmode;        /* 'T' or 'G' */
  908.     extern  char         wmonitor;    /* 'H' 'E' 'V' or 'C' */
  909.     extern char     wega256;        /* 1= ega has 256k of RAM, 0=less avail */
  910.  
  911.     /* page number
  912.      *     In programs that plan to use multiple video pages,
  913.      *    call winit_pages() rather than winit()
  914.      *
  915.      *    wlastpage is #-1 of display pages available to you.
  916.      *        highest valid number is wlastpage.
  917.      *
  918.      *     wnextpage affects the NEXT window openned,
  919.      *           and doesn't actually change the display
  920.      *        just sets where in the screen buffers the output goes
  921.      *
  922.      *    wneedpage  is set internally by winit_pages ()
  923.      *        tells the graphics initializing routine
  924.      *        that a video mode should be selected that allows
  925.      *        multiple paging. DEFAULT is OFF.
  926.      *        only affects VGA monitors, selects 0x10 or 0x12
  927.      *
  928.      *    when a new window is openned, wopen() checks wnextpage
  929.      *        and changes the active page pointers
  930.      *        ( wreopen() and wclose() do the same )
  931.      *        ( so will wlink() and wunlink() when they're done )
  932.      *        (TURBO C BGI programs - also calls setactivepage() )
  933.      *    use wturnpage () setvisualpage() to set the visual page.
  934.      */
  935.     extern  unsigned char     wlastpage;
  936.     extern     unsigned char     wnextpage;
  937.  
  938.     extern  unsigned char   wneedpage;
  939.  
  940.  
  941.  
  942.  
  943.     /* colors for menus, menu box, buttons...
  944.      */
  945.     extern  unsigned char     wmenuattr,
  946.                 wmenuboxattr,
  947.                 wbuttonattr,
  948.                 whelpattr,
  949.                 wformattr;
  950.  
  951.     /* table giving all the different border styles
  952.      * see definition of struct WBOX_PATTERN, above
  953.      * use the _BORDER definitions as subscripts to access these
  954.      * example: the character to draw a double vertical line is:
  955.      *    wbox[DOUBLE_BORDER].vert
  956.      */
  957.     extern const struct WBOX_PATTERN wbox[];
  958.  
  959.  
  960.  
  961.     /* globals used by the wgetc() routines
  962.      *
  963.      *   wunget_buffer == used by wungetc() and wgetc()
  964.      *            NOTE this buffer can hold only one key.
  965.      *
  966.      *   wkeytrap ()   == a user-definable function to examine keystrokes
  967.      *            before they are returned from wgetc()
  968.      *
  969.      *            This routine could do whatever you want
  970.      *            ...dispatch a menu whenever
  971.      *                     an ALT_letter combination is pressed
  972.      *                      ...convert all lower case keys to upper
  973.      *            ...change video display pages in response to
  974.      *                user pressing PAGE_UP or PAGE_DOWN
  975.      *            ...halt the program in response to CTRL_F10
  976.      *            parameter passed by wgetc() to function:
  977.      *                key value
  978.      *            return code expected by wgetc() from func:
  979.      *                new key value to replace old one with
  980.      *                or zero to reject this key
  981.      *                ...and get another
  982.      *
  983.      *
  984.      *   wpipein ()   == a user-definable function that provides input
  985.      *            instead of keyboard/mouse.
  986.      *                if this funciton is non-NULL, wgetc() calls it
  987.      *            for each keystroke rather than calling wreadc
  988.      *   wpipeout ()  == a user-definable function to record each key
  989.      *            value that is returned to the caller.
  990.      *
  991.      *    NOTES:     1) the keytrap routines are called after the pipes.
  992.      *        2) the keytrap routine should 'chain' to other traps.
  993.      *
  994.      *        3) the input pipe has to de-install itself
  995.      *           immediately after the last character is returned.
  996.      *
  997.      *        4) see the routines wpipefin() and wpipefout()
  998.      *           for sample pipes.
  999.      *
  1000.      */
  1001.     extern int     wunget_buffer;
  1002.  
  1003.     extern int     (*wkeytrap)( int );
  1004.  
  1005.     extern int    (*wpipein )( void );
  1006.     extern void    (*wpipeout)( int  );
  1007.  
  1008.  
  1009. /*-------------------- end of DATADEF.DOC -------------------------*/
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.