home *** CD-ROM | disk | FTP | other *** search
- /*
- demoslug.c
-
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Example using the slug menuing system.
-
- In this example the user is asked whether to build a vertical
- (ala Look & Feel) menu or a horizontal (123-type) menu.
-
- All of the menu choices call the function 'empty' defined below.
- */
-
- #include <stdio.h>
-
- #include <cscape.h>
- #include <popdecl.h>
- #include <slug.h>
-
- /*** Note: C-scape uses the _arg macro to turn off prototyping
- for older compilers */
-
- int empty(_arg2(VOID *, int));
-
- struct slug_list dbv_menu[] = { /* note: values must be positive */
-
- { " Insert ", "Insert a record", NULL, empty, 20 },
- { " Delete ", "Delete a record", NULL, empty, 23 },
- { " Next ", "Display next record", NULL, empty, 24 },
- { " Previous ", "Display previous record",NULL, empty, 25 },
- { " Locate ", "Locate record", NULL, empty, 26 },
- { " Sort ", "Sort records", NULL, empty, 27 },
- { " Output ", "List data records", NULL, empty, 28 },
- { NULL, "Block Menu", NULL, NULL, 0 }
- };
-
- struct slug_list block_menu[] = {
-
- { " Copy ", "Copy block to buffer", NULL, empty, 22 },
- { " Delete ", "Delete block", NULL, empty, 23 },
- { " Move ", "Move block", NULL, empty, 25 },
- { " Paste ", "Paste buffer", NULL, empty, 26 },
- { " Fill ", "Fill block", NULL, empty, 27 },
- { " Attribute ", "Colour block", NULL, empty, 28 },
- { " DataBase? ", "Access data base", dbv_menu, empty, 20 },
- { NULL, "Block Menu", NULL, NULL, 0 }
- };
-
- #define QUIT 6
-
- struct slug_list main_menu[] = {
-
- { " Block ", "Block functions", block_menu, NULL, 1},
- { " Characters ", "Character set", NULL, empty, 2},
- { " Disk ", "Disk functions", NULL, empty, 4},
- { " Erase ", "Clear entire screen", NULL, empty, 8},
- { " Field ", "Field functions", NULL, empty, 3},
- { " Lines ", "Line drawing (^L)", NULL, empty, 7},
- { " Set up ", "Set global data", NULL, empty, 5},
- { " Quit ", "Leave the program", NULL, NULL, QUIT},
- { NULL, "Main Menu", NULL, NULL, 0}
- };
-
- /* list for pop_Menu */
- static char *dir[] = {
- "Horizontal",
- "Vertical",
- NULL
- };
-
- void main()
- {
- sed_type slug;
- int row, col;
-
- /* Initialize the display */
- disp_Init(def_ModeText, NULL);
-
- switch (pop_Menu("Select menu direction", dir, -1, -1, -1, -1, '\x70', 0, bd_title)) {
- case 1:
- slug = slug_Open(main_menu, SLUG_HORIZONTAL, bd_123, '\x07', '\x70', '\x07');
- row = 0;
- col = 0;
- /* Paint the menu bar first */
- slug_Repaint(slug, row, col);
- break;
- case 2:
- slug = slug_Open(main_menu, SLUG_VERTICAL, bd_std, '\x70', '\x07', '\x70');
- row = 5;
- col = 20;
- break;
- default:
- return;
- }
-
- slug_Go(slug, 0, row, col, NULL);
- slug_Close(slug);
-
- /* Close down the display interface */
- disp_Close();
- }
-
- int empty(sdata, idata)
- VOID *sdata;
- int idata;
- /*
- A user supplied function...
- */
- {
- char msg[80];
-
- sprintf(msg, "This is message number %d\n", idata);
-
- pop_Prompt(msg, -1, -1, -1, -1, '\x70', bd_2);
-
- /* return 0 to return to menuing system */
- /* return positive value to exit menuing system */
-
- return(0);
- }
-