home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / menu / tcu_32a / pulldown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-26  |  7.5 KB  |  203 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <conio.h>
  5. #include <usr\tcu.h>
  6.  
  7. char               *headings[] = { "RRecords", "FFinance", "LLoad/Store",
  8.                                    "IInvoices", "SStatistics", "OLOGOUT",
  9.                                    NULL };
  10.  
  11. void main (void)
  12. {
  13.    TCU_MENU            records_m,
  14.                        finance_m,
  15.                        load_m,
  16.                        invoices_m,
  17.                        statistics_m,
  18.                       *mlist[6];
  19.    TCU_FORM            form;
  20.    TCU_FIELD_VALUE     frm_val;
  21.    int                 message,
  22.                        menu,
  23.                        option,
  24.                        r1,r2;
  25.    char                msg[26];
  26.    TCU_PULLDOWN        pd;
  27.    void far            help_handler (int),
  28.         far            p_help_handler (int);
  29.  
  30.    char               *records_options[] =
  31.              { "PPatient", "SStaff", "DDoctors", "USUppliers", "AAppointment",
  32.                "IInvoice", NULL };
  33.  
  34.    char               *finance_options[] =
  35.              { "Credits", "Debits", "Insurances", "Unpaid", NULL };
  36.  
  37.    char               *load_options[] =
  38.              { "Remote data load", "Send data to remote", NULL };
  39.  
  40.    char               *invoices_options[] =
  41.              { "New", "Browse all", "Find", "Delete", "Print", NULL };
  42.  
  43.    char               *statistics_options[] =
  44.              { "Patient", "Staff", "Invoices", "Appointments", NULL };
  45.  
  46.    tcu_set_mouse_mode (1);
  47.  
  48.    r1 = tcu_define_menu (&records_m,
  49.                          "Records",
  50.                          tcu_colour_attrib (YELLOW, CYAN),       /* Title */
  51.                          tcu_colour_attrib (BLUE, CYAN),         /* Box */
  52.                          tcu_colour_attrib (WHITE, MAGENTA),     /* Options */
  53.                          tcu_colour_attrib (WHITE, BLUE),        /* Selected */
  54.                          tcu_colour_attrib (LIGHTGRAY, MAGENTA), /* Deselected */
  55.                          TCU_ESC_ESC | TCU_ESC_CNTL_C | TCU_ESC_PGUP | TCU_ESC_FUNC,
  56.                          TCU_BOX_DOUBLE,
  57.                          records_options,
  58.                  tcu_colour_attrib (LIGHTRED, MAGENTA));
  59.  
  60.    r1 = tcu_define_menu (&finance_m,
  61.                          "Finance",
  62.                          tcu_colour_attrib (YELLOW, CYAN),       /* Title */
  63.                          tcu_colour_attrib (BLUE, CYAN),         /* Box */
  64.                          tcu_colour_attrib (WHITE, MAGENTA),     /* Options */
  65.                          tcu_colour_attrib (WHITE, BLUE),        /* Selected */
  66.                          tcu_colour_attrib (LIGHTGRAY, MAGENTA), /* Deselected */
  67.                          TCU_ESC_ESC | TCU_ESC_CNTL_C | TCU_ESC_PGUP | TCU_ESC_FUNC,
  68.                          TCU_BOX_DOUBLE,
  69.                          finance_options,
  70.                  0);
  71.  
  72.    r1 = tcu_define_menu (&load_m,
  73.                          "Data Load",
  74.                          tcu_colour_attrib (YELLOW, CYAN),       /* Title */
  75.                          tcu_colour_attrib (BLUE, CYAN),         /* Box */
  76.                          tcu_colour_attrib (WHITE, MAGENTA),     /* Options */
  77.                          tcu_colour_attrib (WHITE, BLUE),        /* Selected */
  78.                          tcu_colour_attrib (LIGHTGRAY, MAGENTA), /* Deselected */
  79.                          TCU_ESC_ESC | TCU_ESC_CNTL_C | TCU_ESC_PGUP | TCU_ESC_FUNC,
  80.                          TCU_BOX_DOUBLE,
  81.                          load_options,
  82.                  0);
  83.  
  84.    r1 = tcu_define_menu (&invoices_m,
  85.                          "Invoices",
  86.                          tcu_colour_attrib (YELLOW, CYAN),       /* Title */
  87.                          tcu_colour_attrib (BLUE, CYAN),         /* Box */
  88.                          tcu_colour_attrib (WHITE, MAGENTA),     /* Options */
  89.                          tcu_colour_attrib (WHITE, BLUE),        /* Selected */
  90.                          tcu_colour_attrib (LIGHTGRAY, MAGENTA), /* Deselected */
  91.                          TCU_ESC_ESC | TCU_ESC_CNTL_C | TCU_ESC_PGUP | TCU_ESC_FUNC,
  92.                          TCU_BOX_DOUBLE,
  93.                          invoices_options,
  94.                  0);
  95.  
  96.    r1 = tcu_define_menu (&statistics_m,
  97.                          "Statistics",
  98.                          tcu_colour_attrib (YELLOW, CYAN),       /* Title */
  99.                          tcu_colour_attrib (BLUE, CYAN),         /* Box */
  100.                          tcu_colour_attrib (WHITE, MAGENTA),     /* Options */
  101.                          tcu_colour_attrib (WHITE, BLUE),        /* Selected */
  102.                          tcu_colour_attrib (LIGHTGRAY, MAGENTA), /* Deselected */
  103.                          TCU_ESC_ESC | TCU_ESC_CNTL_C | TCU_ESC_PGUP | TCU_ESC_FUNC,
  104.                          TCU_BOX_DOUBLE,
  105.                          statistics_options,
  106.                  0);
  107.  
  108.    tcu_set_menu_help (&invoices_m, help_handler);
  109.    tcu_set_pulldown_help (&pd, p_help_handler);
  110.  
  111.    tcu_set_menu_option (&invoices_m, 4, 0);
  112.  
  113.    mlist[0] = &records_m;
  114.    mlist[1] = &finance_m;
  115.    mlist[2] = &load_m;
  116.    mlist[3] = &invoices_m;
  117.    mlist[4] = &statistics_m;
  118.    mlist[5] = NULL;
  119.  
  120.    tcu_define_pulldown    (&pd,
  121.                            tcu_colour_attrib (WHITE,BLUE),
  122.                            tcu_colour_attrib (YELLOW,BLUE),
  123.                            tcu_colour_attrib (YELLOW,RED),
  124.                            headings,
  125.                    tcu_colour_attrib (LIGHTGREEN, BLUE),
  126.                    mlist);
  127.  
  128.    tcu_set_pulldown_help (&pd, p_help_handler);
  129.  
  130.    tcu_load_form (&form, "pulldown");
  131.  
  132.    tcu_get_field_id (&form, "menu", &menu);
  133.    tcu_get_field_id (&form, "option", &option);
  134.    tcu_get_field_id (&form, "message", &message);
  135.  
  136.    tcu_set_field_mode (&form, menu, TCU_FORM_NOENTER);
  137.    tcu_set_field_mode (&form, option, TCU_FORM_NOENTER);
  138.    tcu_set_field_mode (&form, message, TCU_FORM_CONFIRM);
  139.  
  140.    tcu_display_form (&form, 1, 2);
  141.  
  142.    do {
  143.       tcu_read_pulldown_selection (&pd, &r1, &r2);
  144.       if (r1) {
  145.          frm_val.v_int = r1;
  146.          tcu_put_field (&form, menu, &frm_val);
  147.          frm_val.v_int = r2;
  148.          tcu_put_field (&form, option, &frm_val);
  149.          if (r2)
  150.             msg[0] = '\0';
  151.          else
  152.             strcpy (msg, "No sub-menu available");
  153.          frm_val.v_string = msg;
  154.          tcu_put_field (&form, message, &frm_val);
  155.       }
  156.    } while (r1);
  157.  
  158.    tcu_remove_pulldown    (&pd);
  159.  
  160.    tcu_remove_form (&form);
  161. }
  162.  
  163. void far help_handler (int option)
  164. {
  165.    TCU_NOTICE        notice;
  166.  
  167.    tcu_prepare_notice (¬ice,
  168.                        "Help",
  169.                        tcu_colour_attrib (BLUE, LIGHTGRAY),
  170.                        tcu_colour_attrib (LIGHTBLUE, LIGHTGRAY),
  171.                        tcu_colour_attrib (BLUE, LIGHTGRAY),
  172.                        TCU_BOX_SINGLE);
  173.  
  174.    tcu_notice_text (¬ice, "Sorry, no help defined currently");
  175.    tcu_notice_text (¬ice, "for option %d.", option);
  176.  
  177.    tcu_display_notice (¬ice, 25, 20);
  178.  
  179.    tcu_clear_notice (¬ice);
  180. }
  181.  
  182. void far p_help_handler (int option)
  183. {
  184.    TCU_NOTICE       notice;
  185.  
  186.    tcu_prepare_notice (¬ice,
  187.                        "HELP",
  188.                        tcu_colour_attrib (BLUE, LIGHTGRAY),
  189.                        tcu_colour_attrib (LIGHTBLUE, LIGHTGRAY),
  190.                        tcu_colour_attrib (BLUE, LIGHTGRAY),
  191.                        TCU_BOX_DOUBLE);
  192.  
  193.    tcu_notice_text (¬ice,
  194.                 "Sorry, no help defined currently");
  195.    tcu_notice_text (¬ice,
  196.                 "for option %s.", headings[option-1]);
  197.  
  198.    tcu_display_notice (¬ice,
  199.                        23, 20);
  200.  
  201.    tcu_clear_notice (¬ice);
  202. }
  203.