**********************************
* this file is the head file
* file directory:
* .../tc/include/menu.h
*
**********************************/
#ifndef MENU
#define MENU
#include<graphics.h>
#include<bios.h>
#include<alloc.h>
#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define F1 0x3B00
#define F10 0x4400
#define LEFT 0x4B00
#define RIGHT 0x4D00
#define UP 0x4800
#define DOWN 0x5000
#define ESC 0x011B
#define ENTER 0x1C0D
#define ALT_X 0x2D00
#define MAIN_MENU_NUM 8
void initwindow(void); /* initwindow function's declartion */
void initgraphics(void); /* init graph system */
void welcome(void);
void drawbox(int x1,int y1,int x2,int y2);
void cursor(int x,int y);
void help_fun(void);
void process_main_move(int old_menu,int new_menu); /* ? */
void main_menu_move(void);
void process_down(int down_menu);
void draw_sub_box(int x1,int y1,int x2,int y2,int count);/* ? */
void write_sub_menu(int x1,int y1,int x2,int y2,int count,char *menu[]);
void process_sub_menu(int x,int y,int count,int flag,char* menu[]);
void process_sub_move(int x,int y,int old_menu,int new_menu,char*menu[]);
void process(int new_menu,int count);
void exit_info(void);
char *main_menu[8]={ " File" ,
" Edit" ,
" Run" ,
"Compile" ,
"Project",
"Options",
" Debug",
"Break/Watch"
};
char *sub_menu1[9]={ "Load F3",
"Pick Alt-F3",
"New ",
"Save F2",
"Write to ",
"Director ",
"Change dir ",
"Os shell ",
"Quit Alt-X"
};
char *sub_menu2[0]={ "'\0'" };
char *sub_menu3[6]={ "Run Ctrl-F9",
"Program reset Ctrl-F2",
"Go to cursor F4",
"Trace into F7",
"Step over F8",
"User screen Alt-F5",
};
char *sub_menu4[6]={ "Compile to OBJ D:noname.obj",
"Make EXE file D:noname.exe",
"Link EXE file ",
"Bulid all ",
"Primary C file: ",
"Get info ",
};
char *sub_menu5[5]={ "Project name ",
"Break make on Errors",
"Auto dependence Off ",
"Clear project ",
"Remove message ",
};
char *sub_menu6[7]={ "Compiler ",
"Linker ",
"Enviromeny ",
"Directories ",
"Arguments ",
"Save options ",
"Retrieve options ",
};
char *sub_menu7[6]={ "Evaluate Ctrl-F4 ",
"Call stack Ctrl-F3 ",
"Find function ",
"Refresh dispaly ",
"Dispaly swapping Smart ",
"Source debbuging on ",
};
char *sub_menu8[7]={ "Add watch Ctrl-F7",
"Delete watch ",
"Edit wathch ",
"Remove all watches ",
"Toggle breakpoint Ctrl-F8",
"Clear all breakpoint ",
"View nexe breakpoint ",
};
int width,height;
void *buf;
#endif
/* finished head file */
/* : ) */
/**************** mymenu.c *******
* all function finished in there
* file directory:
* .../tc/lib/mymenu.c
*
*********************************/
void initgraphics(void)
{
int gm=DETECT,gd; /* model 640 X 480 */
initgraph(&gm,&gd,"c:\\turboc2");
}
void drawbox(int x1,int y1,int x2,int y2)
{
rectangle(x1,y1,x2,y2);
return;
}
void cursor(int x,int y)
{
int i;
for(i=1;kbhit()==0;i++)
{
setcolor(BLUE);
line(x,y,x+10,y);
line(x,y+1,x+10,y+1);
delay(30000);
setcolor(WHITE);
line(x,y,x+10,y);
line(x,y+1,x+10,y+1);
delay(30000);
}
setcolor(BLUE);
line(x,y,x+20,y);
line(x,y+1,x+20,y+1);
}
void initwindow(void)
{
int i=0;
int x1=0,x2=0,y1=0,y2=0;
width=70;
height=20;
initgraphics();
y1=width;
y2=height;
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(0,0,639,20);
setcolor(LIGHTGRAY);
drawbox(x1,x2,y1,y2);
setcolor(WHITE);
settextstyle(0,HORIZ_DIR,1);
outtextxy(x1+15,x2+5,main_menu[0]);
x1=y1;
y1=y1+width;
for(i=1;i<MAIN_MENU_NUM;i++)
{
setcolor(LIGHTGRAY);
drawbox(x1,x2,y1,y2);
settextstyle(0,HORIZ_DIR,1);
setcolor(BLACK);
outtextxy(x1+15,x2+5,main_menu[i]);
x1=y1;
y1=y1+width;
}
setfillstyle(SOLID_FILL,BLUE);
bar(0,20,639,460);
setcolor(WHITE);
line(0,25,300,25);/*heng line 1*/
line(0,28,300,28);/*heng line 2*/
outtextxy(305,24," Edit");
line(352,25,635,25);/*heng line 3*/
line(352,28,635,28);/*heng line 4*/
line(0,25,0,453);/*shu line left 1*/
line(0,453,635,453);/*heng line 5*/
line(635,25,635,453);/*shu line 2*/
line(0,415,300,415);/*heng line 6*/
outtextxy(305,410," Watch");
line(360,415,635,415);/*heng line 7*/
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(0,460,639,479);
setcolor(BLACK);
settextstyle(0,HORIZ_DIR,1);
outtextxy(5,467," -Help -Zoom -Switch -Trace -Step"
" -Make -Menu");
setcolor(RED);
outtextxy(5,467," F1 F5 F6 F7"
" F8 F9 F10");
setfillstyle(SOLID_FILL,BLUE);
bar(570,460 ,610,480);
setcolor(WHITE);
outtextxy(580,465,"NUM");
return;
}
void welcome(void)
{
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(150,150,450,350);
settextstyle(0,HORIZ_DIR,1);
setcolor(RED);
outtextxy(170,200,"welcome to enter my menu system");
outtextxy(200,220,"F1 key help information");
outtextxy(230,250,"author:zhangmou");
outtextxy(220,300,"time:12/10/2004");
setcolor(BLACK);
drawbox(160,160,440,340);
getch();
setfillstyle(SOLID_FILL,BLUE);
bar(150,150,450,350);
}
void help_fun(void)
{
/*setcolor(BLACK);
settextstyle(0,HORIZ_DIR,1);
outtextxy(15,5," File");*/
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(100,100,500,400);
setcolor(BLACK);
drawbox(120,120,480,380);
outtextxy(200,140," help information ");
outtextxy(200,170,"Thank you use my system");
outtextxy(200,190,"F1 help ");
outtextxy(200,200,"F10 return menu");
outtextxy(200,210,"UP /\\ ");
outtextxy(200,220,"DOWN \\/ ");
outtextxy(200,230,"RIGHT -> ");
outtextxy(200,240,"LEFT <- ");
outtextxy(200,250,"ALT_X exit.");
outtextxy(200,270,"press any to exit help!");
getch();
setfillstyle(SOLID_FILL,BLUE);
bar(100,100,500,400);
return;
}
void process_main_move(int old_menu,int new_menu)
{
int x1=0,x2=0;
x1=width*old_menu;
settextstyle(0,HORIZ_DIR,1);
setcolor(BLACK);
outtextxy(x1+15,x2+5,main_menu[old_menu]);
x1=width*new_menu;
setcolor(WHITE);
outtextxy(x1+15,x2+5,main_menu[new_menu]);
return ;
}
void main_menu_move(void)
{
int old_menu=0,new_menu=0;
int head=0,tail=7;
int key=0;
int quit=0;
initwindow();
welcome();
while(!quit)
{
while(bioskey(1)==0);
key=bioskey(0);
switch(key)
{
case F1:
help_fun();
break;
case F10:
old_menu=new_menu;
new_menu=0;
process_main_move(old_menu,new_menu);
break;
case LEFT:
if(new_menu==head)
{
old_menu=new_menu;
new_menu=tail;
}
else
{
old_menu=new_menu;
new_menu=new_menu-1;
}
process_main_move(old_menu,new_menu);
break;
case RIGHT:
if(new_menu==tail)
{
old_menu=new_menu;
new_menu=head;
}
else