home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / GUILIB.ZIP / EXAM2.C < prev    next >
C/C++ Source or Header  |  1992-11-27  |  7KB  |  208 lines

  1. /*****************************************************************************
  2. *   PLAIN DESIGN INC COPYRIGHT (C)   1992                                    *
  3. *   MENU EXAMPLE2                                                            *
  4. *                                                                            *
  5. *   BORLANDC :             bcc -DBORLAND exam2.c menu.c                                *
  6. *   MSC      :             cl -DMSC -qc -F 2710 exam2.c menu.c                *
  7. *   POWERC   :             pc -c -e exam2.c menu.c                           *
  8.  
  9. ******************************************************************************
  10.               THIS EXAMPLE DEMONSTRATES A COMPLEX MENU SYSTEM
  11. *****************************************************************************/
  12. #include "stdio.h"
  13. #include "menu.h"
  14.  
  15. /*--------------------------------------------*/
  16. /* set the stack to 10k for borland compilers */
  17. /*--------------------------------------------*/
  18.  
  19. extern _stklen=15000;
  20. extern _heaplen=10000;
  21.  
  22. /*--------------------------------------------*/
  23.  
  24. void set_menu_colors(int);
  25. void reset_colors(void);
  26. void set_new_colors(void);
  27.  
  28. void Ellipse10(int,int,int,int,int);
  29.  
  30. void main(int argc, char *argv[])
  31. {
  32.   int  ch;
  33.   char buffer[100];
  34.   int  i;
  35.  
  36.   if(strnicmp(argv[1],"GRAPHICS",3)==0)set_video_mode(18);
  37.  
  38.  
  39.   set_video_mode(18);
  40.   
  41.   initdisplay();            /* initilize display and the mouse  */
  42.                             /* turn of text cursor */
  43.   txt_curs(OFF);
  44.  
  45.   frect_char(1);             /* change the back_block for frect */
  46.   frect(0,0,txt_scr_xsize-1,txt_scr_ysize-1,0x47,0);
  47.   frect_char(' ');         /* change back_block back to SPACE */
  48.  
  49.  
  50.   show_mouse_cursor();
  51.   ch_menu_filename("MENUFILE.2");
  52.   bar_menu(INIT);           /* initialize the bar_menu function */
  53.  
  54.   for(i=2;i<220;i+=6)
  55.   {
  56.     Ellipse10(320,240,i+((220-i)),i,0);
  57.     Ellipse10(320,240,i,i+((220-i)),0);
  58.     delay(100);
  59.   }
  60.   /*-----------------------------------------------------------------------*/
  61.   /* main loop of the program                                              */
  62.   /*-----------------------------------------------------------------------*/
  63.   while(1)
  64.   { ch=bar_menu(KEY_RETURN);
  65.  
  66.     if(ch==ESC || ch==1200 || ch==1009)
  67.     { break;
  68.     }
  69.     if(ch>=10000 && ch<=11315)
  70.     { set_menu_colors(ch);
  71.       continue;
  72.     }
  73.     switch(ch)
  74.     { case 1001 :
  75.       case 1002 :
  76.       case 1003 :
  77.       case 1004 :
  78.       case 1005 :
  79.       case 1006 :
  80.       case 1100 :
  81.       case 1101 :
  82.       case 1102 :
  83.       case 1103 :
  84.       case 1104 :
  85.       case 1301 :
  86.       case 1302 :
  87.       case 1303 :
  88.        messagebox(23,7,34,9,0x31,0x08,ON,YES);
  89.        pls(27,11,"FEATURE IS NOT IMPLEMENTED",0x30);
  90.        pls(24,14,"press any key to continue ..",0x30);
  91.  
  92.        while(getkey()==EOF && mouse_left_pressed()==NO);
  93.        messagebox(23,7,34,9,0x31,0x08,OFF,YES);
  94.        break;
  95.       case 1007 :
  96.        reset_colors();
  97.        break;
  98.       case 1008 :
  99.        set_new_colors();
  100.        break;
  101.       case 1010 :
  102.        /* about display */
  103.        messagebox(20,7,40,9,0x27,0x08,ON,YES);
  104.        pls(26,11," PLAIN DESIGN MENU EXAMPLE ",0x21);
  105.        pls(36,13,"VER 1.0",0x21);
  106.        while(getkey()==EOF && mouse_left_pressed()==NO);
  107.        messagebox(20,7,40,9,0x27,0x08,OFF,YES);
  108.        break;
  109.       
  110.     }
  111.     if(ch!=EOF)
  112.     { frect(15,22,64,24,0x57,0);
  113.       rect(15,22,64,24,0x57);
  114.       sprintf(buffer,"menu_bar returned  %d",ch);
  115.       pls(25,23,buffer,0x50);
  116.     }
  117.   }
  118.   /*-----------------------------------------------------------------------*/
  119.  
  120.   hide_mouse_cursor();
  121.   txt_curs(ON);
  122. }
  123. /*--------------------------------------------------------------------------*/
  124. void set_menu_colors(int ch)
  125. {
  126.  
  127.  
  128.    /*--------------------------------------*/
  129.    /*   menu rectangle back ground color   */
  130.    /*--------------------------------------*/
  131.    if(ch>=10000 && ch<=10007) bg_menu_color( (ch-(ch/100)*100)<<4 );
  132.    /*--------------------------------------*/
  133.  
  134.    /*--------------------------------------*/
  135.    /*   menu hotkey  back ground color     */
  136.    /*--------------------------------------*/
  137.    if(ch>=10100 && ch<=10107) bg_menu_hotkey_color((ch-(ch/100)*100)<<4 );
  138.    /*--------------------------------------*/
  139.  
  140.    /*--------------------------------------*/
  141.    /* highlighted entry back ground color  */
  142.    /*--------------------------------------*/
  143.    if(ch>=10200 && ch<=10207) bg_menu_sel_color((ch-(ch/100)*100)<<4);
  144.    /*--------------------------------------*/
  145.  
  146.    /*--------------------------------------*/
  147.    /*   menu rectangle background color    */
  148.    /*--------------------------------------*/
  149.    if(ch>=10300 && ch<=10307) bg_menu_shadow( (ch-(ch/100)*100)<<4 );
  150.    /*--------------------------------------*/
  151.  
  152.    
  153.  
  154.    /*--------------------------------------*/
  155.    /*   menu rectangle  forground color    */
  156.    /*--------------------------------------*/
  157.    if(ch>=11000 && ch<=11015) fg_menu_color(ch-(ch/100)*100);
  158.    /*--------------------------------------*/
  159.  
  160.    /*--------------------------------------*/
  161.    /*   menu hotkey   forground color      */
  162.    /*--------------------------------------*/
  163.    if(ch>=11100 && ch<=11115) fg_menu_hotkey_color( ch-(ch/100)*100);
  164.    /*--------------------------------------*/
  165.  
  166.    /*--------------------------------------*/
  167.    /* highlighted entry  forground color   */
  168.    /*--------------------------------------*/
  169.    if(ch>=11200 && ch<=11215) fg_menu_sel_color(ch-(ch/100)*100 );
  170.    /*--------------------------------------*/
  171.  
  172.    /*--------------------------------------*/
  173.    /*   menu rectangle  forground color     */
  174.    /*--------------------------------------*/
  175.    if(ch>=11300 && ch<=11315) fg_menu_shadow( ch-(ch/100)*100);
  176.    /*--------------------------------------*/
  177.  
  178.    bar_menu(DISPLAY);
  179.  
  180. }
  181. /*--------------------------------------------------------------------------*/
  182. void reset_colors(void)
  183. {
  184.   bg_menu_color(BK_WHITE);
  185.   fg_menu_color(FG_BLACK);
  186.   bg_menu_hotkey_color(BK_WHITE);
  187.   fg_menu_hotkey_color(FG_RED);
  188.   bg_menu_sel_color(BK_RED);
  189.   fg_menu_sel_color(FG_WHITE);
  190.   bg_menu_shadow(BK_BLACK);
  191.   fg_menu_shadow(FG_GRAY);
  192.   bar_menu(DISPLAY);
  193. }
  194. /*--------------------------------------------------------------------------*/
  195. void    set_new_colors(void)
  196. {
  197.   bg_menu_color(BK_CYAN);
  198.   fg_menu_color(FG_BLACK);
  199.   bg_menu_hotkey_color(BK_CYAN);
  200.   fg_menu_hotkey_color(FG_WHITE);
  201.   bg_menu_sel_color(BK_BLUE);
  202.   fg_menu_sel_color(FG_BRIGHT_WHITE);
  203.   bg_menu_shadow(BK_BLACK);
  204.   fg_menu_shadow(FG_GRAY);
  205.   bar_menu(DISPLAY);
  206. }
  207. /*--------------------------------------------------------------------------*/
  208.