home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / c / cwl30 / tc3lib / cwlwin.h < prev    next >
C/C++ Source or Header  |  1994-09-22  |  173KB  |  4,591 lines

  1. /*** WINDOW.H ***/
  2.  
  3. /* Written By P.A. McKenzie
  4.  * The C Window Library
  5.  * Copyright (C) 1990,1991,1992,1993,1994   All Rights Reserved
  6.  * Last updated 7/21/94
  7. */
  8.  
  9. #ifndef WINDOW_DEF
  10. #define WINDOW_DEF
  11.  
  12. #ifndef UNKNOWNARGS
  13. #ifndef __cplusplus
  14. #define UNKNOWNARGS
  15. #else
  16. #define UNKNOWNARGS ...
  17. extern "C" {
  18. #endif
  19. #endif
  20.  
  21. /* define prototype macro */
  22. #define MSDOS             /* Define if MSDOS system */
  23. /*define COHERENT*/    /* Define if COHERENT OS */
  24. /* #define UNIX_V   */    /* Define for UNIX System V */
  25.  
  26. #ifdef MSDOS
  27. #define __PROTO__         /* Delete this line for compilers that do not support
  28.                            * prototyping */
  29. #define __CWLVOID__       /* Use this for compilers that have the void keyword */
  30. #define __VOIDPTR__       /* Use this for compilers that support (void *) */
  31. #define __FAR__           /* Use this if compiler supports 'far' keyword */
  32. #define __NEAR__
  33. #define __INTERRUPT__     /* keyword 'interrupt' is defined for this compiler */
  34. #define __NEWSTYLE__      /* defines the new style of function headers */
  35. #define __IBMPC_GRAPHICS__  /* defines the IBM PC upper graphics characters */
  36. #define __USEINT__          /* says that int type is 16 bits wide */
  37. #endif
  38.  
  39. #ifdef GNUCPP
  40. #define __CWLVOID__
  41. #define __VOIDPTR__
  42. #define __PROTO__
  43. #define __NEWSTYLE__
  44. #endif
  45.  
  46. #ifdef COHERENT     /* This definition can also be used for UNIX V
  47.                        operating system */
  48.  
  49. #define __CWLVOID__
  50. #define __BIGALLOC__
  51. #define __IBMPC_GRAPHICS__  /* defines the IBM PC upper graphics characters.
  52.                                Use this for IBM PC CPU's only */
  53. #define __USESHORT__        /* says that short is 16 bits   */
  54. /*#define __EXTATTRIBUTES__ */  /* says that extended attributes are to be used */
  55. #endif
  56.  
  57. #ifdef __PROTO__
  58. #define _PROTO_(s)    s
  59. #else
  60. #define _PROTO_(s) ()
  61. #endif
  62.  
  63. #ifdef __CWLVOID__
  64. #define CWL_VOID    void
  65. #else
  66. #define CWL_VOID
  67. #endif
  68.  
  69. #ifdef __VOIDPTR__
  70. #define VOIDPTR   void *
  71. #else
  72. #define VOIDPTR   char *
  73. #endif
  74.  
  75. #ifdef __FAR__
  76. #define _FAR_  far
  77. #else
  78. #define _FAR_
  79. #endif
  80.  
  81. #ifdef __NEAR__
  82. #define _NEAR_  near
  83. #else
  84. #define _NEAR_
  85. #endif
  86.  
  87. #ifdef __INTERRUPT__
  88. #define _INTERRUPT_  interrupt
  89. #else
  90. #define _INTERRUPT_
  91. #endif
  92.  
  93. #ifdef __NEWSTYLE__
  94. #define _NEWSTYLE_
  95. #endif
  96.  
  97. #ifdef __BIGALLOC__
  98. #define _BIGALLOC_
  99. #endif
  100.  
  101. #ifdef __IBMPC_GRAPHICS__
  102. #define _IBMPC_GRAPHICS_
  103. #endif
  104.  
  105. #ifdef   __USEINT__
  106. typedef  unsigned int   WBUFFERTYPE;
  107. #endif
  108.  
  109. #ifdef   __USESHORT__
  110. typedef  unsigned short  WBUFFERTYPE;
  111. #endif
  112.  
  113. #ifdef __EXTATTRIBUTES__
  114. #define _EXTATTRIBUTES_
  115. #endif
  116.  
  117. #define FUNCPTR_SIZE  (sizeof(VOIDPTR))
  118.  
  119. /* Window definitions */
  120.  
  121. #ifndef WNULLFN
  122. #define WNULLFN   ((WPOINTER (*)()) 0)
  123. #endif
  124. #ifndef VWNULLFN
  125. #define VWNULLFN  ((VWPOINTER (*)()) 0)
  126. #endif
  127. #ifndef NULLFN
  128. #define NULLFN    ((int (*)()) 0)
  129. #endif
  130.  
  131. #ifndef VOIDNULLFN
  132. #ifdef __CWLVOID__
  133. #define VOIDNULLFN  ((CWL_VOID (*)()) 0)
  134. #endif
  135. #endif
  136.  
  137. #ifndef UNULLFN
  138. #define UNULLFN ((unsigned (*)()) 0)
  139. #endif
  140.  
  141. #ifdef MSC
  142. #ifndef NULL
  143. #define NULL ((char *)0)
  144. #endif
  145. #endif
  146.  
  147. #ifdef GLOBAL_DEF
  148. #define CWL_EXTERN
  149. #else
  150. #define CWL_EXTERN  extern
  151. #endif
  152.  
  153. #ifdef POWERC
  154. #define CWLmouse_hidden  mouhid_
  155. #endif
  156.  
  157. #define CWL_NULL     ((char *)0)
  158.  
  159. #if __cplusplus
  160. struct tagWINDOW;
  161. struct tagSCROLLBAR;
  162.  
  163. struct tagBARMENU;
  164. typedef tagBARMENU *BAR_MENU_PTR;
  165.  
  166. struct tagPOPUPMENU;
  167. typedef tagPOPUPMENU *POPUP_MENU_PTR;
  168.  
  169. #endif
  170.  
  171.  
  172. #ifdef MSDOS
  173. #define MAXVBUFSIZE  64000UL  /* Maximum size of each virtual buffer */
  174. #endif
  175.  
  176. #ifdef _BIGALLOC_
  177. #define MAXVBUFSIZE  2000000000UL /* Maximum size for each virtual buffer
  178.                                    Use this if MAXINT is greater than
  179.                                    65,535 and running on a non-segmented
  180.                                    operating system.                   */
  181. #endif
  182.  
  183. #ifdef MSDOS
  184. #ifdef LPOWERC
  185.   typedef  char _FAR_ *  WBUFPTR;
  186. #else
  187.   typedef  char *      WBUFPTR;
  188. #endif
  189. #define CELLSIZE_      sizeof(char)
  190. #endif
  191.  
  192. #ifdef COHERENT
  193. typedef char *  WBUFPTR;
  194. #define  CELLSIZE_   sizeof(char)
  195. #endif
  196.  
  197.  
  198.  
  199. #ifndef NUMBOXCHARS
  200. #define NUMBOXCHARS  8
  201. #endif
  202. #ifndef MAXSCROLLSTRING
  203. #define MAXSCROLLSTRING 36
  204. #endif
  205.  
  206. /* define structures used */
  207.  
  208. typedef struct tagVWINSTATUS
  209. {
  210.   unsigned viewport_flag:1;     /* tells if virtual window has a viewport */
  211.   unsigned vwtype:1;            /* tells what type of virtual window */
  212.   unsigned wrap_flag:1;
  213.   unsigned sync_curs:1;
  214. }  V_WIN_STAT;
  215.  
  216.  
  217.  
  218.  
  219. typedef struct tagVIRTUALWINDOW
  220. {
  221.   unsigned nbufs;                         /* number of buffers required */
  222.   unsigned char _FAR_ * _FAR_ *text;      /* pointer to huge text */
  223.   unsigned char _FAR_ * _FAR_ *attr;      /* pointer to attributes */
  224.   unsigned char _FAR_ * _FAR_ *exattr;    /* pointer to extended attributes */
  225.   unsigned  nrows;                        /* number of rows in window */
  226.   unsigned  ncols;                        /* number of columns in window */
  227.   unsigned row;                           /* row of logical cursor */
  228.   unsigned col;                           /* col of logical cursor */
  229.   int wnum;                               /* virtual window number */
  230.   int num_windows;                        /* total number of viewports */
  231.   int oattr;                              /* original attribute */
  232.   V_WIN_STAT stat_info;
  233. } VWINDOW, *VWPOINTER;
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  /****************************
  240.  * Define window status bits *
  241.  ****************************/
  242.  
  243. typedef struct tagWINSTATUS
  244. {
  245.   unsigned border_flag:1;       /* Window border flag */
  246.   unsigned wrap_flag:1;         /* Window wrap flag */
  247.   unsigned open_flag:1;         /* window open flag */
  248.   unsigned init_flag:1;         /* window initialized flag */
  249.   unsigned visible_flag:1;      /* window visible flag */
  250.   unsigned v_window_flag:1;     /* window is a viewport flag */
  251.   unsigned bufptr_flag:1;       /* tells if memory allocated for window buffer
  252.                                  * pointer   */
  253.   unsigned sync_curs:1;         /* tells if cursor is to be moved */
  254.   unsigned frozen_flag:1;       /* tells if virtual window is frozen */
  255.   unsigned seethru_flag:1;      /* tells if window is a see thru window */
  256.   unsigned move_flag:1;         /* used internally for window update routines */
  257.   unsigned v_hide_cursor:1;     /* tells if cursor is hidden by virtual
  258.                                  * window */
  259.   unsigned use_flag:4;          /* tells the object that is using the window */
  260.   unsigned shadow_use:1;        /* tells if window is used as a shadow to
  261.                                    another window */
  262.   unsigned shadow_trans:1;      /* tells if shadow is transparent */
  263.   unsigned child_enum:1;        /* tells that this is a child that is
  264.                                    to be enumerated in WindowEnumChildren()
  265.                                    function */
  266. } WIN_STAT;
  267.  
  268.  
  269.  
  270.  
  271. typedef struct tagSHADOWSTAT
  272. {
  273.   unsigned shadow_flag:1;       /* tells if there is a shadow */
  274.   unsigned shadow_pos:3;        /* tells where shadow is */
  275. } SHADOW_STAT;
  276.  
  277.  
  278. typedef struct tagBITSTRING
  279. {
  280.   unsigned char *bit_string;
  281.   unsigned nbits;
  282. } BITSTRING;
  283.  
  284.  
  285.  
  286. typedef struct tagWINTITLE
  287. {
  288.   char *titletop;
  289.   char *titlebot;
  290.   int titletop_attr;
  291.   int titlebot_attr;
  292.   unsigned titletop_pos:2;
  293.   unsigned titlebot_pos:2;
  294. } WIN_TITLE;
  295.  
  296.  
  297. typedef struct tagSCROLLBAR
  298. {
  299.   int scr_urow,       /* upper row of window */
  300.       scr_ucol;       /* upper col. of window */
  301.   int scr_min;        /* minimum scroll position */
  302.   int scr_max;        /* maximum scroll position */
  303.   int scr_boxpos;     /* current position of scroll box */
  304.   unsigned int scr_type:2;     /* scroll bar type (horizontal, vertical, or user) */
  305.   int scr_length;     /* length of scroll bar */
  306.   unsigned int scr_enableup:1; /* tells if up or left scroll character is enabled */
  307.   unsigned int scr_enabledown:1; /* tells if down or right scroll char is enabled */
  308.   unsigned int visible:1;      /* tells if scroll bar is visible */
  309.   unsigned int noupdate:1;     /* tells if scroll bar is NOT to be updated */
  310.   unsigned char scr_attr[4];  /* colors of scroll bar */
  311.   unsigned char scr_chars[3]; /* characters that make up scroll bar */
  312.   int scroll_orig_length;     /* original length of scroll bar */
  313.   VOIDPTR obj_ptr;   /* pointer to object that scroll bar will be used for */
  314. #if __cplusplus
  315.   struct tagWINDOW *scr_wind;  /* window to use if this is a scroll control */
  316. #else
  317.   VOIDPTR scr_wind;
  318. #endif
  319. } SCROLLBAR, *SCROLLPTR;
  320.  
  321.  
  322. /* Default Mouse Hotspots */
  323.  
  324. typedef struct tagHOTSPOT
  325. {
  326.   unsigned int border:1;
  327.   unsigned int zoom_on:1;
  328.   unsigned int minimized:1;
  329.   unsigned int caption:1;
  330.   unsigned int adjust:1;
  331.   unsigned int whichzoom:2;
  332.   unsigned int track_scroll_top:1;
  333.   unsigned int track_scroll_bottom:1;
  334.   unsigned int zoomhighlight:1;
  335.   unsigned int save_zoom;
  336.   unsigned char hotspot_string[MAXSCROLLSTRING];
  337.   char box[NUMBOXCHARS];
  338.   char *caption_string;
  339.   int  capture_len;
  340.   int  bitpos;        /* tells the position in the minimize bitstring */
  341.   long     options;
  342.   long     save_options;  /* needed for a minimized window */
  343.   SCROLLPTR sbarvert;
  344.   SCROLLPTR sbarhorz;
  345. #if __cplusplus
  346.   int (*alt_move_func) _PROTO_((struct tagWINDOW *,int,int));
  347. #else
  348.   int (*alt_move_func) ();
  349. #endif
  350. } HOTSPOT, *HOTSPOTPTR;
  351.  
  352. /* object class constants */
  353. #define FORMOBJECT              0
  354. #define POPUPOBJECT             1
  355. #define BAROBJECT               2
  356. #define PULLDOWNOBJECT          3
  357. #define VIRTUALOBJECT           4
  358. #define WINDOWOBJECT            5
  359. #define VBLOCKOBJECT            6
  360. #define KEYTABLEOBJECT          7
  361. #define BARUSEROBJECT           8
  362. #define POPUPUSEROBJECT         9
  363. #define PULLDOWNUSEROBJECT      10
  364. #define TERMINFOOBJECT          11
  365. #define OBJECTCONTAINER         12
  366. #define BASEWINDOWOBJECT        13
  367. #define TRANSPARANTOBJECT       14
  368. #define ACCELOBJECT             15
  369. #define CHILDOBJECT             16
  370.  
  371. #define USEROBJECT              1000
  372.  
  373. typedef struct tagOBJSTRUCT
  374. {
  375. #if defined (MSDOS) || (GNUCPP)
  376.   CWL_VOID **objarray;
  377. #else
  378.   char **objarray;
  379. #endif
  380.   long num;
  381.   int obj_type;
  382. } CWLOBJECT, *CWLOBJECTPTR;
  383.  
  384.  
  385. typedef struct tagWINSHADOW
  386. {
  387.    int schar;                     /* shadow character */
  388.    int sattr;                     /* shadow attribute */
  389.    int swidth;
  390.    int sheight;
  391.    SHADOW_STAT shadow_stat;
  392. } WIN_SHADOW;
  393.  
  394.  
  395.  /**************************
  396.  * Define window structure *
  397.  **************************/
  398.  
  399.  typedef struct tagWINDOW
  400. {
  401.   VWPOINTER vwptr;                 /* pointer to virtual window */
  402.   unsigned int vwrow;              /* virtual window row */
  403.   unsigned int vwcol;              /* virtual window column */
  404.   int origx;                       /* original x-position */
  405.   int origy;                       /* original y-position */
  406.   int col;                         /* window column */
  407.   int row;                         /* window row  */
  408.   int width;                       /* window width */
  409.   int height;                      /* window height */
  410.   int xpos;                        /* current window x position */
  411.   int ypos;                        /* current window y position */
  412.   int srow;                        /* row of window in screen coordinates */
  413.   int scol;                        /* col of window in screen coordinates */
  414.   unsigned wnum;                   /* Window number */
  415.   int rank;                        /* Where window is in list of windows */
  416.   int saverank;                    /* Previous rank of a displayed window */
  417.   int temprank;                    /* rank used for child windows if parent
  418.                                       is not displayed */
  419.   int pagenum;                     /* video page where window is opened */
  420.   int cursorshape;                 /* tells the cursor shape */
  421.   int save_cursorshape;            /* tells shape of cursor if cursor is
  422.                                       * temporarily hidden */
  423.   int battr;                       /* border attribute */
  424.   int wattr;                       /* window attribute */
  425.   char boxchars[NUMBOXCHARS];      /* box characters */
  426.   WBUFPTR textbuf;                 /* points to text plane */
  427.   WBUFPTR exattr;                  /* extended attributes */
  428.   WIN_STAT stat_info;              /* window status flags */
  429.   struct tagWINDOW *shadow_window; /* Window used as a shadow */
  430.   WIN_SHADOW shadow_info;          /* shadow status */
  431.   WIN_TITLE title_info;            /* window title info */
  432.   HOTSPOTPTR hotspot;              /* default hotspots */
  433.   unsigned poplite_loc;            /* location of popup menu highlight */
  434.   VOIDPTR use_ptr;                 /* pointer to object that the window
  435.                                       is being used for */
  436.   CWLOBJECTPTR child;              /* array of child window objects */
  437.   struct tagWINDOW *parent,        /* window's immediate parent   */
  438.                    *baseparent;    /* window's base window ancestor */
  439.  
  440.   int (*window_proc) _PROTO_((struct tagWINDOW *, int, int, long));
  441.                                    /* event driven window procedure */
  442.  
  443.   unsigned first_row;              /* tells where the first writeable row */
  444.   VOIDPTR userbytes;                 /* information needed by the programmer */
  445. } CWLWINDOW, *WPOINTER;
  446.  
  447.  
  448. typedef struct tagCWLPOINT
  449. {
  450.   int x;
  451.   int y;
  452. } CWLPOINT;
  453.  
  454.  
  455. typedef struct tagCWLRECT
  456. {
  457.   int left;
  458.   int top;
  459.   int right;
  460.   int bottom;
  461. } CWLRECT;
  462.  
  463.  
  464. #define MAKEPOINT(x)   (*((CWLPOINT _FAR_ *)&(x)))
  465. typedef int      (*TIMERPROC) _PROTO_((WPOINTER,int,int,long));
  466. typedef int      (*CWLENUMPROC) _PROTO_((WPOINTER,long));
  467.  
  468. typedef struct tagCWLMSG
  469. {
  470.   unsigned message;      /* event */
  471.   CWLPOINT point;        /* position of the mouse */
  472.   unsigned wParam;       /* additional info */
  473.   long     lParam;       /* additional info */
  474.   WPOINTER win;          /* identifies window where message belongs to */
  475.   VOIDPTR  msginfo;      /* extra info concerning message */
  476.   unsigned int post:1;   /* tells if message was posted by the user */
  477. } CWLMSG;
  478.  
  479.  
  480.  
  481. typedef struct tagTIMER
  482. {
  483.   unsigned int status:1;/* tells if timer is being used.  TRUE if
  484.                           used, FALSE otherwise */
  485.   WPOINTER window;      /* window that owns the timer */
  486.   unsigned ticks;       /* current count of the number of clock ticks
  487.                           left before timer goes off */
  488.   unsigned numticks;    /* Total number of clock ticks */
  489.   TIMERPROC TimerProc;  /* user defined function to call */
  490.  
  491. }  CMLTIMER;
  492.  
  493.  
  494.  
  495.  
  496. typedef struct tagQUEUE
  497. {
  498.   CWLMSG *queue_ptr;     /* pointer to message queue */
  499.   int queue_back;        /* indicates back of queue */
  500.   int initial_size;      /* indicates initial size of queue or size of
  501.                             queue when extra entries have to be allocated */
  502.   int extra_size;        /* # of queue entries to allocate if
  503.                             initial size is exceeded */
  504. } QUEUE, *QUEUEPTR;
  505.  
  506.  
  507.  
  508.  
  509.  /**********************************************
  510.   * Define video and other miscellaneous flags *
  511.   *********************************************/
  512.  
  513. #ifdef POWERC
  514.    #define  CWLcrt_port        crtport_
  515.    #define  CWLpagesize        pagesiz_
  516.    #define  CWLcaldelay        caldely_
  517.    #define  CWLstack_seg       stckseg_
  518.    #define  CWLstack_bot       stckbot_
  519.    #define  CWLoldseg          oldseg_
  520.    #define  CWLoldtop          oldtop_
  521.    #define  CWLevents_on       eventon_
  522.    #define  CWLmouse_used      mouused_
  523.    #define  CWLmouse_hidden    mouhid_
  524.    #define  CWLscrnseg         scrnseg_
  525. #endif
  526.  
  527. #ifndef offsetof
  528. #define offsetof(type,memb) \
  529.            (unsigned)&((( type *)0x10)->memb)-(unsigned)(( type *)0x10)
  530. #endif
  531.  
  532. #define MAXBUFSIZE    1024
  533. #define MAXSCROLLWIDTH 140
  534.  
  535.  /********************************
  536.   * Define video block structure *
  537.   *******************************/
  538.  
  539.  
  540. typedef struct tagVBLOCK
  541. {
  542.   CWLRECT vRect;
  543.   int pagenum;        /* page number where block
  544.                          is opened */
  545.   char *scrnsave;     /* pointer to video block
  546.                          structure */
  547. } *VBLOCKPTR, VBLOCK;
  548.  
  549.  
  550. typedef struct tagSYSFLAGS
  551. {
  552.   unsigned  scrnwrt_flag:1;        /* either BIOS or DMA          */
  553.  
  554.   unsigned  cga_flag:1;            /* cga flag                    */
  555.   unsigned  mda_flag:1;            /* mono adapter flag           */
  556.   unsigned  hgc_flag:1;            /* Hercules flag               */
  557.  
  558.   unsigned  vga_in_flag:1;         /* vga installed flag          */
  559.   unsigned  vga_active_flag:1;     /* vga is active flag          */
  560.   unsigned  vga_color_monitor:1;   /* vga color monitor attached  */
  561.   unsigned  vga_color_flag:1;      /* vga color mode on           */
  562.  
  563.   unsigned  mcga_color_flag:1;     /* MCGA color on               */
  564.   unsigned  mcga_in_flag:1;        /* MCGA installed flag         */
  565.  
  566.   unsigned  ega_in_flag:1;         /* ega installed flag          */
  567.   unsigned  ega_active_flag:1;     /* ega active flag             */
  568.   unsigned  ega_color_monitor:1;   /* ega color monitor attached  */
  569.   unsigned  ega_color_flag:1;      /* ega is in color mode flag   */
  570. }  SYS_FLAGS;
  571.  
  572.  
  573. typedef struct tagVCONFIG
  574. {
  575.   unsigned int video_mode;         /* current video mode */
  576.   unsigned int cursor_startline;   /* starting scan line of the cursor */
  577.   unsigned int cursor_endline;     /* ending scan line of the cursor */
  578.   unsigned int cursor_row;         /* row of cursor */
  579.   unsigned int cursor_col;         /* column of cursor */
  580.   unsigned int video_page;         /* video page */
  581.   unsigned int video_pagesize;     /* video page size in bytes */
  582.   unsigned int video_rows;         /* number of displayable rows */
  583.   unsigned int video_cols;         /* number of displayable columns */
  584.   unsigned int char_height;        /* height of characters in scan lines */
  585.   unsigned int crt_port_address;   /* address of crt status port */
  586.   unsigned int crt_mode_setting;   /* mode setting of crt */
  587.   unsigned int crt_color_setting;  /* color setting of crt */
  588. } VIDEO_CONFIG;
  589.  
  590.  
  591.  
  592.  
  593.  /*******************
  594.  * Define box types *
  595.  ********************/
  596.  
  597. #ifdef _IBMPC_GRAPHICS_   /* Use this for PC's only (may use on other non-PC
  598.                              systems, but characters may not be 'safe') */
  599.  
  600. #define DOUBLEBOX      "╔═╗║║╚═╝"
  601. #define SINGLEBOX      "┌─┐││└─┘"
  602. #define MIXEDBOX1      "╒═╕││╘═╛"
  603. #define MIXEDBOX2      "╓─╖║║╙─╜"
  604. #define HATCHBOX1      "░░░░░░░░"
  605. #define HATCHBOX2      "▒▒▒▒▒▒▒▒"
  606. #define HATCHBOX3      "▓▓▓▓▓▓▓▓"
  607. #define SOLIDBOX1      "█▀████▄█"
  608. #define SOLIDBOX2      "████████"
  609. #define BLANKBOX       "        "
  610. #define DOTTEDLINE     "---||---"
  611.  
  612. #else
  613.  
  614. /* If using TERMINFO, you should set up the graphics string using the
  615.    acsc terminfo description. */
  616.  
  617. #define DOUBLEBOX      "---||---"
  618. #define SINGLEBOX      "---||---"
  619. #define MIXEDBOX1      "---||---"
  620. #define MIXEDBOX2      "---||---"
  621. #define HATCHBOX1      "---||---"
  622. #define HATCHBOX2      "---||---"
  623. #define HATCHBOX3      "---||---"
  624. #define SOLIDBOX1      "---||---"
  625. #define SOLIDBOX2      "---||---"
  626. #define BLANKBOX       "        "
  627. #define DOTTEDLINE     "---||---"
  628.  
  629. #endif
  630.  
  631. #ifndef NUMBOXCHARS
  632. #define NUMBOXCHARS  8
  633. #endif
  634.  
  635. /* Macro Definitions */
  636.  
  637. #define SCREEN_WRITE_METHOD       CWLvideo_flags.scrnwrt_flag
  638. #define CGA_ACTIVE                CWLvideo_flags.cga_flag
  639.  
  640. #define VGA_INSTALLED             CWLvideo_flags.vga_in_flag
  641. #define VGA_ACTIVE                CWLvideo_flags.vga_active_flag
  642. #define VGA_COLOR_ON              CWLvideo_flags.vga_color_flag
  643.  
  644. #define MCGA_COLOR_ON             CWLvideo_flags.mcga_color_flag
  645. #define MCGA_INSTALLED            CWLvideo_flags.mcga_in_flag
  646.  
  647. #define EGA_INSTALLED             CWLvideo_flags.ega_in_flag
  648. #define EGA_ACTIVE                CWLvideo_flags.ega_active_flag
  649. #define EGA_COLOR_ON              CWLvideo_flags.ega_color_flag
  650.  
  651. #define VGA_MONO_ON               (VGA_ACTIVE && !VGA_COLOR_ON)
  652. #define EGA_MONO_ON               (EGA_ACTIVE && !EGA_COLOR_ON)
  653. #define HERCULES_ACTIVE           CWLvideo_flags.hgc_flag
  654. #define MDA_ACTIVE                CWLvideo_flags.mda_flag
  655. #define VGA_COLOR_ATTACHED        CWLvideo_flags.vga_color_monitor
  656. #define EGA_COLOR_ATTACHED        CWLvideo_flags.ega_color_monitor
  657.  
  658. #define MONO_MODE_ON              ((!EGA_COLOR_ON && !VGA_COLOR_ON && \
  659.                                     !MCGA_COLOR_ON && !CGA_ACTIVE) || \
  660.                                    (MDA_ACTIVE || HERCULES_ACTIVE))
  661.  
  662. #define COLOR_MODE_ON             (!MONO_MODE_ON)
  663. #define VGA_MODE_ON               (VGA_ACTIVE)
  664. #define EGA_MODE_ON               (EGA_ACTIVE)
  665. #define CGA_MODE_ON               (CGA_ACTIVE)
  666. #define MCGA_MONO_ON              (MCGA_INSTALLED && VGA_ACTIVE && \
  667.                                    !MCGA_COLOR_ON)
  668. #define MCGA_MODE_ON              (MCGA_INSTALLED && VGA_ACTIVE)
  669. #define VGA_MONO_ATTACHED         (VGA_ACTIVE && !VGA_COLOR_ATTACHED)
  670.  
  671. #define CHECK_SNOW                CWLchksnow
  672. #define SCREEN_SEGMENT            CWLscrnseg
  673. #define VIDEO_PAGESIZE            CWLpagesize
  674.  
  675. /*  Video Macros */
  676.  
  677. #define LINEMODE43       (get_video_info(4) == 43)
  678. #define LINEMODE50       (get_video_info(4) == 50)
  679. #define LINEMODE25       (get_video_info(4) == 25)
  680.  
  681. #define CREATE_VIDEO_ATTRIBUTE(x,y) (((int)(x) << 4) + (y)) /* creates a video attribute */
  682. #define GET_BGROUND_COLOR(c)        ((int)(c) >> 4)
  683. #define GET_FGROUND_COLOR(c)        ((int)(c) & 0x000F)
  684.  
  685. #if 0
  686.  
  687. #ifdef COHERENT
  688. #define CREATE_VIDEO_ATTRIBUTE(x,y) (((int)(x) << 8) + (y)) /* creates a video attribute */
  689. #define GET_BGROUND_COLOR(c)        ((int)(c) >> 8)
  690. #define GET_FGROUND_COLOR(c)        ((int)(c) & 0x00FF)
  691. #endif
  692.  
  693. #endif
  694.  
  695. #define SCREEN_OFFSET(r,c,a) \
  696.                           (((((r))*CWLscreen_cols + (c)) + (a)*CWLpagesize)<<1)
  697. #define GET_SEGMENT(x)  \
  698.                   ((unsigned) ((long)(char _FAR_ *)(x) >> 16))
  699. #define GET_OFFSET(x)   \
  700.                    ((unsigned) ((long)(char _FAR_ *)(x) & 0x0000FFFF))
  701. #define SCREEN_OFFSET_ATTR(r,c,a)        (SCREEN_OFFSET((r),(c),(a))+1)
  702.  
  703. #define MAKE_FAR_POINTER(a,b)  ((char _FAR_ *)(((unsigned long)(a) << 16)+(b)))
  704.  
  705. #define GetVideoAttribute(row,col,page)   get_chat((row)+1,(col)+1,(page),1)
  706. #define GetVideoMode()                    get_video_info(1)
  707. #ifdef MSDOS
  708. #define MoveCursor(row,col,page)          goto_xy((row),(col),(page))
  709. #endif
  710. #define ReportCharacter(row,col,page)     get_chat((row),(col),(page),0)
  711.  
  712. /* Fast Output/Non-window related Video Functions */
  713. int                CheckVideoPage _PROTO_((int page));
  714. CWL_VOID           ClearRegion _PROTO_((int urow, int ucol, int lrow, int lcol, int attr));
  715. CWL_VOID           ClearScreen _PROTO_((int attr));
  716. CWL_VOID           GetCursorPosition _PROTO_((unsigned *row, unsigned *col, int page));
  717. CWL_VOID           GetVideoBiosInfo _PROTO_((VIDEO_CONFIG *video_struct));
  718. CWL_VOID           ScrollScreenUp _PROTO_((int numlines, int urow, int ucol, int lrow,
  719.                                            int lcol, int attr));
  720. CWL_VOID           ScrollScreenDown _PROTO_((int numlines, int urow, int ucol, int lrow,
  721.                                              int lcol, int attr));
  722. int                SetActiveVideoPage _PROTO_((int page));
  723. int                SetVisibleVideoPage _PROTO_((int page));
  724. CWL_VOID           SetVideoMode _PROTO_((int modenum));
  725. int                SetVideoRows _PROTO_((int numrows, int flag));
  726. CWL_VOID           VideoDrawBox _PROTO_((int urow, int ucol, int lrow, int lcol, char *box));
  727. CWL_VOID           VideoDrawBoxAttr _PROTO_((int urow, int ucol, int lrow, int lcol,
  728.                                              char *box, int attr));
  729. CWL_VOID           VideoFree _PROTO_((VBLOCKPTR vid_block));
  730. CWL_VOID           VideoMove _PROTO_((VBLOCKPTR vid_block, int row, int col));
  731. CWL_VOID           VideoPrintf _PROTO_((char *format, ...));
  732. CWL_VOID           VideoPrintfAttr _PROTO_((int attr, char *format, ...));
  733. VBLOCKPTR          VideoSave _PROTO_((CWLRECT *vRect));
  734. CWL_VOID           VideoRestore _PROTO_((VBLOCKPTR vid_block));
  735. CWL_VOID           VideoWriteString _PROTO_((char *string, int row, int col));
  736. CWL_VOID           VideoWriteStringAttr _PROTO_((char *string, int row, int col, int attr));
  737. CWL_VOID           VideoWriteAttributes _PROTO_((char *string, int row, int col,
  738.                                                  int length));
  739. CWL_VOID           VideoWriteCenterString _PROTO_((char *string, int row));
  740. CWL_VOID           VideoWriteCenterStringAttr _PROTO_((char *string, int row, int attr));
  741. CWL_VOID           VideoWriteCharAndAttr _PROTO_((char *string, int row, int col,
  742.                                                   int length));
  743. CWL_VOID           VideoWriteStringCC _PROTO_((char *string, int row, int col));
  744. CWL_VOID           VideoWriteStringCCAttr _PROTO_((char *string, int row, int col,
  745.                                                    int attr));
  746. CWL_VOID           VideoWriteStringRJ _PROTO_((char *string, int row, int col));
  747. CWL_VOID           VideoWriteStringRJAttr _PROTO_((char *string, int row, int col,
  748.                                                    int attr));
  749. CWL_VOID           VideoReadAttributes _PROTO_((char *buffer, int row, int col,
  750.                                                 int length));
  751. CWL_VOID           VideoReadCharacters _PROTO_((char *buffer, int row, int col,
  752.                                                 int length));
  753. CWL_VOID           VideoReadCharAndAttr _PROTO_((char *buffer, int row, int col,
  754.                                                  int length));
  755.  
  756. int                InitializeScanLines _PROTO_((int,int));
  757. int                LoadCharacterSet _PROTO_((int,int));
  758. CWL_VOID           goto_xy _PROTO_((int,int,int));
  759.  
  760. /* define the keycodes */
  761.  
  762. /* CWL Key definitions for non-event programming */
  763. #define F1               0x3b00
  764. #define SHIFTF1          0x5400
  765. #define CTRLF1           0x5e00
  766. #define ALTF1            0x6800
  767.  
  768. #define F2               0x3c00
  769. #define SHIFTF2          0x5500
  770. #define CTRLF2           0x5f00
  771. #define ALTF2            0x6900
  772.  
  773. #define F3               0x3d00
  774. #define SHIFTF3          0x5600
  775. #define CTRLF3           0x6000
  776. #define ALTF3            0x6a00
  777.  
  778. #define F4               0x3e00
  779. #define SHIFTF4          0x5700
  780. #define CTRLF4           0x6100
  781. #define ALTF4            0x6b00
  782.  
  783. #define F5               0x3f00
  784. #define SHIFTF5          0x5800
  785. #define CTRLF5           0x6200
  786. #define ALTF5            0x6c00
  787.  
  788. #define F6               0x4000
  789. #define SHIFTF6          0x5900
  790. #define CTRLF6           0x6300
  791. #define ALTF6            0x6d00
  792.  
  793. #define F7               0x4100
  794. #define SHIFTF7          0x5a00
  795. #define CTRLF7           0x6400
  796. #define ALTF7            0x6e00
  797.  
  798. #define F8               0x4200
  799. #define SHIFTF8          0x5b00
  800. #define CTRLF8           0x6500
  801. #define ALTF8            0x6f00
  802.  
  803. #define F9               0x4300
  804. #define SHIFTF9          0x5c00
  805. #define CTRLF9           0x6600
  806. #define ALTF9            0x7000
  807.  
  808. #define F10              0x4400
  809. #define SHIFTF10         0x5d00
  810. #define CTRLF10          0x6700
  811. #define ALTF10           0x7100
  812.  
  813. #define F11              0x8500
  814. #define SHIFTF11         0x8700
  815. #define CTRLF11          0x8900
  816. #define ALTF11           0x8b00
  817.  
  818. #define F12              0x8600
  819. #define SHIFTF12         0x8800
  820. #define CTRLF12          0x8a00
  821. #define ALTF12           0x8c00
  822.  
  823. #define LARROW           0x4b00
  824. #define SHIFTLARROW    '4'
  825. #define CTRLLARROW       0x7300
  826.  
  827. #define RARROW           0x4d00
  828. #define SHIFTRARROW    '6'
  829. #define CTRLRARROW       0x7400
  830.  
  831. #define UARROW           0x4800
  832. #define SHIFTUARROW    '8'
  833. #define CTRLUARROW       0x8d00
  834.  
  835. #define DARROW           0x5000
  836. #define SHIFTDARROW    '2'
  837. #define CTRLDARROW       0x9100
  838.  
  839. #define GRAY_LARROW      0x4be0
  840. #define GRAY_CTRLLARROW  0x73e0
  841.  
  842. #define GRAY_RARROW      0x4de0
  843. #define GRAY_CTRLRARROW  0x74e0
  844.  
  845. #define GRAY_UARROW      0x48e0
  846. #define GRAY_CTRLUARROW  0x8de0
  847.  
  848. #define GRAY_DARROW      0x50e0
  849. #define GRAY_CTRLDARROW  0x91e0
  850.  
  851. #define HOME             0x4700
  852. #define GRAY_HOME        0x47e0
  853. #define SHIFTHOME     '7'
  854.  
  855. #define CTRLHOME         0x7700
  856. #define GRAY_CTRLHOME    0x77e0
  857.  
  858. #define END              0x4f00
  859. #define SHIFTEND      '1'
  860. #define CTRLEND          0x7500
  861.  
  862. #define GRAY_END         0x4fe0
  863. #define GRAY_CTRLEND     0x75e0
  864.  
  865. #define PGUP             0x4900
  866. #define SHIFTPGUP     '9'
  867. #define CTRLPGUP         0x8400
  868.  
  869. #define GRAY_PGUP        0x49e0
  870. #define GRAY_CTRLPGUP    0x84e0
  871.  
  872. #define PGDN             0x5100
  873. #define SHIFTPGDN     '3'
  874. #define CTRLPGDN         0x7600
  875.  
  876. #define GRAY_PGDN        0x51e0
  877. #define GRAY_CTRLPGDN    0x76e0
  878.  
  879. #define INS              0x5200
  880. #define SHIFTINS      '0'
  881.  
  882. #define GRAY_INS         0x52e0
  883.  
  884. #define DEL              0x5300
  885. #define SHIFTDEL      '.'
  886.  
  887. #define GRAY_DEL         0x53e0
  888.  
  889. #define ESC           0x1B
  890. #define SHIFTESC      0x1B
  891. #define CTRLESC       0x1B
  892. #define BACKSP        8
  893. #define SHIFTBACKSP   8
  894. #define CTRLBACKSP    127
  895. #define TAB           9
  896. #define SHIFTTAB      0x0F00
  897. #define RETURN        13
  898. #define CTRLRETURN    10
  899.  
  900. #define GRAY_ENTER     0xe00d
  901. #define GRAY_MINUS     0x4a2d
  902. #define GRAY_PLUS      0x4e2b
  903. #define GRAY_DIVIDE    0xe02f
  904. #define GRAY_MULTIPLY  0x372a
  905.  
  906. #define CTRLA         1
  907. #define CTRLB         2
  908. #define CTRLC         3
  909. #define CTRLD         4
  910. #define CTRLE         5
  911. #define CTRLF         6
  912. #define CTRLG         7
  913. #define CTRLH         8
  914. #define CTRLI         9
  915. #define CTRLJ         10
  916. #define CTRLK         11
  917. #define CTRLL         12
  918. #define CTRLM         13
  919. #define CTRLN         14
  920. #define CTRLO         15
  921. #define CTRLP         16
  922. #define CTRLQ         17
  923. #define CTRLR         18
  924. #define CTRLS         19
  925. #define CTRLT         20
  926. #define CTRLU         21
  927. #define CTRLV         22
  928. #define CTRLW         23
  929. #define CTRLX         24
  930. #define CTRLY         25
  931. #define CTRLZ         26
  932.  
  933. #define ALTA          0x1e00
  934. #define ALTB          0x3000
  935. #define ALTC          0x2e00
  936. #define ALTD          0x2000
  937. #define ALTE          0x1200
  938. #define ALTF          0x2100
  939. #define ALTG          0x2200
  940. #define ALTH          0x2300
  941. #define ALTI          0x1700
  942. #define ALTJ          0x2400
  943. #define ALTK          0x2500
  944. #define ALTL          0x2600
  945. #define ALTM          0x3200
  946. #define ALTN          0x3100
  947. #define ALTO          0x1800
  948. #define ALTP          0x1900
  949. #define ALTQ          0x1000
  950. #define ALTR          0x1300
  951. #define ALTS          0x1f00
  952. #define ALTT          0x1400
  953. #define ALTU          0x1600
  954. #define ALTV          0x2f00
  955. #define ALTW          0x1100
  956. #define ALTX          0x2d00
  957. #define ALTY          0x1500
  958. #define ALTZ          0x2c00
  959. #define ALT0          0x8100
  960. #define ALT1          0x7800
  961. #define ALT2          0x7900
  962. #define ALT3          0x7a00
  963. #define ALT4          0x7b00
  964. #define ALT5          0x7c00
  965. #define ALT6          0x7d00
  966. #define ALT7          0x7e00
  967. #define ALT8          0x7f00
  968. #define ALT9          0x8000
  969. #define ALTHYPHEN     0x8200
  970. #define ALTEQUAL      0x8300
  971.  
  972.  
  973. /* These keys should be used if porting application to UNIX system */
  974. /* The constant names should match the names that are used in tinfo.h */
  975.  
  976. #ifdef MSDOS
  977. #define CWLKEY_FN1       F1
  978. #define CWLKEY_FN2       F2
  979. #define CWLKEY_FN3       F3
  980. #define CWLKEY_FN4       F4
  981. #define CWLKEY_FN5       F5
  982. #define CWLKEY_FN6       F6
  983. #define CWLKEY_FN7       F7
  984. #define CWLKEY_FN8       F8
  985. #define CWLKEY_FN9       F9
  986. #define CWLKEY_FN10       F10
  987. #define CWLKEY_FN11       F11
  988. #define CWLKEY_FN12       F12
  989. #define CWLKEY_DOWN        DARROW
  990. #define CWLKEY_UP          UARROW
  991. #define CWLKEY_LEFT        LARROW
  992. #define CWLKEY_RIGHT       RARROW
  993. #define CWLKEY_HOME        HOME
  994. #define CWLKEY_END         END
  995. #define CWLKEY_DELETE      DEL
  996. #define CWLKEY_BACKSPACE   BACKSP
  997. #define CWLKEY_BACKTAB     SHIFTTAB
  998. #define CWLKEY_PAGEDOWN    PGDN
  999. #define CWLKEY_PAGEUP      PGUP
  1000. #define CWLKEY_INSERT      INS
  1001. #define CWLKEY_CTRLE       CTRLE
  1002. #define CWLKEY_ESCAPE      ESC
  1003. #define CWLKEY_RETURN      13
  1004. #define CWLKEY_TAB         9
  1005. #define CWLKEY_CUSTOM      10000
  1006. #endif
  1007.  
  1008. /* The following keys are used to test the shift state */
  1009.  
  1010. #define RSHIFT        1     /* Right Shift key */
  1011. #define LSHIFT        2     /* Left Shift key */
  1012. #define CTRL          4     /* Control key */
  1013. #define ALT           8     /* Alt key */
  1014. #define SCRLOCK       16    /* Scroll lock */
  1015. #define NUMLOCK       32    /* Num lock    */
  1016. #define CAPSLOCK      64    /* Caps Lock   */
  1017. #define INSERT        128   /* Insert key  */
  1018. #define LCTRL         256   /* Left CTRL key (enhanced keyboard only) */
  1019. #define LALT          512   /* Left ALT key (enhanced keyboard only) */
  1020. #define RCTRL         1024  /* Right CTRL key (enhanced keyboard only) */
  1021. #define RALT          2048  /* Right ALT key */
  1022. #define SCRLOCK2      4096  /* Same as SCRLOCK (enhanced keyboard only) */
  1023. #define NUMLOCK2      8192  /* Same as NUMLOCK (enhanced keyboard only) */
  1024. #define CAPSLOCK2     16384 /* Same as CAPSLOCK (enhanced keyboard only) */
  1025. #define SYSREQ        32768 /* SYSREQ (can only be tested with INT 15H) */
  1026.  
  1027.  
  1028.  
  1029. /* PC scan codes */
  1030.  
  1031. #define SC_ESC                   0x01
  1032. #define SC_1                     0x02
  1033. #define SC_2                     0x03
  1034. #define SC_3                     0x04
  1035. #define SC_4                     0x05
  1036. #define SC_5                     0x06
  1037. #define SC_6                     0x07
  1038. #define SC_7                     0x08
  1039. #define SC_8                     0x09
  1040. #define SC_9                     0x0A
  1041. #define SC_0                     0x0B
  1042. #define SC_HYPHEN                0x0C
  1043. #define SC_EQUAL                 0x0D
  1044. #define SC_BS                    0x0E
  1045. #define SC_TAB                   0x0F
  1046. #define SC_Q                     0x10
  1047. #define SC_W                     0x11
  1048. #define SC_E                     0x12
  1049. #define SC_R                     0x13
  1050. #define SC_T                     0x14
  1051. #define SC_Y                     0x15
  1052. #define SC_U                     0x16
  1053. #define SC_I                     0x17
  1054. #define SC_O                     0x18
  1055. #define SC_P                     0x19
  1056. #define SC_LBRACKET              0x1A
  1057. #define SC_RBRACKET              0x1B
  1058. #define SC_ENTER                 0x1C
  1059. #define SC_CTRL                  0x1D
  1060. #define SC_A                     0x1E
  1061. #define SC_S                     0x1F
  1062. #define SC_D                     0x20
  1063. #define SC_F                     0x21
  1064. #define SC_G                     0x22
  1065. #define SC_H                     0x23
  1066. #define SC_J                     0x24
  1067. #define SC_K                     0x25
  1068. #define SC_L                     0x26
  1069. #define SC_SCOLON                0x27
  1070. #define SC_QUOTE                 0x28
  1071. #define SC_ACCENT                0x29
  1072. #define SC_LSHIFT                0x2A
  1073. #define SC_BSLASH                0x2B
  1074. #define SC_Z                     0x2C
  1075. #define SC_X                     0x2D
  1076. #define SC_C                     0x2E
  1077. #define SC_V                     0x2F
  1078. #define SC_B                     0x30
  1079. #define SC_N                     0x31
  1080. #define SC_M                     0x32
  1081. #define SC_COMMA                 0x33
  1082. #define SC_DOT                   0x34
  1083. #define SC_FSLASH                0x35
  1084. #define SC_RSHIFT                0x36
  1085. #define SC_MULTIPLY              0x37
  1086. #define SC_ALT                   0x38
  1087. #define SC_SPACE                 0x39
  1088. #define SC_CAPSLOCK              0x3A
  1089. #define SC_F1                    0x3B
  1090. #define SC_F2                    0x3C
  1091. #define SC_F3                    0x3D
  1092. #define SC_F4                    0x3E
  1093. #define SC_F5                    0x3F
  1094. #define SC_F6                    0x40
  1095. #define SC_F7                    0x41
  1096. #define SC_F8                    0x42
  1097. #define SC_F9                    0x43
  1098. #define SC_F10                   0x44
  1099. #define SC_NUMLOCK               0x45
  1100. #define SC_SCRLOCK               0x46
  1101. #define SC_HOME                  0x47
  1102. #define SC_UP                    0x48
  1103. #define SC_PGUP                  0x49
  1104. #define SC_MINUS                 0x4A
  1105. #define SC_LEFT                  0x4B
  1106. #define SC_NUMPAD5               0x4C
  1107. #define SC_RIGHT                 0x4D
  1108. #define SC_ADD                   0x4E
  1109. #define SC_END                   0x4F
  1110. #define SC_DOWN                  0x50
  1111. #define SC_PGDN                  0x51
  1112. #define SC_INS                   0x52
  1113. #define SC_DEL                   0x53
  1114. #define SC_F11                   0x57
  1115. #define SC_F12                   0x58
  1116.  
  1117. #define SC_LBUTTON               0x60
  1118. #define SC_RBUTTON               0x61
  1119. #define SC_MBUTTON               0x62
  1120.  
  1121. /* Fake scan codes for enhanced keys */
  1122. #define FAKE_SCAN                0xE0
  1123. #define SC_ENHANCED              (FAKE_SCAN + 0)
  1124. #define SC_PRTSCR                (FAKE_SCAN + 1)   /* Made up printscr scan code */
  1125.  
  1126.  
  1127. #define ISFKEY(code)      (((code) >= SC_F1 && (code) <= SC_F10) || \
  1128.                             (code) == SC_F11 || (code) == SC_F12)
  1129.  
  1130. #define SC_NUMPAD0        0x70
  1131. #define SC_NUMPAD1        0x71
  1132. #define SC_NUMPAD2        0x72
  1133. #define SC_NUMPAD3        0x73
  1134. #define SC_NUMPAD4        0x74
  1135. #define SC_NUMPAD6        0x75
  1136. #define SC_NUMPAD7        0x76
  1137. #define SC_NUMPAD8        0x77
  1138. #define SC_NUMPAD9        0x78
  1139.  
  1140.  
  1141. /* virtual keys (compatible with Microsoft Windows) */
  1142. #define VK_LBUTTON          0x01
  1143. #define VK_RBUTTON          0x02
  1144. #define VK_CANCEL           0x03
  1145. #define VK_MBUTTON          0x04
  1146. #define VK_BACK             0x08
  1147. #define VK_TAB              0x09
  1148. #define VK_CLEAR            0x0C
  1149. #define VK_RETURN           0x0D
  1150. #define VK_SHIFT            0x10
  1151. #define VK_CONTROL          0x11
  1152. #define VK_MENU             0x12
  1153. #define VK_PAUSE            0x13
  1154. #define VK_CAPITAL          0x14
  1155. #define VK_ESCAPE           0x1B
  1156. #define VK_SPACE            0x20
  1157. #define VK_PRIOR            0x21
  1158. #define VK_NEXT             0x22
  1159. #define VK_END              0x23
  1160. #define VK_HOME             0x24
  1161. #define VK_LEFT             0x25
  1162. #define VK_UP               0x26
  1163. #define VK_RIGHT            0x27
  1164. #define VK_DOWN             0x28
  1165. #define VK_SELECT           0x29
  1166. #define VK_PRINT            0x2A
  1167. #define VK_EXECUTE          0x2B
  1168. #define VK_SNAPSHOT         0x2C
  1169. #define VK_INSERT           0x2D
  1170. #define VK_DELETE           0x2E
  1171. #define VK_HELP             0x2F
  1172.  
  1173. #define VK_0                0x30
  1174. #define VK_1                0x31
  1175. #define VK_2                0x32
  1176. #define VK_3                0x33
  1177. #define VK_4                0x34
  1178. #define VK_5                0x35
  1179. #define VK_6                0x36
  1180. #define VK_7                0x37
  1181. #define VK_8                0x38
  1182. #define VK_9                0x39
  1183. #define VK_A                0x41
  1184. #define VK_B                0x42
  1185. #define VK_C                0x43
  1186. #define VK_D                0x44
  1187. #define VK_E                0x45
  1188. #define VK_F                0x46
  1189. #define VK_G                0x47
  1190. #define VK_H                0x48
  1191. #define VK_I                0x49
  1192. #define VK_J                0x4A
  1193. #define VK_K                0x4B
  1194. #define VK_L                0x4C
  1195. #define VK_M                0x4D
  1196. #define VK_N                0x4E
  1197. #define VK_O                0x4F
  1198. #define VK_P                0x50
  1199. #define VK_Q                0x51
  1200. #define VK_R                0x52
  1201. #define VK_S                0x53
  1202. #define VK_T                0x54
  1203. #define VK_U                0x55
  1204. #define VK_V                0x56
  1205. #define VK_W                0x57
  1206. #define VK_X                0x58
  1207. #define VK_Y                0x59
  1208. #define VK_Z                0x5A
  1209.  
  1210. #define VK_NUMPAD0          0x60
  1211. #define VK_NUMPAD1          0x61
  1212. #define VK_NUMPAD2          0x62
  1213. #define VK_NUMPAD3          0x63
  1214. #define VK_NUMPAD4          0x64
  1215. #define VK_NUMPAD5          0x65
  1216. #define VK_NUMPAD6          0x66
  1217. #define VK_NUMPAD7          0x67
  1218. #define VK_NUMPAD8          0x68
  1219. #define VK_NUMPAD9          0x69
  1220. #define VK_MULTIPLY         0x6A
  1221. #define VK_ADD              0x6B
  1222. #define VK_SEPARATOR        0x6C
  1223. #define VK_SUBTRACT         0x6D
  1224. #define VK_DECIMAL          0x6E
  1225. #define VK_DIVIDE           0x6F
  1226. #define VK_F1               0x70
  1227. #define VK_F2               0x71
  1228. #define VK_F3               0x72
  1229. #define VK_F4               0x73
  1230. #define VK_F5               0x74
  1231. #define VK_F6               0x75
  1232. #define VK_F7               0x76
  1233. #define VK_F8               0x77
  1234. #define VK_F9               0x78
  1235. #define VK_F10              0x79
  1236. #define VK_F11              0x7A
  1237. #define VK_F12              0x7B
  1238. #define VK_F13              0x7C
  1239. #define VK_F14              0x7D
  1240. #define VK_F15              0x7E
  1241. #define VK_F16              0x7F
  1242. #define VK_F17              0x80
  1243. #define VK_F18              0x81
  1244. #define VK_F19              0x82
  1245. #define VK_F20              0x83
  1246. #define VK_F21              0x84
  1247. #define VK_F22              0x85
  1248. #define VK_F23              0x86
  1249. #define VK_F24              0x87
  1250. #define VK_NUMLOCK          0x90
  1251. #define VK_SCROLL           0x91
  1252. #define VK_COMMA            0xBC
  1253. #define VK_PERIOD           0xBE
  1254.  
  1255. #define VK_LSHIFT           0xC0
  1256. #define VK_RSHIFT           0xC1
  1257.  
  1258. #define VK_ALT              VK_MENU
  1259.  
  1260. #define ST_NUMLOCK          0
  1261. #define ST_CAPITAL          1
  1262. #define ST_SCROLL           2
  1263. #define NUMTOGGLEKEYS       3
  1264.  
  1265. #ifdef MSDOS
  1266. #define FLUSH_KEYBOARD()       flush_keyboard(CWLenhanced_keyboard?17:1)
  1267. #define ISKEYREADY()           key_ready(CWLenhanced_keyboard?17:1)
  1268. #define GET_SHIFT_STATE()      bioskbd(2)
  1269. #define GET_KEY()              getkeyfunc(0)
  1270. #define GET_ENHANCED_KEY()     getkeyfunc(1)
  1271. #define ENHANCED_KEYBOARD()    (CWLenhanced_keyboard?1:0)
  1272. #endif
  1273.  
  1274. #ifdef COHERENT
  1275. #define GET_KEY()              CWLtermgetkey()
  1276. #define ISKEYREADY()           CWLtermkeyready()
  1277. #define GET_ENHANCED_KEY()     GET_KEY()
  1278. #define GET_SHIFT_STATE()      (0)
  1279. #define FLUSH_KEYBOARD()       CWLtermflushkbd()
  1280. #endif
  1281.  
  1282.  
  1283. #define OVERSTRIKEMODE      0
  1284. #define INSERTMODE          1
  1285.  
  1286. #define KEYPRESSED          0
  1287. #define MOUSEPRESSED        1
  1288.  
  1289.  
  1290. #define UPPERCASE                1
  1291. #define LOWERCASE                2
  1292. #define CHECKSPACES              4
  1293. #define ENHANCEDKEY              8
  1294. #define CHECKREGEXP             16
  1295. #define AUTORETURN              32
  1296. #define CHECKREGEXP_IGNORECASE  64
  1297. #define FLUSHBUFFER            128
  1298. #define HOMECURSOR             256
  1299. #define USEMOUSE               512
  1300. #define CLEARFIELD            1024
  1301. #define VIRTUALFIELD          2048
  1302.  
  1303. #define DONT_PROCESS        0
  1304. #define MOVE_CURSOR_LEFT    1
  1305. #define MOVE_CURSOR_RIGHT   2
  1306. #define DELETE_AT_CURSOR    3
  1307. #define TOGGLE_INSERT       4
  1308. #define DESTRUCT_BACKSPACE  5
  1309. #define ACCEPT_INPUT        6
  1310. #define ACCEPT_DEFAULT      7
  1311. #define ERASE_INPUT         8
  1312. #define GOTO_FIRST          9
  1313. #define GOTO_LAST          10
  1314. #define INSERT_CHARACTER   11
  1315. #define MOVE_TO_CHARACTER  12
  1316. #define GOTO_NEXT_FIELD    13
  1317. #define GOTO_PREV_FIELD    14
  1318. #define EXIT_FORM_ACCEPT   15
  1319. #define EXIT_FORM_CLEAR    16
  1320. #define CLEAR_FORM         17
  1321.  
  1322. #define MOVELEFT_KEY        0
  1323. #define MOVERIGHT_KEY       1
  1324. #define DELNOMOVE_KEY       2
  1325. #define INSTOGGLE_KEY       3
  1326. #define ERASE_KEY           4
  1327. #define BACKSPACE_KEY       5
  1328. #define ACCEPT_KEY          6
  1329. #define ACCEPTDEFAULT_KEY   7
  1330. #define HOME_KEY            8
  1331. #define END_KEY             9
  1332.  
  1333. /********************************************
  1334.  * Key locations in the CWLform_edit_key array *
  1335.  ********************************************/
  1336.  
  1337. #define FIELD_MOVELEFT_KEY         MOVELEFT_KEY
  1338. #define FIELD_MOVERIGHT_KEY        MOVERIGHT_KEY
  1339. #define FIELD_DELNOMOVE_KEY        DELNOMOVE_KEY
  1340. #define FIELD_INSTOGGLE_KEY        INSTOGGLE_KEY
  1341. #define FIELD_ERASE_KEY            ERASE_KEY
  1342. #define FIELD_BACKSPACE_KEY        BACKSPACE_KEY
  1343. #define FIELD_ACCEPT_KEY           ACCEPT_KEY
  1344. #define FIELD_ACCEPTDEFAULT_KEY    ACCEPTDEFAULT_KEY
  1345. #define FIELD_HOME_KEY             HOME_KEY
  1346. #define FIELD_END_KEY              END_KEY
  1347. #define FIELD_PREVFIELD_KEY        10
  1348. #define FIELD_NEXTFIELD_KEY        11
  1349. #define FORM_EXIT_ACCEPT_KEY       12
  1350. #define FORM_CANCEL_KEY            13
  1351. #define FORM_CLEAR_KEY             14
  1352. #define FIELD_TOGGLE_KEY           15
  1353.  
  1354. #define RADIO_PREVENTRY_KEY        16
  1355. #define RADIO_NEXTENTRY_KEY        17
  1356. #define RADIO_NEXTFIELD_KEY        18
  1357. #define RADIO_PREVFIELD_KEY        19
  1358.  
  1359. #define CHECKBOX_CHOICE_KEY        20
  1360. #define CHECKBOX_PREVENTRY_KEY     21
  1361. #define CHECKBOX_NEXTENTRY_KEY     22
  1362. #define CHECKBOX_NEXTFIELD_KEY     23
  1363. #define CHECKBOX_PREVFIELD_KEY     24
  1364.  
  1365. #define BUTTON_ACCEPT_KEY          25
  1366. #define BUTTON_PREVFIELD_KEY       26
  1367. #define BUTTON_NEXTFIELD_KEY       27
  1368.  
  1369. #define LIST_UP_KEY              28
  1370. #define LIST_DOWN_KEY            29
  1371. #define LIST_ACCEPT_KEY          30
  1372. #define LIST_HOME_KEY            31
  1373. #define LIST_END_KEY             32
  1374. #define LIST_PAGEUP_KEY          33
  1375. #define LIST_PAGEDOWN_KEY        34
  1376. #define LIST_NEXTFIELD_KEY       35
  1377. #define LIST_PREVFIELD_KEY       36
  1378.  
  1379.  
  1380. #define FIELD_CONTINUE         DONT_PROCESS
  1381. #define FIELD_MOVELEFT         MOVE_CURSOR_LEFT
  1382. #define FIELD_MOVERIGHT        MOVE_CURSOR_RIGHT
  1383. #define FIELD_DELNOMOVE        DELETE_AT_CURSOR
  1384. #define FIELD_INSTOGGLE        TOGGLE_INSERT
  1385. #define FIELD_BACKSPACE        DESTRUCT_BACKSPACE
  1386. #define FIELD_ACCEPT           ACCEPT_INPUT
  1387. #define FIELD_ACCEPTDEFAULT    ACCEPT_DEFAULT
  1388. #define FIELD_ERASEINPUT       ERASE_INPUT
  1389. #define FIELD_GOTOFIRST        GOTO_FIRST
  1390. #define FIELD_GOTOLAST         GOTO_LAST
  1391. #define FIELD_INSERTCHAR       INSERT_CHARACTER
  1392. #define FIELD_MOVE_TO_CHARACTER MOVE_TO_CHARACTER
  1393. #define FIELD_NEXTFIELD        GOTO_NEXT_FIELD
  1394. #define FIELD_PREVFIELD        GOTO_PREV_FIELD
  1395. #define FORM_ACCEPT            EXIT_FORM_ACCEPT
  1396. #define FORM_CANCEL            EXIT_FORM_CLEAR
  1397. #define FORM_CLEAR             CLEAR_FORM
  1398.  
  1399.  
  1400. #define FORM_END                18
  1401. #define FIELD_REEDIT            19
  1402. #define FIELD_NEWFIELD          20
  1403. #define FIELD_PROCESS_DATA      21
  1404. #define FIELD_CONTINUE_PROCESS  22
  1405. #define FORM_REEDIT             23
  1406. #define FIELD_EDIT              24
  1407. #define FORM_END_PROCESS        25
  1408. #define LIST_MOVE_UP            26
  1409. #define LIST_MOVE_DOWN          27
  1410. #define LIST_ACCEPT             28
  1411. #define LIST_PAGEUP             29
  1412. #define LIST_PAGEDOWN           30
  1413. #define LIST_HOME               31
  1414. #define LIST_END                32
  1415.  
  1416.  
  1417. #define NO_HELP                 (-1)
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423. unsigned      bioskbd _PROTO_((int));
  1424. int           GetEnhancedKeyboard _PROTO_((CWL_VOID ));
  1425. #ifdef MSDOS
  1426. unsigned      getkeyfunc _PROTO_((int));
  1427. #endif
  1428. int           key_ready _PROTO_((int));
  1429. CWL_VOID      flush_keyboard _PROTO_((int));
  1430. unsigned      process_keyval _PROTO_((int));
  1431. int           CWLcheck_form_help _PROTO_((unsigned));
  1432. CWL_VOID      StartKeyboardEvent _PROTO_((CWL_VOID ));
  1433. CWL_VOID      EndKeyboardEvent _PROTO_((CWL_VOID ));
  1434. CWL_VOID      CWLQuitMessage _PROTO_((CWL_VOID ));
  1435.  
  1436.  
  1437. /* define error messages */
  1438. /******************** Window Error Codes*****************/
  1439. #define NO_ERROR            0
  1440.  
  1441. #define NO_HEAP_MEM        (-1)
  1442. #define BAD_DISPLAY_PAGE   (-2)
  1443. #define INVALID_VIDEO_MODE (-3)
  1444. #define INVALID_ROWS       (-4)
  1445. #define NOT_SUPPORTED      (-5)
  1446.  
  1447. #define BAD_WINDOW         (-100)
  1448. #define BAD_WINDOW_SIZE    (-101)
  1449. #define WINDOW_NOT_OPEN    (-102)
  1450. #define WINDOW_BOUND       (-103)
  1451. #define MAX_WINDOW         (-104)
  1452. #define WINDOW_INV_PARAM   (-105)
  1453. #define NO_INPUT_CHARS     (-106)
  1454. #define TOO_MANY_CHARS     (-107)
  1455.  
  1456. #define BAD_V_WINDOW       (-200)
  1457. #define END_V_WINDOW       (-201)
  1458. #define V_WINDOW_BOUND     (-202)
  1459. #define MAX_V_WINDOW       (-203)
  1460. #define NO_ATTRIB          (-204)
  1461.  
  1462. #define FILE_NO_EXIST      (-300)
  1463. #define FILE_CANT_CLOSE    (-301)
  1464. #define FILE_CANT_OPEN     (-302)
  1465.  
  1466.  
  1467. #define MENU_ENTRY_INVALID  (-400)
  1468. #define POPUP_VHEIGHT_ERROR (-401)
  1469. #define POPUP_VWIDTH_ERROR  (-402)
  1470. #define BAR_WWIDTH_ERROR    (-403)
  1471. #define BAR_WHEIGHT_ERROR   (-404)
  1472. #define POPUP_NOT_ATTACHED  (-405)
  1473. #define BAR_NOT_ATTACHED    (-406)
  1474. #define PULL_NO_BARMENU     (-407)
  1475. #define POPUP_MENU_INVALID  (-408)
  1476. #define BAR_MENU_INVALID    (-409)
  1477. #define PULLDOWN_MENU_INVALID (-410)
  1478. #define NO_ENTRIES_DEFINED  (-411)
  1479.  
  1480.  
  1481.  
  1482. #define NO_FIELDS_DEFINED    (-500)
  1483. #define UNDEFINED_FORM       (-501)
  1484. #define UNDEFINED_FIELD      (-502)
  1485. #define FIELD_MINCHARS_ERROR (-503)
  1486. #define FIELD_REGEXP_ERROR   (-504)
  1487. #define FIELD_RANGE_ERROR    (-505)
  1488. #define INVALID_FIELD_OPTION (-506)
  1489. #define FIELD_NOT_IN_VIEW    (-507)
  1490. #define NO_FIELD_HELP        (-508)
  1491. #define FIELDTYPE_NOT_SUPPORTED (-509)
  1492. #define HELP_NOT_SUPPORTED   (-510)
  1493. #define VFORM_NOT_SUPPORTED  (-511)
  1494. #define WRONG_FIELDTYPE      (-512)
  1495. #define HELP_NOT_ON          (-513)
  1496.  
  1497.  
  1498. #define NO_USER_HOTSPOTS     (-600)
  1499. #define HOTSPOT_NOT_DEFINED  (-601)
  1500. #define NO_DEFAULT_HOTSPOTS  (-602)
  1501. #define NO_CAPTION           (-603)
  1502.  
  1503. #define NO_TIMERS            (-603)
  1504. #define INVALID_TIMEID       (-604)
  1505.  
  1506. #define TERM_ENVIRONMENT     (-700)
  1507. #define TERMINAL_NOT_FOUND   (-701)
  1508. #define TERMINFO_NOT_FOUND   (-702)
  1509. #define TERMINAL_CLOSE_ERROR (-703)
  1510. #define TERMINAL_OPEN_ERROR  (-704)
  1511. #define TERMKEY_NOT_FOUND    (-705)
  1512.  
  1513. #define NUM_WINDOW_ERRORS  48
  1514. /**********************  End of Error Codes ************************/
  1515.  
  1516. /* define constants that non MS-DOS systems will use for output */
  1517. #define CLEAR_SCREEN      0
  1518. #define CURSOR_GETPOS     1
  1519. #define CURSOR_SETPOS     2
  1520. #define CHAR_ATTR         3
  1521. #define READ_WRITE_MATRIX 4
  1522. #define CHAR_ATTR_VERT    5
  1523. #define CURSOR_OFF        6
  1524. #define CURSOR_ON         7
  1525. #define BLINK_MODE      8
  1526. #define BOLD_MODE         9
  1527. #define STANDOUT_MODE    10
  1528. #define UNDERLINE_MODE   11
  1529. #define EXIT_BLINK_MODE     12
  1530. #define EXIT_STANDOUT_MODE 13
  1531. #define EXIT_BOLD_MODE   14
  1532. #define EXIT_UNDERLINE_MODE   15
  1533. #define CHAR_NOATTR_NULL  16
  1534. #define CHAR_NOATTR    17
  1535. #define CHAR_ATTR_1_NULL 18
  1536. #define CURSOR_SAVE_POS  19
  1537. #define CURSOR_RESTORE_POS 20
  1538. #define SCROLL_UP    21
  1539. #define SCROLL_DOWN    22
  1540. #define KEYPAD_ON       23
  1541. #define KEYPAD_OFF      24
  1542.  
  1543. /**********************  Cursor Definitions ************************/
  1544. #define CREATE_CURSOR_SHAPE(beginline,endline)  ((beginline)<<4+(endline))
  1545. #define THIN          0
  1546. #define BLOCK         1
  1547. #define HALFBLOCK     2
  1548. #define INVISIBLE     3
  1549.  
  1550. /**********************  Testing Constants *************************/
  1551. #define NO_RELATION        0
  1552. #define PARENT_CHILD       1
  1553. #define CHILD_PARENT       2
  1554. #define PARENT_DESCENDANT  3
  1555. #define DESCENDANT_PARENT  4
  1556. #define SIBLING_WINDOWS    5
  1557.  
  1558.  
  1559. CWL_VOID  GetCursorShape _PROTO_((unsigned *, unsigned *));
  1560. CWL_VOID  ChangeCursor _PROTO_((unsigned, unsigned));
  1561. CWL_VOID  BlockCursor _PROTO_((CWL_VOID ));
  1562. CWL_VOID  ThinCursor _PROTO_((CWL_VOID ));
  1563. CWL_VOID  HideCursor _PROTO_((CWL_VOID ));
  1564. CWL_VOID  HalfblockCursor _PROTO_((CWL_VOID ));
  1565.  
  1566. #define SOURCE_LINE   __LINE__
  1567. #define SOURCE_FILE   __FILE__
  1568.  
  1569. /* define window manifest constants and functions */
  1570.  
  1571. #define WIN_NULL_PTR    ((WPOINTER)0)   /* Null Window Pointer */
  1572. #define VWIN_NULL_PTR   ((VWPOINTER)0)  /* Null virtual window pointer */
  1573. #define VBLOCK_NULL_PTR ((VBLOCKPTR)0)  /* Null video block pointer */
  1574.  
  1575. /* Other defines */
  1576.  
  1577. #define SAVE          0
  1578. #define RESTORE       1
  1579.  
  1580. #define BORDER        1
  1581. #define NOBORDER      0
  1582.  
  1583. #define NOATTRIBUTE 0
  1584. #define ATTRIBUTE   1
  1585.  
  1586. #ifndef TRUE
  1587. #define TRUE          1
  1588. #endif
  1589.  
  1590. #ifndef FALSE
  1591. #define FALSE         (!TRUE)
  1592. #endif
  1593.  
  1594. #define MAXWIDTH         140     /* Maximum width of the screen in columns */
  1595. #define MAXCOLS          140     /* Maximum columns in a normal window */
  1596. #define NUMEDITKEYS      12      /* Number of field edit keys */
  1597.  
  1598. #define MAXHEIGHT     80      /* Maximum height of a normal window */
  1599. #define MAXBUFSIZE    1024    /* Maximum internal write buffer size */
  1600.  
  1601. #define DMA           1       /* Direct Screen write */
  1602. #define BIOS          0       /* BIOS screen write */
  1603.  
  1604. #define WRAP          1       /* Wrap flag in window */
  1605. #define CLIP          0       /* Clip output in window */
  1606.  
  1607. #define ANCHORLEFT    1
  1608. #define ANCHORRIGHT   2
  1609. #define ANCHORTOP     1
  1610. #define ANCHORBOTTOM  2
  1611.  
  1612. #define WINDOW_HIDDEN_RANK  (-1)
  1613.  
  1614. #define UP            1
  1615. #define DOWN          2
  1616. #define LEFT          3
  1617. #define RIGHT         4
  1618.  
  1619. #define MAXTAB        50      /* Maximum tab size in windows */
  1620. #define DEFTAB        4       /* Default tab size */
  1621.  
  1622. #define NO_OPTIONS     0      /* Constant defining no options */
  1623.  
  1624. #define MAXPAGES      16      /* Maximum number of video pages */
  1625. #define MAXWINDOWS    32767   /* Maximum windows including base screen */
  1626.  
  1627. #define SHADOWUPLEFT   1      /* Shadow position */
  1628. #define SHADOWUPRIGHT  2      /*       "         */
  1629. #define SHADOWLOWLEFT  3      /*       "         */
  1630. #define SHADOWLOWRIGHT 4      /*       "         */
  1631.  
  1632. #define WINDOWCHECK    1      /* Check constant  */
  1633. #define VWINDOWCHECK   2      /* Check constant  */
  1634.  
  1635. /* Explosion effects */
  1636. #define NOEFFECT       0
  1637. #define EXPLODE        1
  1638. #define CONTRACT       2
  1639. #define BRICKS         3
  1640. #define MIDDLEROWOUT   4
  1641. #define TOPBOTTOMIN    5
  1642. #define TOPDOWN        6
  1643. #define BOTTOMUP       7
  1644. #define MIDDLECOLOUT   8
  1645. #define LEFTRIGHTIN    9
  1646. #define LEFTTORIGHT   10
  1647. #define RIGHTTOLEFT   11
  1648. #define SLIDELEFT     12
  1649. #define SLIDERIGHT    13
  1650. #define SLIDEDOWN     14
  1651. #define SLIDEUP       15
  1652.  
  1653. #define MAX_SPECIAL_EFFECT  15
  1654.  
  1655. /*** Colors used as macros ***/
  1656.  
  1657. #define BLACK_        0
  1658. #define BLUE_         1
  1659. #define GREEN_        2
  1660. #define CYAN_         3
  1661. #define RED_          4
  1662. #define MAGENTA_      5
  1663. #define BROWN_        6
  1664. #define WHITE_        7
  1665. #define GRAY_         8
  1666. #define LIGHTBLUE_    9
  1667. #define LIGHTGREEN_   10
  1668. #define LIGHTCYAN_    11
  1669. #define LIGHTRED_     12
  1670. #define LIGHTMAGENTA_ 13
  1671. #define YELLOW_       14
  1672. #define LIGHTWHITE_   15
  1673.  
  1674. #ifdef MSDOS
  1675. #define UNDERLINE_    BLUE_       /* use as foreground */
  1676.  
  1677. #if 0
  1678. #define BRIGHT_       LIGHTBLUE_  /* use as foreground */
  1679. #define BLINK_        LIGHTBLUE_  /* use as background */
  1680. #endif
  1681.  
  1682. #endif
  1683.  
  1684. #ifdef MSDOS
  1685. /* Macros for monochrome colors */
  1686. #define BRIGHT_        8
  1687. #define BLINK_         8
  1688. #endif
  1689.  
  1690. /* Macros for COHERENT / UNIX */
  1691.  
  1692. #ifdef COHERENT
  1693. #define BLINK_     8
  1694. #define BOLD_      8
  1695. #endif
  1696.  
  1697. /* Constants used for centering a window */
  1698. #define HORIZCENTER   1
  1699. #define VERTCENTER    2
  1700.  
  1701. /* Constants used when copying window */
  1702. #define COPYTEXT      1
  1703. #define MAKEVIEWPORT  2
  1704.  
  1705. /* define is... macros */
  1706. #define ISBORDER(w)          (int) (((w)->stat_info.border_flag)?1:0)
  1707. #define ISWRAP(w)            (int) (((w)->stat_info.wrap_flag)?1:0)
  1708. #define ISOPEN(w)            (int) (((w)->stat_info.open_flag)?1:0)
  1709. #define ISVISIBLE(w)         (int) (((w)->stat_info.visible_flag)?1:0)
  1710. #define ISVIEWPORT(w)        (int) (((w)->stat_info.v_window_flag)?1:0)
  1711. #define ISWINDOW(vw)         (int) (((vw)->stat_info.viewport_flag)?1:0)
  1712. #define ISSEETHRU(w)         (int) (((w)->stat_info.seethru_flag)?1:0)
  1713. #define ISINITIAL(w)         (int) (((w)->stat_info.init_flag)?1:0)
  1714. #define ISFROZEN(w)          (int) (((w)->stat_info.frozen_flag)?1:0)
  1715. #define ISSHADOW(w)          (int) \
  1716.                               (((w)->shadow_info.shadow_stat.shadow_flag)?1:0)
  1717. #define ISSHADOWTRANS(w)     (int) ((ISSHADOW(w) && \
  1718.                              SHADOW_WINDOW(w)->stat_info.shadow_trans)?1:0)
  1719.  
  1720. #define TRANSPARENT_WINDOW(w) (int) ((w)->stat_info.shadow_trans)
  1721.  
  1722. /* The following macros are title macros */
  1723. #define ISNULLCHAR(s)        (((s) == (char *)0) || (*(s) == '\0'))
  1724. #define WINDOW_TITLE_TOP(w)       ((w)->title_info.titletop)
  1725. #define WINDOW_TITLE_BOTTOM(w)    ((w)->title_info.titlebot)
  1726. #define WINDOW_TITLE_TOP_COLOR(w)       ((w)->title_info.titletop_attr)
  1727. #define WINDOW_TITLE_BOTTOM_COLOR(w)    ((w)->title_info.titlebot_attr)
  1728.  
  1729. #define ISTITLE_TOP(w)        (int) (ISNULLCHAR(WINDOW_TITLE_TOP(w))?0:1)
  1730.  
  1731. #define WINDOW_TITLE_TOP_POS(w)  (int) \
  1732.                              (ISTITLE_TOP(w)?(w)->title_info.titletop_pos:0)
  1733.  
  1734. #define ISTITLE_BOTTOM(w)     (int) (ISNULLCHAR(WINDOW_TITLE_BOTTOM(w))?0:1)
  1735.  
  1736. #define WINDOW_TITLE_BOTTOM_POS(w)  (int) \
  1737.                              (ISTITLE_BOTTOM(w)?(w)->title_info.titlebot_pos:0)
  1738.  
  1739. #define ISTITLE(w)           (int) (ISTITLE_TOP(w) || ISTITLE_BOTTOM(w))
  1740.  
  1741. #define TITLECENTER          1
  1742. #define TITLELEFT            2
  1743. #define TITLERIGHT           3
  1744. #define TITLETOP             4
  1745. #define TITLEBOTTOM          5
  1746.  
  1747. /***************************************************/
  1748.  
  1749. /* Shadow macros */
  1750. #define SHADOW_POS(w)        (int)(((w)->shadow_info.shadow_stat.shadow_pos))
  1751. #define SHADOW_CHAR(w)       (int)(((w)->shadow_info.schar))
  1752. #define SHADOW_ATTR(w)       (int)(((w)->shadow_info.sattr))
  1753. #define SHADOW_WIDTH(w)      (int)(((w)->shadow_info.swidth))
  1754. #define SHADOW_HEIGHT(w)     (int)(((w)->shadow_info.sheight))
  1755.  
  1756.  
  1757. #define VWTYPE(vw)      (int) ((vw)->stat_info.vwtype)
  1758. #define VWWRAP(vw)      (vw)->stat_info.wrap_flag
  1759.  
  1760. #define EDGES(w)              ((int)((ISBORDER((w))?2:0)))
  1761. #define EDGEDIF(w)            ((int)((ISBORDER((w))?1:-1)))
  1762.  
  1763. #define WLASTROW(w)           get_last_row(w)
  1764.  
  1765. #define WLASTCOL(w)           get_last_col(w)
  1766.  
  1767. /* Existence macros */
  1768. #define WINDOW_EXIST(w)   ((CWLfind_object(CWLwindow_object,(w)) == -1 \
  1769.                              || (!w))?0:1)
  1770.  
  1771. #define VIRTUAL_WINDOW_EXIST(vw) ((CWLfind_object(CWLvwindow_object,(vw)) == -1 \
  1772.                                     || (!vw))?0:1)
  1773.  
  1774. /* General window macros */
  1775.  
  1776. #define DESKTOP_WINDOW               ((WPOINTER)1)
  1777. #define DESKTOP_PAGE_WINDOW(x)       ((WPOINTER)((x) + 1))
  1778.  
  1779. #define VIEWPORT_ROW(w)              ((w)->vwrow)
  1780. #define VIEWPORT_COLUMN(w)           ((w)->vwcol)
  1781. #define VIRTUAL_WINDOW(w)            ((w)->vwptr)
  1782. #define WINDOW_RANK(w)               ((w)->rank)
  1783. #define WINDOW_TEXT_COLOR(w)         ((w)->wattr)
  1784. #define WINDOW_BORDER_COLOR(w)       ((w)->battr)
  1785. #define WINDOW_PAGENUM(w)            ((w)->pagenum)
  1786. #define WINDOW_WIDTH(w)              ((w)->width)
  1787. #define WINDOW_HEIGHT(w)             ((w)->height)
  1788. #define SHADOW_WINDOW(w)             ((w)->shadow_window)
  1789. #define SHADOW_USE(w)                ((w)->stat_info.shadow_use)
  1790. #define CHILD_ENUM(w)                ((w)->stat_info.child_enum)
  1791. #define WINDOW_ROW(w)                ((w)->row)
  1792. #define WINDOW_FIRST_ROW(w)          ((w)->first_row)
  1793. #define WINDOW_TEXTAREA_HEIGHT(w)    ((w)->height - (w)->first_row)
  1794. #define WINDOW_TEXTAREA_WIDTH(w)     ((w)->width)
  1795. #define WINDOW_NCHEIGHT(w)           (WINDOW_HEIGHT(w) - \
  1796.                                       WINDOW_TEXTAREA_HEIGHT(w) + ISBORDER(w))
  1797. #define WINDOW_NCWIDTH(w)            (ISBORDER(w))
  1798. #define WINDOW_TOTAL_HEIGHT(w)       ((w)->height + EDGES(w))
  1799. #define WINDOW_TOTAL_WIDTH(w)        ((w)->width + EDGES(w))
  1800. #define WINDOW_PARENT(w)             ((w)->parent)
  1801. #define BASEPARENT(w)                ((w)->baseparent)
  1802. #define ABS_SCREEN_ROW(w)            ((w)->srow)
  1803. #define ABS_SCREEN_COL(w)            ((w)->scol)
  1804.  
  1805. #define WINDOWPTR(i)        ((WPOINTER)(CWLwindow_object->objarray[i]))
  1806.  
  1807. #define FIND_WINDOWPTR(w)   (CWLfind_object(CWLwindow_object,(w)))
  1808.  
  1809. #define ADD_WINDOWPTR(w)    (CWLadd_object(CWLwindow_object,(w)))
  1810.  
  1811. #define DELETE_WINDOWPTR(w) (CWLdelete_object(CWLwindow_object, \
  1812.                                               FIND_WINDOWPTR(w)))
  1813.  
  1814. #ifdef POWERC
  1815.   int WINDOW_COLUMN(WPOINTER w);
  1816. #else
  1817.   #define WINDOW_COLUMN(w)             ((w)->col)
  1818. #endif
  1819.  
  1820. #define WINDOW_BORDER_CHARS(w)       ((w)->boxchars)
  1821. #define VIRTUAL_TEXT_COLOR(vw)       ((vw)->attr)
  1822. #define VIRTUAL_WIDTH(vw)            ((vw)->ncols)
  1823. #define VIRTUAL_HEIGHT(vw)           ((vw)->nrows)
  1824. #define VIRTUAL_ATTRIBUTE_ON(vw)     ((vw)->stat_info.vwtype)
  1825. #define VWINDOW_COORD_IN_VIEWPORT(w,row,col) \
  1826.                                    ((((col) >= (w)->vwcol) && \
  1827.                                    ((col) <= (w)->vwcol+(w)->width-1) && \
  1828.                                    ((row) >= (w)->vwrow) && \
  1829.                                    ((row) <= (w)->vwrow+(w)->height-1))?1:0)
  1830.  
  1831. #define WINDOW_USE(w)              ((w)->stat_info.use_flag)
  1832.  
  1833. /* miscellaneous macros */
  1834. #define SCROLL_BOTTOM      1
  1835. #define SCROLL_SIDE        2
  1836.  
  1837. #define POPUP_USE            1
  1838. #define BAR_USE              2
  1839. #define FORM_USE             3
  1840. #define HIWORD(x)            ((long)((long)(x) >> 16))
  1841. #define LOWORD(x)            ((long)((long)(x) & 0x0000FFFF))
  1842. #define LOBYTE(w)            ((unsigned char)(w))
  1843. #define HIBYTE(w)            ((unsigned char)((unsigned)(w) >> 8))
  1844. #define MAKELONG(low, high)  ((unsigned long)(((unsigned)(low)) | \
  1845.                              (((unsigned long)((unsigned)(high))) << 16)))
  1846. #ifdef MSDOS
  1847. #define SETNULLFUNC(x)       memset((CWL_VOID **)&(x),0,sizeof(NULLFN))
  1848. #else
  1849. #define SETNULLFUNC(x)       memset((char **)&(x),0,sizeof(NULLFN))
  1850. #endif
  1851.  
  1852. #define UPDATE_CHILDREN    0
  1853. #define HIDE_CHILDREN      1
  1854. #define CHILD_ADD_COL      2
  1855. #define CHILD_ADD_ROW      3
  1856. #define REPLACE_CHILDREN   4
  1857. #define MOVE_RELATIVE_X    5
  1858. #define MOVE_RELATIVE_Y    6
  1859. #define HIGH_LEVEL_HIDE    7
  1860. #define HIGH_LEVEL_DISPLAY 8
  1861. #define INITIALIZE_POSITION 9
  1862. #define RERANK_CHILDREN    10
  1863. #define CHILD_ADD_SROW     11
  1864. #define CHILD_ADD_SCOL     12
  1865. #define CHILD_MOVE_VERT    13
  1866. #define CHILD_MOVE_HORZ    14
  1867. #define CLOSE_CHILDREN     15
  1868. #define CHILD_PAINT_SEETHRU 16
  1869.  
  1870.  
  1871. /* Virtual Window Panning Keys */
  1872.  
  1873. #define  VPAN_RIGHT     0
  1874. #define  VPAN_LEFT      1
  1875. #define  VPAN_DOWN      2
  1876. #define  VPAN_UP        3
  1877. #define  VPAN_PGDN      4
  1878. #define  VPAN_PGUP      5
  1879. #define  VPAN_HOME      6
  1880. #define  VPAN_END       7
  1881. #define  VPAN_ELINE     8
  1882. #define  VPAN_BLINE     9
  1883. #define  VPAN_PGRT      10
  1884. #define  VPAN_PGLT      11
  1885. #define  VPAN_QUIT      12
  1886.  
  1887. #define NUMVPANKEYS     13
  1888. #define DEFAULTPANKEYS  ((unsigned int *)0)
  1889.  
  1890.  
  1891.  
  1892.  /*****************************
  1893.   * Define external variables *
  1894.   ****************************/
  1895.  
  1896.  
  1897. /* Miscellaneous Routines */
  1898. CWL_VOID      AdjustGlobalData _PROTO_((CWL_VOID ));
  1899. int           AdjustScreenInfo _PROTO_((int page));
  1900. VOIDPTR       Allocate2DArray _PROTO_((int rows, int cols, int size));
  1901. char *        ParseEntryName _PROTO_((char *str, char *outstr));
  1902. char *        CharToString _PROTO_((int));
  1903. char *        CreateRepeatedString _PROTO_((char *str, int num));
  1904. CWL_VOID      Free2DArray _PROTO_((VOIDPTR *array));
  1905. int           RegExpStringLength _PROTO_((char *regexp));
  1906. char *        RegExpString _PROTO_((char *regexp, char *buffer, int *reverse));
  1907. CWL_VOID      MakeSound _PROTO_((unsigned freq, unsigned millisec));
  1908.  
  1909.  
  1910. int           TranslateCaptionPosToWindowPos _PROTO_((WPOINTER w, int crow,
  1911.                                  int ccol, int *wrow, int *wcol));
  1912. char *        TranslateMaskStringToString _PROTO_((char *str, char *mask, char *str2,
  1913.                                              int mchar));
  1914. char *        TranslateStringToMaskString _PROTO_((char *str, char *mask, char *str2,
  1915.                                              int mchar, int flag));
  1916. int           TranslateMaskPosToStringPos _PROTO_((char *, int, int));
  1917.  
  1918. int           TranslateStringPosToMaskPos _PROTO_((char *, int, int));
  1919. int           TranslateVirtualPosToWindowPos _PROTO_((WPOINTER w, unsigned r,
  1920.                                                 unsigned c, int *wr, int *wc));
  1921. int           TranslateWindowPosToVirtualPos _PROTO_((WPOINTER w, int r, int c,
  1922.                                                 unsigned *wr, unsigned *wc));
  1923. int           VirtualClear _PROTO_((VWPOINTER vw));
  1924. int           VirtualClearAttr _PROTO_((VWPOINTER vw, int attr));
  1925. int           VirtualClearRegion _PROTO_((VWPOINTER vw, unsigned urow, unsigned ucol,
  1926.                                     unsigned lrow, unsigned lcol));
  1927. int           VirtualClearRegionAttr _PROTO_((VWPOINTER vw, unsigned urow,
  1928.                                         unsigned ucol, unsigned lrow,
  1929.                                         unsigned lcol, int attr));
  1930. int           VirtualClose _PROTO_((VWPOINTER vw, int hideflag, int effect));
  1931. int           VirtualGetCursorPosition _PROTO_((VWPOINTER vw, unsigned *row,
  1932.                                           unsigned *col));
  1933. VWPOINTER     VirtualInitialize _PROTO_((int vwtype, unsigned nrows, unsigned ncols,
  1934.                                    int attr));
  1935. int           VirtualMoveCursor _PROTO_((VWPOINTER vw, unsigned row, unsigned col));
  1936. int           VirtualPrintf _PROTO_((VWPOINTER vw, char *format, ...));
  1937. int           VirtualPrintfAttr _PROTO_((VWPOINTER vw, int attr, char *format, ...));
  1938. int           VirtualReadAttributes _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1939.                                        unsigned col, unsigned length));
  1940. int           VirtualReadCharacters _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1941.                                        unsigned col, unsigned length));
  1942. int           VirtualReadCharAndAttr _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1943.                                         unsigned col, unsigned length));
  1944. int           VirtualResize _PROTO_((VWPOINTER *vw, unsigned nrows, unsigned ncols));
  1945. int           VirtualSetWrap _PROTO_((VWPOINTER vw, int wrapflag));
  1946. int           VirtualWriteAttributes _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1947.                                         unsigned col, unsigned length));
  1948. int           VirtualWriteCenterString _PROTO_((VWPOINTER vw, char *string,
  1949.                                           unsigned row));
  1950. int           VirtualWriteCenterStringAttr _PROTO_((VWPOINTER vw, char *string,
  1951.                                               unsigned row, int attr));
  1952. int           VirtualWriteCharacters _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1953.                                         unsigned col, unsigned length));
  1954. int           VirtualWriteCharactersAttr _PROTO_((VWPOINTER w, char *buffer,
  1955.                                             unsigned row, unsigned col,
  1956.                                             int attr, unsigned length));
  1957. int           VirtualWriteCharAndAttr _PROTO_((VWPOINTER vw, char *buffer, unsigned row,
  1958.                                          unsigned col, unsigned length));
  1959. int           VirtualWriteRepeatAttribute _PROTO_((VWPOINTER vw, int attr, unsigned row,
  1960.                                              unsigned col, unsigned length));
  1961. int           VirtualWriteRepeatCharacter _PROTO_((VWPOINTER vw, int ch, unsigned row,
  1962.                                              unsigned col, unsigned length));
  1963. int           VirtualWriteString _PROTO_((VWPOINTER vw, char *string, unsigned row,
  1964.                                     unsigned col));
  1965. int           VirtualWriteStringAttr _PROTO_((VWPOINTER vw, char *string, unsigned row,
  1966.                                         unsigned col, int attr));
  1967. int           VirtualWriteStringCC _PROTO_((VWPOINTER vw, char *string, unsigned row,
  1968.                                       unsigned col));
  1969. int           VirtualWriteStringCCAttr _PROTO_((VWPOINTER vw, char *string,
  1970.                                           unsigned row, unsigned col, int attr));
  1971. int           VirtualWriteStringRJ _PROTO_((VWPOINTER vw, char *string, unsigned row,
  1972.                                             unsigned col));
  1973. int           VirtualWriteStringRJAttr _PROTO_((VWPOINTER vw, char *string,
  1974.                                           unsigned row, unsigned col, int attr));
  1975. int           VirtualWriteTextToFile _PROTO_((VWPOINTER vw, char *filename, int mode));
  1976.  
  1977. /* Window Functions */
  1978. int           WindowAllocUserBytes _PROTO_((WPOINTER w, int numbytes));
  1979. int           WindowAssignToVirtual _PROTO_((WPOINTER w, VWPOINTER vw, unsigned row,
  1980.                                        unsigned col));
  1981. int           WindowCenter _PROTO_((WPOINTER w, int options));
  1982. int           WindowChangeCursor _PROTO_((WPOINTER w, int shape));
  1983. int           WindowChangeBorderAttribute _PROTO_((WPOINTER w, int attr));
  1984. int           WindowChangeTextAttribute _PROTO_((WPOINTER w, int attr));
  1985. int           WindowClear _PROTO_((WPOINTER w));
  1986. int           WindowClearAttr _PROTO_((WPOINTER w, int attr));
  1987. int           WindowClearRegion _PROTO_((WPOINTER w, int urow, int ucol, int lrow,
  1988.                                    int lcol));
  1989. int           WindowClearRegionAttr _PROTO_((WPOINTER w, int urow, int ucol, int lrow,
  1990.                                        int lcol, int attr));
  1991.  
  1992. int           WindowClearEOL _PROTO_((WPOINTER w, int row, int col));
  1993. int           WindowClearBOL _PROTO_((WPOINTER w, int row, int col));
  1994. int           WindowClearEOLAttr _PROTO_((WPOINTER w, int row,
  1995.                                           int col, int attr));
  1996. int           WindowClearBOLAttr _PROTO_((WPOINTER w, int row, int col,
  1997.                                           int attr));
  1998. int           WindowClearLine _PROTO_((WPOINTER w, int row));
  1999. int           WindowClearLineAttr _PROTO_((WPOINTER w, int row, int attr));
  2000.  
  2001.  
  2002. int           WindowClose _PROTO_((WPOINTER w, int effect));
  2003. int           WindowCloseAll _PROTO_((int page, int effect));
  2004. int           WindowCloseViewport _PROTO_((WPOINTER w, int hide, int effect));
  2005. int           WindowCompareRank _PROTO_((WPOINTER w1, WPOINTER w2));
  2006. WPOINTER      WindowCopy _PROTO_((WPOINTER w, int row, int col, int options));
  2007. int           WindowDisplay _PROTO_((WPOINTER w, int rank, int effect));
  2008. int           WindowDrawBox _PROTO_((WPOINTER w, int urow, int ucol, int lrow,
  2009.                                int lcol, char *box));
  2010. int           WindowDrawBoxAttr _PROTO_((WPOINTER w, int urow, int ucol, int lrow,
  2011.                                    int lcol, char *box, int attr));
  2012. int           WindowDrawBorder _PROTO_((WPOINTER w, char *box));
  2013. int           WindowDrawShadow _PROTO_((WPOINTER w, int spos, int swidth,
  2014.                                   int sheight, int schar, int sattr, int tflag));
  2015. int           WindowEnumChildren _PROTO_((WPOINTER parent,
  2016.                                           CWLENUMPROC enumproc,
  2017.                                           long lParam));
  2018. int           WindowFill _PROTO_((WPOINTER w, int ch));
  2019. int           WindowFreeze _PROTO_((WPOINTER w, int flag));
  2020. int           WindowFreeUserBytes _PROTO_((WPOINTER w));
  2021.  
  2022. int           WindowGetCursorPosition _PROTO_((WPOINTER w, int *row, int *col));
  2023.  
  2024. int           WindowGetMaskPassword _PROTO_((WPOINTER w, int row, int col,
  2025.                                        char *buffer, char *mask, int fillchar,
  2026.                                        int passchar, int minchars, int maxwidth,
  2027.                                        long options, int startpos, char *regexp));
  2028.  
  2029. int           WindowGetMaskPasswordAttr _PROTO_((WPOINTER w, int row, int col,
  2030.                                            char *buffer, char *mask,
  2031.                                            int fillchar, int passchar,
  2032.                                            int minchars, int maxwidth,
  2033.                                            long options, int startpos,
  2034.                                            int attr, char *regexp));
  2035.  
  2036. int           WindowGetMaskString _PROTO_((WPOINTER w, int row, int col, char *buffer,
  2037.                                      char *mask, int fillchar, int minchars,
  2038.                                      int maxwidth, long options,
  2039.                                      int startpos, char *regexp));
  2040.  
  2041. int           WindowGetMaskStringAttr _PROTO_((WPOINTER w, int row, int col,
  2042.                                          char *buffer, char *mask, int fillchar,
  2043.                                          int minchars, int maxwidth,
  2044.                                          long options, int startpos,
  2045.                                          int attr, char *regexp));
  2046.  
  2047. int           WindowGetPassword _PROTO_((WPOINTER w, int row, int col, char *buffer,
  2048.                                    int fillchar, int passchar, int minchars,
  2049.                                    int maxwidth, long options,
  2050.                                    int startpos, char *regexp));
  2051.  
  2052. int           WindowGetPasswordAttr _PROTO_((WPOINTER w, int row, int col,
  2053.                                        char *buffer, int fillchar, int passchar,
  2054.                                        int minchars, int maxwidth, long options,
  2055.                                        int startpos, int attr, char *regexp));
  2056.  
  2057. int           WindowGetString _PROTO_((WPOINTER w, int row, int col, char *buffer,
  2058.                                  int fillchar, int minchars, int maxwidth,
  2059.                                  long options, int startpos, char *regexp));
  2060.  
  2061. int           WindowGetStringAttr _PROTO_((WPOINTER w, int row, int col, char *buffer,
  2062.                                      int fillchar, int minchars, int maxwidth,
  2063.                                      long options, int startpos, int attr,
  2064.                                      char *regexp));
  2065.  
  2066. int           WindowHide _PROTO_((WPOINTER w, int effect));
  2067. WPOINTER      WindowInitialize _PROTO_((WPOINTER parent,int bordflag, int rows,
  2068.                                         int cols, int width,
  2069.                                         int height, int wattr, int battr,
  2070.                                         char *box));
  2071.  
  2072. int           WindowInitializeSystem _PROTO_((CWL_VOID));
  2073. int           WindowIsChild _PROTO_((WPOINTER parent, WPOINTER child));
  2074. int           WindowIsDescendant _PROTO_((WPOINTER w1, WPOINTER w2));
  2075. int           WindowIsRelated _PROTO_((WPOINTER w1, WPOINTER w2));
  2076. int           WindowIsSibling _PROTO_((WPOINTER w1, WPOINTER w2));
  2077. int           WindowSetParent _PROTO_((WPOINTER parent, WPOINTER child,
  2078.                                        int rank, int row, int col));
  2079. WPOINTER      WindowGetParent _PROTO_((WPOINTER w));
  2080.  
  2081. CWL_VOID      CWLDesktopToClient    _PROTO_((WPOINTER w, CWLPOINT * point));
  2082. CWL_VOID      CWLClientToDesktop    _PROTO_((WPOINTER w, CWLPOINT * point));
  2083. CWL_VOID      CWLMapWindowPoints    _PROTO_((WPOINTER w, WPOINTER w2,
  2084.                                           CWLPOINT * point, unsigned numpts));
  2085. CWL_VOID      CWLMouseToScreen   _PROTO_((CWLPOINT *pt));
  2086. CWL_VOID      CWLScreenToMouse   _PROTO_((CWLPOINT *pt));
  2087. CWL_VOID      CWLMouseToClient   _PROTO_((WPOINTER w, CWLPOINT *p));
  2088. CWL_VOID      CWLClientToMouse   _PROTO_((WPOINTER w, CWLPOINT *p));
  2089. CWL_VOID      CWLVirtualToClient _PROTO_((WPOINTER w, CWLPOINT *pt));
  2090. CWL_VOID      CWLClientToVirtual _PROTO_((WPOINTER w, CWLPOINT *pt));
  2091. int           CWLGetClientRect   _PROTO_((WPOINTER w, CWLRECT *r));
  2092. unsigned      CWLGetRectArea _PROTO_((CWLRECT *r));
  2093. int           CWLGetWindowRect   _PROTO_((WPOINTER w, CWLRECT *r));
  2094. int           CWLPointInRect     _PROTO_((CWLRECT *r, CWLPOINT *p));
  2095. int           CWLGetVisibleWindowRect _PROTO_((WPOINTER w, CWLRECT *r));
  2096. int           CWLGetIntersectRect _PROTO_((CWLRECT *r, CWLRECT *result,
  2097.                                            int numrects));
  2098. int           CWLDefWindowProc   _PROTO_((WPOINTER w, int message,
  2099.                                           int wParam, long lParam));
  2100.  
  2101. int           get_last_row _PROTO_((WPOINTER w));
  2102. int           get_last_col _PROTO_((WPOINTER w));
  2103. int           AbsoluteWindowRow _PROTO_((WPOINTER w, int row));
  2104. int           AbsoluteWindowCol _PROTO_((WPOINTER w, int col));
  2105. int           AbsoluteWindowCol _PROTO_((WPOINTER w, int col));
  2106.  
  2107. int           WindowMakeNormal _PROTO_((WPOINTER w));
  2108. int           WindowMakeSeeThru _PROTO_((WPOINTER w));
  2109. int           WindowMove _PROTO_((WPOINTER w, int row, int col));
  2110. int           WindowMoveCursor _PROTO_((WPOINTER w, int row, int col));
  2111. int           WindowMoveViewportCursor _PROTO_((WPOINTER w, unsigned row,
  2112.                                           unsigned col));
  2113. int           WindowOpen _PROTO_((WPOINTER w));
  2114. int           WindowPanViewport _PROTO_((WPOINTER w, unsigned int *VPanKeys));
  2115. int           WindowPositionViewport _PROTO_((WPOINTER w, unsigned row, unsigned col));
  2116. int           WindowPrintf _PROTO_((WPOINTER w, char *format, ...));
  2117. int           WindowPrintfAttr _PROTO_((WPOINTER w, int attr, char *format, ...));
  2118. int           WindowReadCharacters _PROTO_((WPOINTER w, char *buffer, int row,
  2119.                                       int col, int length));
  2120. int           WindowReadAttributes _PROTO_((WPOINTER w, char *buffer, int row,
  2121.                                       int col, int length));
  2122. int           WindowReadCharAndAttr _PROTO_((WPOINTER w, char *buffer, int row,
  2123.                                        int col, int length));
  2124. int           WindowRemoveBorder _PROTO_((WPOINTER w));
  2125. int           WindowRemoveShadow _PROTO_((WPOINTER w));
  2126. int           WindowResizeHeight _PROTO_((WPOINTER w, int height, int flag));
  2127. int           WindowResizeWidth _PROTO_((WPOINTER w, int width, int flag));
  2128. int           WindowInitDesktop _PROTO_((int page));
  2129. int           WindowScroll _PROTO_((WPOINTER w, int lines, int direct));
  2130. int           WindowScrollAttr _PROTO_((WPOINTER w, int lines, int direct, int attr));
  2131. int           WindowScrollRegion _PROTO_((WPOINTER w, int lines, int urow, int ucol,
  2132.                                     int lrow, int lcol, int direct));
  2133. int           WindowScrollRegionAttr _PROTO_((WPOINTER w, int lines, int urow,
  2134.                                         int ucol, int lrow, int lcol, int direct,
  2135.                                         int attr));
  2136. int           WindowScrollViewport _PROTO_((WPOINTER w, unsigned units, int direct));
  2137. int           WindowSetWrap _PROTO_((WPOINTER w, int flag));
  2138. int           WindowSlide _PROTO_((WPOINTER w, int direct, int num));
  2139. int           WindowSyncCursor _PROTO_((WPOINTER w, int flag));
  2140. int           WindowTitleBottom _PROTO_((WPOINTER w, char *title, int pos));
  2141. int           WindowTitleBottomAttr _PROTO_((WPOINTER w, char *title, int pos,
  2142.                                        int attr));
  2143. int           WindowTitleTop _PROTO_((WPOINTER w, char *title, int pos));
  2144. int           WindowTitleTopAttr _PROTO_((WPOINTER w, char *title, int pos,
  2145.                                     int attr));
  2146. CWL_VOID      WindowUninitSystem _PROTO_((CWL_VOID ));
  2147. VOIDPTR       WindowUserBytesPtr _PROTO_((WPOINTER w));
  2148. WPOINTER      WindowWhich _PROTO_((int row, int col, int page));
  2149. int           WindowWriteAttributes _PROTO_((WPOINTER w, char *buffer, int row,
  2150.                                        int col, int length));
  2151. int           WindowWriteCharacters _PROTO_((WPOINTER w, char *buffer, int row,
  2152.                                        int col, int length));
  2153. int           WindowWriteCharAndAttr _PROTO_((WPOINTER w,char *buffer, int row,
  2154.                                         int col, int length));
  2155. int           WindowWriteCharactersAttr _PROTO_((WPOINTER w, char *buffer, int row,
  2156.                                            int col, int attr, int length));
  2157. int           WindowWriteCenterString _PROTO_((WPOINTER w, char *string, int row));
  2158. int           WindowWriteCenterStringAttr _PROTO_((WPOINTER w, char *string, int row,
  2159.                                              int attr));
  2160. int           WindowWriteRepeatAttribute _PROTO_((WPOINTER w, int attr, int row,
  2161.                                             int col, int length));
  2162. int           WindowWriteRepeatCharacter _PROTO_((WPOINTER w, int ch, int row,
  2163.                                             int col, int length));
  2164. int           WindowWriteRepeatCharAttr _PROTO_((WPOINTER w, int ch, int attr,
  2165.                                                int row, int col, int length));
  2166.  
  2167. int           WindowWriteString _PROTO_((WPOINTER w, char *string, int row, int col));
  2168. int           WindowWriteStringAttr _PROTO_((WPOINTER w, char *string, int row,
  2169.                                        int col, int attr));
  2170. int           WindowWriteStringRJ _PROTO_((WPOINTER w, char *string, int row, int col));
  2171. int           WindowWriteStringRJAttr _PROTO_((WPOINTER w, char *string, int row,
  2172.                                          int col, int attr));
  2173. int           WindowWriteStringCC _PROTO_((WPOINTER w, char *string, int row, int col));
  2174. int           WindowWriteStringCCAttr _PROTO_((WPOINTER w, char *string,int row,
  2175.                                          int col, int attr));
  2176. int           WindowWriteTextToFile _PROTO_((WPOINTER w, char *string, int mode));
  2177.  
  2178.  
  2179. /****************** Scroll bar functions ************************/
  2180.  
  2181. /* Scroll bar constants and functions */
  2182. #define SB_HORZ             0
  2183. #define SB_VERT             1
  2184. #define SB_CTL              2
  2185. #define SB_BOTH             3
  2186.  
  2187. #define SCR_UP_ARROW        0
  2188. #define SCR_DOWN_ARROW      1
  2189. #define SCR_REGION_CHAR     2
  2190.  
  2191. #define SCR_LEFT_ARROW        SCR_UP_ARROW
  2192. #define SCR_RIGHT_ARROW       SCR_DOWN_ARROW
  2193.  
  2194. #define SCR_UP_ATTR         0
  2195. #define SCR_DOWN_ATTR       1
  2196. #define SCR_RIGHT_ATTR      SCR_DOWN_ATTR
  2197. #define SCR_LEFT_ATTR       SCR_UP_ATTR
  2198. #define SCR_HBOX_NORM     2
  2199. #define SCR_HBOX_HIGH     3
  2200. #define SCR_VBOX_NORM     SCR_HBOX_NORM
  2201. #define SCR_VBOX_HIGH     SCR_HBOX_HIGH
  2202.  
  2203. #define SCRLEFT    1
  2204. #define SCRRIGHT   2
  2205. #define SCRUP      3
  2206. #define SCRDOWN    4
  2207. #define SCRVBOX    5
  2208. #define SCRHBOX    6
  2209. #define SCRPGLEFT  7
  2210. #define SCRPGRIGHT 8
  2211. #define SCRPGUP    9
  2212. #define SCRPGDOWN  10
  2213. #define MOVETOP    11
  2214.  
  2215.  
  2216. SCROLLPTR ScrollBarCreate _PROTO_((int type, int minnum, int maxnum,
  2217.                                      int length, int *attr));
  2218.  
  2219.  
  2220. /* define point translation macros */
  2221. #define MOUSE_TO_CLIENT(w,row,col,nrow,ncol)   {  \
  2222.                                      CWLPOINT pt; \
  2223.                                      pt.x = col,  \
  2224.                                      pt.y = row,  \
  2225.                                      CWLMouseToClient(w,&pt), \
  2226.                                      nrow = pt.y, \
  2227.                                      ncol = pt.x; \
  2228.                                      }
  2229.  
  2230. #define CLIENT_TO_VIRTUAL(w,row,col,nrow,ncol)   {  \
  2231.                                      CWLPOINT pt; \
  2232.                                      pt.x = col,  \
  2233.                                      pt.y = row,  \
  2234.                                      CWLClientToVirtual(w,&pt), \
  2235.                                      nrow = pt.y, \
  2236.                                      ncol = pt.x; \
  2237.                                      }
  2238.  
  2239.  
  2240. #define VIRTUAL_TO_CLIENT(w,row,col,nrow,ncol)   {  \
  2241.                                      CWLPOINT pt; \
  2242.                                      pt.x = col,  \
  2243.                                      pt.y = row,  \
  2244.                                      CWLVirtualToClient(w,&pt), \
  2245.                                      nrow = pt.y, \
  2246.                                      ncol = pt.x; \
  2247.                                      }
  2248.  
  2249. #define CLIENT_TO_MOUSE(w,row,col,nrow,ncol)   {  \
  2250.                                      CWLPOINT pt; \
  2251.                                      pt.x = col,  \
  2252.                                      pt.y = row,  \
  2253.                                      CWLClientToMouse(w,&pt), \
  2254.                                      nrow = pt.y, \
  2255.                                      ncol = pt.x; \
  2256.                                      }
  2257.  
  2258. #define MOUSE_TO_SCREEN(row,col,nrow,ncol)   {  \
  2259.                                      CWLPOINT pt; \
  2260.                                      pt.x = col,  \
  2261.                                      pt.y = row,  \
  2262.                                      CWLMouseToScreen(&pt), \
  2263.                                      nrow = pt.y, \
  2264.                                      ncol = pt.x; \
  2265.                                      }
  2266.  
  2267.  
  2268. #define SCREEN_TO_MOUSE(row,col,nrow,ncol)   {  \
  2269.                                      CWLPOINT pt; \
  2270.                                      pt.x = col,  \
  2271.                                      pt.y = row,  \
  2272.                                      CWLScreenToMouse(&pt), \
  2273.                                      nrow = pt.y, \
  2274.                                      ncol = pt.x; \
  2275.                                      }
  2276.  
  2277. #define DESKTOP_TO_CLIENT(w,row,col,nrow,ncol)   {  \
  2278.                                      CWLPOINT pt; \
  2279.                                      pt.x = col,  \
  2280.                                      pt.y = row,  \
  2281.                                      CWLDesktopToClient(w,&pt), \
  2282.                                      nrow = pt.y, \
  2283.                                      ncol = pt.x; \
  2284.                                      }
  2285.  
  2286. #define CLIENT_TO_DESKTOP(w,row,col,nrow,ncol)   {  \
  2287.                                      CWLPOINT pt; \
  2288.                                      pt.x = col,  \
  2289.                                      pt.y = row,  \
  2290.                                      CWLClientToDesktop(w,&pt), \
  2291.                                      nrow = pt.y, \
  2292.                                      ncol = pt.x; \
  2293.                                      }
  2294.  
  2295. #define INIT_RECT(rect, t, l, b, r)   { \
  2296.                                          (rect).top = t,    \
  2297.                                          (rect).left = l,   \
  2298.                                          (rect).bottom = b, \
  2299.                                          (rect).right = r;  \
  2300.                                       }
  2301.  
  2302.  
  2303. /******** Define CWL Menu Functions and Structures ******/
  2304.  
  2305. #define MAXMENUBUFFER  256
  2306. #define MAXMENUSTRING  (MAXMENUBUFFER - 2)
  2307.  
  2308. /* define offsets for pop-up menu keys */
  2309.  
  2310. #define POPUP_UPKEY              0
  2311. #define POPUP_DOWNKEY            1
  2312. #define POPUP_ACCEPTKEY          2
  2313. #define POPUP_QUITKEY            3
  2314. #define POPUP_HOMEKEY            4
  2315. #define POPUP_ENDKEY             5
  2316. #define POPUP_RIGHTKEY           6
  2317. #define POPUP_LEFTKEY            7
  2318. #define POPUP_PULLDOWN_QUITKEY   8
  2319. #define POPUP_PAGEUPKEY          9
  2320. #define POPUP_PAGEDOWNKEY       10
  2321.  
  2322. #define NUMPOPUPKEYS     11
  2323.  
  2324. #define PULLDOWN_EXIT       3
  2325. #define PULLDOWN_CONTINUE   5
  2326.  
  2327. /* define offsets for bar menu keys */
  2328. #define BAR_RIGHTKEY           0
  2329. #define BAR_LEFTKEY            1
  2330. #define BAR_ACCEPTKEY          2
  2331. #define BAR_QUITKEY            3
  2332. #define BAR_HOMEKEY            4
  2333. #define BAR_ENDKEY             5
  2334.  
  2335. #define NUMBARKEYS     6
  2336.  
  2337. #define NO_BAR_OPTIONS 0
  2338. #define BARWRAP        1
  2339. #define BARSTATIC      2
  2340. #define BARCONFIRM     4
  2341. #define BARDISPLAY     8
  2342. #define BAROVERRIDE    16
  2343. #define BARENHANCEDKEY 32
  2344. #define BARMOUSE       64
  2345. #define BARCREATEWIN   128
  2346.  
  2347. #define BARDEFOPTIONS  (BARWRAP | BARMOUSE | BARCREATEWIN | BARSTATIC)
  2348.  
  2349. #define NO_POPUP_OPTIONS 0
  2350. #define POPUPWRAP        1
  2351. #define POPUPSTATIC      2
  2352. #define POPUPCONFIRM     4
  2353. #define POPUPDISPLAY     8
  2354. #define POPUPOVERRIDE    16
  2355. #define POPUPENHANCEDKEY 32
  2356. #define POPUPMOUSE       64
  2357. #define POPUPCREATEWIN   128
  2358. #define POPUPSCROLL      256
  2359. #define POPUPSCROLLBAR   (POPUPSCROLL | POPUPMOUSE)
  2360. #define POPUPRESIZEWIDTH    512
  2361. #define POPUPRESIZEHEIGHT   1024
  2362. #define POPUPRESIZEALL      (POPUPRESIZEWIDTH | POPUPRESIZEHEIGHT)
  2363.  
  2364. #define POPUPDEFOPTIONS   (POPUPMOUSE | POPUPRESIZEALL | \
  2365.                            POPUPSCROLLBAR | POPUPCREATEWIN | POPUPSTATIC)
  2366.  
  2367. #define CWL_MRESIZE       0x1
  2368. #define CWL_MDISABLED     0x2
  2369. #define CWL_MSTRING       0x4
  2370. #define CWL_MSEPARATOR    0x8
  2371. #define CWL_BYPOSITION    0x10
  2372. #define CWL_BYCOMMAND     0x20
  2373. #define CWL_MPOPUP        (CWL_MSTRING | 0x40)
  2374. #define CWL_MCHECKED      0x80
  2375. #define CWL_MGRAYED       0x100
  2376. #define CWL_MUNCHECKED    0x00
  2377. #define CWL_MENABLED      0x00
  2378.  
  2379.  
  2380. /**********  Popup return values for user-defined functions **********/
  2381.  
  2382. #define KEEP_GETTING_INPUT         0
  2383. #define MOVE_CONTINUE_DONE        (-1)
  2384. #define POPUP_CONTINUE            (-2)
  2385. #define POPUP_MOVE_UP             (-3)
  2386. #define POPUP_MOVE_DOWN           (-4)
  2387. #define POPUP_DO_CHOICE           (-5)
  2388. #define POPUP_MOVE_CONTINUE       (-6)
  2389. #define POPUP_ESCAPE              (-7)
  2390. #define POPUP_MOVE_LEFT           (-8)
  2391. #define POPUP_MOVE_RIGHT          (-9)
  2392. #define POPUP_MOVE_HOME           (-10)
  2393. #define POPUP_MOVE_END            (-11)
  2394. #define POPUP_PULLDOWN_QUIT       (-12)
  2395. #define POPUP_MOVE_BAR_CHOICE     (-13)
  2396. #define POPUP_MOVE_PAGEDOWN       (-14)
  2397. #define POPUP_MOVE_PAGEUP         (-15)
  2398.  
  2399.  
  2400. /* The following macros are used for compatibility with versions prior to
  2401.  * Version 1.5 */
  2402. #define PULLDOWN_POPUP_EXIT   POPUP_PULLDOWN_QUIT
  2403. #define POPUP_PULLDOWN_EXIT   POPUP_PULLDOWN_QUIT
  2404. #define PULLDOWN_POPUP_QUIT   POPUP_PULLDOWN_QUIT
  2405. #define POPUP_EXIT            POPUP_ESCAPE
  2406. #define BAR_EXIT              BAR_ESCAPE
  2407.  
  2408. /**********  Bar return values for user-defined functions **********/
  2409.  
  2410. #define BAR_CONTINUE         (-14)
  2411. #define BAR_MOVE_RIGHT       (-15)
  2412. #define BAR_MOVE_LEFT        (-16)
  2413. #define BAR_DO_CHOICE        (-17)
  2414. #define BAR_MOVE_CONTINUE    (-18)
  2415. #define BAR_ESCAPE           (-19)
  2416. #define BAR_MOVE_HOME        (-20)
  2417. #define BAR_MOVE_END         (-21)
  2418.  
  2419.  
  2420. #define ENTRYCOLOR       0
  2421. #define BORDERCOLOR      1
  2422. #define HOTKEYCOLOR      2
  2423. #define HIGHLIGHTCOLOR   3
  2424. #define UNAVAILCOLOR     4
  2425.  
  2426. #define NUMPOPUPCOLORS 5
  2427. #define NUMBARCOLORS   5
  2428.  
  2429. #define MENU_PRESS     0
  2430. #define MENU_RELEASE   1
  2431. #define NUMMOUSEINFO   8
  2432.  
  2433. #define SEPARATOR      ((char *)1)
  2434. #define NO_HEIGHT_LIMIT  (-1)
  2435. #define NO_WIDTH_LIMIT   (-1)
  2436.  
  2437. #define POPUP_SETHEIGHT   0x1
  2438. #define POPUP_SETWIDTH    0x2
  2439. #define POPUP_SETALL      (POPUP_SETHEIGHT | POPUP_SETWIDTH)
  2440.  
  2441. typedef struct tagPOPSTATUS
  2442. {
  2443.   unsigned int open_flag:1;     /* menu is activated ? */
  2444.   unsigned int pulldown_flag:1; /* menu is part of pulldown system? */
  2445.   unsigned int pick_list:1;     /* tells if popup menu is used as a picklist */
  2446.  
  2447. } POPUP_MENU_STAT, BAR_MENU_STAT;
  2448.  
  2449.  
  2450. typedef struct tagPOPUPENTRY
  2451. {
  2452.   char *entry_name;
  2453.   unsigned int menuid;
  2454.   unsigned int mtype;
  2455. #if __cplusplus
  2456.   int (*func) _PROTO_((struct tagPOPUPMENU *, int));
  2457. #else
  2458.   int (*func) _PROTO_((UNKNOWNARGS));
  2459. #endif
  2460. } POPUP_MENU_ENTRY, *POPUP_MENU_ENTRY_PTR;
  2461.  
  2462.  
  2463. typedef struct tagPOPUPEXTRA  /* Allocated members for each popup entry */
  2464. {
  2465.   POPUP_MENU_ENTRY pop;
  2466.   unsigned char hotkey_pos;
  2467.   int  row;
  2468.   int entry_offset;
  2469.   unsigned int cascade:1;
  2470.   unsigned int highlighted:1;
  2471.   unsigned char *menu_string;
  2472.   VOIDPTR popmenu;
  2473. } POPUP_ENTRY_EXTRA;
  2474.  
  2475.  
  2476. typedef struct tagPOPUPMENU
  2477. {
  2478.   WPOINTER w;
  2479.   struct tagPOPUPMENU *parent;
  2480.   CWLOBJECTPTR entry_object;
  2481.   unsigned menu_color[NUMPOPUPCOLORS];
  2482.   unsigned menu_key[NUMPOPUPKEYS];
  2483.   POPUP_MENU_STAT popmenu_flags;
  2484.   int options;
  2485.   int num_entries;
  2486.   int totheight;
  2487.   int totwidth;
  2488.   BITSTRING active_entry;
  2489.   unsigned int attached:1;
  2490.   unsigned int cascade:1;
  2491.   unsigned int init_highlight:1;
  2492.   unsigned int exit_cascade:1;
  2493.   unsigned int hide_cascade:1;
  2494.   unsigned int lowlight_first:1;
  2495.   unsigned int unshrinkable:1;
  2496.   unsigned int show_disabled:1;
  2497.   int next_select;
  2498.   int maxheight;
  2499.   int maxwidth;
  2500.   int pwidth;
  2501.   int last_entry;
  2502.   int exp_method;
  2503.   unsigned int scr_repaint:1;
  2504.   VOIDPTR pulldown;
  2505.   VOIDPTR listptr;
  2506.   int (*confirm_func) _PROTO_((struct tagPOPUPMENU *, unsigned));
  2507.   unsigned int mouse_scroll:1;
  2508.   int (*local_undef_key) _PROTO_((struct tagPOPUPMENU *, int, int *));
  2509.   int (*stray_click_func) _PROTO_((struct tagPOPUPMENU *, int, int, int));
  2510.   unsigned press_no_wait:1;
  2511.   unsigned owner_window:1;
  2512.   int form_entry;
  2513.   SCROLLPTR sptr;
  2514.  
  2515. } POPUP_MENU, *POPUP_MENU_PTR;
  2516.  
  2517.  
  2518.  
  2519.  
  2520. #define POPUP_WRAP_ON(p)              ((p)->options & POPUPWRAP)
  2521. #define POPUP_STATIC_ON(p)            ((p)->options & POPUPSTATIC)
  2522. #define POPUP_CONFIRM_ON(p)           ((p)->options & POPUPCONFIRM)
  2523. #define POPUP_DISPLAY_ON(p)           ((p)->options & POPUPDISPLAY)
  2524. #define POPUP_OVERRIDE_ON(p)          ((p)->options & POPUPOVERRIDE)
  2525. #define POPUP_ENHANCED_ON(p)          ((p)->options & POPUPENHANCEDKEY)
  2526. #define POPUP_MOUSE_ON(p)             ((p)->options & POPUPMOUSE)
  2527. #define POPUP_CREATEWIN_ON(p)         ((p)->options & POPUPCREATEWIN)
  2528. #define POPUP_SCROLL_ON(p)            ((p)->options & POPUPSCROLL)
  2529. #define POPUP_RESIZE_WIDTH_ON(p)      ((p)->options & POPUPRESIZEWIDTH)
  2530. #define POPUP_RESIZE_HEIGHT_ON(p)     ((p)->options & POPUPRESIZEHEIGHT)
  2531.  
  2532. #define POPUP_OPEN(p)                 ((p)->popmenu_flags.open_flag)
  2533. #define POPUP_PULLDOWN_ON(p)          ((p)->popmenu_flags.pulldown_flag)
  2534. #define POPUP_LIST_ON(p)              ((p)->popmenu_flags.pick_list)
  2535.  
  2536.  
  2537. #define S_UP_CHAR   0
  2538. #define S_DN_CHAR   1
  2539. #define S_UP_ATTR   2
  2540. #define S_DN_ATTR   3
  2541. #define S_UP_ROW    4
  2542. #define S_UP_COL    5
  2543. #define S_DN_ROW    6
  2544. #define S_DN_COL    7
  2545.  
  2546. #define OTHER_BUTTON     0
  2547. #define OUTSIDE_POPUP    1
  2548. #define OUTSIDE_PULLDOWN 2
  2549. #define OUTSIDE_BAR      3
  2550.  
  2551. #define MAXMENULEN      256
  2552.  
  2553. #define POPUP_SCROLL_UP_CHAR(p)       (p)->popup_mouse_status[S_UP_CHAR]
  2554. #define POPUP_SCROLL_DOWN_CHAR(p)     (p)->popup_mouse_status[S_DN_CHAR]
  2555. #define POPUP_SCROLL_UP_ATTR(p)       (p)->popup_mouse_status[S_UP_ATTR]
  2556. #define POPUP_SCROLL_DOWN_ATTR(p)     (p)->popup_mouse_status[S_DN_ATTR]
  2557. #define POPUP_SCROLL_UP_ROW(p)        (p)->popup_mouse_status[S_UP_ROW]
  2558. #define POPUP_SCROLL_UP_COLUMN(p)     (p)->popup_mouse_status[S_UP_COL]
  2559. #define POPUP_SCROLL_DOWN_ROW(p)      (p)->popup_mouse_status[S_DN_ROW]
  2560. #define POPUP_SCROLL_DOWN_COLUMN(p)   (p)->popup_mouse_status[S_DN_COL]
  2561.  
  2562. CWL_VOID menu_init();
  2563.  
  2564. typedef struct tagBARENTRY
  2565. {
  2566.   char *entry_name;
  2567.   unsigned int menuid;
  2568.   unsigned int mtype;
  2569. #if __cplusplus
  2570.   int (*func) _PROTO_((struct tagBARMENU *, int));
  2571. #else
  2572.   int (*func) _PROTO_((UNKNOWNARGS));
  2573. #endif
  2574. } BAR_MENU_ENTRY, *BAR_MENU_ENTRY_PTR;
  2575.  
  2576.  
  2577.  
  2578. typedef struct tagBAREXTRA
  2579. {
  2580.   BAR_MENU_ENTRY bar;
  2581.   unsigned char hotkey_pos;
  2582.   int entry_offset;
  2583.   int row;
  2584.   int col;
  2585.   char *menu_string;
  2586. } BAR_ENTRY_EXTRA;
  2587.  
  2588.  
  2589.  
  2590. typedef struct tagBARMENU
  2591. {
  2592.   WPOINTER w;
  2593.   unsigned attached : 1;
  2594.   unsigned options;
  2595.   unsigned menu_color[NUMBARCOLORS];
  2596.   unsigned menu_key[NUMBARKEYS];
  2597.   CWLOBJECTPTR entry_object;
  2598.   BITSTRING active_entry;
  2599.   int num_entries;
  2600.   BAR_MENU_STAT barmenu_flags;
  2601.   int exp_method;
  2602.   unsigned last_entry;
  2603.   int (*confirm_func) _PROTO_((struct tagBARMENU *, unsigned));
  2604.   VOIDPTR pulldown;
  2605.   int (*local_undef_key) _PROTO_((struct tagBARMENU *, unsigned, unsigned *));
  2606.   int (*stray_click_func) _PROTO_((struct tagBARMENU *, int, int, int));
  2607. } BAR_MENU, *BAR_MENU_PTR;
  2608.  
  2609.  
  2610.  
  2611. #define BAR_WRAP_ON(b)              ((b)->options & BARWRAP)
  2612. #define BAR_STATIC_ON(b)            ((b)->options & BARSTATIC)
  2613. #define BAR_CONFIRM_ON(b)           ((b)->options & BARCONFIRM)
  2614. #define BAR_DISPLAY_ON(b)           ((b)->options & BARDISPLAY)
  2615. #define BAR_OVERRIDE_ON(b)          ((b)->options & BAROVERRIDE)
  2616. #define BAR_ENHANCED_ON(b)          ((b)->options & BARENHANCEDKEY)
  2617. #define BAR_MOUSE_ON(b)             ((b)->options & BARMOUSE)
  2618. #define BAR_CREATEWIN_ON(b)         ((b)->options & BARCREATEWIN)
  2619.  
  2620.  
  2621. #define BAR_OPEN(b)                 (b)->barmenu_flags.open_flag
  2622. #define BAR_PULLDOWN_ON(b)          (b)->barmenu_flags.pulldown_flag
  2623.  
  2624. typedef struct tagPULLEXTRA
  2625. {
  2626.   POPUP_MENU_PTR popup;      /* popup item */
  2627. } PULLDOWN_ENTRY_EXTRA;
  2628.  
  2629.  
  2630. typedef struct tagPULLMENU
  2631. {
  2632.   BAR_MENU_PTR barmenu;
  2633.   CWLOBJECTPTR entry_object;
  2634.   WPOINTER wOwner;
  2635.   int num_entries;
  2636.   unsigned int attached:1;
  2637.   unsigned int show_disabled:1;
  2638. }  PULLDOWN_MENU, *PULLDOWN_MENU_PTR;
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. typedef WPOINTER  (*BARWPROC)           _PROTO_((CWL_VOID));
  2645. typedef int       (*BARCONFIRMPROC)     _PROTO_((BAR_MENU_PTR,unsigned));
  2646. typedef int       (*BARCLICKPROC)       _PROTO_((BAR_MENU_PTR,int,int,int));
  2647. typedef int       (*BARSELECTPROC)      _PROTO_((BAR_MENU_PTR,int));
  2648. typedef int       (*BARUNDEFKEYPROC)    _PROTO_((BAR_MENU_PTR,unsigned,int *));
  2649.  
  2650. typedef WPOINTER  (*POPUPWPROC)         _PROTO_((CWL_VOID));
  2651. typedef VWPOINTER (*POPUPVWPROC)        _PROTO_((CWL_VOID));
  2652. typedef int       (*POPUPCLICKPROC)     _PROTO_((POPUP_MENU_PTR,int,int,int));
  2653. typedef int       (*POPUPSELECTPROC)    _PROTO_((POPUP_MENU_PTR,int));
  2654. typedef int       (*POPUPCONFIRMPROC)   _PROTO_((POPUP_MENU_PTR,unsigned));
  2655. typedef int       (*POPUPUNDEFKEYPROC)  _PROTO_((POPUP_MENU_PTR, unsigned, int *));
  2656.  
  2657. typedef struct tagENTRYINFO
  2658. {
  2659.   unsigned menu_type:1;             /* 0 for popup, 1 for bar */
  2660.   int  menu_entry_num;              /* entry number */
  2661.   int  menu_entry_type;             /* entry type bits */
  2662.   char *menu_string;                /* menu string (includes ampersand) */
  2663.   char *menu_display_string;        /* actual string displayed */
  2664.   unsigned menu_entry_active: 1;    /* 1 if enabled, 0 otherwise */
  2665.   union {
  2666.     POPUPSELECTPROC popmenu_func;     /* pointer to menu function if popup */
  2667.     BARSELECTPROC barmenu_func;       /* pointer to menu function if bar */
  2668.   } menu_proc;
  2669.   int  menu_id;                     /* menu id */
  2670. } POPUP_ENTRY_INFO, BAR_ENTRY_INFO;
  2671.  
  2672.  
  2673. typedef struct tagACCELERATOR
  2674. {
  2675.   VOIDPTR menuptr;    /* pointer to menu, can be void *
  2676.                          if general accelerator */
  2677.   int entry;          /* entry that contains key definition */
  2678.   int menuid;         /* The id of the menu */
  2679.   unsigned key;       /* The key to look for */
  2680.   unsigned keyflag;   /* key flags (ALT, CTRL, etc.) */
  2681. }  CWL_ACCELERATOR;
  2682.  
  2683. int                FindPopupInParent _PROTO_((POPUP_MENU_PTR p));
  2684.  
  2685. int                FindPopupInBar _PROTO_((POPUP_MENU_PTR p));
  2686.  
  2687. int                AddAcceleratorKey _PROTO_((VOIDPTR menuptr,
  2688.                                               unsigned key, int entry));
  2689.  
  2690. int                SearchAcceleratorKey _PROTO_((VOIDPTR menuptr,
  2691.                                                  unsigned key));
  2692.  
  2693. int                DeleteMenuAccelerators _PROTO_((VOIDPTR menu));
  2694.  
  2695. BAR_MENU_ENTRY_PTR BarAllocate _PROTO_((int numentry));
  2696.  
  2697. int                BarAppendEntry _PROTO_((BAR_MENU_PTR b,
  2698.                                            int type,
  2699.                                            char *entry_string,
  2700.                                            int menuid,
  2701.                                            BARSELECTPROC func));
  2702.  
  2703. int               BarAppendMultEntries _PROTO_((BAR_MENU_PTR b,
  2704.                                                 BAR_MENU_ENTRY *entry,
  2705.                                                 int numentries));
  2706.  
  2707. int               BarAssignColors _PROTO_((BAR_MENU_PTR barptr,
  2708.                                            unsigned *colors));
  2709.  
  2710. int               BarAssignKeys _PROTO_((BAR_MENU_PTR barptr,
  2711.                                          unsigned *keys));
  2712.  
  2713. int               BarSetEntryString _PROTO_((BAR_MENU_PTR barptr,
  2714.                                                 int entry,
  2715.                                                 char *string));
  2716.  
  2717. CWL_VOID          BarCreateEntry _PROTO_((BAR_MENU_ENTRY *entry,
  2718.                                           int entrynum,
  2719.                                           char *name,
  2720.                                           int menuid,
  2721.                                           BARSELECTPROC func));
  2722.  
  2723. BAR_MENU_PTR      BarCreateMenu _PROTO_((WPOINTER wOwner,
  2724.                                          unsigned options,
  2725.                                          unsigned *bcolor,
  2726.                                          int row,
  2727.                                          int col,
  2728.                                          int width));
  2729.  
  2730. CWL_VOID          BarDeallocate _PROTO_((BAR_MENU_ENTRY_PTR bentry));
  2731.  
  2732. int               BarDeleteEntry _PROTO_((BAR_MENU_PTR b, int where));
  2733.  
  2734. int               BarDeleteMultEntries _PROTO_((BAR_MENU_PTR b,
  2735.                                                 int where, int num));
  2736. int               BarEnableEntry _PROTO_((BAR_MENU_PTR b,
  2737.                                           int entry, unsigned mflags));
  2738.  
  2739. CWL_VOID          BarEntryEnd _PROTO_((BAR_MENU_ENTRY_PTR entry,
  2740.                                        int numfields));
  2741.  
  2742. POPUP_MENU_PTR    BarGetPopup _PROTO_((BAR_MENU_PTR b, int entry));
  2743.  
  2744. int               BarInsertEntry _PROTO_((BAR_MENU_PTR b,
  2745.                                           int type,
  2746.                                           int where,
  2747.                                           char *entry_string,
  2748.                                           unsigned menuid,
  2749.                                           BARSELECTPROC func));
  2750.  
  2751. int               BarInsertMultEntries _PROTO_((BAR_MENU_PTR b,
  2752.                                                 int where,
  2753.                                                 BAR_MENU_ENTRY *entry,
  2754.                                                 int numentries));
  2755.  
  2756. int               BarMenuClose _PROTO_((BAR_MENU_PTR barptr));
  2757.  
  2758. int               BarMenuCloseAll _PROTO_((CWL_VOID));
  2759.  
  2760. int               BarSetExplosionType _PROTO_((BAR_MENU_PTR barptr,
  2761.                                                int effect));
  2762.  
  2763. int               BarSetOptions _PROTO_((BAR_MENU_PTR barptr,
  2764.                                          int options, int flag));
  2765.  
  2766. int               BarSelectMenu _PROTO_((BAR_MENU_PTR barptr,
  2767.                                          int rank, int entry));
  2768.  
  2769. int               BarSetConfirmFunction _PROTO_((BAR_MENU_PTR barptr,
  2770.                                                  BARCONFIRMPROC cfunc));
  2771.  
  2772. int               BarSetClickFunction _PROTO_((BAR_MENU_PTR barptr,
  2773.                                                BARCLICKPROC func));
  2774.  
  2775.  
  2776. POPUP_MENU_ENTRY_PTR   PopupAllocate _PROTO_((int numentry));
  2777.  
  2778. int               PopupAppendEntry _PROTO_((POPUP_MENU_PTR p,
  2779.                                            int type,
  2780.                                            char *entry_string,
  2781.                                            int menuid,
  2782.                                            POPUPSELECTPROC func));
  2783.  
  2784. int               PopupAppendPopup _PROTO_((POPUP_MENU_PTR p,
  2785.                                             POPUP_MENU_PTR p2, int type,
  2786.                                             char *entry_string, int menuid));
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793. int               PopupAssignColors _PROTO_((POPUP_MENU_PTR popptr,
  2794.                                              unsigned *colors));
  2795.  
  2796. int               PopupAssignKeys _PROTO_((POPUP_MENU_PTR popptr,
  2797.                                            unsigned *keys));
  2798.  
  2799. int               PopupCheckEntry _PROTO_((POPUP_MENU_PTR p,
  2800.                                            int entry,
  2801.                                            unsigned onoff));
  2802.  
  2803. CWL_VOID          PopupCreateEntry _PROTO_((POPUP_MENU_ENTRY_PTR entry,
  2804.                                             int entrynum,
  2805.                                             char *name,
  2806.                                             int menuid,
  2807.                                             POPUPSELECTPROC func));
  2808.  
  2809. POPUP_MENU_PTR    PopupCreateMenu _PROTO_((WPOINTER wOwner,
  2810.                                            unsigned options, /* options to use */
  2811.                                            unsigned *pcolor,
  2812.                                            int row, int col)); /* colors for popup menu */
  2813.  
  2814. CWL_VOID          PopupDeallocate _PROTO_((POPUP_MENU_ENTRY_PTR pentry));
  2815.  
  2816. int               PopupDeleteEntry _PROTO_((POPUP_MENU_PTR p, int where));
  2817.  
  2818. int               PopupEnableEntry _PROTO_((POPUP_MENU_PTR p, int entry,
  2819.                                             unsigned mflags));
  2820.  
  2821. CWL_VOID          PopupEntryEnd _PROTO_((POPUP_MENU_ENTRY_PTR entry,
  2822.                                          int numfields));
  2823.  
  2824. BAR_MENU_PTR      PopupGetBar _PROTO_((POPUP_MENU_PTR p));
  2825.  
  2826. PULLDOWN_MENU_PTR PopupGetPulldown _PROTO_((POPUP_MENU_PTR p));
  2827.  
  2828.  
  2829. CWL_VOID          PopupGetEntryInfo _PROTO_((POPUP_MENU_PTR p,
  2830.                                              int entry,
  2831.                                              POPUP_ENTRY_INFO *pinfo));
  2832.  
  2833. int               PopupInsertEntry _PROTO_((POPUP_MENU_PTR p,
  2834.                                             int where,
  2835.                                             int type,
  2836.                                             char *entry_string,
  2837.                                             int menuid,
  2838.                                             POPUPSELECTPROC func));
  2839.  
  2840. int               PopupInsertPopup _PROTO_((POPUP_MENU_PTR p,
  2841.                                             POPUP_MENU_PTR p2, int type,
  2842.                                             int where, char *entry_string,
  2843.                                             int menuid));
  2844.  
  2845.  
  2846. int               PopupMenuCloseAll _PROTO_((CWL_VOID));
  2847.  
  2848. int               PopupSelectMenu _PROTO_((POPUP_MENU_PTR popptr, int rank,
  2849.                                            int entry));
  2850.  
  2851. int               PopupSetOptions _PROTO_((POPUP_MENU_PTR popptr,
  2852.                                            unsigned options,
  2853.                                            int flag));
  2854.  
  2855. int               PopupSetDimensions _PROTO_((POPUP_MENU_PTR p, int width,
  2856.                                               int height, int option));
  2857.  
  2858. int               PopupShowDisabled _PROTO_((POPUP_MENU_PTR p, int flag));
  2859.  
  2860.  
  2861.  
  2862. int               PopupSetEntryString _PROTO_((POPUP_MENU_PTR popptr,
  2863.                                                   int entry, char *string));
  2864.  
  2865. int               PopupSetExplosionType _PROTO_((POPUP_MENU_PTR popptr,
  2866.                                                  int effect));
  2867.  
  2868. int               PopupSetClickFunction _PROTO_((POPUP_MENU_PTR popptr,
  2869.                                                  POPUPCLICKPROC func));
  2870.  
  2871. int               PopupSetConfirmFunction _PROTO_((POPUP_MENU_PTR popptr,
  2872.                                                    POPUPCONFIRMPROC cfunc));
  2873.  
  2874. int               PopupSetWinDimensions _PROTO_((POPUP_MENU_PTR popptr,
  2875.                                       int width, int height, int options));
  2876.  
  2877. int               PopupMenuClose _PROTO_((POPUP_MENU_PTR popptr));
  2878.  
  2879. PULLDOWN_MENU_PTR PulldownCreateMenu _PROTO_((WPOINTER wOwner,int options,
  2880.                                         unsigned *bcolor, int row, int col,
  2881.                                         int width));
  2882.  
  2883. int               PulldownInsertEntry _PROTO_((PULLDOWN_MENU_PTR pd,
  2884.                                                int type,
  2885.                                                int where,
  2886.                                                char *entry_string,
  2887.                                                int menuid,
  2888.                                                BARSELECTPROC func,
  2889.                                                POPUP_MENU_PTR p));
  2890.  
  2891. int               PulldownAppendEntry _PROTO_((PULLDOWN_MENU_PTR pd,
  2892.                                                int type,
  2893.                                                char *entry_string,
  2894.                                                int menuid,
  2895.                                                BARSELECTPROC func,
  2896.                                                POPUP_MENU_PTR p));
  2897.  
  2898. int               PulldownCUA _PROTO_((PULLDOWN_MENU_PTR pull));
  2899. int               PulldownDeleteEntry _PROTO_((PULLDOWN_MENU_PTR pd,
  2900.                                                int where));
  2901. BAR_MENU_PTR      PulldownGetBar _PROTO_((PULLDOWN_MENU_PTR pd));
  2902.  
  2903. POPUP_MENU_PTR    PulldownGetPopup _PROTO_((PULLDOWN_MENU_PTR pd, int entry));
  2904.  
  2905. int               PulldownSelectMenu _PROTO_((PULLDOWN_MENU_PTR pullptr,
  2906.                                               int rankbar,
  2907.                                               int startbar,
  2908.                                               int imode));
  2909.  
  2910. int               PulldownMenuClose    _PROTO_((PULLDOWN_MENU_PTR pullptr));
  2911. int               PulldownMenuCloseAll _PROTO_((PULLDOWN_MENU_PTR pullptr));
  2912. int               PulldownShowDisabled _PROTO_((PULLDOWN_MENU_PTR pullptr,
  2913.                                                 int flag));
  2914.  
  2915.  
  2916. /* Other defines */
  2917. #define   BAR_NULL_PTR      ((BAR_MENU_PTR)0)
  2918. #define   POPUP_NULL_PTR    ((POPUP_MENU_PTR)0)
  2919. #define   PULLDOWN_NULL_PTR ((PULLDOWN_MENU_PTR)0)
  2920. #define   BAR_ENTRY_NULL    ((BAR_MENU_ENTRY *)0)
  2921. #define   POPUP_ENTRY_NULL  ((POPUP_MENU_ENTRY *)0)
  2922. #define   POPUP_ENTRY_AVAILABLE(p,e) (test_bit((p)->active_entry,(e)))
  2923.  
  2924. #define   POPUP_GET_MENU_ENTRY(p,e) \
  2925.           ((POPUP_ENTRY_EXTRA *)CWLget_object((p)->entry_object,(long)(e)))
  2926.  
  2927. #define   BAR_GET_MENU_ENTRY(b,e) \
  2928.                ((BAR_ENTRY_EXTRA *)CWLget_object((b)->entry_object,(e)))
  2929.  
  2930. #define   BAR_ENTRY_OFFSET(b,e) \
  2931.             (BAR_GET_MENU_ENTRY(b,e)->entry_offset)
  2932.  
  2933. #define   POPUP_ENTRY_TYPEBITS(p,e)  (POPUP_GET_MENU_ENTRY(p,e)->pop.mtype)
  2934.  
  2935. #define   POPUP_ENTRY_TYPE(p,e)  \
  2936.           ((POPUP_ENTRY_TYPEBITS(p,e) & CWL_MSEPARATOR)?CWL_MSEPARATOR: \
  2937.           ((POPUP_ENTRY_TYPEBITS(p,e) & CWL_MPOPUP)?CWL_MPOPUP:CWL_MSTRING))
  2938.  
  2939. #define   BAR_ENTRY_TYPEBITS(b,e)  (BAR_GET_MENU_ENTRY(b,e)->bar.mtype)
  2940.  
  2941. #define   BAR_ENTRY_TYPE(b,e)  \
  2942.           ((BAR_ENTRY_TYPEBITS(b,e) & CWL_MSEPARATOR)?CWL_MSEPARATOR: \
  2943.           ((BAR_ENTRY_TYPEBITS(b,e) & CWL_MPOPUP)?CWL_MPOPUP:CWL_MSTRING))
  2944.  
  2945. #define   BAR_ENTRY_ID(b,e) \
  2946.             (BAR_GET_MENU_ENTRY(b,e)->bar.menuid)
  2947.  
  2948.  
  2949. #define   POPUP_ENTRY_ID(p,e) \
  2950.             (POPUP_GET_MENU_ENTRY(p,e)->pop.menuid)
  2951.  
  2952. #define   POPUP_ENTRY_FUNCTION(p,e) \
  2953.             (POPUP_GET_MENU_ENTRY(p,e)->pop.func)
  2954.  
  2955. #define   POPUP_CASCADE(p)              ((p)->cascade)
  2956. #define   POPUP_CASCADE_ENTRY(p,e)    \
  2957.             (POPUP_GET_MENU_ENTRY(p,e)->cascade)
  2958.  
  2959. #define   POPUP_MENU_FROM_CASCADE(p,e) \
  2960.                 ((POPUP_MENU_PTR)(POPUP_GET_MENU_ENTRY(p,e)->popmenu))
  2961.  
  2962. #define   POPUP_PARENT(p)               ((p)->parent)
  2963. #define   POPUP_PARENT_ENTRY(p)   \
  2964.                       (FindPopupInParent(p))
  2965. #define   POPUP_BAR_ENTRY(p)      \
  2966.                       (FindPopupInBar(p))
  2967. #define   POPUP_WINDOW(p)               ((p)->w)
  2968. #define   POPUP_VIRTUAL_WINDOW(p)       ((p)->w->vwptr)
  2969.  
  2970. #define   POPUP_ENTRY_OFFSET(p,e) \
  2971.             (POPUP_GET_MENU_ENTRY(p,e)->entry_offset)
  2972.  
  2973. #define   POPUP_ENTRY_STRING(p,e) \
  2974.              (POPUP_GET_MENU_ENTRY(p,e)->menu_string)
  2975.  
  2976. #define   POPUP_ENTRY_RAWSTRING(p,e) \
  2977.              (POPUP_ENTRY_STRING(p,e) + POPUP_ENTRY_OFFSET(p,e))
  2978.  
  2979. #define   POPUP_ENTRY_HIGHLIGHTED(p,e) \
  2980.             (POPUP_GET_MENU_ENTRY(p,e)->highlighted)
  2981.  
  2982. #define   POPUP_ENTRY_CHECKED(p,e)      (POPUP_ENTRY_TYPEBITS(p,e) & \
  2983.                                          CWL_MCHECKED)
  2984. #define   POPUP_ENTRY_GRAYED(p,e)       (POPUP_ENTRY_TYPEBITS(p,e) & \
  2985.                                          CWL_MGRAYED)
  2986. #define   POPUP_ENTRY_DISABLED(p,e)     (POPUP_ENTRY_TYPEBITS(p,e) & \
  2987.                                          CWL_MDISABLED)
  2988. #define   BAR_ENTRY_AVAILABLE(b,e)      (POPUP_ENTRY_AVAILABLE((b),(e)))
  2989. #define   BAR_WINDOW(b)                 ((b)->w)
  2990.  
  2991.  
  2992. #define   BAR_ENTRY_STRING(b,e)  \
  2993.                 (BAR_GET_MENU_ENTRY(b,e)->menu_string)
  2994.  
  2995. #define   BAR_ENTRY_RAWSTRING(b,e) \
  2996.              (BAR_ENTRY_STRING(b,e) + BAR_ENTRY_OFFSET(b,e))
  2997.  
  2998. #define   BAR_GET_HOTKEY(b,e,c) \
  2999.                                 { \
  3000.                                   BAR_ENTRY_EXTRA *be; \
  3001.                                   char *s = BAR_ENTRY_RAWSTRING(b,e); \
  3002.                                   be = BAR_GET_MENU_ENTRY(b,e);   \
  3003.                                   if (be->hotkey_pos == strlen(s)) \
  3004.                                     c = '\0'; \
  3005.                                   else       \
  3006.                                     c = *(s + be->hotkey_pos + 1); \
  3007.                                 }
  3008.  
  3009.  
  3010. #define   PULLDOWN_MENU_PTR_FROM_BAR(b)  \
  3011.                       ((PULLDOWN_MENU_PTR)((b)->pulldown))
  3012.  
  3013. #define   PULLDOWN_MENU_PTR_FROM_POPUP(p) \
  3014.                       ((PULLDOWN_MENU_PTR)((p)->pulldown))
  3015.  
  3016. #define   BAR_MENU_PTR_FROM_PULLDOWN(pull) ((pull)->barmenu)
  3017.  
  3018. #define   PULLDOWN_GET_MENU_ENTRY(pull,entry) \
  3019.    ((PULLDOWN_ENTRY_EXTRA *)CWLget_object((pull)->entry_object,(long)(entry)))
  3020.  
  3021. #define   POPUP_MENU_PTR_FROM_PULLDOWN(pull,entry) \
  3022.               ((POPUP_MENU_PTR)(PULLDOWN_GET_MENU_ENTRY(pull,entry)->popup))
  3023.  
  3024. #define   PULLDOWN_POPUP_PTR(pull,entry) \
  3025.               POPUP_MENU_PTR_FROM_PULLDOWN(pull,entry)
  3026.  
  3027. #define   BAR_MENU_PTR_FROM_POPUP(p) \
  3028.           (BAR_MENU_PTR_FROM_PULLDOWN(PULLDOWN_MENU_PTR_FROM_POPUP(p)))
  3029.  
  3030. #define   POPUP_MENU_PTR_FROM_BAR(b,entry) \
  3031.           (POPUP_MENU_PTR_FROM_PULLDOWN(PULLDOWN_MENU_PTR_FROM_BAR(b),entry))
  3032.  
  3033. #define   ISPOPUP_MENU(w) (int)(((w)->stat_info.use_flag == POPUP_USE)?1:0)
  3034. #define   ISBAR_MENU(w)   (int)(((w)->stat_info.use_flag == BAR_USE)?1:0)
  3035.  
  3036. #define   GET_POPUP_FROM_WINDOW(w) \
  3037.              (ISPOPUP_MENU(w)?(POPUP_MENU_PTR)((w)->use_ptr):POPUP_NULL_PTR)
  3038.  
  3039. #define   GET_BAR_FROM_WINDOW(w) \
  3040.              (ISBAR_MENU(w)?(BAR_MENU_PTR)((w)->use_ptr):BAR_NULL_PTR)
  3041.  
  3042. #define   POPUP_ENTRY_ROW(p,e)  (POPUP_GET_MENU_ENTRY(p,e)->row)
  3043. #define   POPUP_OWNER_WINDOW(p) ((p)->owner_window)
  3044.  
  3045. #define   BAR_ENTRY_ROW(b,e)  (BAR_GET_MENU_ENTRY(b,e)->row)
  3046. #define   BAR_ENTRY_COL(b,e)  (BAR_GET_MENU_ENTRY(b,e)->col)
  3047.  
  3048. #define   POPUP_STRING_IN_WINDOW(p,e)  \
  3049.             VWINDOW_COORD_IN_VIEWPORT(POPUP_WINDOW(p),POPUP_ENTRY_ROW(p,e),0)
  3050.  
  3051. /**************** Define CWL Form structures and functions ***************/
  3052.  
  3053. enum field_types   {FIELDEND,
  3054.                     INTEGER=1,
  3055.                     UINTEGER,
  3056.                     LINTEGER,
  3057.                     ULINTEGER,
  3058.                     FLOAT,
  3059.                     DOUBLE,
  3060.                     STRING,
  3061.                     CHAR,
  3062.                     TOGGLE,
  3063.                     NORMALFIELDCUTOFF,
  3064.                     BUTTON,
  3065.                     SUBFORM,
  3066.                     VSUBFORM,
  3067.                     RADIO,
  3068.                     CHECKBOX,
  3069.                     LIST,
  3070.                     USERTYPE
  3071.                     };
  3072.  
  3073.  
  3074. #define NO_FIELD_OPTIONS             0UL
  3075. #define NO_FORM_OPTIONS              0UL
  3076. #define FIELD_UPPERCASE              0x1UL
  3077. #define FIELD_LOWERCASE              0x2UL
  3078. #define FIELD_CHECKSPACES            0x4UL
  3079. #define FIELD_ENHANCEDKEY            0x8UL
  3080. #define FIELD_CHECKREGEXP            0x10UL
  3081. #define FIELD_AUTORETURN             0x20UL
  3082. #define FIELD_CHECKREGEXP_IGNORECASE 0x40UL
  3083. #define FIELD_FLUSHBUFFER            0x80UL
  3084.  
  3085. #define FIELD_HOMECURSOR             0x100UL
  3086. #if !defined (SHAREWARE)
  3087. #define FIELD_USEMOUSE               0x200UL
  3088. #else
  3089. #define FIELD_USEMOUSE               0x0UL
  3090. #endif
  3091. #define FIELD_CLEARFIELD             0x400UL
  3092. #define FIELD_VIRTUAL                0x800UL
  3093. #define FIELD_PROTECT                0x1000UL
  3094. #define FIELD_COMMA                  0x2000UL
  3095. #define FIELD_RJUSTIFY               0x4000UL
  3096. #define FIELD_LJUSTIFY               0x8000UL
  3097. #define FIELD_ZSUPPRESS1             0x10000UL
  3098. #define FIELD_ZSUPPRESS2             0x20000UL
  3099. #define FIELD_PASSWORD               0x40000UL
  3100. #define FIELD_CHECK                  0x80000UL
  3101. #define FIELD_OVERRIDE_FORWARD       0x100000UL
  3102. #define FIELD_OVERRIDE_BACKWARD      0x200000UL
  3103. #define FORMFLAG                     0x800000UL
  3104.  
  3105. #define NUMFIELDOPTS               22
  3106.  
  3107. #define HELP_START_KEY          0
  3108. #define HELP_END_KEY            1
  3109. #define HELP_UP_KEY             2
  3110. #define HELP_DOWN_KEY           3
  3111. #define HELP_RIGHT_KEY          4
  3112. #define HELP_LEFT_KEY           5
  3113. #define HELP_ZOOM_KEY           6
  3114.  
  3115. #define NUMHELPKEYS             7
  3116.  
  3117. #define NUMFORMKEYS             45      /* Number of form edit keys */
  3118.  
  3119.  
  3120. #define USINGFORM   (1UL << NUMFIELDOPTS)
  3121. #define FORM_FORWARD  1
  3122. #define FORM_BACKWARD 2
  3123. #define FORM_BOTHDIR  3
  3124. #define FORM_WRAP          1
  3125. #define FORM_CHECK         2
  3126. #define FORM_EXIT_INITIAL  4
  3127. #define FORM_NOEXIT_LAST   8
  3128. #define FORM_HIGHLIGHT     16
  3129.  
  3130. #if !defined (SHAREWARE)
  3131. #define FORM_VIRTUAL       32
  3132. #else
  3133. #define FORM_VIRTUAL       0
  3134. #endif
  3135.  
  3136. #define FORM_STATIC        64
  3137.  
  3138. #define FIELD_LOW           1
  3139. #define FIELD_HIGH          2
  3140. #define FIELD_OUT_OF_RANGE  (FIELD_LOW | FIELD_HIGH)
  3141. #define FIELD_OK            0
  3142.  
  3143. #define INCLUDE_LOW         1
  3144. #define INCLUDE_HIGH        2
  3145. #define EXCLUDE_LOW         4
  3146. #define EXCLUDE_HIGH        8
  3147. #define NO_RANGE_OPT        (INCLUDE_LOW|INCLUDE_HIGH)
  3148.  
  3149.  
  3150. #define UINTEGER_REGEXP "[0-9]"
  3151. #define SINTEGER_REGEXP "[0-9+/-]"
  3152. #define UDECIMAL_REGEXP "[0-9/.]"
  3153. #define DECIMAL_REGEXP  "[0-9/.+/-]"
  3154. #define SCIENTIFIC_REGEXP "[0-9/.Ee+/-]"
  3155. #define REPEAT_REGEXP(regexp,num)  num##regexp
  3156. #define FORM_NULL_PTR   ((FORMPTR)0)
  3157. #define FIELD_ENTRY_NULL_PTR  ((FIELD_ENTRY_PTR)0)
  3158.  
  3159. #define MAXFIELDSIZE  256
  3160.  
  3161.  
  3162.  
  3163. #define INTMAX    "32767"
  3164. #define INTMIN    "32768"
  3165. #define UINTMAX   "65535"
  3166. #define UINTMIN   "0"
  3167. #define LINTMIN   "2147483648"
  3168. #define LINTMAX   "2147483647"
  3169. #define ULINTMIN  "0"
  3170. #define ULINTMAX  "4294967295"
  3171.  
  3172. #define FIELD_PROTECT_ON(entry)           (int) ((entry).options & FIELD_PROTECT)
  3173. #define FIELD_COMMA_ON(entry)             (int) ((entry).options & FIELD_COMMA)
  3174. #define FIELD_RJUSTIFY_ON(entry)          (int) ((entry).options & FIELD_RJUSTIFY)
  3175. #define FIELD_LJUSTIFY_ON(entry)          (int) ((entry).options & FIELD_LJUSTIFY)
  3176. #define FIELD_UPPERCASE_ON(entry)         (int) ((entry).options & FIELD_UPPERCASE)
  3177. #define FIELD_LOWERCASE_ON(entry)         (int) ((entry).options & FIELD_LOWERCASE)
  3178. #define FIELD_CHECKSPACES_ON(entry)       (int) ((entry).options & FIELD_CHECKSPACES)
  3179. #define FIELD_ENHANCEDKEY_ON(entry)       (int) ((entry).options & FIELD_ENHANCEDKEY)
  3180. #define FIELD_CHECKREGEXP_ON(entry)       (int) ((entry).options & FIELD_CHECKREGEXP)
  3181. #define FIELD_AUTORETURN_ON(entry)        (int) ((entry).options & FIELD_AUTORETURN)
  3182. #define FIELD_CHECKREGEXP_IGNORECASE_ON(entry)   (int) ((entry).options & \
  3183.                                                   FIELD_CHECKREGEXP_IGNORECASE)
  3184. #define FIELD_FLUSHBUFFER_ON(entry)       (int) ((entry).options & FIELD_FLUSHBUFFER)
  3185. #define FIELD_HOMECURSOR_ON(entry)        (int) ((entry).options & FIELD_HOMECURSOR)
  3186. #define FIELD_ZSUPPRESS1_ON(entry)        (int) ((entry).options & FIELD_ZSUPPRESS1)
  3187. #define FIELD_ZSUPPRESS2_ON(entry)        (int) ((entry).options & FIELD_ZSUPPRESS2)
  3188. #define FIELD_PASSWORD_ON(entry)          (int) ((entry).options & FIELD_PASSWORD)
  3189. #define FIELD_CHECK_ON(entry)             (int) ((entry).options & FIELD_CHECK)
  3190. #define FIELD_SUBFORM_ON(entry)           (int) ((entry).options & FIELD_SUBFORM_DEF)
  3191. #define FIELD_OVERRIDE_FORWARD_ON(entry)  (int) ((entry).options & FIELD_OVERRIDE_FORWARD)
  3192. #define FIELD_OVERRIDE_BACKWARD_ON(entry) (int) ((entry).options & FIELD_OVERRIDE_BACKWARD)
  3193. #define FIELD_USEMOUSE_ON(entry)          (int) ((entry).options & FIELD_USEMOUSE)
  3194. #define FIELD_CLEARFIELD_ON(entry)        (int) ((entry).options & FIELD_CLEARFIELD)
  3195.  
  3196.  
  3197. #define FORM_DIRECTION(form)         ((form)->formdir)
  3198. #define FORM_EXPLODE_TYPE(form)      ((form)->explode)
  3199. #define FORM_WRAP_ON(form)           ((form)->options & FORM_WRAP)
  3200. #define FORM_CHECK_ON(form)          ((form)->options & FORM_CHECK)
  3201. #define FORM_EXIT_INITIAL_ON(form)   ((form)->options & FORM_EXIT_INITIAL)
  3202. #define FORM_HIGHLIGHT_ON(form)      ((form)->options & FORM_HIGHLIGHT)
  3203. #define FORM_VIRTUAL_ON(form)        ((form)->options & FORM_VIRTUAL)
  3204. #define FORM_NOEXIT_LAST_ON(form)    ((form)->options & FORM_NOEXIT_LAST)
  3205. #define FORM_STATIC_ON(form)         ((form)->options & FORM_STATIC)
  3206.  
  3207. #define GET_FIELDPTR_FROM_FORM(form,fldnum) \
  3208.                     ((FIELDPTR)((form)->field[(fldnum)]))
  3209.  
  3210. #define GET_FIELD_FROM_FORM(form,entry) \
  3211.                     (GET_FIELDPTR_FROM_FORM(form,entry)->fentry)
  3212.  
  3213. #define GET_FIELD_NUMBER(form,entry) \
  3214.           (GET_FIELDPTR_FROM_FORM(form,entry)->field_number)
  3215.  
  3216. #define FIELD_DECIMAL_PLACES(form,entry) \
  3217.         (GET_FIELDPTR_FROM_FORM(form,entry)->numdec)
  3218.  
  3219.  
  3220.  
  3221. #define FIELD_ROW(entry)                  ((entry).row)
  3222. #define FIELD_COLUMN(entry)               ((entry).col)
  3223. #define FIELD_TYPE(entry)                 ((entry).type)
  3224. #define FIELD_MASK(entry)                 ((entry).mask)
  3225. #define FIELD_FILL(entry)                 ((entry).fillchar)
  3226. #define FIELD_MINIMUM(entry)              ((entry).minchars)
  3227. #define FIELD_VISIBLE_WIDTH(entry)        ((entry).maxwidth)
  3228. #define FIELD_REGEXP(entry)               ((entry).regexp)
  3229. #define FIELD_ATTRIBUTE(entry)            ((entry).attr)
  3230. #define FIELD_START_POSITION(entry)       ((entry).startpos)
  3231. #define FIELD_VARPTR(form,entry)          \
  3232.                        (GET_FIELDPTR_FROM_FORM(form,entry)->uservar)
  3233. #define FIELD_CHANGE(form,entry)          \
  3234.                        (GET_FIELDPTR_FROM_FORM(form,entry)->field_change)
  3235.  
  3236. #define FIELD_NUMERIC(field)   ((field)->fentry.type == INTEGER    || \
  3237.                                 (field)->fentry.type == UINTEGER   || \
  3238.                                 (field)->fentry.type == LINTEGER   || \
  3239.                                 (field)->fentry.type == ULINTEGER  || \
  3240.                                 (field)->fentry.type == FLOAT      || \
  3241.                                 (field)->fentry.type == DOUBLE)
  3242.  
  3243. #define FIELD_BUFSIZE(form,entry) (GET_FIELDPTR_FROM_FORM(form,entry)->bufsize)
  3244.  
  3245. #define FORM_WINDOW(form)                 ((form)->form_window)
  3246. #define FORM_VIRTUAL_WINDOW(form)         ((form)->form_vwindow)
  3247. #define FORM_CHANGE(form)                 ((form)->form_change)
  3248. #define FORM_NUMBER_OF_FIELDS(form)       ((form)->numfields)
  3249. #define FIELD_IN_RANGE(form,entry)    (((entry) < FORM_NUMBER_OF_FIELDS(form)) \
  3250.                                         && ((entry) >= 0))
  3251.  
  3252. #define FIELD_CURSORTYPE(form,entry,which) \
  3253.   (GET_FIELDPTR_FROM_FORM(form,entry)->cursortype[which])
  3254.  
  3255. #define FIELD_CURSORMODE(form,entry) \
  3256.   (GET_FIELDPTR_FROM_FORM(form,entry)->defmode)
  3257.  
  3258.  
  3259. #define SUBFORM_UP     1
  3260. #define SUBFORM_DOWN   2
  3261. #define SKIP_FIELD     24
  3262. #define FIELD_ERROR    25
  3263.  
  3264. #define LAST_FIELD_EXIT  (-1)
  3265. #define FIRST_FIELD_EXIT (-2)
  3266. #define FORM_END_CLEAR   (-3)
  3267. #define TESTFORM  1
  3268. #define TESTFIELD 2
  3269. #define TOGGLE_NULL  ((char *)0)
  3270.  
  3271. #define FIELD_HELP_CONTINUE  0
  3272. #define FIELD_HELP_UP        1
  3273. #define FIELD_HELP_DOWN      2
  3274. #define FIELD_HELP_RIGHT     3
  3275. #define FIELD_HELP_LEFT      4
  3276. #define FIELD_HELP_QUIT      5
  3277. #define FIELD_HELP_ZOOM      6
  3278. #define VIRTUAL_HELP         0
  3279. #define DISK_HELP            1
  3280. #define ONLINE_HELP          1
  3281. #define STATIC_HELP          0
  3282. #define FIELDHELPLEN         15
  3283.  
  3284.  
  3285. #define MAXHELPLINE  132
  3286.  
  3287. #define GET_HELP_TYPE(form,htype) \
  3288.       ((htype == ONLINE_HELP)?((FIELD_HELP_PTR)((form)->field_help1)): \
  3289.                               ((FIELD_HELP_PTR)((form)->field_help2)))
  3290.  
  3291. #define FIELD_HELP_START_KEY(fhp) \
  3292.          (fhp->help_key[HELP_START_KEY])
  3293.  
  3294. #define FIELD_HELP_END_KEY(fhp)   \
  3295.          (fhp->help_key[HELP_END_KEY])
  3296.  
  3297. #define FIELD_HELP_UP_KEY(fhp)    \
  3298.          (fhp->help_key[HELP_UP_KEY])
  3299.  
  3300. #define FIELD_HELP_DOWN_KEY(fhp)  \
  3301.          (fhp->help_key[HELP_DOWN_KEY])
  3302.  
  3303. #define FIELD_HELP_LEFT_KEY(fhp)  \
  3304.          (fhp->help_key[HELP_LEFT_KEY])
  3305.  
  3306. #define FIELD_HELP_RIGHT_KEY(fhp) \
  3307.          (fhp->help_key[HELP_RIGHT_KEY])
  3308.  
  3309. #define FIELD_HELP_ZOOM_KEY(fhp) \
  3310.          (fhp->help_key[HELP_ZOOM_KEY])
  3311.  
  3312. #define FIELD_HELP_DEFINED(fhp) (fhp)
  3313.  
  3314. #define FIELD_HELP_ON(form,htype) \
  3315.       ((htype == ONLINE_HELP)?(form)->help1_on:(form)->help2_on)
  3316.  
  3317.  
  3318. #define FIELD_HELP_WINDOW(fhp)  (fhp->help_window)
  3319.  
  3320. #define FIELD_HELP_VWINDOW(fhp) (fhp->help_vwindow)
  3321.  
  3322. #define FIELD_HELP_NAME(fhp, num) (fhp->helpname[num])
  3323. #define FIELD_HELP_TYPE(fhp)      (fhp->helptype)
  3324.  
  3325. #define NUMRADIOCOLORS       4
  3326. #define NUMCHECKBOXCOLORS    NUMRADIOCOLORS
  3327. #define NUMBUTTONCOLORS      NUMRADIOCOLORS
  3328. #define NORMATTR             0
  3329. #define HIATTR               1
  3330. #define HOTATTR              2
  3331. #define UNAVAILATTR          3
  3332.  
  3333.  
  3334.  
  3335. typedef struct {
  3336.     unsigned alldigits:1;      /* tells if all digits */
  3337.     unsigned attrdef:1;        /* attribute is defined */
  3338.     unsigned maskdisp:1;        /* mask defined */
  3339.     unsigned insert:1;         /* tells if in insert mode */
  3340.     unsigned uppercase:1;      /* tells if alpha characters are displayed in
  3341.                                 * upper case */
  3342.     unsigned lowercase:1;      /* tells if alpha characters are displayed in
  3343.                                 * lower case */
  3344.     unsigned checkspaces:1;    /* tells if input manager should check for
  3345.                                 * blank spaces when checking input
  3346.                                 * requirements */
  3347.     unsigned enhancedkey:1;    /* Tells if enhanced keys should be detected */
  3348.     unsigned checkregexp:1;    /* tells if each input position matches the
  3349.                                 * regular expression desired */
  3350.     unsigned other_field_type:3; /* other field type */
  3351.  }
  3352.  FIELD_OPTIONS;
  3353.  
  3354.  
  3355.  
  3356. /* define form structure */
  3357.  
  3358. typedef struct tagFORMSTRUCT
  3359. {
  3360.   char **field;             /* pointer to char must be
  3361.                                same size as pointer to field -
  3362.                                array of field pointers */
  3363.   unsigned *form_key;       /* keys defined for form */
  3364.   WPOINTER form_window;     /* window for form */
  3365.   VWPOINTER form_vwindow;   /* virtual window for form */
  3366.   char *inputbuffer;
  3367.   int orig_rank;            /* used for forms with list fields */
  3368.   int (*form_exit_func) _PROTO_((struct tagFORMSTRUCT *, int, int *));
  3369.   int numfields;
  3370.   unsigned long total_bufsize;
  3371.   unsigned num_protected;
  3372.   int explode;
  3373.   unsigned formdir:3;
  3374.   unsigned form_change:1;
  3375.   unsigned options;
  3376.   unsigned help1_on:1;
  3377.   unsigned help2_on:1;
  3378.   VOIDPTR field_help1;       /* pointer to field help structure */
  3379.   VOIDPTR field_help2;       /* pointer to perpetual field help */
  3380.  
  3381. } FORM, *FORMPTR;
  3382.  
  3383. typedef int (*FORMEXITPROC)      _PROTO_((FORMPTR, int, int *));
  3384. typedef int (*FIELDPREPROC)      _PROTO_((FORMPTR, int *));
  3385. typedef int (*FIELDPOSTPROC)     _PROTO_((FORMPTR, int *));
  3386. typedef int (*FIELDVALIDATEPROC) _PROTO_((FORMPTR, int, char *));
  3387. typedef int (*BUTTONPROC)        _PROTO_((FORMPTR,int,int *));
  3388.  
  3389. /* define basic field entry */
  3390.  
  3391. typedef struct tagFIELDENTRY
  3392. {
  3393.   int type;              /* field type */
  3394.   unsigned row,          /* field row */
  3395.            col;          /* field column */
  3396.   char *mask;            /* user defined mask */
  3397.   int fillchar;          /* fill character */
  3398.   int minchars;          /* minimum characters */
  3399.   int maxwidth;          /* maximum width of shown field */
  3400.   unsigned long options; /* options */
  3401.   int startpos;          /* starting position in the field */
  3402.   int attr;              /* attribute to use for the field */
  3403.   char *regexp;          /* regular expression */
  3404. } FIELD_ENTRY, *FIELD_ENTRY_PTR;
  3405.  
  3406.  
  3407.  
  3408. /* define 'official' field entry */
  3409. typedef struct tagFIELD
  3410. {
  3411.   int field_number;     /* field position */
  3412.   FIELD_ENTRY fentry;   /* basic field entry */
  3413.   FIELDPREPROC  prefunc;            /* pre function to field */
  3414.   FIELDPOSTPROC postfunc;           /* post function to field */
  3415.   FIELDVALIDATEPROC validate_func;  /* error function */
  3416.   int cursortype[2];    /* cursor shapes for insert/overwrite */
  3417.   unsigned defmode:1;  /* cursor mode on start of input */
  3418.   VOIDPTR uservar;        /* pointer to user variable */
  3419.   VOIDPTR other;           /* pointer to other types of fields -
  3420.                          * for future expansion */
  3421.   int passchar;         /* password character if passwords used */
  3422.   int bufsize;          /* size of field buffer
  3423.                          *  (depends on regular expression)   */
  3424.   char *buffer;         /* field buffer */
  3425.   unsigned editkeys[NUMFORMKEYS];   /* field edit keys */
  3426.   unsigned int numdec;  /*  number of decimal places */
  3427.   unsigned field_change:1; /* 1 if field has been changed, 0 otherwise */
  3428.   FIELD_OPTIONS field_opt;  /* options for field */
  3429. } FIELD, *FIELDPTR;
  3430.  
  3431.  
  3432. /* help info structure pointers */
  3433. typedef struct tagVHELPSTRUCT
  3434. {
  3435.   unsigned f_line;
  3436.   unsigned l_line;
  3437.   unsigned line_length;
  3438. } VHELP_STRUCT, *VHELP_STRUCT_PTR;
  3439.  
  3440.  
  3441. typedef struct tagDHELPSTRUCT
  3442. {
  3443.   long filepos;
  3444.   unsigned nlines;
  3445.   unsigned line_length;
  3446. } DHELP_STRUCT, *DHELP_STRUCT_PTR;
  3447.  
  3448.  
  3449. /* field help structure */
  3450. typedef struct tagFIELD_HELP
  3451. {
  3452.   FIELDPTR *field;
  3453.   char *filename;
  3454.   WPOINTER help_window;
  3455.   VWPOINTER help_vwindow;
  3456.   unsigned help_key[NUMHELPKEYS];
  3457.   VHELP_STRUCT_PTR vhelp_struct;
  3458.   DHELP_STRUCT_PTR dhelp_struct;
  3459.   unsigned num_help;
  3460.   unsigned helptype:1;
  3461.   unsigned fileopen:1;
  3462.   unsigned online:1;
  3463.   char **helpname;
  3464.   VOIDPTR handle;
  3465. } FIELD_HELP, *FIELD_HELP_PTR;
  3466.  
  3467.  
  3468. /* SUBFORM structure */
  3469. typedef struct tagSUBFORM
  3470. {
  3471.   FORMPTR parent;
  3472.   FORMPTR form;
  3473.   int start_entry;
  3474.   int rank;
  3475. } SUBFORM_FIELD, *SUBFORM_FIELD_PTR, VSUBFORM_FIELD, *VSUBFORM_FIELD_PTR;
  3476.  
  3477.  
  3478. /* LIST structure */
  3479. typedef struct tagLIST
  3480. {
  3481.   POPUP_MENU_PTR popup;
  3482.   int choice;
  3483.   int start_entry;
  3484.   int rank;
  3485.   int new_entry;    /* needed if new entry was found */
  3486.   int return_value; /* return value used by form manager */
  3487. } LIST_FIELD, *LIST_FIELD_PTR;
  3488.  
  3489.  
  3490.  
  3491.  
  3492. /* TOGGLE structure */
  3493. typedef struct tagTOGGLE
  3494. {
  3495.   char **toglist;
  3496.   int choice;
  3497.   int start_entry;
  3498. } TOGGLE_FIELD, *TOGGLE_FIELD_PTR;
  3499.  
  3500.  
  3501.  
  3502. /* BUTTON structure */
  3503. typedef struct tagBUTTON
  3504. {
  3505.   int retval;
  3506.   char *name;
  3507.   BUTTONPROC button_func;
  3508.   int attr[NUMBUTTONCOLORS];
  3509.   int pending;
  3510. } BUTTON_FIELD, *BUTTON_FIELD_PTR;
  3511.  
  3512.  
  3513. /* RADIO_ENTRY and CHECKBOX structure */
  3514. typedef union tagRADCHECK
  3515. {
  3516.   unsigned radio_prompt_row,
  3517.            checkbox_prompt_row;
  3518. } PROMPT_ROW;
  3519.  
  3520.  
  3521. typedef union
  3522. {
  3523.   unsigned radio_prompt_col,
  3524.            checkbox_prompt_col;
  3525. } PROMPT_COL;
  3526.  
  3527.  
  3528. typedef union
  3529. {
  3530.   unsigned radio_button_row,
  3531.            checkbox_button_row;
  3532. } BUTTON_ROW;
  3533.  
  3534.  
  3535. typedef union
  3536. {
  3537.   unsigned radio_button_col,
  3538.            checkbox_button_col;
  3539. } BUTTON_COL;
  3540.  
  3541.  
  3542. typedef struct
  3543. {
  3544.   char *prompt;
  3545.   int  hot_letter;
  3546.   PROMPT_ROW p_row;
  3547.   PROMPT_COL p_col;
  3548.   BUTTON_ROW b_row;
  3549.   BUTTON_COL b_col;
  3550. } RADIO_ENTRY, *RADIO_ENTRY_PTR, CHECKBOX_ENTRY, *CHECKBOX_ENTRY_PTR;
  3551.  
  3552.  
  3553.  
  3554. /* RADIO structure */
  3555. typedef struct tagRADIO
  3556. {
  3557.   int radio_current;
  3558.   int radio_char;
  3559.   int num_entries;
  3560.   int attr[NUMRADIOCOLORS];  /* attribute of unhighlighted radio button */
  3561.   BITSTRING active;
  3562.   int pending;
  3563.   int start_entry;
  3564.   RADIO_ENTRY_PTR radio_entry;
  3565. } RADIO_FIELD, *RADIO_FIELD_PTR;
  3566.  
  3567.  
  3568.  
  3569. typedef struct tagCHECKBOX
  3570. {
  3571.   int checkbox_current;
  3572.   int checkbox_char;
  3573.   int num_entries;
  3574.   int attr[NUMCHECKBOXCOLORS];
  3575.   int pending;
  3576.   int start_entry;
  3577.   BITSTRING active;
  3578.   BITSTRING chosen;
  3579.   CHECKBOX_ENTRY_PTR checkbox_entry;
  3580. } CHECKBOX_FIELD, *CHECKBOX_FIELD_PTR;
  3581.  
  3582.  
  3583.  
  3584. #define GET_LIST_FIELD(form,entry) \
  3585.      ((LIST_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3586.  
  3587. #define GET_LIST_FIELD_FROM_POPUP(p)  ((LIST_FIELD_PTR)((p)->listptr))
  3588.  
  3589. #define GET_POPUP_FROM_LIST_FIELD(form,entry) \
  3590.         (GET_LIST_FIELD(form,entry)->popup)
  3591.  
  3592. #define GET_TOGGLE_FIELD(form,entry) \
  3593.      ((TOGGLE_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3594.  
  3595. #define GET_BUTTON_FIELD(form,entry) \
  3596.      ((BUTTON_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3597.  
  3598.  
  3599. #define GET_RADIO_FIELD(form,entry) \
  3600.      ((RADIO_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3601.  
  3602. #define GET_SUBFORM_FIELD(form,entry) \
  3603.      ((SUBFORM_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3604.  
  3605. #define GET_SUBFORM_FORMPTR(form,entry) \
  3606.      ((GET_SUBFORM_FIELD(form,entry))->subform)
  3607.  
  3608.  
  3609. #define GET_VSUBFORM_FIELD(form,entry) \
  3610.      ((VSUBFORM_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3611.  
  3612. #define GET_VSUBFORM_FORMPTR(form,entry) \
  3613.      ((GET_VSUBFORM_FIELD(form,entry))->subform)
  3614.  
  3615. #define GET_CHECKBOX_FIELD(form,entry) \
  3616.       ((CHECKBOX_FIELD_PTR)(GET_FIELDPTR_FROM_FORM(form,entry))->other)
  3617.  
  3618. #define LIST_START_ENTRY(form,entry) \
  3619.     (GET_LIST_FIELD(form,entry)->start_entry)
  3620.  
  3621. #define TOGGLE_START_ENTRY(form,entry) \
  3622.     (GET_TOGGLE_FIELD(form,entry)->start_entry)
  3623.  
  3624. #define CHECKBOX_START_ENTRY(form,entry) \
  3625.     (GET_CHECKBOX_FIELD(form,entry)->start_entry)
  3626.  
  3627. #define RADIO_START_ENTRY(form,entry) \
  3628.     (GET_RADIO_FIELD(form,entry)->start_entry)
  3629.  
  3630. #define SUBFORM_START_ENTRY(form,entry) \
  3631.     (GET_SUBFORM_FIELD(form,entry)->start_entry)
  3632.  
  3633. #define VSUBFORM_START_ENTRY(form,entry) \
  3634.     (GET_VSUBFORM_FIELD(form,entry)->start_entry)
  3635.  
  3636. #define BUTTON_FIELD_RETURN(form,entry) \
  3637.         (GET_BUTTON_FIELD(form,entry)->retval)
  3638.  
  3639. #define BUTTON_FIELD_USER_FUNC(form,entry) \
  3640.         (GET_BUTTON_FIELD(form,entry)->button_func)
  3641.  
  3642. #define BUTTON_FIELD_PENDING(form,entry) \
  3643.         (GET_BUTTON_FIELD(form,entry)->pending)
  3644.  
  3645. #define LIST_FIELD_CHOICE(form,entry) \
  3646.       (GET_LIST_FIELD(form,entry)->choice)
  3647.  
  3648.  
  3649. #define LIST_FIELD_NEWENTRY(form,entry) \
  3650.       (GET_LIST_FIELD(form,entry)->new_entry)
  3651.  
  3652. #define TOGGLE_FIELD_CHOICE(form,entry) \
  3653.       (GET_TOGGLE_FIELD(form,entry)->choice)
  3654.  
  3655.  
  3656. #define CHECKBOX_FIELD_PENDING(form,entry) \
  3657.         (GET_CHECKBOX_FIELD(form,entry)->pending)
  3658.  
  3659. #define CHECKBOX_FIELD_ACTIVE(form,entry,entrynum) \
  3660.         (test_bit((GET_CHECKBOX_FIELD(form,entry)->active),(entrynum)))
  3661.  
  3662. #define CHECKBOX_FIELD_CHOSEN(form,entry,entrynum) \
  3663.         (test_bit((GET_CHECKBOX_FIELD(form,entry)->chosen),(entrynum)))
  3664.  
  3665. #define CHECKBOX_FIELD_BUTTON_ROW(form,entry,entrynum) \
  3666. (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].b_row.checkbox_button_row)
  3667.  
  3668. #define CHECKBOX_FIELD_BUTTON_COLUMN(form,entry,entrynum) \
  3669. (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].b_col.checkbox_button_col)
  3670.  
  3671. #define CHECKBOX_FIELD_PROMPT_COLUMN(form,entry,entrynum) \
  3672. (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].p_col.checkbox_prompt_col)
  3673.  
  3674. #define CHECKBOX_FIELD_PROMPT_ROW(form,entry,entrynum) \
  3675. (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].p_row.checkbox_prompt_row)
  3676.  
  3677. #define CHECKBOX_FIELD_HOTKEY_LETTER(form,entry,entrynum) \
  3678. (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].hot_letter)
  3679.  
  3680. #define CHECKBOX_FIELD_NORMATTR(form,entry) \
  3681.      (GET_CHECKBOX_FIELD(form,entry)->attr[NORMATTR])
  3682.  
  3683. #define CHECKBOX_FIELD_HIATTR(form,entry) \
  3684.      (GET_CHECKBOX_FIELD(form,entry)->attr[HIATTR])
  3685.  
  3686. #define CHECKBOX_FIELD_HOTATTR(form,entry) \
  3687.      (GET_CHECKBOX_FIELD(form,entry)->attr[HOTATTR])
  3688.  
  3689. #define CHECKBOX_FIELD_UNAVAILATTR(form,entry) \
  3690.      (GET_CHECKBOX_FIELD(form,entry)->attr[UNAVAILATTR])
  3691.  
  3692. #define CHECKBOX_FIELD_PROMPT(form,entry,entrynum) \
  3693.      (GET_CHECKBOX_FIELD(form,entry)->checkbox_entry[(entrynum)].prompt)
  3694.  
  3695. #define CHECKBOX_FIELD_CURRENT_CHOICE(form,entry) \
  3696.      (GET_CHECKBOX_FIELD(form,entry)->checkbox_current)
  3697.  
  3698. #define CHECKBOX_FIELD_CHAR(form,entry) \
  3699.      (GET_CHECKBOX_FIELD(form,entry)->checkbox_char)
  3700.  
  3701. #define CHECKBOX_FIELD_NUM_ENTRIES(form,entry) \
  3702.      (GET_CHECKBOX_FIELD(form,entry)->num_entries)
  3703.  
  3704. #define RADIO_FIELD_PENDING(form,entry) \
  3705.         (GET_RADIO_FIELD(form,entry)->pending)
  3706.  
  3707. #define RADIO_FIELD_ACTIVE(form,entry,entrynum) \
  3708.         (test_bit((GET_RADIO_FIELD(form,entry)->active),(entrynum)))
  3709.  
  3710. #define RADIO_FIELD_BUTTON_ROW(form,entry,entrynum) \
  3711. (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].b_row.radio_button_row)
  3712.  
  3713. #define RADIO_FIELD_BUTTON_COLUMN(form,entry,entrynum) \
  3714. (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].b_col.radio_button_col)
  3715.  
  3716. #define RADIO_FIELD_PROMPT_COLUMN(form,entry,entrynum) \
  3717. (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].p_col.radio_prompt_col)
  3718.  
  3719. #define RADIO_FIELD_PROMPT_ROW(form,entry,entrynum) \
  3720. (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].p_row.radio_prompt_row)
  3721.  
  3722. #define RADIO_FIELD_HOTKEY_LETTER(form,entry,entrynum) \
  3723.         (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].hot_letter)
  3724.  
  3725. #define RADIO_FIELD_NORMATTR(form,entry) \
  3726.         (GET_RADIO_FIELD(form,entry)->attr[NORMATTR])
  3727.  
  3728. #define RADIO_FIELD_HIATTR(form,entry) \
  3729.         (GET_RADIO_FIELD(form,entry)->attr[HIATTR])
  3730.  
  3731. #define RADIO_FIELD_HOTATTR(form,entry) \
  3732.         (GET_RADIO_FIELD(form,entry)->attr[HOTATTR])
  3733.  
  3734. #define RADIO_FIELD_UNAVAILATTR(form,entry) \
  3735.         (GET_RADIO_FIELD(form,entry)->attr[UNAVAILATTR])
  3736.  
  3737. #define RADIO_FIELD_PROMPT(form,entry,entrynum) \
  3738.         (GET_RADIO_FIELD(form,entry)->radio_entry[(entrynum)].prompt)
  3739.  
  3740. #define RADIO_FIELD_CURRENT_CHOICE(form,entry) \
  3741.         (GET_RADIO_FIELD(form,entry)->radio_current)
  3742.  
  3743. #define RADIO_FIELD_CHOSEN   RADIO_FIELD_CURRENT_CHOICE
  3744.  
  3745. #define RADIO_FIELD_CHAR(form,entry) \
  3746.         (GET_RADIO_FIELD(form,entry)->radio_char)
  3747.  
  3748. #define RADIO_FIELD_NUM_ENTRIES(form,entry) \
  3749.         (GET_RADIO_FIELD(form,entry)->num_entries)
  3750.  
  3751. #define NO_BUTTON_FUNC         ((BUTTONPROC)0)
  3752. #define NO_UNDEF_SPECIAL_FUNC  ((int (*)(FORMPTR,int,int *))0)
  3753.  
  3754.  
  3755. CHECKBOX_ENTRY_PTR CheckboxAllocate _PROTO_((int num));
  3756.  
  3757. CWL_VOID         CheckboxDeallocate _PROTO_((CHECKBOX_ENTRY_PTR pentry));
  3758.  
  3759. CWL_VOID         CheckboxCreateEntry _PROTO_((CHECKBOX_ENTRY *entry,
  3760.                                       int entrynum,
  3761.                                       char *pname, int hot_letter,
  3762.                                       unsigned prow, unsigned pcol,
  3763.                                       unsigned brow, unsigned bcol));
  3764.  
  3765. CWL_VOID         CheckboxEntryEnd _PROTO_((CHECKBOX_ENTRY_PTR entry,
  3766.                                          int numfields));
  3767.  
  3768. FIELD_ENTRY_PTR  FieldAllocate _PROTO_((int numfields));
  3769.  
  3770. CWL_VOID         FieldCreate _PROTO_((FIELD_ENTRY_PTR field, int fldnum,
  3771.                                       int fldtype, unsigned fldrow,
  3772.                                       unsigned fldcol, char *mask,
  3773.                                       int fillchar, int minchars, int maxwidth,
  3774.                                       unsigned long fldopts, int startpos,
  3775.                                       int attr, char *regexp));
  3776.  
  3777. CWL_VOID         FieldEnd _PROTO_((FIELD_ENTRY_PTR field, int numfields));
  3778.  
  3779. CWL_VOID         FieldDeallocate _PROTO_((FIELD_ENTRY_PTR field));
  3780.  
  3781. int              FormActivateRadioEntry _PROTO_((FORMPTR form, int entry,
  3782.                                            int entrynum, int flag));
  3783.  
  3784. int              FormActivateCheckboxEntry _PROTO_((FORMPTR form, int entry,
  3785.                                               int entrynum, int flag));
  3786.  
  3787. int              FormCallFieldHelp _PROTO_((FORMPTR form, int entry,
  3788.                                             int online));
  3789. int              FormCheckCheckboxEntry _PROTO_((FORMPTR form, int entry,
  3790.                                                  int centry,int flag));
  3791.  
  3792. int              FormCloseHelp _PROTO_((FORMPTR form, int online));
  3793.  
  3794. int              FormConvDataToString _PROTO_((FORMPTR form, int entry,
  3795.                                          VOIDPTR dataptr, char *buf));
  3796.  
  3797. int              FormDisplay _PROTO_((FORMPTR form, int rank, int effect));
  3798.  
  3799. int              FormGetHelpNumber _PROTO_((FORMPTR form, char *name, int online));
  3800.  
  3801. int              FormGetListChoice _PROTO_((FORMPTR form, int entry));
  3802.  
  3803. int              FormGetRadioChoice _PROTO_((FORMPTR form, int entry));
  3804.  
  3805. int              FormGetToggleChoice _PROTO_((FORMPTR form, int entry));
  3806.  
  3807. int              FormGetCheckboxChoice _PROTO_((FORMPTR form, int entry,
  3808.                                           int centry));
  3809.  
  3810. int              FormHide _PROTO_((FORMPTR form, int effect));
  3811.  
  3812. FORMPTR          FormInitialize _PROTO_((VOIDPTR win, FIELD_ENTRY *fldptr, int options));
  3813.  
  3814. int              FormInitializeSystem _PROTO_((CWL_VOID));
  3815.  
  3816. int              FormInitializeFieldData _PROTO_((FORMPTR form, char **data, int start,
  3817.                                            int end));
  3818.  
  3819. int              FormInitializeFieldHelp _PROTO_((FORMPTR form, WPOINTER w,
  3820.                                             char *filename, int helptype,
  3821.                                             int online));
  3822.  
  3823. CWL_VOID         FormInitializeFloat _PROTO_((CWL_VOID));
  3824.  
  3825. int              FormMove _PROTO_((FORMPTR form, int row, int col));
  3826.  
  3827. int              FormGetInput _PROTO_((FORMPTR form, int rank, int entry, ...));
  3828.  
  3829. int              FormClose _PROTO_((FORMPTR form));
  3830.  
  3831. CWL_VOID         FormCloseAll _PROTO_((CWL_VOID ));
  3832.  
  3833. int              FormSetButtonField _PROTO_((FORMPTR form, int entry, int retval,
  3834.                                        char *name, int *attr,
  3835.                                        BUTTONPROC func));
  3836.  
  3837. int              FormSetCheckboxField _PROTO_((FORMPTR form, int entry,
  3838.                                          CHECKBOX_ENTRY_PTR cptr,
  3839.                                          int cchar, int start, int *attr));
  3840.  
  3841. int              FormSetFieldOptions _PROTO_((FORMPTR form, int entry,
  3842.                                         unsigned long option, int flag));
  3843.  
  3844. int              FormSetFieldPreFunction _PROTO_((FORMPTR form, int entry,
  3845.                                                   FIELDPREPROC func));
  3846.  
  3847. int              FormSetExitFunction _PROTO_((FORMPTR form,
  3848.                                               FORMEXITPROC exit_func));
  3849.  
  3850. int              FormSetFieldValidateFunction _PROTO_((FORMPTR form, int entry,
  3851.                                                        FIELDVALIDATEPROC func));
  3852.  
  3853. int              FormSetFieldPostFunction _PROTO_((FORMPTR form, int entry,
  3854.                                                    FIELDPOSTPROC func));
  3855.  
  3856. int              FormSetFieldStart _PROTO_((FORMPTR form,  int entry,
  3857.                                             int startpos));
  3858.  
  3859. int              FormSetFieldDecimal _PROTO_((FORMPTR form, int entry,
  3860.                                               unsigned numdec));
  3861.  
  3862. int              FormSetHelpKeys _PROTO_((FORMPTR form, unsigned *keys,
  3863.                                           int online));
  3864.  
  3865. int              FormSetListField _PROTO_((FORMPTR form, int entry, int rank,
  3866.                                            int start, POPUP_MENU_PTR p));
  3867.  
  3868. int              FormSetMouse _PROTO_((FORMPTR form, int opt));
  3869.  
  3870. int              FormSetOptions _PROTO_((FORMPTR form, int options, int flag));
  3871.  
  3872. int              FormSetRadioField _PROTO_((FORMPTR form, int entry,
  3873.                                             RADIO_ENTRY_PTR rptr, int rchar,
  3874.                                             int start, int *attr));
  3875.  
  3876. int              FormSetSubformField _PROTO_((FORMPTR form, int entry, int rank,
  3877.                                               int start,
  3878.                                               FORMPTR subform));
  3879.  
  3880. int              FormSetVSubformField _PROTO_((FORMPTR form, int entry,
  3881.                                                int rank, int start,
  3882.                                                FORMPTR subform, WPOINTER w));
  3883.  
  3884. int              FormSetToggleField _PROTO_((FORMPTR form, int entry,
  3885.                                              char **toglist));
  3886.  
  3887. int              FormToggleFieldHelp _PROTO_((FORMPTR form, int online,
  3888.                                               int flag));
  3889.  
  3890. int              FormAssignFieldKeys _PROTO_((FORMPTR form, int entry,
  3891.                                               unsigned *keys));
  3892.  
  3893. int              FormGetFieldRowCol _PROTO_((FORMPTR form, int entry,
  3894.                                              unsigned *row,
  3895.                                              unsigned *col));
  3896.  
  3897. int              FormGetFieldData _PROTO_((FORMPTR form, int entry,
  3898.                                            VOIDPTR data));
  3899.  
  3900. char *           FormGetFieldString _PROTO_((FORMPTR form, int entry));
  3901.  
  3902. int              FormClear _PROTO_((FORMPTR form, int entry));
  3903.  
  3904. int              FormSetFieldVariable _PROTO_((FORMPTR form, int entry,
  3905.                                                VOIDPTR dataptr, int display));
  3906.  
  3907. int              FormPutFieldData _PROTO_((FORMPTR form, int entry, ...));
  3908.  
  3909. int              FormWriteFieldValue _PROTO_((FORMPTR form, int entry,
  3910.                                               char *value));
  3911.  
  3912. int              FormCheckFieldRange _PROTO_((FORMPTR form, int entrynum,
  3913.                                               int options, ...));
  3914.  
  3915. RADIO_ENTRY_PTR  RadioAllocate _PROTO_((int num));
  3916.  
  3917. CWL_VOID         RadioDeallocate _PROTO_((RADIO_ENTRY_PTR pentry));
  3918.  
  3919. CWL_VOID         RadioCreateEntry _PROTO_((RADIO_ENTRY *entry, int entrynum,
  3920.                                            char *pname, int hot_letter,
  3921.                                            unsigned prow, unsigned pcol,
  3922.                                            unsigned brow, unsigned bcol));
  3923.  
  3924. CWL_VOID         RadioEntryEnd _PROTO_((RADIO_ENTRY_PTR entry, int numfields));
  3925.  
  3926.  
  3927.  
  3928. /*********************** End of Forms Definitions *************************/
  3929.  
  3930.  
  3931. /*********************** Mouse Functions *****************************/
  3932. #define NOMOUSE   (-1)
  3933. #define MOUSEFOUND 0
  3934.  
  3935. #define MOUSELEFT_PRESS            500
  3936. #define MOUSERIGHT_PRESS           501
  3937. #define MOUSEMIDDLE_PRESS          502
  3938. #define MOUSELEFTRIGHT_PRESS       503
  3939. #define MOUSEMIDDLERIGHT_PRESS     504
  3940. #define MOUSEMIDDLELEFT_PRESS      505
  3941. #define MOUSEMIDDLERIGHTLEFT_PRESS 506
  3942.  
  3943. #define LEFT_MBUTTON           0
  3944. #define RIGHT_MBUTTON          1
  3945. #define MIDDLE_MBUTTON         2
  3946.  
  3947. #define CURSORMOVE             1
  3948. #define LEFTBUTTONPRESSED      2
  3949. #define LEFTBUTTONRELEASED     4
  3950. #define RIGHTBUTTONPRESSED     8
  3951. #define RIGHTBUTTONRELEASED    16
  3952. #define MIDDLEBUTTONPRESSED    32
  3953. #define MIDDLEBUTTONRELEASED   64
  3954. #define IGNORERELEASE         128
  3955. #define PRESSFIRST            256
  3956. #define RELEASEFIRST          512
  3957. #define PRESSORRELEASEFIRST   (PRESSFIRST | RELEASEFIRST)
  3958. #define BUTTONRELEASED     (LEFTBUTTONRELEASED | RIGHTBUTTONRELEASED | \
  3959.                             MIDDLEBUTTONRELEASED)
  3960. #define BUTTONPRESSED      (LEFTBUTTONPRESSED | RIGHTBUTTONPRESSED | \
  3961.                             MIDDLEBUTTONPRESSED)
  3962.  
  3963. #define RIGHTBUTTON_DPRESS  (RIGHTBUTTONPRESSED|IGNORERELEASE|PRESSFIRST)
  3964. #define LEFTBUTTON_DPRESS   (LEFTBUTTONPRESSED|IGNORERELEASE|PRESSFIRST)
  3965. #define MIDDLEBUTTON_DPRESS (MIDDLEBUTTONPRESS|IGNORERELEASE|PRESSFIRST)
  3966.  
  3967. #define RIGHTBUTTON_PRESSRELEASE (RIGHTBUTTONPRESSED|RIGHTBUTTONRELEASED| \
  3968.                                    PRESSFIRST)
  3969. #define LEFTBUTTON_PRESSRELEASE (LEFTBUTTONPRESSED|LEFTBUTTONRELEASED| \
  3970.                                    PRESSFIRST)
  3971. #define MIDDLEBUTTON_PRESSRELEASE (MIDDLEBUTTONPRESSED|MIDDLEBUTTONRELEASED| \
  3972.                                    PRESSFIRST)
  3973.  
  3974.  
  3975. #define LEFTTOPCORNER     0
  3976. #define LEFTBOTTOMCORNER  1
  3977. #define RIGHTTOPCORNER    2
  3978. #define RIGHTBOTTOMCORNER 3
  3979.  
  3980. #define MIN_HOTSPOT_WIDTH       7
  3981. #define MIN_SCROLLBAR_SIZE      4
  3982. #define DEFAULT_SCROLLHI_COLOR  CREATE_VIDEO_ATTRIBUTE(BLACK_,LIGHTWHITE_)
  3983. #define NO_MOUSE_GRAB_FUNC      ((CWL_VOID (*)(WPOINTER,int,int))0)
  3984.  
  3985. #define M_EVENT    1
  3986. #define K_EVENT    2
  3987. #define T_EVENT    4
  3988. #define NUMTIMERS  16       /* define the maximum number of timers */
  3989.  
  3990. /* Use Microsoft Windows style macros */
  3991. #define WS_VSCROLL          0x00200000L
  3992. #define WS_HSCROLL          0x00100000L
  3993. #define WS_MINIMIZEBOX      0x00020000L
  3994. #define WS_MAXIMIZEBOX      0x00010000L
  3995. #define WS_SYSMENU          0x00080000L
  3996.  
  3997.  
  3998. #define CWL_VSCROLL          WS_VSCROLL
  3999. #define CWL_HSCROLL          WS_HSCROLL
  4000. #define CWL_MINIMIZEBOX      WS_MINIMIZEBOX
  4001. #define CWL_MAXIMIZEBOX      WS_MAXIMIZEBOX
  4002. #define CWL_SYSMENU          WS_SYSMENU
  4003. #define CWL_MINMAXBOX        (WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
  4004. #define CWL_MINBOX           WS_MINIMIZEBOX
  4005. #define CWL_MAXBOX           WS_MAXIMIZEBOX
  4006.  
  4007.  
  4008. /* Mouse Messages Microsoft Windows Style */
  4009. #define CWL_MOUSEMOVE        0x0200
  4010. #define CWL_LBUTTONDOWN      0x0201
  4011. #define CWL_LBUTTONUP        0x0202
  4012. #define CWL_LBUTTONDBLCLK    0x0203
  4013. #define CWL_RBUTTONDOWN      0x0204
  4014. #define CWL_RBUTTONUP        0x0205
  4015. #define CWL_RBUTTONDBLCLK    0x0206
  4016. #define CWL_MBUTTONDOWN      0x0207
  4017. #define CWL_MBUTTONUP        0x0208
  4018. #define CWL_MBUTTONDBLCLK    0x0209
  4019. #define CWL_PRERESIZE        0x020A
  4020. #define CWL_POSTRESIZE       0x020B
  4021. #define CWL_PREMOVE          0x020C
  4022. #define CWL_POSTMOVE         0x020D
  4023. #define CWL_BEGINRESIZE      0x020E
  4024. #define CWL_BEGINMOVE        0x020F
  4025.  
  4026. /* Mouse return and event messages */
  4027. #define CWL_ENDRESIZE       0x0210
  4028. #define CWL_ENDMOVE         0x0211
  4029. #define CWL_SIZE            0x0005
  4030. #define CWL_MOVE            0x0003
  4031.  
  4032. /* User message starting point */
  4033. #define CWL_USER                0x0400
  4034.  
  4035. /* Timer message */
  4036. #define CWL_TIMER       0x0113
  4037.  
  4038. /* Hit test message */
  4039. #define CWL_HITTEST     0x0084
  4040.  
  4041. /* Keyboard messages */
  4042. #define CWL_KEYDOWN          0x0100
  4043. #define CWL_KEYUP            0x0101
  4044. #define CWL_CHAR             0x0102
  4045. #define CWL_MESSAGE_QUIT     0x0012
  4046.  
  4047. /* Mouse 'Where Are You' Codes */
  4048. #define CWL_HTMINBUTTON      2
  4049. #define CWL_HTMAXBUTTON      3
  4050. #define CWL_HTCAPTION        4
  4051. #define CWL_HTZOOM           CWL_HTMAXBUTTON
  4052. #define CWL_HTREDUCE         CWL_HTMINBUTTON
  4053. #define CWL_HTRIGHT          5
  4054. #define CWL_HTLEFT           6
  4055. #define CWL_HTTOP            7
  4056. #define CWL_HTBOTTOM         8
  4057. #define CWL_HTBOTTOMLEFT     9
  4058. #define CWL_HTBOTTOMRIGHT    10
  4059. #define CWL_HTTOPLEFT        11
  4060. #define CWL_HTTOPRIGHT       12
  4061. #define CWL_HTHSCROLL        13
  4062. #define CWL_HTVSCROLL        14
  4063. #define CWL_HTCLIENT         15
  4064. #define CWL_HTNOWHERE        16
  4065. #define CWL_HTBORDER         17
  4066.  
  4067.  
  4068. /* Other mouse macros */
  4069. #define CLIENT_AREA            1
  4070. #define NONCLIENT_AREA         0
  4071.  
  4072. #define CWL_MKLBUTTON          0x0001
  4073. #define CWL_MKRBUTTON          0x0002
  4074. #define CWL_MKSHIFT            0x0004
  4075. #define CWL_MKCONTROL          0x0008
  4076. #define CWL_MKMBUTTON          0x0010
  4077.  
  4078. #define RESIZE_DOWNRIGHT       0x0001
  4079. #define RESIZE_DOWNLEFT        0x0002
  4080. #define RESIZE_UPRIGHT         0x0003
  4081. #define RESIZE_UPLEFT          0x0004
  4082. #define RESIZE_DOWN            0x0005
  4083. #define RESIZE_UP              0x0006
  4084. #define RESIZE_LEFT            0x0007
  4085. #define RESIZE_RIGHT           0x0008
  4086.  
  4087. #define CWLMOUSE_ACTIVE        1
  4088. #define CWLMOUSE_SAVE          TRUE
  4089.  
  4090.  
  4091.  
  4092. /* Hotspot macros */
  4093.  
  4094. #define NO_SCROLLBARS                    0L
  4095. #define SCROLLBAR_VERTICAL               WS_VSCROLL
  4096. #define SCROLLBAR_HORIZONTAL             WS_HSCROLL
  4097. #define WINDOW_MAXIMIZE                  WS_MAXIMIZEBOX
  4098. #define WINDOW_MINIMIZE                  WS_MINIMIZEBOX
  4099. #define WINDOW_HIDE                      0x8L
  4100. #define WINDOW_CLOSE                     0x10L
  4101. #define WINDOW_MOVE_TOP                  0x20L
  4102. #define WINDOW_MOVE_BOTTOM               0x40L
  4103. #define WINDOW_MOVE_LSIDE                0x80L
  4104. #define WINDOW_MOVE_RSIDE                0x100L
  4105. #define WINDOW_RESIZE_TOPLEFT            0x200L
  4106. #define WINDOW_RESIZE_TOPRIGHT           0x400L
  4107. #define WINDOW_RESIZE_BOTTOMLEFT         0x800L
  4108. #define WINDOW_RESIZE_BOTTOMRIGHT        0x1000L
  4109. #define WINDOW_PLACE_ON_TOP              0x2000L
  4110. #define WINDOW_DBLCLK                    0x4000L
  4111. #define WINDOW_SYSMENU                   WS_SYSMENU
  4112. #define CWL_DEFAULT_SCROLLBARS           (WS_VSCROLL | WS_HSCROLL)
  4113. #define CWL_DBLCLK                       WINDOW_DBLCLK
  4114. #define CWL_BACKGROUND                   0x8000L
  4115. #define WINDOW_ZOOM                      WINDOW_MAXIMIZE
  4116.  
  4117. #define SEETHRU_MODE         1
  4118. #define NORMAL_MODE          2
  4119.  
  4120.  
  4121.  
  4122. #define ONZOOM               1
  4123. #define ONMINIMIZE           2
  4124. #define ALLZOOM              3
  4125. #define MINSCROLLHEIGHT      4
  4126. #define MINIMIZE_WIDTH       7
  4127.  
  4128.  
  4129. #define H_C_CHAR             0
  4130. #define Z_CHAR               1
  4131. #define UNZ_CHAR             2
  4132. #define H_C_ATTR             3
  4133. #define Z_ATTR               4
  4134. #define UNZ_ATTR             5
  4135. #define Z_ROW                6
  4136. #define Z_COL                7
  4137. #define H_C_ROW              8
  4138. #define H_C_COL              9
  4139. #define Z_OLDHEIGHT         10
  4140. #define Z_OLDWIDTH          11
  4141. #define Z_OLDROW            12
  4142. #define Z_OLDCOL            13
  4143. #define MIN_ROW             14
  4144. #define MIN_COL             15
  4145. #define MAXIMIZE_CHAR       16
  4146. #define MINIMIZE_CHAR       17
  4147. #define Z_OPEN_CHAR         18
  4148. #define Z_OPEN_ATTR         19
  4149. #define Z_CLOSE_CHAR        20
  4150. #define Z_CLOSE_ATTR        21
  4151. #define Z_MIN_ROW           22
  4152. #define Z_MIN_COL           23
  4153. #define Z_MIN_WIDTH         24
  4154. #define Z_MIN_HEIGHT        25
  4155. #define Z_MIN_CHAR          26
  4156. #define Z_MIN_ATTR          27
  4157. #define CAP_ATTR            28
  4158. #define Z_HIGH_ATTR         29
  4159. #define N_OLDHEIGHT         30
  4160. #define N_OLDWIDTH          31
  4161. #define N_OLDROW            32
  4162. #define N_OLDCOL            33
  4163.  
  4164.  
  4165.  
  4166. #define ANY_SCROLLBARS  (SCROLLBAR_HORIZONTAL | SCROLLBAR_VERTICAL)
  4167.  
  4168.  
  4169. #define WIN_CLOSE  1
  4170. #define WIN_HIDE   2
  4171.  
  4172. #define WINDOW_MOVE  (WINDOW_MOVE_TOP | WINDOW_MOVE_BOTTOM | WINDOW_MOVE_LSIDE | \
  4173.                       WINDOW_MOVE_RSIDE)
  4174.  
  4175. #define CWL_CAPTION   WINDOW_MOVE_TOP
  4176.  
  4177.  
  4178. #define CWL_DEFAULT_RESIZE  (WINDOW_RESIZE_TOPLEFT | WINDOW_RESIZE_TOPRIGHT | \
  4179.                              WINDOW_RESIZE_BOTTOMLEFT | \
  4180.                              WINDOW_RESIZE_BOTTOMRIGHT)
  4181.  
  4182. #define CWL_RESIZE  CWL_DEFAULT_RESIZE
  4183.  
  4184. #define CWL_DEFAULT_HOTSPOTS   (CWL_DEFAULT_SCROLLBARS | WINDOW_ZOOM | \
  4185.                                 WINDOW_HIDE | WINDOW_MOVE | CWL_DEFAULT_RESIZE | \
  4186.                                 WINDOW_PLACE_ON_TOP)
  4187.  
  4188. #define DEFAULT_HOTSPOTS(w) ((w)->hotspot)
  4189. #define HOTSPOTS_DEFINED(w)   \
  4190.                  (USER_HOTSPOTS(w) || DEFAULT_HOTSPOTS(w))
  4191.  
  4192. #define HIDE_CLOSE_CHAR(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[H_C_CHAR])
  4193. #define ZOOM_CHAR(w)        (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_CHAR])
  4194. #define UNZOOM_CHAR(w)      (DEFAULT_HOTSPOTS(w)->hotspot_string[UNZ_CHAR])
  4195. #define HIDE_CLOSE_ATTR(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[H_C_ATTR])
  4196. #define ZOOM_ATTR(w)        (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_ATTR])
  4197. #define UNZOOM_ATTR(w)      (DEFAULT_HOTSPOTS(w)->hotspot_string[UNZ_ATTR])
  4198. #define ZOOM_ROW(w)         (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_ROW])
  4199. #define ZOOM_COLUMN(w)      (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_COL])
  4200. #define ZOOM_ORIG_HEIGHT(w) (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OLDHEIGHT])
  4201. #define ZOOM_ORIG_WIDTH(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OLDWIDTH])
  4202. #define ZOOM_ORIG_ROW(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OLDROW])
  4203. #define ZOOM_ORIG_COL(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OLDCOL])
  4204. #define ZOOM_OPEN_CHAR(w)   (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OPEN_CHAR])
  4205. #define ZOOM_OPEN_ATTR(w)   (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_OPEN_ATTR])
  4206. #define ZOOM_CLOSE_CHAR(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_CLOSE_CHAR])
  4207. #define ZOOM_CLOSE_ATTR(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_CLOSE_ATTR])
  4208. #define ZOOM_MIN_ROW(w)     (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_ROW])
  4209. #define ZOOM_MIN_COLUMN(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_COL])
  4210. #define ZOOM_MIN_WIDTH(w)   (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_WIDTH])
  4211. #define ZOOM_MIN_HEIGHT(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_HEIGHT])
  4212. #define ZOOM_MIN_CHAR(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_CHAR])
  4213. #define ZOOM_MIN_ATTR(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_MIN_ATTR])
  4214. #define CAPTION_ATTR(w)     (DEFAULT_HOTSPOTS(w)->hotspot_string[CAP_ATTR])
  4215. #define ZOOM_HIGH_ATTR(w)   (DEFAULT_HOTSPOTS(w)->hotspot_string[Z_HIGH_ATTR])
  4216. #define NORM_ORIG_HEIGHT(w) (DEFAULT_HOTSPOTS(w)->hotspot_string[N_OLDHEIGHT])
  4217. #define NORM_ORIG_WIDTH(w)  (DEFAULT_HOTSPOTS(w)->hotspot_string[N_OLDWIDTH])
  4218. #define NORM_ORIG_ROW(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[N_OLDROW])
  4219. #define NORM_ORIG_COL(w)    (DEFAULT_HOTSPOTS(w)->hotspot_string[N_OLDCOL])
  4220.  
  4221.  
  4222. #define CHARTOINT(c)         (int)(c)
  4223. #define INTTOCHAR(i)         (char)(i)
  4224.  
  4225.  
  4226. #define RESIZE_RIGHTTOP_ON(w)    (DEFAULT_HOTSPOTS(w) && \
  4227.                (DEFAULT_HOTSPOTS(w)->options & WINDOW_RESIZE_TOPRIGHT))
  4228.  
  4229. #define RESIZE_LEFTTOP_ON(w)     (DEFAULT_HOTSPOTS(w) && \
  4230.                (DEFAULT_HOTSPOTS(w)->options & WINDOW_RESIZE_TOPLEFT))
  4231.  
  4232. #define RESIZE_RIGHTBOTTOM_ON(w) (DEFAULT_HOTSPOTS(w) && \
  4233.                (DEFAULT_HOTSPOTS(w)->options & WINDOW_RESIZE_BOTTOMRIGHT))
  4234.  
  4235. #define RESIZE_LEFTBOTTOM_ON(w)  (DEFAULT_HOTSPOTS(w) && \
  4236.                (DEFAULT_HOTSPOTS(w)->options & WINDOW_RESIZE_BOTTOMLEFT))
  4237.  
  4238. #define RESIZE_ON(w) (RESIZE_RIGHTTOP_ON(w) || RESIZE_LEFTTOP_ON(w) || \
  4239.                       RESIZE_RIGHTBOTTOM_ON(w) || RESIZE_LEFTBOTTOM_ON(w))
  4240.  
  4241. #define SCROLLBARS_ON(w)      (DEFAULT_HOTSPOTS(w) && \
  4242.                (DEFAULT_HOTSPOTS(w)->options & ANY_SCROLLBARS))
  4243.  
  4244. #define SCROLLBAR_HORIZONTAL_ON(w)  (SCROLLBARS_ON(w) && \
  4245.                         (DEFAULT_HOTSPOTS(w)->options & SCROLLBAR_HORIZONTAL))
  4246.  
  4247. #define SCROLLBAR_VERTICAL_ON(w)  (SCROLLBARS_ON(w) && \
  4248.                         (DEFAULT_HOTSPOTS(w)->options & SCROLLBAR_VERTICAL))
  4249.  
  4250.  
  4251. #define GET_SCROLLBAR_HORZ(w)  (DEFAULT_HOTSPOTS(w)->sbarhorz)
  4252.  
  4253. #define GET_SCROLLBAR_VERT(w)  (DEFAULT_HOTSPOTS(w)->sbarvert)
  4254.  
  4255. #define SCROLLBAR_HORZ_VISIBLE(w) (SCROLLBAR_HORIZONTAL_ON(w) && \
  4256.                                    GET_SCROLLBAR_HORZ(w)->visible)
  4257.  
  4258. #define SCROLLBAR_VERT_VISIBLE(w) (SCROLLBAR_VERTICAL_ON(w) && \
  4259.                                    GET_SCROLLBAR_VERT(w)->visible)
  4260.  
  4261. #define ZOOM_BUTTON(w) (DEFAULT_HOTSPOTS(w) && (DEFAULT_HOTSPOTS(w)->options & WINDOW_ZOOM))
  4262.  
  4263.  
  4264. #define ZOOM_MODE_ON(w)     (ZOOM_BUTTON(w) && DEFAULT_HOTSPOTS(w)->zoom_on)
  4265.  
  4266. #define MINIMIZE_BUTTON(w)  (DEFAULT_HOTSPOTS(w) && (DEFAULT_HOTSPOTS(w)->options & WINDOW_MINIMIZE))
  4267.  
  4268. #define MINIMIZE_MODE_ON(w) (MINIMIZE_BUTTON(w) && DEFAULT_HOTSPOTS(w)->minimized)
  4269.  
  4270. #define WINDOW_PLACEONTOP_ON(w)     (DEFAULT_HOTSPOTS(w) && \
  4271.                                    (DEFAULT_HOTSPOTS(w)->options & WINDOW_PLACE_ON_TOP))
  4272.  
  4273. #define WINDOW_BACKGROUND_ON(w)    (DEFAULT_HOTSPOTS(w) && \
  4274.                                    (DEFAULT_HOTSPOTS(w)->options & CWL_BACKGROUND))
  4275.  
  4276. #define WINDOW_MOVE_ON(w)    (DEFAULT_HOTSPOTS(w) && \
  4277.                              (DEFAULT_HOTSPOTS(w)->options & WINDOW_MOVE))
  4278.  
  4279. #define WINDOW_MOVE_TOP_ON(w) (DEFAULT_HOTSPOTS(w) && \
  4280.                               (DEFAULT_HOTSPOTS(w)->options & WINDOW_MOVE_TOP))
  4281.  
  4282. #define WINDOW_MOVE_BOTTOM_ON(w) (DEFAULT_HOTSPOTS(w) && \
  4283.                                  (DEFAULT_HOTSPOTS(w)->options & WINDOW_MOVE_BOTTOM))
  4284.  
  4285. #define WINDOW_MOVE_LSIDE_ON(w) (DEFAULT_HOTSPOTS(w) && \
  4286.                                 (DEFAULT_HOTSPOTS(w)->options & WINDOW_MOVE_LSIDE))
  4287.  
  4288. #define WINDOW_MOVE_RSIDE_ON(w) (DEFAULT_HOTSPOTS(w) && \
  4289.                                 (DEFAULT_HOTSPOTS(w)->options & WINDOW_MOVE_RSIDE))
  4290.  
  4291. #define TRACK_SCROLL_SIDE(w)  (DEFAULT_HOTSPOTS(w)->track_scroll_top)
  4292.  
  4293. #define TRACK_SCROLL_BOTTOM(w) (DEFAULT_HOTSPOTS(w)->track_scroll_bottom)
  4294.  
  4295. #define WINDOW_DOUBLE_CLICK(w) (DEFAULT_HOTSPOTS(w) && \
  4296.                                (DEFAULT_HOTSPOTS(w)->options & WINDOW_DBLCLK))
  4297.  
  4298. #define ISWINDOW_MINIMIZED(w)  (DEFAULT_HOTSPOTS(w) && \
  4299.                                 DEFAULT_HOTSPOTS(w)->minimized)
  4300.  
  4301. #define WINDOW_MINIMIZE_ON(w)  (DEFAULT_HOTSPOTS(w) && \
  4302.                                 DEFAULT_HOTSPOTS(w)->options & CWL_MINBOX)
  4303.  
  4304. #define WINDOW_MAXIMIZE_ON(w)  (DEFAULT_HOTSPOTS(w) && \
  4305.                                 DEFAULT_HOTSPOTS(w)->options & CWL_MAXBOX)
  4306.  
  4307. #define WINDOW_MINMAX_ON(w)    (DEFAULT_HOTSPOTS(w) && \
  4308.                                (DEFAULT_HOTSPOTS(w)->options & CWL_MINMAXBOX))
  4309.  
  4310. #define MINZOOMWIDTH(w)        (WINDOW_MINIMIZE_ON(w)?3:0 + \
  4311.                                 WINDOW_MAXIMIZE_ON(w)?3:0)
  4312.  
  4313. #define WINDOW_CAPTION(w)      (DEFAULT_HOTSPOTS(w)->caption)
  4314. #define WINDOW_CAPTION_ON(w)   (DEFAULT_HOTSPOTS(w) && WINDOW_CAPTION(w)?1:0)
  4315. #define WINDOW_CAPTION_STRING(w) \
  4316.           (WINDOW_CAPTION_ON(w)?DEFAULT_HOTSPOTS(w)->caption_string:(char *)0)
  4317.  
  4318. #define WINDOW_MINMAX_VISIBLE(w)  (WINDOW_MINMAX_ON(w) && \
  4319.                                    WINDOW_CAPTION_ON(w) && \
  4320.                                    WINDOW_WIDTH(w) >= MINZOOMWIDTH(w) && \
  4321.                                    !ISWINDOW_MINIMIZED(w))
  4322.  
  4323. #define WINDOW_SAVE_BORDER(w)       (DEFAULT_HOTSPOTS(w)->border)
  4324. #define WINDOW_SAVE_BORDER_CHARS(w) (DEFAULT_HOTSPOTS(w)->box)
  4325. #define ALTERNATE_MOVE_FUNC(w)      (DEFAULT_HOTSPOTS(w)->alt_move_func)
  4326. #define WINDOW_NOBORDER_SCROLL(w)   (SCROLLBARS_ON(w) && !ISBORDER(w))
  4327. #define WINDOW_NOBORDER_SCRH(w)    (int)(SCROLLBAR_HORIZONTAL_ON(w) && !ISBORDER(w))
  4328. #define WINDOW_NOBORDER_SCRV(w)    (int)(SCROLLBAR_VERTICAL_ON(w) && !ISBORDER(w))
  4329.  
  4330.  
  4331.  
  4332. #define MOUSEPRESSED               1
  4333. #define KEYBOARDPRESSED            0
  4334.  
  4335. #define MOUSE_FULL_INSTALL         1
  4336. #define MOUSE_TEST                 2
  4337. #define GET_MPRESS_KEY(a)                get_mouse_or_key(0,a)
  4338. #define GET_MPRESS_ENHANCED_KEY(a)       get_mouse_or_key(1,a)
  4339. #define FOCUS    1
  4340. #define NOFOCUS  2
  4341.  
  4342.  
  4343. #define WINDOW_PROC(w)      ((w)->window_proc)
  4344.  
  4345.  
  4346. #if defined (POWERC)
  4347. CWL_EXTERN unsigned pow_ss_;
  4348. CWL_EXTERN unsigned pow_sp_;
  4349. CWL_EXTERN unsigned pow_stk_;
  4350. CWL_EXTERN unsigned pow_top_;
  4351. CWL_EXTERN unsigned pow_stack_;
  4352. #endif
  4353.  
  4354.  
  4355.  
  4356. typedef struct tagMINVALUES
  4357. {
  4358.   int           num;    /* Number of minimized windows per row */
  4359.   unsigned char *table;  /* table of column positions */
  4360.   int           width;  /* width of each minimized window */
  4361.   int           total;  /* total number of minimized windows */
  4362.   BITSTRING     bits;   /* determines next position for minimized window */
  4363.   unsigned int  isinit:1;
  4364. } MINVALUES;
  4365.  
  4366.  
  4367. typedef int (*WNDPROC)     _PROTO_((WPOINTER,int,int,long));
  4368.  
  4369.  
  4370. int       _FAR_ EventFunction _PROTO_((CWL_VOID));
  4371. CWL_VOID      _FAR_ EnqueueEvents _PROTO_((int event, int status, int y, int x));
  4372. CWL_VOID      MouseStartQueue _PROTO_((CWL_VOID));
  4373. CWL_VOID      MouseSwapButtons _PROTO_((CWL_VOID));
  4374. int           MouseButtonsSwapped _PROTO_((CWL_VOID));
  4375. CWL_VOID      StartMouseEvent _PROTO_((CWL_VOID));
  4376. CWL_VOID      EventLoop _PROTO_((CWL_VOID));
  4377. int           ProcessAllEvents _PROTO_((int option));
  4378. CWL_VOID      StartKeyboardEvent _PROTO_((CWL_VOID));
  4379. CWL_VOID      EndKeyboardEvent _PROTO_((CWL_VOID));
  4380. CWL_VOID      EndMouseEvent _PROTO_((CWL_VOID));
  4381. CWL_VOID      StartTimerEvent _PROTO_((CWL_VOID));
  4382. CWL_VOID      EndTimerEvent _PROTO_((CWL_VOID));
  4383.  
  4384.  
  4385. /* The Int 13H functions */
  4386. CWL_VOID      _FAR_ CWLdisk_handler _PROTO_((UNKNOWNARGS));
  4387. CWL_VOID      _FAR_ CWLDiskHandler _PROTO_((UNKNOWNARGS));
  4388. /* all assembly modules have UNKNOWNARGS as the prototype.  Refer to the
  4389.    documentation for exact parameters */
  4390.  
  4391. int           MouseInitializeSystem _PROTO_((int intype, int *num,
  4392.                                              int row, int col));
  4393. int           MouseInstall _PROTO_((int row, int col));
  4394. CWL_VOID _FAR_  MouseAssembly   _PROTO_((CWL_VOID));
  4395. CWL_VOID _FAR_  CWLInt9Handler _PROTO_((CWL_VOID));
  4396. CWL_VOID _FAR_  CWLInt1CHandler _PROTO_((CWL_VOID));
  4397. CWL_VOID _FAR_  CWLKbdHandler   _PROTO_((int scancode, int brkcode));
  4398. CWL_VOID _FAR_  CWLTimerHandler _PROTO_((CWL_VOID));
  4399. CWL_VOID _FAR_  CWLInt13Handler _PROTO_((CWL_VOID));
  4400. int           MouseRestoreSystem _PROTO_((int save));
  4401.  
  4402.  
  4403. int           MouseInitialize _PROTO_((UNKNOWNARGS));
  4404. CWL_VOID      MouseShow _PROTO_((UNKNOWNARGS));
  4405. CWL_VOID      MouseHide _PROTO_((UNKNOWNARGS));
  4406. CWL_VOID      MouseGetStatAndPos _PROTO_((UNKNOWNARGS));
  4407. CWL_VOID      MouseSetCursorPos _PROTO_((UNKNOWNARGS));
  4408. CWL_VOID      MouseGetButtonPress _PROTO_((UNKNOWNARGS));
  4409. CWL_VOID      MouseGetButtonRelease _PROTO_((UNKNOWNARGS));
  4410. CWL_VOID      MouseSetHMinMax _PROTO_((UNKNOWNARGS));
  4411. CWL_VOID      MouseSetVMinMax _PROTO_((UNKNOWNARGS));
  4412. CWL_VOID      MouseSetGraphicsCursor _PROTO_((UNKNOWNARGS));
  4413. CWL_VOID      MouseSetPage _PROTO_((UNKNOWNARGS));
  4414. CWL_VOID      MouseSetTextCursor _PROTO_((UNKNOWNARGS));
  4415. CWL_VOID      MouseReadMotionCounters _PROTO_((UNKNOWNARGS));
  4416. CWL_VOID      MouseSetIntAddress _PROTO_((UNKNOWNARGS));
  4417. CWL_VOID      MouseEnableLightPen _PROTO_((UNKNOWNARGS));
  4418. CWL_VOID      MouseDisableLightPen _PROTO_((UNKNOWNARGS));
  4419. CWL_VOID      MouseSetMickeyPixelRatio _PROTO_((UNKNOWNARGS));
  4420. CWL_VOID      MouseConditionalOff _PROTO_((UNKNOWNARGS));
  4421. CWL_VOID      MouseSetThresholdSpeed _PROTO_((UNKNOWNARGS));
  4422. CWL_VOID      MouseSwapIntFunctions _PROTO_((UNKNOWNARGS));
  4423. int           MouseGetStorageSize _PROTO_((UNKNOWNARGS));
  4424. CWL_VOID      MouseSaveState _PROTO_((UNKNOWNARGS));
  4425. CWL_VOID      MouseRestoreState _PROTO_((UNKNOWNARGS));
  4426. int           MouseSetAltIntFunction _PROTO_((UNKNOWNARGS));
  4427. int           MouseGetAltFuncAddress _PROTO_((UNKNOWNARGS));
  4428. CWL_VOID      MouseSetSensitivity _PROTO_((UNKNOWNARGS));
  4429. CWL_VOID      MouseGetSensitivity _PROTO_((UNKNOWNARGS));
  4430. CWL_VOID      MouseSetIntRate _PROTO_((UNKNOWNARGS));
  4431. int           MouseDisableDriver _PROTO_((UNKNOWNARGS));
  4432. int           MouseEnableDriver _PROTO_((UNKNOWNARGS));
  4433. int           MouseSoftwareReset _PROTO_((UNKNOWNARGS));
  4434. CWL_VOID      MouseSetLanguage _PROTO_((UNKNOWNARGS));
  4435. int           MouseGetLanguage _PROTO_((UNKNOWNARGS));
  4436. CWL_VOID      MouseGetDriverIRQType _PROTO_((UNKNOWNARGS));
  4437. int           MouseGetDriverInfo _PROTO_((UNKNOWNARGS));
  4438. CWL_VOID      MouseGetMaxVirtualXY _PROTO_((UNKNOWNARGS));
  4439. CWL_VOID      MouseGetMaskMickeyCount _PROTO_((UNKNOWNARGS));
  4440. int           MouseSetVideoMode _PROTO_((UNKNOWNARGS));
  4441. CWL_VOID      MouseCountVideoModes _PROTO_((UNKNOWNARGS));
  4442. CWL_VOID      MouseGetHotspot _PROTO_((UNKNOWNARGS));
  4443. int           MouseLoadAccCurves _PROTO_((UNKNOWNARGS));
  4444. int           MouseReadAccCurves _PROTO_((UNKNOWNARGS));
  4445. int           MouseSetGetAccCurve _PROTO_((UNKNOWNARGS));
  4446. int           MouseHardwareReset _PROTO_((UNKNOWNARGS));
  4447. int           MouseSetGetBallInfo _PROTO_((UNKNOWNARGS));
  4448. CWL_VOID      MouseGetMinMaxCoords _PROTO_((UNKNOWNARGS));
  4449. int           MouseGetAdvancedFuncs _PROTO_((UNKNOWNARGS));
  4450. CWL_VOID      MouseGetSwitchSettings _PROTO_((UNKNOWNARGS));
  4451. CWL_VOID      MouseGetINI _PROTO_((UNKNOWNARGS));
  4452.  
  4453. SCROLLPTR     ScrollBarCreate _PROTO_((int type, int minnum, int maxnum,
  4454.                                        int length, int *attr));
  4455.  
  4456. int           TranslateMousePress _PROTO_((int press));
  4457.  
  4458. CWL_VOID      TranslateMousePosToScreenPos _PROTO_((int ypos,int xpos,int *nypos,
  4459.                                          int *nxpos));
  4460. CWL_VOID      TranslateScreenPosToMousePos _PROTO_((int ypos,int xpos,int *nypos,
  4461.                                           int *nxpos));
  4462. CWL_VOID      TranslateMousePosToWindowPos _PROTO_((WPOINTER w, int ypos, int xpos,
  4463.                                           int *nypos, int *nxpos));
  4464. CWL_VOID      TranslateWindowPosToMousePos _PROTO_((WPOINTER w, int ypos, int xpos,
  4465.                                           int *nypos, int *nxpos));
  4466. int           WindowMinimize _PROTO_((WPOINTER w));
  4467.  
  4468. int           WindowSetEventStyle _PROTO_((WPOINTER w, long stylebits));
  4469. int           WindowGetEventStyle _PROTO_((WPOINTER w, long *stylebits));
  4470. int           WindowFreeEventStyle _PROTO_((WPOINTER w));
  4471. int           WindowSetCaption _PROTO_((WPOINTER w, char *caption));
  4472. int           WindowGetCaption _PROTO_((WPOINTER w, char *buffer, int len));
  4473. CWL_VOID      SetCaptionColor _PROTO_((int color, int flag));
  4474. int           GetCaptionColor _PROTO_((int flag));
  4475.  
  4476. int           WindowZoom _PROTO_((WPOINTER w));
  4477.  
  4478. int          WindowScrollVisible _PROTO_((WPOINTER w, int which));
  4479. int          WindowSetCapture _PROTO_((WPOINTER w));
  4480. CWL_VOID     WindowReleaseCapture _PROTO_((CWL_VOID));
  4481. WPOINTER     WindowGetCapture _PROTO_((CWL_VOID));
  4482. int          WindowSetEventProc _PROTO_((WPOINTER w, WNDPROC func));
  4483. int          WindowSetFocus _PROTO_((WPOINTER w));
  4484. WPOINTER     WindowGetFocus _PROTO_((CWL_VOID));
  4485. CWL_VOID     CWLQuitMessage _PROTO_((CWL_VOID));
  4486. int          SendWinMessage _PROTO_((WPOINTER w, int message, int wParam, long lParam));
  4487. int          PostWinMessage _PROTO_((WPOINTER w, int message, int wParam, long lParam));
  4488. int          SetWinTimer _PROTO_((WPOINTER w, int TimeID, unsigned mil, TIMERPROC TimeFunc));
  4489. void         GetTimerInfo _PROTO_((int TimeID, CMLTIMER * tm));
  4490.  
  4491. int          GetCurKeyState _PROTO_((int vkey));
  4492. int          GetKeyStateAtMsg _PROTO_((int vkey));
  4493. CWL_VOID     SetAllToggleKeys _PROTO_((int state));
  4494. CWL_VOID     SetToggleKey _PROTO_((int vkey, int state));
  4495. int          GetToggleKeyState _PROTO_((int vkey));
  4496. CWL_VOID     GetCurKeyboardState _PROTO_((unsigned char *buf));
  4497. CWL_VOID     GetKeyboardStateAtMsg _PROTO_((unsigned char *buf));
  4498. CWL_VOID     SetKeyboardState _PROTO_((unsigned char *buf));
  4499.  
  4500.  
  4501.  
  4502. /*******************************************/
  4503. #ifndef SOUND_DEF
  4504. #define SOUND_DEF
  4505.  
  4506. #ifdef POWERC
  4507. CWL_VOID           cwlsound _PROTO_((UNKNOWNARGS));
  4508. #define sound(x)      cwlsound(x)
  4509. #endif
  4510.  
  4511. #endif
  4512.  
  4513. #ifndef __TURBOC__
  4514. CWL_VOID          delay _PROTO_((unsigned));
  4515. #ifndef POWERC
  4516. CWL_VOID          sound _PROTO_((unsigned));
  4517. #endif
  4518. CWL_VOID          nosound _PROTO_((CWL_VOID));
  4519. #endif
  4520.  
  4521. #ifdef COHERENT
  4522. long nap();
  4523. #define delay(x)  nap(x)
  4524. #endif
  4525.  
  4526. /* More functional typedefs */
  4527. typedef CWL_VOID (*CWLERRORPROC)      _PROTO_((int errorcode, char *sourcefile,
  4528.                                                int sourceline, char *funcname));
  4529.  
  4530. typedef int      (*UNDEFKEYPROC)      _PROTO_((char *,int,int,int *));
  4531.  
  4532. typedef int      (*CHARSENTEREDPROC)  _PROTO_((char *,int));
  4533.  
  4534. typedef int      (*REGEXPERRORPROC)   _PROTO_((char *, int));
  4535.  
  4536. typedef int      (*FIELDERRORPROC)    _PROTO_((int, char *, int, int));
  4537.  
  4538. typedef int      (*FORMUNDEFPROC)     _PROTO_((char *, int, int *, int));
  4539.  
  4540. typedef CWL_VOID (*KEYIDLEPROC)       _PROTO_((CWL_VOID));
  4541.  
  4542. typedef unsigned (*KEYINTERCEPTPROC)  _PROTO_((int,unsigned));
  4543.  
  4544. typedef int      (*BARPREPROC)        _PROTO_((BAR_MENU_PTR,int *));
  4545.  
  4546. typedef int      (*POPUPPREPROC)      _PROTO_((POPUP_MENU_PTR, int *));
  4547.  
  4548. typedef CWL_VOID (*POPUPMOUSEPROC)    _PROTO_((POPUP_MENU_PTR p,
  4549.                                                unsigned sel));
  4550.  
  4551. typedef int      (*FIELDUNDEFKEYPROC) _PROTO_((FORMPTR, int, int, int *));
  4552.  
  4553. typedef CWL_VOID (*SPECFIELDPREPROC)  _PROTO_((FORMPTR,int,int));
  4554.  
  4555. typedef int      (*FORMLISTPROC)      _PROTO_((POPUP_MENU_PTR, unsigned));
  4556.  
  4557. typedef int      (*EDITERRORPROC)     _PROTO_((FORMPTR,int,int,char *,int));
  4558.  
  4559. typedef int      (*FORMUNDEFKEYPROC)  _PROTO_((FORMPTR,int,char *,int,int *));
  4560.  
  4561. typedef int      (*HELPUNDEFKEYPROC)  _PROTO_((FORMPTR, int, int));
  4562.  
  4563. typedef int      (*HELPPREPROC)       _PROTO_((FORMPTR,int,WPOINTER,int,
  4564.                                                int, int));
  4565.  
  4566. typedef CWL_VOID  (_FAR_ *VOIDFARPROC)  _PROTO_((UNKNOWNARGS));
  4567.  
  4568. /* Compatibility with CWL 2.53 */
  4569. #define VirtualFree(x,y,z)            VirtualClose(x,y,z)
  4570. #define WindowFree(x,y)               WindowClose(x,y)
  4571. #define WindowFreeAll(x,y)            WindowCloseAll(x,y)
  4572. #define PopupMenuFree(x)              PopupMenuClose(x)
  4573. #define PopupMenuFreeAll()            PopupMenuCloseAll()
  4574. #define BarMenuFree(x)                BarMenuClose(x)
  4575. #define BarMenuFreeAll()              BarMenuCloseAll()
  4576. #define PulldownMenuFree(x)           PulldownMenuClose(x)
  4577. #define PulldownMenuFreeAll()         PulldownMenuCloseAll()
  4578.  
  4579. #ifdef COHERENT
  4580. #include "tinfo.h"
  4581. #endif
  4582.  
  4583. #include "cwlglob.h"
  4584. #include "internal.h"
  4585. #ifdef __cplusplus
  4586. }
  4587. #endif
  4588.  
  4589. #endif
  4590.  
  4591.