home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / tui160 / t.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  15.1 KB  |  316 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* T.H                                                                      */
  4. /*                                                                          */
  5. /*                                                                          */
  6. /****************************************************************************/
  7. #ifndef __T_H
  8. #define __T_H
  9. #include "uw.h"
  10.  
  11. /*---------------------------- dialog defines ------------------------------*/
  12. #define   ADD_FAIL        -1
  13. #define   ADD_TO_END      -1
  14.  
  15. /*------------------------------- TUI types --------------------------------*/
  16. #define   T_DIALOG        0x01                  /* The main dlg parent      */
  17. #define   T_BOX           0x02                  /* sub-boxes within the dlg */
  18. #define   T_BUTTON        0x03                  /* the button               */
  19. #define   T_CHECK         0x04                  /* the checkable type       */
  20. #define   T_INPUT         0x05                  /* string input type        */
  21. #define   T_SLIDER        0x06                  /* slider track and box     */
  22. #define   T_ICON          0x07                  /* icon with two images     */
  23.  
  24. /*------------------------------- TUI errors -------------------------------*/
  25. #define   T_ERROR_NO_MEM  0x01                  /* out of memory for TUI    */
  26. #define   T_ERROR_BAD_INX 0x02                  /* invalid item index       */
  27.  
  28. /*------------------------------ flag values -------------------------------*/
  29. #define   F_SELECTABLE    0x0001
  30. #define   F_TABABLE       0x0002
  31. #define   F_RADIO         0x0004
  32.  
  33. #define   F_EXIT_PRESS    0x0008
  34. #define   F_EXIT_RELEASE  0x0010
  35. #define   F_EXIT_OVER     0x0020
  36. #define   F_IS_EXIT       0x0038
  37.  
  38. #define   F_SELECTED      0x0040
  39. #define   F_TABBED        0x0080
  40. #define   F_DESEL_RADIO   0x0100
  41. #define   F_EXIT_ALL      0x0200
  42. #define   F_FULL_TAB_ATT  0x0400
  43.  
  44. #define   F_LEFT_JUST     0x1000
  45. #define   F_RIGHT_JUST    0x2000
  46.  
  47. /*---------------------------------- styles --------------------------------*/
  48. #define   S_NORMAL        0x00
  49. #define   S_SHADOWED      0x01
  50.  
  51. /*------------------------- slider char index values -----------------------*/
  52. #define   SLIDER_LEFT     0
  53. #define   SLIDER_RIGHT    1
  54. #define   SLIDER_TOP      2
  55. #define   SLIDER_BOTTOM   3
  56. #define   SLIDER_TRACK    4
  57. #define   SLIDER_BOX      5
  58.  
  59. /*-------------------------- dialog processing flags -----------------------*/
  60. #define   DO_NORMAL       0x0001                /* normal dialog processing */
  61. #define   DO_RETURN_EVENT 0x0002                /* return unknown events    */
  62.  
  63. #define   DO_RETURN_TAB   0x0004                /* command key defines      */
  64. #define   DO_RETURN_ENTER 0x0008
  65. #define   DO_RETURN_LEFT  0x0010
  66. #define   DO_RETURN_RIGHT 0x0020
  67. #define   DO_RETURN_UP    0x0040
  68. #define   DO_RETURN_DOWN  0x0080
  69.  
  70. #define   DO_RETURN_ARROW 0x00F0                /* return dialog arrow keys */
  71. #define   DO_RETURN_CMD   0x00FC                /* return dialog cmd keys   */
  72.  
  73. #define   DO_INPUT_ADV    0x0100                /* advance tab on input     */
  74.  
  75. #define   NO_SELECTION    -1                    /* just esc from do_dialog  */
  76. #define   EVENT_RETURNED  -2                    /* unprocessed event        */
  77.  
  78. /*------------------------------- help defines -----------------------------*/
  79. #define   FNAME_LEN       41                    /* TUI help defines         */
  80. #define   MATCH_LEN       41
  81.  
  82. /*------------------------ TUI dialog object structres ---------------------*/
  83. typedef union ptr_union_struct                  /* structure for compatible */
  84. {                                               /* pointer sizes between    */
  85.   uchar   data[4];                              /* large and small models!  */
  86.   uchar   *ptr;
  87. } PTR_UNION;
  88.  
  89. typedef struct tui_base_struct
  90. {
  91.   usint     flags;                              /* 16 bits for flags        */
  92.   uchar     type;                               /* the type of TUI object   */
  93.   uchar     x_off;                              /* x offset from parent     */
  94.   uchar     y_off;                              /* x offset from parent     */
  95.   uchar     width;                              /* width in cells           */
  96.   uchar     height;                             /* height in cells          */
  97.   uchar     p_att;                              /* primary attribute        */
  98.   uchar     s_att;                              /* secondary attribute      */
  99.   uchar     style;                              /* the style - shadow, norm */
  100.   sint      parent;                             /* index of the parent      */
  101.   PTR_UNION more;                               /* pointer to more params   */
  102.   sint      hot_key;                            /* hot key to select item   */
  103.   sint      transfer;                           /* dialog transfer index    */
  104.   uchar     expansion[12];                      /* for later expansion      */
  105. } TUI_BASE;
  106.  
  107. typedef struct tui_button_struct
  108. {
  109.   uchar     norm_att;                           /* normal attribute         */
  110.   uchar     norm_f_att;                         /* normal first attribute   */
  111.   uchar     sel_att;                            /* selected attribute       */
  112.   uchar     sel_f_att;                          /* selected first attribute */
  113.   uchar     tab_color;                          /* tabbed text color!       */
  114.   uchar     first_pos;                          /* first letter position    */
  115.   sint      len;                                /* button text length       */
  116.   PTR_UNION text;                               /* the button text          */
  117.   uchar     expansion[4];                       /* for later expansion      */
  118. } TUI_BUTTON;
  119.  
  120. typedef struct tui_check_struct
  121. {
  122.   uchar     norm_att;                           /* normal attribute         */
  123.   uchar     tab_color;                          /* tabbed text color!       */
  124.   uchar     mark_pos;                           /* position for mark char   */
  125.   uchar     mark_char;                          /* mark character itself    */
  126.   sint      len;                                /* check text length        */
  127.   PTR_UNION text;                               /* the check text itself    */
  128.   uchar     norm_f_att;                         /* normal first attribute   */
  129.   uchar     first_pos;                          /* first letter position    */
  130.   uchar     expansion[2];                       /* for later expansion      */
  131. } TUI_CHECK;
  132.  
  133. typedef struct tui_input_struct
  134. {
  135.   uchar     norm_att;                           /* normal attribute         */
  136.   uchar     tab_color;                          /* tabbed text color        */
  137.   sint      len;                                /* input length             */
  138.   PTR_UNION text;                               /* the edited string        */
  139.   PTR_UNION mask;                               /* the mask for display     */
  140.   PTR_UNION tplt;                               /* validation characters    */
  141.   usint     input_flags;                        /* input modes & bit values */
  142.   uchar     expansion[2];                       /* for later expansion      */
  143. } TUI_INPUT;
  144.  
  145. typedef struct tui_slider_struct
  146. {
  147.   uchar   arrow_att;                            /* attribute for arrow      */
  148.   uchar   track_att;                            /* attribute for track      */
  149.   uchar   grab_att;                             /* attribute for grabber    */
  150.   uchar   slider_chars[6];                      /* the chars for the slider */
  151.   long    position;                             /* runs from 0..(total-1)   */
  152.   long    page_amt;                             /* amt to page up/down      */
  153.   long    total;                                /* total represented        */
  154.   uchar   expansion[4];                         /* for later expansion      */
  155. } TUI_SLIDER;
  156.  
  157. typedef struct tui_icon_struct
  158. {
  159.   uchar     norm_att;                           /* normal attribute         */
  160.   uchar     sel_att;                            /* selected attribute       */
  161.   uchar     tab_color;                          /* tabbed color!            */
  162.   PTR_UNION images;                             /* ptr to w x h images      */
  163.   uchar     expansion[4];                       /* for later expansion      */
  164. } TUI_ICON;
  165.  
  166. typedef struct tui_struct                       /* the actual TUI structure */
  167. {
  168.   sint      num_base;                           /* number of base items     */
  169.   long      version_num;                        /* tui version number       */
  170.   uchar     font_0_used;                        /* is the first font used?  */
  171.   char      font_0_name[13];                    /* filename for font 0      */
  172.   uchar     font_1_used;                        /* is the second font used? */
  173.   char      font_1_name[13];                    /* filename for font 1      */
  174.   uchar     blink_set;                          /* is blink enable set?     */
  175.   uchar     manager_used;                       /* do we use the manager?   */
  176.   uchar     rows;                               /* number of rows for video */
  177.   uchar     back_att;                           /* main back window color   */
  178.   uchar     back_bdr_att;                       /* main back border color   */
  179.   uchar     palette[16];                        /* the color palette        */
  180.   uchar     expansion[457];                     /* for later expansion      */
  181.  
  182.   WINDOW    *back_wnp;                          /* back screen window ptr   */
  183.   TUI_BASE  *base;
  184. } TUI;
  185.  
  186. /*---------------------------- TUI help structres --------------------------*/
  187. typedef struct tui_keyword_struct
  188. {
  189.   sint   line;                                  /* keyword line             */
  190.   sint   col;                                   /* keyword column           */
  191.   sint   dos_cmd;                               /* 1 if extra is dos cmd    */
  192.   char   *search;                               /* str associated with kwd  */
  193.   char   *keyword;                              /* the keyword itself       */
  194.   char   *fname;                                /* filename if not in file  */
  195.   struct tui_keyword_struct *prev;              /* pointer to prev keyword  */
  196.   struct tui_keyword_struct *next;              /* pointer to next keyword  */
  197. } TUI_KEYWORD;
  198.  
  199. typedef struct tui_help_struct
  200. {
  201.   uchar       keyword_att;
  202.   uchar       hilite_att;
  203.   uchar       default_att;
  204.   uchar       first_char_att;
  205.   sint        num_lines;
  206.   char        **lines;
  207.   char        *line_atts;
  208.   TUI_KEYWORD *keyword_list, *keyword_end;
  209.   sint        num_keywords;
  210.   sint        tab_size;
  211.   sint        first_col, curr_col;
  212.   sint        top_line, curr_line;
  213.   sint        chain_flag;
  214.   WINDOW      *wnp;
  215.   char        fname[FNAME_LEN];
  216.   char        match[MATCH_LEN];
  217. } TUI_HELP;
  218.  
  219. /*------------------------ time/date/directory defines ---------------------*/
  220. typedef struct tui_fblk_struct  /* provide common typedef for all compilers */
  221. {
  222.   char        reserved[21];
  223.   char        attrib;
  224.   usint       ftime;
  225.   usint       fdate;
  226.   long        fsize;
  227.   char        name[13];
  228. } TUI_FBLK;
  229.  
  230. typedef struct tui_file_tmdt_struct
  231. {
  232.   unsigned    seconds : 5;
  233.   unsigned    minutes : 6;
  234.   unsigned    hours   : 5;
  235.   unsigned    days    : 5;
  236.   unsigned    months  : 4;
  237.   unsigned    years   : 7;
  238. } TUI_FILE_TMDT;
  239.  
  240. typedef struct tui_dir_struct
  241. {
  242.   char          f_attrib;
  243.   TUI_FILE_TMDT f_tmdt;
  244.   long          f_size;
  245.   char          f_name[9];
  246.   char          f_ext[4];
  247. } TUI_DIR;
  248.  
  249. #ifndef ENQ_DEBUG
  250. #ifndef SOURCE_TRACE
  251. /*------------------------------ get macros --------------------------------*/
  252. #define get_dlg_wnp(tp, i)    ((WINDOW *) (tp)->base[i].more.ptr)
  253. #define get_item_type(tp, i)  ((tp)->base[i].type)
  254. #define get_item_x(tp, i)     ((tp)->base[i].x_off)
  255. #define get_item_y(tp, i)     ((tp)->base[i].y_off)
  256. #define get_item_w(tp, i)     ((tp)->base[i].width)
  257. #define get_item_h(tp, i)     ((tp)->base[i].height)
  258. #define get_box_att(tp, i)    ((tp)->base[i].p_att)
  259. #define get_sldr_pos(tp, i)   (((TUI_SLIDER *)((tp)->base[i].more.ptr))->position)
  260. #define get_str_text(tp, i)   ((char *) ((TUI_BUTTON *)((tp)->base[i].more.ptr))->text.ptr)
  261. #define get_btn_text(tp, i)   ((char *) ((TUI_BUTTON *)((tp)->base[i].more.ptr))->text.ptr)
  262. #define get_btn_att(tp, i)    (((TUI_BUTTON *)((tp)->base[i].more.ptr))->norm_att)
  263. #define get_btn_f_att(tp, i)  (((TUI_BUTTON *)((tp)->base[i].more.ptr))->norm_f_att)
  264. #define get_btn_sel_att(tp,i) (((TUI_BUTTON *)((tp)->base[i].more.ptr))->sel_att)
  265. #define get_check_text(tp, i) ((char *) ((TUI_CHECK *)((tp)->base[i].more.ptr))->text.ptr)
  266. #define get_inp_text(tp, i)   ((char *) ((TUI_INPUT *)((tp)->base[i].more.ptr))->text.ptr)
  267. #define get_inp_mask(tp, i)   ((char *) ((TUI_INPUT *)((tp)->base[i].more.ptr))->mask.ptr)
  268. #define get_inp_tplt(tp, i)   ((char *) ((TUI_INPUT *)((tp)->base[i].more.ptr))->tplt.ptr)
  269.  
  270. /*------------------------------ set macros --------------------------------*/
  271. #define set_item_x(tp,i,x)        (tp)->base[i].x_off = x
  272. #define set_item_y(tp,i,x)        (tp)->base[i].y_off = x
  273. #define set_item_w(tp,i,x)        (tp)->base[i].width = x
  274. #define set_item_h(tp,i,x)        (tp)->base[i].height = x
  275. #define set_box_att(tp,i,x)       (tp)->base[i].p_att = x
  276. #define set_sldr_pos(tp,i,x)      ((TUI_SLIDER *)((tp)->base[i].more.ptr))->position = x
  277. #define set_str_text(tp,i,s)      set_base_btn_text(&(tp)->base[i], s)
  278. #define set_btn_text(tp,i,s)      set_base_btn_text(&(tp)->base[i], s)
  279. #define set_btn_att(tp,i,x)       ((TUI_BUTTON *)((tp)->base[i].more.ptr))->norm_att = x
  280. #define set_btn_f_att(tp,i,x)     ((TUI_BUTTON *)((tp)->base[i].more.ptr))->norm_f_att = x
  281. #define set_btn_sel_att(tp,i,x)   ((TUI_BUTTON *)((tp)->base[i].more.ptr))->sel_att = x
  282. #define set_check_text(tp,i,s)    set_base_check_text(&(tp)->base[i], s)
  283. #define set_inp_strs(tp,i,t,m,p)  set_base_input_strs(&(tp)->base[i], t, m, p)
  284.  
  285. /*----------------------------- other macros -------------------------------*/
  286. #define is_valid_inx(tp, i)   (range(1, i, ((tp)->num_base - 1)))
  287. #define is_selected(tp, i)    ((tp)->base[i].flags & F_SELECTED)
  288. #define is_tabbed(tp, i)      ((tp)->base[i].flags & F_TABBED)
  289. #define is_tabable(tp, i)     ((tp)->base[i].flags & F_TABABLE)
  290. #define is_enabled(tp, i)     ((tp)->base[i].flags & F_SELECTABLE)
  291.  
  292. #define select(tp, i)         ((tp)->base[i].flags |= F_SELECTED)
  293. #define deselect(tp, i)       ((tp)->base[i].flags &= ~F_SELECTED)
  294. #define tabable(tp, i)        ((tp)->base[i].flags |= F_TABABLE)
  295. #define detabable(tp, i)      ((tp)->base[i].flags &= ~F_TABABLE)
  296. #define tab(tp, i)            ((tp)->base[i].flags |= F_TABBED)
  297. #define detab(tp, i)          ((tp)->base[i].flags &= ~F_TABBED)
  298. #define enable_item(tp, i)    ((tp)->base[i].flags |= F_SELECTABLE)
  299. #define disable_item(tp, i)   ((tp)->base[i].flags &= ~F_SELECTABLE)
  300.  
  301. #endif
  302. #endif
  303.  
  304. /*----------------------------- global variables ---------------------------*/
  305. #ifndef TUI_ERROR_DEFINED
  306. extern usint Tui_error;
  307. #endif
  308.  
  309. /*------------------------------ tui prototypes ----------------------------*/
  310. #include "t_proto.h"
  311. #include "t_dbg.h"
  312.  
  313. #endif     /* __T_H */
  314.  
  315. /*** END OF FILE ***/
  316.