home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / OMEGA2 / T_B2.CPP < prev    next >
C/C++ Source or Header  |  1992-04-25  |  2KB  |  74 lines

  1. //
  2. // *************************************************************************
  3. // *                                                                       *
  4. // *    T_Button Demonstration #2                                          *
  5. // *                                                                       *
  6. // *    OMEGA C++ Windowing Class Library                                  *
  7. // *    =================================                                  *
  8. // *                                                                       *
  9. // *    Copyright 1991,92 Tom Clancy                                       *
  10. // *    Submitted to the public domain, April 1992                         *
  11. // *                                                                       *
  12. // *************************************************************************
  13. //
  14.  
  15. #include "omscreen.hpp"
  16. #include "ombutton.hpp"
  17.  
  18. class mybuttons : public oButton {
  19. public:
  20.   mybuttons();
  21.   int handle_key_event();
  22.   int handle_mouse_event();
  23.   void run();
  24. };
  25.  
  26. mybuttons::mybuttons() {
  27.   int x,y;
  28.   setwindow(1,1,80,24,WHITE,LIGHTGRAY,DOUBLEBAR);
  29.   settitle(" Lotsa Buttons ",tCenter,BLACK,LIGHTGRAY);
  30.   setsolidheader(OFF);
  31.   for(y=1; y<=10; y++)
  32.     for(x=1; x<=10; x++)
  33.       addbutton(" PUSH ",8*(x-1)+1,2*y,BLACK,GREEN,WHITE,GREEN);
  34. }
  35.  
  36. int mybuttons::handle_mouse_event() {
  37.   int c=oWindow::handle_mouse_event();
  38.   if(c==cmdWithinwin)
  39.     c=oButton::handle_mouse_event();
  40.   return c;
  41. }
  42.  
  43. int mybuttons::handle_key_event() {
  44.   int c=oWindow::handle_key_event();
  45.   if(!c)
  46.     c=oButton::handle_key_event();
  47.   return c;
  48. }
  49.  
  50. void mybuttons::run() {
  51.   while(getlastcmd()!=cmdClose)
  52.     handle_events();
  53. }
  54.  
  55. main() {
  56.   initmouse();
  57.   OMEGA_SETUP;
  58.  
  59.   oScreen s;
  60.   s.setvga50();
  61.   mybuttons b;
  62.   s.fillscreen(WHITE,BLUE,32);
  63.   s.cursoroff();
  64.   b.activate_virtual();
  65.   b.openwin();
  66.   b.deactivate_virtual();
  67.   s.showmouse();
  68.   b.run();
  69.   s.fillscreen(WHITE,BLACK,32);
  70.   s.hidemouse();
  71.   s.cursoron();
  72. }
  73.  
  74.