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

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3.  
  4. /**********************   PD-DEMO.C   ***************************/
  5.  
  6.  
  7. /* Link with pd.c and library */
  8.  
  9. #include "mydef.h"
  10. #include <stdio.h>
  11. #include <ctype.h>
  12. #include <dos.h>
  13. #include <stdlib.h>
  14.  
  15. /* the number of main options is defined in mydef.h as MAIN_OPT */
  16.  
  17. /* the maximum number of suboptions is defined in
  18.    "menu.h" as  PD_SUB  */
  19.  
  20. /* function prototypes */
  21.  
  22. int demo();   
  23. void howto(void);
  24. int printer(void);
  25.  
  26.  
  27. int start(void)
  28. {
  29. extern struct screen_structure scr;
  30. extern struct window_structure w[];
  31.  
  32. char ch,ext;
  33. int return_code;
  34. int i;
  35. int menu_win;
  36.  
  37. struct pd_str m_menu [MAIN_OPT]={
  38.  
  39. /* main menu   sub-menu       *function     list select values  */
  40.  
  41. "Sort",
  42.               " Ascending  ",
  43.               " Descending ",
  44.               "",
  45.                               demo,
  46.                               demo,
  47.                               NULL,
  48.                                             0,
  49.                                             0,
  50.                                             0,
  51. "Print",
  52.               " Printer   ",
  53.               " Text-file ",
  54.               "",
  55.                               printer,
  56.                               demo,
  57.                               NULL,
  58.                                             0,
  59.                                             0,
  60.                                             0,
  61. "Delete",
  62.               " Data-file    ",
  63.               " program-File ",
  64.               " Programmer   ",
  65.  
  66.                               demo,
  67.                               demo,
  68.                               demo,
  69.                                             0,
  70.                                             0,
  71.                                             0,
  72. "Copy",
  73.               " Block ",
  74.               " Line  ",
  75.               "",
  76.                               demo,
  77.                               demo,
  78.                               NULL,
  79.                                              0,
  80.                                              0,
  81.                                              0,
  82. "Quit",
  83.               " Exit program ",
  84.               "",
  85.               "",
  86.                               NULL,
  87.                               NULL,
  88.                               NULL,
  89.                                             1,
  90.                                             0,
  91.                                             0,
  92. };
  93.  
  94. /* colors for main and pull-down windows */
  95. struct window_colors color;   
  96.  
  97. /*initilize window colors*/
  98.  
  99. if (scr.mode==COLOR_80){
  100.  color.main_frame=set_color(YELLOW,BLACK);
  101.  color.main_interior=set_color(WHITE,BLUE);
  102.  color.main_inverse=set_color(BLUE,WHITE);
  103.  
  104.  color.pd_frame=set_color(YELLOW,BLACK);
  105.  color.pd_interior=set_color(WHITE,BLUE);
  106.  color.pd_inverse=set_color(BLUE,WHITE);
  107.  }
  108.  else{
  109.  
  110.  color.main_frame=scr.normal;
  111.  color.main_interior=scr.normal;
  112.  color.main_inverse=scr.inverse;
  113.  
  114.  color.pd_frame=scr.normal;
  115.  color.pd_interior=scr.normal;
  116.  color.pd_inverse=scr.inverse;
  117.  }
  118.  
  119. howto();       /* SHOW INSTRUCTIONS */
  120.  
  121.    return_code=pull_down(m_menu,color);
  122.  
  123.  cursor(NORMAL_CURSOR);  /* restore normal cursor */
  124.  
  125. cls();
  126.  
  127. return(return_code);
  128. }
  129.  
  130. void howto()
  131. {
  132.   if (scr.mode==COLOR_80)
  133.    scr.current=  set_color(GREEN,BLACK);
  134.     else
  135.      scr.current = NORMAL;
  136.  
  137.  cls();
  138.  print (1,4,"INSTRUCTIONS:");
  139.  print (1,6,"EXPERT MODE: Select by touching the\
  140.  key which represents each option");
  141.  print (14,7,"(the capital letter).");
  142.  
  143.  print (1,10, "ASSIST MODE: Pull down menu by touching\
  144.  Enter or a cursor key.");
  145.  print (14,11,"Select by highlighting with cursor keys -\
  146.  then touch Enter.");
  147.  print (14,13,"Return to Expert mode by touching Escape.");
  148.  
  149.  print (1,15,"EXIT:        To exit to DOS, touch\
  150.  Escape while in Expert mode.");
  151.  
  152. }
  153.  
  154.  
  155. int demo(void)
  156. {
  157. int demo_win;
  158. char ch,ext;
  159.  
  160.  demo_win=win_make(24,10,30,5,STD_FRAME," Demo window ",
  161.                    scr.normal,scr.normal);
  162.  
  163.   print(1,1,"Make believe window");
  164.  
  165.   scr.bold_caps=TRUE;
  166.     print(1,3,"TOUCH ANY KEY TO EXIT");
  167.   scr.bold_caps=FALSE;
  168.      get_key(&ch,&ext);
  169.   win_delete(demo_win);
  170.  return(0);
  171. }
  172.  
  173.  
  174. int printer(void)
  175. {
  176. extern struct screen_structure scr;
  177. extern struct window_structure w[];
  178.  
  179.  
  180.  /* set up menu structure */
  181.  
  182.  struct pop_struc pop_menu [3]={
  183.             " Lpt1:   " ,NULL,   0,
  184.             " lPt2:  "  ,NULL,   0,
  185.             "\0"      /* mark the end of the options list */
  186.  };
  187.  
  188. /* call routine to handle menu */
  189. return (pop_up (pop_menu,25,5,scr.normal,scr.inverse));
  190.   
  191. }
  192.