home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011046a < prev    next >
Text File  |  1992-09-08  |  2KB  |  148 lines

  1.  
  2. *****************************************************
  3.  
  4. // Listing 1 - VSMANIP.CPP
  5.  
  6. #include "vstream.h"
  7. #include <conio.h>
  8. #include <dos.h>
  9. #include "vsmanip.h"
  10.  
  11.  
  12.  
  13. /* Simple no argument manipulator functions */
  14. ostream& beep(ostream& str)
  15.   {
  16.   sound(1000);
  17.   delay(50);
  18.   nosound();
  19.   return str;
  20.   }
  21.  
  22. ostream& clear_screen(ostream& str)
  23.   {
  24.   clrscr();
  25.   return str;
  26.   }
  27.  
  28. ostream& del_line(ostream& str)
  29.   {
  30.   delline();
  31.   return str;
  32.   }
  33.  
  34. ostream& high_video(ostream& str)
  35.   {
  36.   highvideo();
  37.   return str;
  38.   }
  39.  
  40. ostream& ins_line(ostream& str)
  41.   {
  42.   insline();
  43.   return str;
  44.   }
  45.  
  46. ostream& low_video(ostream& str)
  47.   {
  48.   lowvideo();
  49.   return str;
  50.   }
  51.  
  52. ostream& norm_video(ostream& str)
  53.   {
  54.   normvideo();
  55.   return str;
  56.   }
  57.  
  58. /* Single argument manipulator action functions.
  59.    These functions are static -- they are only used
  60.    by the manipulator object functions of the same
  61.    name (see below) */
  62. static ostream& text_color(ostream& osr,int color)
  63.   {
  64.   textcolor(color);
  65.   return osr;
  66.   }
  67.  
  68. static ostream& text_background(ostream& osr,int color)
  69.   {
  70.   textbackground(color);
  71.   return osr;
  72.   }
  73.  
  74. static ostream& text_attr(ostream& osr,int color)
  75.   {
  76.   if (win::top_window())
  77.     win::top_window()->setcolor(color);
  78.   textattr(color);
  79.   return osr;
  80.   }
  81.  
  82. /* make window goto top */
  83. static ostream& top_window(ostream& osr, win& w)
  84.   {
  85.   w.maketop();
  86.   return osr;
  87.   }
  88.  
  89.  
  90. /* Functions for manipulators with two arguments */
  91. static ostream& go_xy(ostream& osr,int& x,int& y)
  92.   {
  93.   gotoxy(x,y);
  94.   return osr;
  95.   }
  96.  
  97. static ostream& where_xy(ostream& osr,int& x,int& y)
  98.   {
  99.   x=wherex();
  100.   y=wherey();
  101.   return osr;
  102.   }
  103.  
  104.  
  105. /* These functions build manipulator objects that
  106.    contain the argument(s) and the action function
  107.    of the same name */
  108.  
  109. /* One argument */
  110. omanip_int1 text_color(int color)
  111.   {
  112.   omanip_int1 rv(text_color,color);
  113.   return rv;
  114.   };
  115.  
  116. omanip_int1 text_background(int color)
  117.   {
  118.   omanip_int1 rv(text_background,color);
  119.   return rv;
  120.   };
  121.  
  122. omanip_int1 text_attr(int color)
  123.   {
  124.   omanip_int1 rv(text_attr,color);
  125.   return rv;
  126.   };
  127.  
  128. omanip_winr top_window(win& w)
  129.   {
  130.   omanip_winr rv(top_window,w);
  131.   return rv;
  132.   }
  133.  
  134. /* Two argument functions */
  135. omanip_intr2 go_xy(int& x,int& y)
  136.   {
  137.   omanip_intr2 rv(go_xy,x,y);
  138.   return rv;
  139.   }
  140.  
  141. omanip_intr2 where_xy(int& x,int& y)
  142.   {
  143.   omanip_intr2 rv(where_xy,x,y);
  144.   return rv;
  145.   }
  146.  
  147.  
  148.