home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / DSIIC2.ZIP / PD-DEMO.C < prev    next >
C/C++ Source or Header  |  1991-07-15  |  5KB  |  198 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.    "mydef.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(int argc, char *argv[])
  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. extern struct screen_structure scr;
  133. extern struct window_structure w[];
  134.  
  135.   if (scr.mode==COLOR_80)
  136.    scr.current=  set_color(GREEN,BLACK);
  137.     else
  138.      scr.current = NORMAL;
  139.  
  140.  cls();
  141.  print (1,4,"INSTRUCTIONS:");
  142.  print (1,6,"EXPERT MODE: Select by touching the\
  143.  key which represents each option");
  144.  print (14,7,"(the capital letter).");
  145.  
  146.  print (1,10, "ASSIST MODE: Pull down menu by touching\
  147.  Enter or a cursor key.");
  148.  print (14,11,"Select by highlighting with cursor keys -\
  149.  then touch Enter.");
  150.  print (14,13,"Return to Expert mode by touching Escape.");
  151.  
  152.  print (1,15,"EXIT:        To exit to DOS, touch\
  153.  Escape while in Expert mode.");
  154.  
  155. }
  156.  
  157.  
  158. int demo(void)
  159. {
  160. extern struct screen_structure scr;
  161. extern struct window_structure w[];
  162.  
  163. int demo_win;
  164. char ch,ext;
  165.  
  166.  demo_win=win_make(24,10,30,5,STD_FRAME," Demo window ",
  167.                    scr.normal,scr.normal);
  168.  
  169.   print(1,1,"Make believe window");
  170.  
  171.   scr.bold_caps=TRUE;
  172.     print(1,3,"TOUCH ANY KEY TO EXIT");
  173.   scr.bold_caps=FALSE;
  174.      get_key(&ch,&ext);
  175.   win_delete(demo_win);
  176.  return(0);
  177. }
  178.  
  179.  
  180. int printer(void)
  181. {
  182. extern struct screen_structure scr;
  183. extern struct window_structure w[];
  184.  
  185.  
  186.  /* set up menu structure */
  187.  
  188.  struct pop_struc pop_menu [3]={
  189.             " Lpt1:   " ,NULL,   0,
  190.             " lPt2:  "  ,NULL,   0,
  191.             "\0"      /* mark the end of the options list */
  192.  };
  193.  
  194. /* call routine to handle menu */
  195. return (pop_up (pop_menu,25,5,scr.normal,scr.inverse));
  196.   
  197. }
  198.