home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
GUILIB.ZIP
/
EXAM2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-27
|
7KB
|
208 lines
/*****************************************************************************
* PLAIN DESIGN INC COPYRIGHT (C) 1992 *
* MENU EXAMPLE2 *
* *
* BORLANDC : bcc -DBORLAND exam2.c menu.c *
* MSC : cl -DMSC -qc -F 2710 exam2.c menu.c *
* POWERC : pc -c -e exam2.c menu.c *
******************************************************************************
THIS EXAMPLE DEMONSTRATES A COMPLEX MENU SYSTEM
*****************************************************************************/
#include "stdio.h"
#include "menu.h"
/*--------------------------------------------*/
/* set the stack to 10k for borland compilers */
/*--------------------------------------------*/
extern _stklen=15000;
extern _heaplen=10000;
/*--------------------------------------------*/
void set_menu_colors(int);
void reset_colors(void);
void set_new_colors(void);
void Ellipse10(int,int,int,int,int);
void main(int argc, char *argv[])
{
int ch;
char buffer[100];
int i;
if(strnicmp(argv[1],"GRAPHICS",3)==0)set_video_mode(18);
set_video_mode(18);
initdisplay(); /* initilize display and the mouse */
/* turn of text cursor */
txt_curs(OFF);
frect_char(1); /* change the back_block for frect */
frect(0,0,txt_scr_xsize-1,txt_scr_ysize-1,0x47,0);
frect_char(' '); /* change back_block back to SPACE */
show_mouse_cursor();
ch_menu_filename("MENUFILE.2");
bar_menu(INIT); /* initialize the bar_menu function */
for(i=2;i<220;i+=6)
{
Ellipse10(320,240,i+((220-i)),i,0);
Ellipse10(320,240,i,i+((220-i)),0);
delay(100);
}
/*-----------------------------------------------------------------------*/
/* main loop of the program */
/*-----------------------------------------------------------------------*/
while(1)
{ ch=bar_menu(KEY_RETURN);
if(ch==ESC || ch==1200 || ch==1009)
{ break;
}
if(ch>=10000 && ch<=11315)
{ set_menu_colors(ch);
continue;
}
switch(ch)
{ case 1001 :
case 1002 :
case 1003 :
case 1004 :
case 1005 :
case 1006 :
case 1100 :
case 1101 :
case 1102 :
case 1103 :
case 1104 :
case 1301 :
case 1302 :
case 1303 :
messagebox(23,7,34,9,0x31,0x08,ON,YES);
pls(27,11,"FEATURE IS NOT IMPLEMENTED",0x30);
pls(24,14,"press any key to continue ..",0x30);
while(getkey()==EOF && mouse_left_pressed()==NO);
messagebox(23,7,34,9,0x31,0x08,OFF,YES);
break;
case 1007 :
reset_colors();
break;
case 1008 :
set_new_colors();
break;
case 1010 :
/* about display */
messagebox(20,7,40,9,0x27,0x08,ON,YES);
pls(26,11," PLAIN DESIGN MENU EXAMPLE ",0x21);
pls(36,13,"VER 1.0",0x21);
while(getkey()==EOF && mouse_left_pressed()==NO);
messagebox(20,7,40,9,0x27,0x08,OFF,YES);
break;
}
if(ch!=EOF)
{ frect(15,22,64,24,0x57,0);
rect(15,22,64,24,0x57);
sprintf(buffer,"menu_bar returned %d",ch);
pls(25,23,buffer,0x50);
}
}
/*-----------------------------------------------------------------------*/
hide_mouse_cursor();
txt_curs(ON);
}
/*--------------------------------------------------------------------------*/
void set_menu_colors(int ch)
{
/*--------------------------------------*/
/* menu rectangle back ground color */
/*--------------------------------------*/
if(ch>=10000 && ch<=10007) bg_menu_color( (ch-(ch/100)*100)<<4 );
/*--------------------------------------*/
/*--------------------------------------*/
/* menu hotkey back ground color */
/*--------------------------------------*/
if(ch>=10100 && ch<=10107) bg_menu_hotkey_color((ch-(ch/100)*100)<<4 );
/*--------------------------------------*/
/*--------------------------------------*/
/* highlighted entry back ground color */
/*--------------------------------------*/
if(ch>=10200 && ch<=10207) bg_menu_sel_color((ch-(ch/100)*100)<<4);
/*--------------------------------------*/
/*--------------------------------------*/
/* menu rectangle background color */
/*--------------------------------------*/
if(ch>=10300 && ch<=10307) bg_menu_shadow( (ch-(ch/100)*100)<<4 );
/*--------------------------------------*/
/*--------------------------------------*/
/* menu rectangle forground color */
/*--------------------------------------*/
if(ch>=11000 && ch<=11015) fg_menu_color(ch-(ch/100)*100);
/*--------------------------------------*/
/*--------------------------------------*/
/* menu hotkey forground color */
/*--------------------------------------*/
if(ch>=11100 && ch<=11115) fg_menu_hotkey_color( ch-(ch/100)*100);
/*--------------------------------------*/
/*--------------------------------------*/
/* highlighted entry forground color */
/*--------------------------------------*/
if(ch>=11200 && ch<=11215) fg_menu_sel_color(ch-(ch/100)*100 );
/*--------------------------------------*/
/*--------------------------------------*/
/* menu rectangle forground color */
/*--------------------------------------*/
if(ch>=11300 && ch<=11315) fg_menu_shadow( ch-(ch/100)*100);
/*--------------------------------------*/
bar_menu(DISPLAY);
}
/*--------------------------------------------------------------------------*/
void reset_colors(void)
{
bg_menu_color(BK_WHITE);
fg_menu_color(FG_BLACK);
bg_menu_hotkey_color(BK_WHITE);
fg_menu_hotkey_color(FG_RED);
bg_menu_sel_color(BK_RED);
fg_menu_sel_color(FG_WHITE);
bg_menu_shadow(BK_BLACK);
fg_menu_shadow(FG_GRAY);
bar_menu(DISPLAY);
}
/*--------------------------------------------------------------------------*/
void set_new_colors(void)
{
bg_menu_color(BK_CYAN);
fg_menu_color(FG_BLACK);
bg_menu_hotkey_color(BK_CYAN);
fg_menu_hotkey_color(FG_WHITE);
bg_menu_sel_color(BK_BLUE);
fg_menu_sel_color(FG_BRIGHT_WHITE);
bg_menu_shadow(BK_BLACK);
fg_menu_shadow(FG_GRAY);
bar_menu(DISPLAY);
}
/*--------------------------------------------------------------------------*/