home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 337_01 / popdemo.c < prev    next >
C/C++ Source or Header  |  1991-01-14  |  3KB  |  131 lines

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3. /**********************  POPDEMO.C  ***************************/
  4.  
  5. /* demonstrates the use of pop-up menus */
  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()
  21. {
  22. extern struct screen_structure scr;
  23. extern struct window_structure w[];
  24.  
  25. int i;
  26. char string[MAX_STRING];
  27.  
  28.  /* set up menu structure */
  29.  
  30.  struct pop_struc pop_menu [6]={
  31. /*  *name   (*fun)()  select_id  */
  32.     " Sort   " ,fake,   0,
  33.     " Print  " ,prtdemo,0,
  34.     " Delete " ,fake,   0,
  35.     " Copy   " ,fake,   0,
  36.     " Quit   " ,NULL,   1,  /* returns a 1 when selected */
  37.     "\0"      /* mark the end of the options list */
  38.  };
  39.  
  40.  
  41. cls();
  42.  
  43. /* fill the screen with dots '.'*/
  44. /* make up a string of '.' wide enough to fill each row */
  45.  
  46.   for(i=0;i<scr.columns;i++) string[i]='.';  /* build the string */
  47.   string[i]= '\0';                           /* terminate it */
  48.  
  49. /* now fill each row of the screen with the string of '.' */
  50.  
  51.   for (i=1;i<=scr.rows;i++) print(1,i,string);
  52.  
  53. /* create the pop-up menu */
  54. return (pop_up (pop_menu,33,10,scr.normal,scr.inverse));
  55.         /* pop-up appears at column,row 33,10 */
  56.  
  57. }  /* end of start(); */
  58.  
  59.  
  60. int prtdemo()
  61. {
  62. extern struct screen_structure scr;
  63. extern struct window_structure w[];
  64.  
  65. int return_code;
  66.  
  67.  /* set up menu structure */
  68.  
  69.  struct pop_struc pop_menu [3]={
  70.  
  71. /*  *name        (*fun)()  select_id  */
  72.  " Printer   "  ,printer,  0,
  73.  " Text-file  " ,text,     0,
  74.  "\0"      /* mark the end of the options list */
  75.  };
  76.  
  77. /* call routine to handle menu */
  78. return_code= (pop_up (pop_menu,41,13,scr.normal,scr.inverse));   
  79.              /* pop-up appears at column-row */
  80.              /* 41,13 */
  81.  
  82. /* we could examine return_code here if necessary */
  83.  
  84. return(0); /* return a zero so the parent menu does not close */
  85. }
  86.  
  87.  
  88. int printer()
  89. {
  90. extern struct screen_structure scr;
  91. extern struct window_structure w[];
  92.  
  93.  /* set up menu structure */
  94.  
  95.  struct pop_struc pop_menu [3]={
  96.  
  97. /*  *name        (*fun)()  select_id  */
  98.   " Lpt1:   ",   lpt1,     0,
  99.   " lPt2:  " ,   lpt2,     0,
  100.   "\0"      /* mark the end of the options list */
  101.  };
  102.  
  103. /* call routine to handle menu */
  104. return (pop_up (pop_menu,53,15,scr.normal,scr.inverse));   
  105.         /* pop-up appears at column-row 53,15 */
  106. }
  107.  
  108.  
  109. int lpt1(void)
  110. {
  111. return(1);  /* return a non-zero number to close menu */
  112. }
  113.  
  114.  
  115. int lpt2(void)
  116. {
  117. return(1);  /* return a non-zero number to close menu */
  118. }
  119.  
  120.  
  121. int text(void)
  122. {
  123. return(1);  /* return a non-zero number to close menu */
  124. }
  125.  
  126.  
  127. int fake(void)
  128. {
  129. return(0);  /* return a zero so the menu does not close */
  130. }
  131.