home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 1.ddi / EXAMPLE.EXE / CSCAPE / EXAMPLE / DEMOSLUG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-12  |  3.2 KB  |  122 lines

  1. /* 
  2.     demoslug.c
  3.  
  4.     Copyright (c) 1988, by Oakland Group, Inc.
  5.     ALL RIGHTS RESERVED.
  6.  
  7.     Example using the slug menuing system.
  8.  
  9.     In this example the user is asked whether to build a vertical
  10.     (ala Look & Feel) menu or a horizontal (123-type) menu.
  11.  
  12.     All of the menu choices call the function 'empty' defined below.
  13. */
  14.  
  15. #include <stdio.h>
  16.  
  17. #include <cscape.h>
  18. #include <popdecl.h>
  19. #include <slug.h>
  20.  
  21. /*** Note: C-scape uses the _arg macro to turn off prototyping 
  22.      for older compilers */
  23.  
  24. int empty(_arg2(VOID *, int));
  25.  
  26. struct slug_list dbv_menu[] = {         /* note: values must be positive */
  27.  
  28.     {    " Insert ", "Insert a record",            NULL, empty, 20 },
  29.     {    " Delete ", "Delete a record",              NULL, empty, 23 },
  30.     {    " Next ",     "Display next record",        NULL, empty, 24 },
  31.     {    " Previous ", "Display previous record",NULL, empty, 25 },
  32.     {    " Locate ", "Locate record",             NULL, empty, 26 },
  33.     {    " Sort ",     "Sort records",                  NULL, empty, 27 },
  34.     {    " Output ", "List data records",         NULL, empty, 28 },
  35.     {   NULL,         "Block Menu",                  NULL, NULL,   0 }
  36. };
  37.  
  38. struct slug_list block_menu[] = {
  39.  
  40.     {    " Copy ",   "Copy block to buffer",         NULL, empty, 22 },
  41.     {    " Delete ", "Delete block",                 NULL, empty, 23 },
  42.     {    " Move ",   "Move block",                  NULL, empty, 25 },
  43.     {    " Paste ",  "Paste buffer",                 NULL, empty, 26 },
  44.     {    " Fill ",   "Fill block",                NULL, empty, 27 },
  45.     {    " Attribute ", "Colour block",            NULL, empty, 28 },
  46.     {    " DataBase? ", "Access data base",        dbv_menu, empty, 20 },
  47.     {   NULL,         "Block Menu",                  NULL, NULL,      0 }
  48. };
  49.  
  50. #define    QUIT        6
  51.  
  52. struct slug_list main_menu[] = {
  53.  
  54.     {    " Block ",    "Block functions",             block_menu,    NULL,      1},
  55.     {    " Characters ",    "Character set",         NULL,     empty,        2},
  56.     {    " Disk ",    "Disk functions",            NULL,     empty,         4},
  57.     {    " Erase ",    "Clear entire screen",        NULL,     empty,         8},
  58.     {    " Field ",    "Field functions",            NULL,     empty,         3},
  59.     {    " Lines ",    "Line drawing  (^L)",          NULL,     empty,         7},
  60.     {    " Set up ", "Set global data",             NULL,     empty,        5},
  61.     {    " Quit ",    "Leave the program",        NULL,     NULL,      QUIT},
  62.     {   NULL,         "Main Menu",                  NULL,     NULL,         0}
  63. };
  64.  
  65. /* list for pop_Menu */
  66. static char *dir[] = {
  67.     "Horizontal",
  68.     "Vertical", 
  69.     NULL
  70. };
  71.  
  72. void main()
  73. {
  74.     sed_type slug;
  75.     int row, col;
  76.  
  77.     /* Initialize the display */
  78.     disp_Init(def_ModeText, NULL);
  79.  
  80.     switch (pop_Menu("Select menu direction", dir, -1, -1, -1, -1, '\x70', 0, bd_title)) {
  81.     case 1:
  82.         slug = slug_Open(main_menu,    SLUG_HORIZONTAL, bd_123, '\x07', '\x70', '\x07');
  83.         row = 0;
  84.         col = 0;
  85.         /* Paint the menu bar first */
  86.         slug_Repaint(slug, row, col);
  87.         break;
  88.     case 2:
  89.         slug = slug_Open(main_menu, SLUG_VERTICAL, bd_std, '\x70', '\x07', '\x70');
  90.         row = 5;
  91.         col = 20;
  92.         break;
  93.     default:
  94.         return;
  95.     }
  96.  
  97.     slug_Go(slug, 0, row, col, NULL);
  98.     slug_Close(slug);
  99.  
  100.     /* Close down the display interface */
  101.     disp_Close();
  102. }
  103.  
  104. int empty(sdata, idata)
  105.     VOID *sdata;
  106.     int idata;
  107. /*
  108.     A user supplied function...
  109. */
  110. {
  111.     char msg[80];
  112.  
  113.     sprintf(msg, "This is message number %d\n", idata);
  114.  
  115.     pop_Prompt(msg, -1, -1, -1, -1, '\x70', bd_2);
  116.  
  117.     /* return 0 to return to menuing system */
  118.     /* return positive value to exit menuing system */
  119.  
  120.     return(0);
  121. }
  122.