home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / DSIIC2.ZIP / BARDEMO.C next >
C/C++ Source or Header  |  1991-07-15  |  3KB  |  127 lines

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3. /**********************   BARDEMO.C   ***************************/
  4.  
  5. /* Demonstration of a un-stacked horizontal moving light bar menu.*/
  6.  
  7. #include "mydef.h"
  8. #include "stdio.h"
  9.  
  10. /* function prototypes */
  11.  
  12. int fake(void);
  13. int prtdemo(void);
  14. int printer(void);
  15. int lpt1(void);
  16. int lpt2(void);
  17. int text(void);
  18.  
  19.  
  20. int start(int argc, char *argv[])
  21. {
  22. extern struct screen_structure scr;
  23. extern struct window_structure w[];
  24.  
  25. int win1;
  26. int return_code;
  27.  
  28.  struct bar_struc main_menu [6]={
  29.  
  30.  /* *name      *info                        (*fun)()   select_id */
  31.  
  32.    "Sort",     "Sort the data file",        fake,      0,
  33.    "Print",    "Printer, Text-file" ,       prtdemo,   0,
  34.    "Delete",   "Delete current data file",  fake,      0,
  35.    "Copy",     "Copy data file to backup",  fake,      0,
  36.    "Quit",     "Quit and return to DOS",    NULL,      1,
  37.    "\0"      /* mark the end of the options list */
  38.   };
  39.  
  40.  cls();
  41.  
  42.  /* make a window for the bar menu */
  43.  win1=win_make(2,2,scr.columns-2,2,STD_FRAME,"",
  44.               scr.current,scr.current);
  45.  
  46.  /* call the bar menu*/
  47.  
  48.  return_code= bar_menu(main_menu,scr.normal,scr.inverse);
  49.  
  50.  win_delete(win1);  /* delete window */
  51.  return(return_code);  /* pass along the return code */
  52. }
  53.  
  54.  
  55. int prtdemo(void)
  56. {
  57. extern struct screen_structure scr;
  58. extern struct window_structure w[];
  59.  
  60. int win1;
  61. int return_code;
  62.  
  63.  /* set up new menu */
  64.  struct bar_struc main_menu [3]={
  65.  
  66.   /*
  67.   *name        *info                         (*fun)()  select_id */
  68.   "Printer",   "Lpt1:, Lpt2:",               printer,  0,
  69.   "Text-file", "Send output to a text file", text,     0,
  70.   "\0"      /* mark the end of the options list */
  71.  };
  72.  
  73.  cls();  /* clear the existing menu window */
  74.  return_code= bar_menu(main_menu,scr.normal,scr.inverse);
  75.  
  76.  return(0); /* return a zero instead of "return_code"
  77.                so previous menu remains open
  78.                so we don't close the main menu */
  79. }
  80.  
  81.  
  82. int printer(void)
  83. {
  84. extern struct  screen_structure scr;
  85. extern struct window_structure w[];
  86.  
  87. int win1;
  88. int return_code;
  89.  
  90.  
  91.  struct bar_struc main_menu [3]={
  92.  
  93.  /*
  94.   *name       *info                                  (*fun)()  id */
  95.  
  96.   "Lpt1:",   "Route output to printer on port lpt1:", lpt1,     0,
  97.   "lPt2:",   "Route output to printer on port lpt2:", lpt2,     0,
  98.   "\0"       /* mark the end of the options list */
  99.  };
  100.  
  101. cls();  /* clear the existing menu window */
  102.  
  103. return(bar_menu(main_menu,scr.normal,scr.inverse));
  104.  
  105. }
  106.  
  107.  
  108. int lpt1(void)
  109. {
  110. return(1);  /* return a non-zero number so that menu closes down */
  111. }
  112.  
  113. int lpt2(void)
  114. {
  115. return(1);  /* send back a non-zero number to close the menu */
  116. }
  117.  
  118. int text(void)
  119. {
  120. return(1);  /* send back a non-zero number to close the menu */
  121. }
  122.  
  123. int fake(void)
  124. {
  125. return(0);  /* send back a zero and keep the menu open */
  126. }
  127.