home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / window / ultrawin / uw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-20  |  11.1 KB  |  298 lines

  1. /****************************************************************************/
  2. /*                                                                                                                                                    */
  3. /* UW.H                                                                                                                                            */
  4. /*                                                                                                                                                    */
  5. /* This is the main header for uWin, containing all the defines and                    */
  6. /* typedefs for the program.                                                                                                */
  7. /*                                                                                                                    Kevin Huck            */
  8. /*                                                                                                                    Boyd Gafford        */
  9. /*                                                                                                                                                    */
  10. /****************************************************************************/
  11. #include <dos.h>                            /* for the REGS definition used for mouse int    */
  12. #include <stdlib.h>
  13. #include <time.h>
  14. #include <conio.h>
  15. #include <string.h>
  16. #ifdef M_I86                                /* Microsofts are malloc.h and memory.h        */
  17.     #include <malloc.h>
  18.     #include <memory.h>
  19.     #include <sys\types.h>
  20.     #pragma pack(1)
  21. #else                                                /* Borlands are alloc.h and mem.h              */
  22.     #include <alloc.h>
  23.     #include <mem.h>
  24. #endif
  25.  
  26. #ifdef M_I86
  27. #include <stddef.h>
  28. #define setmem(p,c,v)                memset((p),(v),(c))
  29. #define movmem(s,d,c)                memmove((d),(s),(c))
  30. #define random(x)               (rand() % (x))
  31. #define bioskey(c)                    _bios_keybrd(c)
  32. #define biosprint(s, d, p)    _bios_printer(s, p, d)
  33. #define getvect(i)          _dos_getvect(i)
  34. #define setvect(i,hdlr)     _dos_setvect(i,hdlr)
  35. #define enable              _enable
  36. #define disable             _disable
  37. #define setcolor            _setcolor
  38. #define moveto              _moveto
  39. #define lineto              _lineto
  40. struct  REGPACK {
  41.     unsigned    r_ax, r_bx, r_cx, r_dx;
  42.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  43. };
  44. enum COLORS {
  45.     BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN,
  46.     LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN,
  47.     LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
  48. };
  49. #define BW80 2
  50. #define C80  3
  51. #define MONO 7
  52. #endif
  53.  
  54. #define HEAD_ROOM        0x8000L        /* 32K memory head room space for allocation    */
  55.  
  56. /*------------------------ rectangle operation defines ---------------------*/
  57. #define     NO_OVERLAP            0
  58. #define        OVERLAP                    1
  59. #define        FIRST_ENCLOSED    2
  60. #define        SECOND_ENCLOSED    3
  61.  
  62. /*---------------------------- general defines -----------------------------*/
  63. #define   ON        1
  64. #define   OFF       0
  65. #define   UP        0
  66. #define   DOWN      1
  67. #define   LEFT      2
  68. #define   RIGHT     3
  69.  
  70. /*------------------------------ menuing defines ---------------------------*/
  71. #define     M_HORIZONTAL            0
  72. #define     M_VERTICAL                1
  73. #define     M_MAX_ENTRIES            20
  74. #define        M_GET_EVENT                0
  75. #define        M_PROC_EVENT            1
  76.  
  77.  
  78. /*---------------------------- mouse defines -------------------------------*/
  79. #define        TDELAY (clock_t) 4    /* clock ticks to check for multiple clicks        */
  80. #define        LB                0                    /* m_event->flag is 4 for left button                 */
  81. #define        MB                2                    /* m_event->flag is 64 for middle button            */
  82. #define        RB                1                    /* m_event->flag is 16 for right button                */
  83.  
  84. /*---------------------------- window defines ------------------------------*/
  85. #define   NO_BDR    0
  86. #define   SGL_BDR   1
  87. #define   DBL_BDR   2
  88. #define   SLD_BDR   3
  89. #define        DUAL_BDR    4
  90.  
  91. #define   CENTERED   -1
  92. #define   LEFT_JUST  -2
  93. #define   RIGHT_JUST -3
  94.  
  95. #define     ALPHA           'A'
  96. #define     DIGITS       'D'
  97. #define     C_LINE            0
  98. #define     C_SBLOCK    1
  99. #define     C_FBLOCK    2
  100.  
  101. #define   IN             0
  102. #define   OUT              1
  103. #define   BUFF             0
  104. #define   SAVE            1
  105.  
  106. #define        WN_POPUP    1
  107. #define        WN_NORMAL    0
  108.  
  109. #define   DELETE    1
  110. #define   INSERT    0
  111.  
  112. #define   STRIP_ON  1
  113. #define   STRIP_OFF 0
  114.  
  115. /*----------------------- printer support defines --------------------------*/
  116. #define PRT_BLOCK 2048
  117. #define MAX_PRINTERS 4
  118.  
  119. #define BLOCK_SIZE 512
  120.  
  121. #define READ  0
  122. #define WRITE 1
  123.  
  124. /*------------------------- flags for wn_gets_ll ---------------------------*/
  125. #define G_STRIP          0x0001
  126. #define G_STRIP_END      0x0002
  127. #define G_UP_FST_CHAR    0x0004
  128. #define G_ARROW          0x0008
  129. #define G_VALIDATE       0x0010
  130. #define G_RIGHT_TO_LEFT  0x0020
  131. #define G_EXIT_ON_FILL   0x0040
  132. #define G_CLEAR_ON_FIRST 0x0080
  133.  
  134.  
  135. #define H_ENTRY          0
  136. #define H_PROCESS        1
  137. #define H_EXIT           2
  138.  
  139. /*-------------------------- base level typedefs ---------------------------*/
  140. typedef unsigned char uchar;
  141. typedef unsigned int  uint;
  142. typedef unsigned long ulong;
  143.  
  144. /*---------------------------- mouse structures ----------------------------*/
  145. typedef struct reset_struct
  146. {
  147.     int exists;
  148.     int n_buttons;
  149. } M_RESET;
  150.  
  151. typedef struct loc_struct
  152. {
  153.     int button_status;
  154.     int count;
  155.     int col;
  156.     int row;
  157. } M_LOC;
  158.  
  159. typedef struct move_struct
  160. {
  161.     int h_count;
  162.     int v_count;
  163. } M_MOVE;
  164.  
  165. typedef struct event_struct
  166. {
  167.     char        is_mouse;
  168.     int            key;
  169.     int            mod;
  170.     int            m_x, m_y;
  171.     char        m_count, m_button;
  172. } EVENT;
  173.  
  174. /*---------------------------- rectangle structure -------------------------*/
  175. typedef struct rect_struct
  176. {
  177.     int x_min, x_max, y_min, y_max;                    /* rectangle coordinates                     */
  178. } RECT;
  179.  
  180.  
  181. /*--------------------------- window structure -----------------------------*/
  182. typedef struct w_struct
  183. {
  184.     struct w_struct    *next;                                    /* next window in linked list            */
  185.     struct w_struct    *previous;                            /* previous window in list                */
  186.     RECT                        pane;                   /* the window rectangle           */
  187.     RECT                        old_pane;               /* for full size toggle           */
  188.     int                            rows;                                        /* save buffer rows and columns        */
  189.     int                            cols;
  190.     int                         csr_x;                  /* the "soft" cursor location     */
  191.     int                         csr_y;
  192.     int                         att;                    /* the window's attribute         */
  193.     int                         bdr_att;                /* the window's border attribute  */
  194.     int                         bdr_style;              /* the border style               */
  195.     int                         name_loc;                                /* CENTERED, LEFTJUST, RIGHTJUST    */
  196.     char                        *name;                  /* pointer to window name         */
  197.     uchar                        *save;                                    /* pointer to save buffer area        */
  198.     uchar                        *buff;                                    /* pointer to write buffer area        */
  199.     uchar                        *mask;                                    /* pointer to window buffer mask    */
  200.  
  201.     uchar           *tabs;                                    /* tabs stops                     */
  202.     int                            reg_s, reg_e;                        /* scroll region start and end        */
  203.  
  204.     unsigned                w_wrap            : 1;                /* word wrap on/off                                */
  205.     unsigned                hidden            : 1;        /* 1 if window hidden             */
  206.     unsigned                overlapped    : 1;        /* 1 if window overlapped         */
  207.     unsigned                csr_adv            : 1;                /* advance the cursor?                        */
  208.     unsigned                csr_on            : 1;                /* does flashing cursor track?        */
  209.     unsigned                 inside      : 1;                /* 1 if bordered and inside              */
  210.     unsigned                 mask_on     : 1;                /* 1 if window mask is active            */
  211.     unsigned                 cr_lf       : 1;                /* 1 if cr translated to cr/lf        */
  212.     unsigned                full_size        : 1;        /* 1 if window full sized         */
  213.     unsigned                popup                :    1;                /* 1 if window is popup                        */
  214.     unsigned                 scroll      : 1;                /* 1 if window auto-scrolls                */
  215.     unsigned                bs_clear        : 1;                /* 1 if backspace is destructive    */
  216.     unsigned                eol_wrap        : 1;                /* 1 if cursor wraps at end of ln */
  217.     unsigned                unused            : 3;
  218.  
  219.     void            *usr_ptr;                 /* user expansion pointer         */
  220.     uchar           usr_exp[4];                            /* user expansion space                        */
  221.                                           /* DO NOT USE BELOW VARIABLES     */
  222.     void            *sys_ptr;               /* system expansion pointer       */
  223.     uchar           sys_exp[4];                          /* system expansion space                    */
  224. } WINDOW;
  225.  
  226. /*---------------------------- menu structure ------------------------------*/
  227. typedef struct menu_struct
  228. {
  229.     WINDOW        *wnp;                                                            /* the window for output            */
  230.     uchar            direction;                                              /* menu direction, vt or hz   */
  231.     uchar            num_entries;                                            /* number of entries in menu    */
  232.     uchar            csr_att;                                                    /* the cursor attribute                */
  233.     uchar            first_att;                                                /* the first letter attribute    */
  234.     int                csr_pos;                                                    /* current cursor position        */
  235.     char            first_pos[M_MAX_ENTRIES];                    /* first letter position      */
  236.     int             id[M_MAX_ENTRIES];                                /* id value for each entry        */
  237.     uchar            x[M_MAX_ENTRIES];                                    /* x location for each entry    */
  238.     char            *entry[M_MAX_ENTRIES];                        /* array of char pointers            */
  239. } MENU;
  240.  
  241. typedef struct printer
  242. {
  243.     int   active;                                            /* set to 1 if printer init'd/active    */
  244.     int   halt;                       /* set to 1 to temporarily stop printer */
  245.     int   prt_dev;                    /* file handle for printer device                */
  246.     char  device[81];                 /* name of printer device               */
  247.     int   prt_buff[2];                                /* file handles for printer buffer            */
  248.     char  buffer[81];                 /* name of printer buffer               */
  249.     int   cr_cnt;                     /* number of carriage returns to send   */
  250.     int   lf_cnt;                         /* number of line feeds to send         */
  251.     int   block_mode;                                    /* allows faster output on block devices*/
  252.  
  253.     long  max_que_size;                                /* maximum size of print que                      */
  254.     long  init_que_size;                            /* initial size of print que                        */
  255.     long  curr_que_size;                            /* current size of print que                        */
  256.     long  read;                                                /* print que read  index                */
  257.     long  write;                      /* print que write index                */
  258.     long  cnt;                           /* print que cnt (number of bytes in q) */
  259.  
  260.     uchar *que;                              /* pointer to print que data            */
  261.     uchar *xlat;                      /* pointer to translation table                    */
  262.     int   xlat_flag;                  /* translation flag                                            */
  263. } PRINT;
  264.  
  265. /*----------------------------- generic macros -----------------------------*/
  266. #define lower(x, y)          (((x) < (y)) ? (x) : (y))
  267. #define upper(x, y)          (((x) > (y)) ? (x) : (y))
  268. #define lobyte(c)              (uchar) ((c) & 0x00ff)
  269. #define hibyte(c)              (uchar) ((c) >> 8)
  270. #define range(l,b,h)    ( (((b) >= (l)) && ((b) <= (h))) ? 1:0 )
  271. #define swap( a,b,c)      ( (c) = (a), (a) = (b), (b) = (c) )
  272.  
  273. #ifndef min
  274. #define min(x, y)              (((x) < (y)) ? (x) : (y))
  275. #define max(x, y)              (((x) > (y)) ? (x) : (y))
  276. #endif
  277.  
  278. /*----------------------------- window macros ------------------------------*/
  279. #define wn_att(a,wnp)             ( (wnp)->att = (a) )
  280. #define wn_color(f,b,wnp)          ( (wnp)->att = ((b) << 4) | (f) )
  281. #define wn_bdratt(a,wnp)          ( (wnp)->bdr_att = (a) )
  282. #define wn_bdr_color(f,b,wnp)    ( (wnp)->bdr_att = ((b) << 4) | (f) )
  283. #define mv_cs(c,r,wnp)                ( (wnp)->csr_x = (c), (wnp)->csr_y = (r) )
  284. #define wn_rqty(wnp)                    ( (wnp)->inside ? ((wnp)->rows - 2) : (wnp)->rows )
  285. #define wn_sqty(wnp)                    ( (wnp)->reg_e - (wnp)->reg_s )
  286. #define wn_cqty(wnp)                    ( (wnp)->inside ? ((wnp)->cols - 2) : (wnp)->cols )
  287. #define wn_name(n, wnp)                ( (wnp)->name = (n) )
  288. #define wn_name_loc(l, wnp)        ( (wnp)->name_loc = (l) )
  289. #define wn_save( wnp )                ( wn_io( IN, SAVE, (wnp)) )
  290. #define wn_restore( wnp )            ( wn_io(OUT, SAVE, (wnp)) )
  291. #define wn_rfsh( wnp )                ( wn_io(OUT, BUFF, (wnp)) )
  292. #define wn_read( wnp )                ( wn_io( IN, BUFF, (wnp)) )
  293. #define cls()                                    ( setmem(Screen, V_cols * V_rows * 2, 0) )
  294. #define push(x)                              ( Stack[Stack_ptr++] = (x) )
  295. #define pop(x)                               ( x = Stack[--Stack_ptr] )
  296.  
  297. #include "uw_proto.h"
  298. /**** END OF FILE ****/