home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / tcu_32.zip / TCU_32.ZIP / TCU.H < prev    next >
Text File  |  1991-03-26  |  25KB  |  482 lines

  1. /*==========================================================================*
  2.  *                                                                          *
  3.  *          Header #include file for Turbo-C Utilities version 3. 2         *
  4.  *          ------------------------------------------------------          *
  5.  *                                                                          *
  6.  *                    (c) Copyright Karl Keyte, 1990-91                     *
  7.  *                                                                          *
  8.  *  Karl Keyte                           Phone:  +(49) 6150 2499            *                       *
  9.  *  Gross-Gerauer Strasse 10                                                *
  10.  *  D-6108 Weiterstadt                   e-Mail: KKEYTE@ESOC.BITNET         *
  11.  *  Germany                              Bix:    kkeyte                     *
  12.  *                                                                          *
  13.  *==========================================================================*/
  14.  
  15.  
  16. #if     !defined(__TCU__)
  17. #define __TCU__
  18.  
  19. #define TCU_BOX_SINGLE              1      /* Box bordered by single lines */
  20. #define TCU_BOX_DOUBLE              2      /* Box bordered by double lines */
  21. #define TCU_BOX_BLANK               3      /* Box bordered by spaces       */
  22.  
  23.  
  24. #define TCU_ESC_ESC              0x01      /* ESCAPE key exit */
  25. #define TCU_ESC_PGUP             0x02      /* Page Up key exit */
  26. #define TCU_ESC_PGDN             0x04      /* Page Down key exit */
  27. #define TCU_ESC_CLEFT            0x08      /* Cursor left exit */
  28. #define TCU_ESC_CRIGHT           0x10      /* Cursor right exit */
  29. #define TCU_ESC_FUNC             0x20      /* Function key exit */
  30. #define TCU_ESC_CNTL_C           0x40      /* Control-C exit */
  31. #define TCU_ESC_PULLDOWN         0x80      /* Pulldown bar selection */
  32.  
  33. #define TCU_ESC_USERKEY        0x0100      /* User defined escape key */
  34.  
  35. #define TCU_ESC_MOUSE_CLICK_L  0xE000      /* Left mouse button click */
  36. #define TCU_ESC_MOUSE_CLICK_R  0xE100      /* Right mouse button click */
  37. #define TCU_USER_DEFINED_SAVE  0xE200      /* User defined accept key */
  38. #define TCU_USER_DEFINED_ESC   0xE300      /* User defined escape key */
  39.  
  40.  
  41. #define TCU_MENU_TITLE              1      /* Title */
  42. #define TCU_MENU_BOX                2      /* Surrounding box */
  43. #define TCU_MENU_OPTION             3      /* Option line */
  44. #define TCU_MENU_SELECT             4      /* Selected option line */
  45. #define TCU_MENU_UNAVAIL            5      /* Unavailable option line */
  46.  
  47.  
  48. #define TCU_OK                      0      /* Successful TCU service */
  49. #define TCU_ERROR                   1      /* Unsuccessful TCU service */
  50.  
  51.  
  52. #define TCU_FORM_EDIT               1      /* Enable edit ability for field */
  53. #define TCU_FORM_NOEDIT             2      /* Disable edit ability for field */
  54. #define TCU_FORM_ECHO               3      /* Echo field when input */
  55. #define TCU_FORM_NOECHO             4      /* No echo on input field */
  56. #define TCU_FORM_ENTER              5      /* Enter the field in edit */
  57. #define TCU_FORM_NOENTER            6      /* Don't enter the field in edit */
  58. #define TCU_FORM_CONFIRM            7      /* Field needs ENTER to confirm */
  59. #define TCU_FORM_NOCONFIRM          8      /* No ENTER needed to confirm */
  60. #define TCU_FORM_ESCS               9      /* Escape keys work in forms */
  61. #define TCU_FORM_NOESCS            10      /* Disable escape keys in forms */
  62.  
  63.  
  64. #define TCU_FRM_MAXFIELD          128      /* Maximum fields on form */
  65. #define TCU_MAX_SCREEN_LINES       25      /* Number of lines on screen */
  66.  
  67.  
  68. #define TCU_FLD_INT                 1      /* Integer (32 bits) */
  69. #define TCU_FLD_FLOAT               2      /* Floating point (64 bits) */
  70. #define TCU_FLD_STRING              3      /* String, ASCIIZ format */
  71. #define TCU_FLD_DATE                4      /* Date (01.01.70 ...) */
  72. #define TCU_FLD_LOGICAL             5      /* True/False, Yes/No, On/Off */
  73. #define TCU_FLD_CHOICE              6      /* Enumerated choice type */
  74. #define TCU_FLD_BUTTON              7      /* Button selection field */
  75.  
  76.  
  77. #define TCU_FLD_DAYFIRST            1      /* Dates with day number first */
  78. #define TCU_FLD_MONTHFIRST          2      /* Dates with month number first */
  79.                                            
  80.  
  81. #define TCU_FLD_TRUEFALSE           1      /* Logicals as TRUE/FALSE */
  82. #define TCU_FLD_YESNO               2      /* Logicals as YES/NO */
  83. #define TCU_FLD_ONOFF               3      /* Logicals as ON/OFF */
  84.  
  85.  
  86. #define TCU_FLD_ESCNEXT             1      /* NEXT FIELD field edit escape */
  87. #define TCU_FLD_ESCPREV             2      /* PREVIOUS FIELD escape */
  88. #define TCU_FLD_ESCFIRST            3      /* FIRST FIELD escape */
  89. #define TCU_FLD_ESCLAST             4      /* LAST FIELD escape */
  90. #define TCU_FLD_SELECT              5      /* Field select escape */
  91. #define TCU_FLD_CLICKSELECT         6      /* Mouse click field select */
  92. #define TCU_FLD_ESCESC             -1      /* ESC key escape */
  93. #define TCU_FLD_ESCCNTLC           -2      /* CNTL/C key escape */
  94. #define TCU_FLD_ESCPGUP            -3      /* Page-Up key escape */
  95. #define TCU_FLD_ESCPGDN            -4      /* Page-Down key escape */
  96. #define TCU_FLD_FNKEYSAVE          -5      /* Function key save escape */
  97. #define TCU_FLD_FNKEYESC           -6      /* Function key abort escape */
  98. #define TCU_FLD_BUTTONSAVE         -7      /* Button save escape */
  99. #define TCU_FLD_BUTTONESC          -8      /* Button abort escape */
  100. #define TCU_FLD_USERSAVE           -9      /* User defined accept key */
  101. #define TCU_FLD_USERESC           -10      /* User defined escape key */
  102.  
  103.  
  104. typedef struct {
  105.    short               x, y;               /* X and Y coords of current pos */
  106.    short               height,             /* External size of menu */
  107.                        width;              /* External width of menu */
  108.    char               *title;              /* Title of menu */
  109.    unsigned char       title_attrib,       /* Attributes of title */
  110.                        box_attrib,         /* Attributes of surrounding box */
  111.                        option_attrib,      /* Attributes of menu option */
  112.                        select_attrib,      /* Attributes of selected option */
  113.                        unavail_attrib;     /* Attributes of unavailables */
  114.    unsigned char       escape_keys;        /* Keys which allow exit */
  115.    unsigned char       box_type;           /* Type of external box */
  116.    unsigned char       last_selection;     /* Last selected option */
  117.    void far          (*help_fn)(int);      /* User's help function */
  118.    char              **options;            /* Pointer to list of options */
  119.    unsigned char      *cover_zone;         /* Pointer to covered screen */
  120.    unsigned char       short_code;         /* Flags if short code select on */
  121.    unsigned long       option_avail;       /* Option availability flags */
  122. } TCU_MENU;
  123.  
  124.  
  125. typedef struct {
  126.    int                 in_use;             /* Flags current use mode */
  127.    char               *cover_zone,
  128.                       *title;
  129.    int                 height,
  130.                        width;
  131.    unsigned char       box_attrib,
  132.                        window_attrib,
  133.                        input_attrib,
  134.                        title_attrib,
  135.                        box_type;
  136.    unsigned char       with_input;
  137.    int                 input_x,
  138.                        input_y;
  139.    char               *input_str;
  140.    char               *txt_line[TCU_MAX_SCREEN_LINES - 2];
  141.    int                 txt_lines;
  142. } TCU_NOTICE;
  143.  
  144.  
  145. typedef struct {
  146.    int                 in_use;             /* Flags current use mode */
  147.    char               *cover_zone;
  148.    char               *title;
  149.    int                 cursor_x,
  150.                        cursor_y,
  151.                height,
  152.                        width,
  153.                        pos_x,
  154.                        pos_y;
  155.    unsigned char       box_attrib,
  156.                        title_attrib,
  157.                        window_attrib,
  158.                        box_type;
  159. } TCU_WINDOW;
  160.  
  161.  
  162. typedef struct {
  163.    unsigned char       linecolour,         /* Colour of header line */
  164.                        optioncolour,       /* Colour of possible options */
  165.                        selectcolour;       /* Colour of selected option */
  166.    char              **headings;           /* List of header titles */
  167.    TCU_MENU          **menus;              /* List of menus */
  168.    void far          (*help_fn)(int);      /* User's help function */
  169.    unsigned char       selected,           /* Currently selected menu */
  170.                        use_mode;           /* Current mode of use */
  171.    unsigned char      *cover_zone;         /* Screen contents area */
  172.    unsigned char       short_code;         /* Flags if short code select on */
  173. } TCU_PULLDOWN;
  174.  
  175.  
  176. typedef struct {
  177.    unsigned char       sel,                /* Selected choice */
  178.                        max;                /* Maximum choices available */
  179.    char               *str;                /* String of separated choices */
  180. } TCU_CHOICE_TYPE;
  181.  
  182.  
  183. typedef union {
  184.    long                v_int;              /* Integer field value */
  185.    double              v_float;            /* Floating field value */
  186.    char               *v_string;           /* String field value */
  187.    unsigned short      v_date;             /* Date value (days -> 01.01.70) */
  188.    unsigned char       v_logical;          /* Logical field value */
  189.    TCU_CHOICE_TYPE     v_choice;           /* Enumerated choice type */
  190. } TCU_FIELD_VALUE;
  191.  
  192.  
  193. typedef struct {
  194.    char                   f_name[9];       /* Field name */
  195.    unsigned char          f_type,          /* Type of field */
  196.                           f_size,          /* Width of field on screen */
  197.                           f_decimal,       /* Decimal places if numeric */
  198.                           f_present,       /* Presentation form of data */
  199.                           f_xpos,          /* Window x-coordinate */
  200.                           f_ypos;          /* Window y-coordinate */
  201.    unsigned char          f_usemin,        /* Flags use of minimum range */
  202.                           f_usemax,        /* Flags use of maximum range */
  203.                           f_useval,        /* Flags if initial value used */
  204.                           f_usetmp;        /* Flags if string template used */
  205.    union {
  206.       struct {
  207.          long             f_min,           /* Minimum value */
  208.                           f_max;           /* Maximum value */
  209.       } i;
  210.       struct {
  211.          double           f_min,           /* Minimum value */
  212.                           f_max;           /* Maximum value */
  213.       } f;
  214.       struct {
  215.          unsigned short   f_min,           /* Minimum value */
  216.                           f_max;           /* Maximum value */
  217.       } d;
  218.    } range;
  219.    unsigned char          f_colour,        /* Colour attributes */
  220.                           f_editcolour;    /* Colour during field editing */
  221.    struct {
  222.       unsigned int        a_ronly : 1,     /* Read only flag */
  223.                           a_noecho : 1,    /* No-echo input flag */
  224.                           a_fixtext : 1,   /* Fixed text field flag */
  225.                           a_param : 1,     /* Non-editable variable field */
  226.                           a_confirm : 1;   /* ENTER confirmation needed flag */
  227.    } attrib;
  228.    TCU_FIELD_VALUE        val;             /* Value of field */
  229.    unsigned char          dummy;           /* Marker for start of pointers */
  230.    char                  *f_template;      /* Template for string inputs */
  231. } TCU_FIELD;
  232.  
  233.  
  234. typedef struct {
  235.    unsigned int           num_fields;      /* Number of fields */
  236.    unsigned char          colour,          /* Colour attribute */
  237.                           input_colour;    /* Input field colour default */
  238.    char                   title[77];       /* Form title string */
  239.    unsigned char          xpos,            /* x-coordinate on screen */
  240.                           ypos,            /* y-coordinate on screen */
  241.                           height,          /* Height of form */
  242.                           width,           /* Width of form */
  243.                           type,            /* Form surround type */
  244.                           title_attrib,    /* Colour attributes for title */
  245.                           current_field,   /* Current field with focus */
  246.                           use_mode;        /* Flags whether in use/displayed */
  247.    struct {
  248.       unsigned int        ronly : 1,       /* Form is read only */
  249.                           no_esc : 1;      /* No direct escape keys allowed */
  250.    } attrib;
  251.    unsigned char          dummy;           /* Marker for start of pointers */
  252.    TCU_FIELD             *field[TCU_FRM_MAXFIELD]; /* Fields */
  253.    int far              (*verify_fn)
  254.                             (void *, int, TCU_FIELD_VALUE *); /* verify fn */
  255.    void far             (*help_fn)
  256.                             (void *, int);         /* User's help function */
  257.    int far              (*fn_key_fn)
  258.                             (void *, int, int);    /* Function key handler */
  259.    int far              (*button_fn)
  260.                             (void *, int);         /* Button select handler */
  261.    unsigned char         *cover_zone;      /* Screen cover buffer */
  262. } TCU_FORM;
  263.  
  264.  
  265. typedef struct {
  266.    char                   name[9];         /* Field name */
  267.    unsigned char          type,            /* Type of field */
  268.                           size,            /* Width of field on screen */
  269.                           decimal,         /* Decimal places if numeric */
  270.                           present,         /* Presentation form of data */
  271.                           xpos,            /* Window x-coordinate */
  272.                           ypos,            /* Window y-coordinate */
  273.                           usemin,          /* Flags use of minimum range */
  274.                           usemax,          /* Flags use of maximum range */
  275.                           useval,          /* Flags if initial value used */
  276.                           usetmp;          /* Flags if string template used */
  277.    union {
  278.       struct {
  279.          long             min,             /* Minimum value */
  280.                           max;             /* Maximum value */
  281.       } i;
  282.       struct {
  283.          double           min,             /* Minimum value */
  284.                           max;             /* Maximum value */
  285.       } f;
  286.       struct {
  287.          unsigned short   min,             /* Minimum value */
  288.                           max;             /* Maximum value */
  289.       } d;
  290.    } range;
  291.    unsigned char          colour,          /* Colour attributes */
  292.                           editcolour;      /* Colour during field editing */
  293.    struct {
  294.       unsigned int        ronly : 1,       /* Read only flag */
  295.                           noecho : 1,      /* No-echo input flag */
  296.                           fixtext : 1,     /* Fixed text field flag */
  297.                           param : 1,       /* Non-editable variable field */
  298.                           confirm : 1;     /* ENTER confirmation needed flag */
  299.    } attr;
  300.    TCU_FIELD_VALUE        val;             /* Value of field */
  301. } TCU_FIELD_INFO;
  302.  
  303.  
  304. typedef struct {
  305.    unsigned int           num_fields;      /* Number of fields */
  306.    char                  *title;           /* Title string of form */
  307.    unsigned char          text_colour,     /* Colour attribute */
  308.                           field_colour,    /* Input field colour default */
  309.                           title_colour,    /* Title string colour */
  310.                           xpos,            /* x-coordinate on screen */
  311.                           ypos,            /* y-coordinate on screen */
  312.                           height,          /* Height of form */
  313.                           width,           /* Width of form */
  314.                           box_type,        /* Form surround type */
  315.                           mode,            /* Flags whether in use/displayed */
  316.                           verify_fn,       /* Verification function active */
  317.                           help_fn,         /* Help function active */
  318.                           fn_key_fn,       /* 1 if fn. key handler active */
  319.                           button_fn;       /* 1 if button select handler */
  320.    struct {
  321.       unsigned int        ronly : 1,       /* Form is read only */
  322.                           no_esc : 1;      /* Escape keys disabled */
  323.    } attr;
  324. } TCU_FORM_INFO;
  325.  
  326.  
  327.  
  328. /* External objects */
  329.  
  330. extern TCU_FORM *_TCU_UPDATE_form;
  331.  
  332.  
  333.  
  334. /* Add prefix to function prototypes for C++ compilation */
  335.  
  336. #ifdef __cplusplus
  337. #define c_cpp extern "C"
  338. #else
  339. #define c_cpp
  340. #endif
  341.  
  342.  
  343. /*--------------------------------------------------------------------------*/
  344. /*                                                                          */
  345. /*                  Pop-Up & Pulldown Menu Services                         */
  346. /*                                                                          */
  347. /*--------------------------------------------------------------------------*/
  348.  
  349.  
  350. c_cpp int tcu_change_menu_attribs      (TCU_MENU *, int, unsigned char);
  351. c_cpp int tcu_change_menu_escapes      (TCU_MENU *, unsigned char);
  352. c_cpp int tcu_clear_menu_in_pulldown   (TCU_PULLDOWN *);
  353. c_cpp int tcu_define_menu              (TCU_MENU *, char *, unsigned char,
  354.                                         unsigned char, unsigned char,
  355.                                         unsigned char, unsigned char,
  356.                                         unsigned char, unsigned char, char **,
  357.                                         unsigned char);
  358. c_cpp int tcu_define_pulldown          (TCU_PULLDOWN *, unsigned char,
  359.                                         unsigned char, unsigned char, char **,
  360.                                         unsigned char, TCU_MENU **);
  361. c_cpp int tcu_display_menu             (TCU_MENU *, int, int);
  362. c_cpp int tcu_display_pulldown_header  (TCU_PULLDOWN *);
  363. c_cpp int tcu_escape_fkey              (void);
  364. c_cpp int tcu_new_pulldown_cover       (TCU_PULLDOWN *);
  365. c_cpp int tcu_read_menu_selection      (TCU_MENU *);
  366. c_cpp int tcu_read_pulldown_selection  (TCU_PULLDOWN *, int *, int *);
  367. c_cpp int tcu_remove_menu              (TCU_MENU *);
  368. c_cpp int tcu_remove_pulldown          (TCU_PULLDOWN *);
  369. c_cpp int tcu_set_menu_help            (TCU_MENU *, void far (*)(int));
  370. c_cpp int tcu_set_menu_option          (TCU_MENU *, int, int);
  371. c_cpp int tcu_set_pulldown_help        (TCU_PULLDOWN *, void far (*)(int));
  372.  
  373.  
  374.  
  375. /*--------------------------------------------------------------------------*/
  376. /*                                                                          */
  377. /*                       Prompt & Notice Utilities                          */
  378. /*                                                                          */
  379. /*--------------------------------------------------------------------------*/
  380.  
  381.  
  382. c_cpp int tcu_clear_notice             (TCU_NOTICE *);
  383. c_cpp int tcu_display_notice           (TCU_NOTICE *, int, int);
  384. c_cpp int tcu_get_confirm              (int, int, unsigned char, unsigned char,
  385.                                         char *, ...);
  386. c_cpp int tcu_notice_text              (TCU_NOTICE *, char *, ...);
  387. c_cpp int tcu_prepare_notice           (TCU_NOTICE *, char *, unsigned char,
  388.                                         unsigned char, unsigned char,
  389.                                         unsigned char);
  390. c_cpp int tcu_prompt_input             (TCU_NOTICE *, int, int, char *,
  391.                                         unsigned char);
  392.  
  393.  
  394.  
  395. /*--------------------------------------------------------------------------*/
  396. /*                                                                          */
  397. /*                           Screen/Form Utilities                          */
  398. /*                                                                          */
  399. /*--------------------------------------------------------------------------*/
  400.  
  401.  
  402. c_cpp int tcu_display_form             (TCU_FORM *, int, int);
  403. c_cpp int tcu_edit_form                (TCU_FORM *, int, int *);
  404. c_cpp int tcu_form_record_size         (TCU_FORM *);
  405. c_cpp int tcu_get_field                (TCU_FORM *, int, TCU_FIELD_VALUE *);
  406. c_cpp int tcu_get_field_choice_string  (TCU_FORM *, int, char *);
  407. c_cpp int tcu_get_field_id             (TCU_FORM *, char *, int *);
  408. c_cpp int tcu_get_field_info           (TCU_FORM *, int, TCU_FIELD_INFO *);
  409. c_cpp int tcu_get_form_info            (TCU_FORM *, TCU_FORM_INFO *);
  410. c_cpp int tcu_load_form                (TCU_FORM *, char *);
  411. c_cpp int tcu_load_image_form          (TCU_FORM *, TCU_FORM *);
  412. c_cpp int tcu_put_field                (TCU_FORM *, int, TCU_FIELD_VALUE *);
  413. c_cpp int tcu_read_formrec             (TCU_FORM *, char *);
  414. c_cpp int tcu_remove_form              (TCU_FORM *);
  415. c_cpp int tcu_select_field             (TCU_FORM *, int, int *);
  416. c_cpp int tcu_set_button_fn            (TCU_FORM *, int far (*)(TCU_FORM *,
  417.                                                                 int));
  418. c_cpp int tcu_set_field_attrib         (TCU_FORM *, int, unsigned char);
  419. c_cpp int tcu_set_field_mode           (TCU_FORM *, int, int);
  420. c_cpp int tcu_set_field_verify         (TCU_FORM *, int far (*)
  421.                                                     (TCU_FORM *, int,
  422.                                                      TCU_FIELD_VALUE *));
  423. c_cpp int tcu_set_form_fnkey_fn        (TCU_FORM *, int far (*)
  424.                                                     (TCU_FORM *, int, int));
  425. c_cpp int tcu_set_form_help            (TCU_FORM *, void far (*)
  426.                                                     (TCU_FORM *, int));
  427. c_cpp int tcu_set_form_mode            (TCU_FORM *, int);
  428. c_cpp int tcu_unload_form              (TCU_FORM *);
  429. c_cpp int tcu_write_formrec            (TCU_FORM *, char *);
  430.  
  431.  
  432.  
  433. /*--------------------------------------------------------------------------*/
  434. /*                                                                          */
  435. /*                          Windowing Utilities                             */
  436. /*                                                                          */
  437. /*--------------------------------------------------------------------------*/
  438.  
  439.  
  440. c_cpp int tcu_change_colour            (TCU_WINDOW *, unsigned char);
  441. c_cpp int tcu_clear_window             (TCU_WINDOW *);
  442. c_cpp int tcu_close_window             (TCU_WINDOW *);
  443. c_cpp int tcu_open_window              (TCU_WINDOW *, int, int, int, int,
  444.                                         char *, unsigned char, unsigned char,
  445.                                         unsigned char, unsigned char);
  446. c_cpp int tcu_position_cursor          (TCU_WINDOW *, int, int);
  447. c_cpp int tcu_wprintf                  (TCU_WINDOW *, char *, ...);
  448. c_cpp int tcu_wgets                    (TCU_WINDOW *, int, char *, int *);
  449.  
  450.  
  451.  
  452. /*--------------------------------------------------------------------------*/
  453. /*                                                                          */
  454. /*                            General Utilities                             */
  455. /*                                                                          */
  456. /*--------------------------------------------------------------------------*/
  457.  
  458.  
  459. c_cpp unsigned char  tcu_colour_attrib        (int, int);
  460. c_cpp char          *tcu_date_string          (unsigned short, unsigned char);
  461. c_cpp unsigned short tcu_date_value           (char *, unsigned char);
  462. c_cpp unsigned short tcu_get_user_keypress    (void);
  463. c_cpp unsigned long  tcu_hash_value           (char *, unsigned long);
  464. c_cpp void           tcu_restore_environment  (void);
  465. c_cpp void           tcu_save_environment     (void);
  466. c_cpp int            tcu_set_idle_loop        (int far (*)(unsigned long));
  467. c_cpp int            tcu_set_mouse_mode       (unsigned char);
  468. c_cpp int            tcu_set_user_key_handler (int far (*)(unsigned short *));
  469. c_cpp void           tcu_warnbeep             (void);
  470.  
  471.  
  472.  
  473. /* If TCU compatibility mode is selected to be compatible with pre version */
  474. /* 3.2 then we must include the 'tcupre32.h' file here to alias the right */
  475. /* bits.  Don't rely on this always being here... it won't be! */
  476.  
  477. #if      defined(__TCUPRE32__)
  478. #include <usr\tcupre32.h>
  479. #endif
  480.  
  481. #endif
  482.