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

  1. //
  2. // *************************************************************************
  3. // *                                                                       *
  4. // *    T_Button Demonstration #1                                          *
  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 <dos.h>
  16. #include "omscreen.hpp"
  17. #include "ombutton.hpp"
  18.  
  19. class mybuttons : public oButton {
  20. public:
  21.   mybuttons();
  22.   int handle_key_event();
  23.   int handle_mouse_event();
  24. };
  25.  
  26. mybuttons::mybuttons() {
  27.   setwindow(1,1,50,13,WHITE,BLUE,DOUBLEBAR);
  28.   settitle(" Test Buttons ",tCenter,BLACK,CYAN);
  29.   setshadow(ON,shBottomright);
  30.   addbutton(" 1 ",2, 2,BLACK,GREEN,WHITE,GREEN);
  31.   addbutton(" 2 ",2, 4,BLACK,GREEN,WHITE,GREEN);
  32.   addbutton(" 3 ",2, 6,BLACK,GREEN,WHITE,GREEN);
  33.   addbutton(" 4 ",2, 8,BLACK,GREEN,WHITE,GREEN);
  34.   addbutton(" 5 ",2,10,BLACK,GREEN,WHITE,GREEN);
  35.  
  36.   addbutton("   OK   ",12, 2,BLACK,GREEN,WHITE,GREEN);
  37.   addbutton("  Edit  ",12, 4,BLACK,GREEN,WHITE,GREEN);
  38.   addbutton(" Delete ",12, 6,BLACK,GREEN,WHITE,GREEN);
  39.   addbutton(" Cancel ",12, 8,BLACK,GREEN,WHITE,GREEN);
  40.   addbutton("  Help  ",12,10,BLACK,GREEN,WHITE,GREEN);
  41.  
  42.   addbutton("   OK   ",22, 2,BLACK,GREEN,WHITE,GREEN);
  43.   addbutton("  Edit  ",22, 4,BLACK,GREEN,WHITE,GREEN);
  44.   addbutton(" Delete ",22, 6,BLACK,GREEN,WHITE,GREEN);
  45.   addbutton(" Cancel ",22, 8,BLACK,GREEN,WHITE,GREEN);
  46.   addbutton("  Help  ",22,10,BLACK,GREEN,WHITE,GREEN);
  47. }
  48.  
  49. int mybuttons::handle_key_event() {
  50.   inc c=oWindow::handle_key_event();
  51.   if(!c)
  52.     c=oButton::handle_key_event();
  53.   return c;
  54. }
  55.  
  56. int mybuttons::handle_mouse_event() {
  57.   int c=oWindow::handle_mouse_event();
  58.   if(c==cmdWithinwin)
  59.     c=oButton::handle_mouse_event();
  60.   return c;
  61. }
  62.  
  63. main () {
  64.   initmouse();
  65.   OMEGA_SETUP();
  66.   oScreen S;
  67.   S.setvga50();
  68.   S.fillscreen(LIGHTGRAY,WHITE,176);
  69.   S.showmouse();
  70.   mybuttons B;
  71.   B.snaptocenter();
  72.   B.run();
  73.   S.setvidmode(v80x25);
  74.   S.hidemouse();
  75.   S.setfgcolor(WHITE);
  76.   S.setbkcolor(BLACK);
  77.   S.clrscr();
  78.   return 0;
  79. }
  80.  
  81.  
  82.