home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
EXAMPLES
/
DEMOSLUG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-09
|
4KB
|
161 lines
/*
demoslug.c
C-scape 3.2 Example Program
Copyright (c) 1988, 1990 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 the menu choices call the function 'empty' defined below.
Revision History:
-----------------
4/01/90 jmd ansi-fied
5/18/90 jmd converted a NULL to FNULL
6/06/90 jmd changed main to return an int
9/14/90 bkd changed to use exit(0) instead of return(0).
10/19/90 pmcm included ostdlib.h for exit(), added return(1)
12/01/90 ted added oak_notused() macro to suppress warnings.
12/01/90 ted prototyped main, except if Turbo C++.
12/01/90 ted added disp_Close in default case.
12/04/90 ted restored "" includes for C-scape headers (not <> includes).
*/
#include <stdio.h>
#include "cscape.h"
#include "ostdlib.h" /* for exit() */
#include "popdecl.h"
#include "slug.h"
/*** Function prototypes ***/
/* Turbo C++ complains if main is prototyped */
#ifndef TCP
int main(void);
#endif
int empty(VOID *sdata, int idata);
/* slug menu definition */
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, "Database Menu", NULL, FNULL, 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, FNULL, 0 }
};
#define QUIT 6
struct slug_list main_menu[] = {
{ " Block ", "Block functions", block_menu, FNULL, 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, FNULL, QUIT},
{ NULL, "Main Menu", NULL, FNULL, 0}
};
/* list for pop_Menu */
static char *dir[] = {
"Horizontal",
"Vertical",
NULL
};
int main(void)
{
sed_type slug;
int row, col;
/* Initialize the display */
disp_Init(def_ModeText, FNULL);
/* Turn on the mouse */
if (!hard_InitMouse()) {
pop_Prompt("Mouse driver not found!", -1, -1, -1, 25, 0x70, bd_prompt);
}
else {
/* Turn on sedwin mouse, link in mouse border support */
/* You must call this if you want to use mouse borders */
/* You can ignore this call if you do not want to use mouse borders */
sedwin_ClassInit();
}
switch (pop_Menu("Select menu direction", dir, -1, -1, -1, -1, 0x70, 0, bd_title)) {
case 1:
slug = slug_Open(main_menu, SLUG_HORIZONTAL, bd_123, 0x07, 0x70, 0x07);
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, 0x70, 0x07, 0x70);
row = 5;
col = 20;
break;
default:
/* Close down the display interface */
disp_Close();
exit(0);
return(0);
}
slug_Go(slug, 0, row, col, NULL);
slug_Close(slug);
/* Close down the display interface */
disp_Close();
exit(0);
return(0);
}
int empty(VOID *sdata, int idata)
/*
A user supplied function...
*/
{
char msg[80];
oak_notused(sdata);
sprintf(msg, "This is message number %d\n", idata);
pop_Prompt(msg, -1, -1, -1, -1, 0x70, bd_2);
/* return 0 to return to menuing system */
/* return positive value to exit menuing system */
return(0);
}