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

  1. //
  2. // *************************************************************************
  3. // *                                                                       *
  4. // *    OMEGA C++ Windowing Class Library                                  *
  5. // *    =================================                                  *
  6. // *                                                                       *
  7. // *    Copyright 1991,92 Tom Clancy                                       *
  8. // *    Submitted to the public domain, April 1992                         *
  9. // *                                                                       *
  10. // *************************************************************************
  11. // *                                                                       *
  12. // *    Window Class Object                                                *
  13. // *                                                                       *
  14. // *************************************************************************
  15. //
  16.  
  17. #ifndef _OMWINDOW
  18. #define _OMWINDOW
  19. #endif
  20.  
  21. #ifndef _OMSCREEN
  22. #include "omscreen.hpp"
  23. #define _OMSCREEN
  24. #endif
  25.  
  26. #define CLOSECHAR     0xFE
  27. #define EXPANDCHAR    0x18
  28. #define CONTRACTCHAR  0x19
  29. #define RESIZECHAR1   0xC4
  30. #define RESIZECHAR2   0xD9
  31.  
  32.  
  33.  
  34.  
  35. enum Titleposition {
  36.  tRight,
  37.  tLeft,
  38.  tCenter,
  39. };
  40.  
  41. enum windowjust {
  42.   mNojust,
  43.   mCenterX,
  44.   mCenterY,
  45.   mCenterBoth
  46. };
  47.  
  48. class oWindow : public oScreen {
  49.  
  50.   image Behind;
  51.   image Shside1,Shside2;
  52.  
  53.   int  Startx, Starty, Endx, Endy;
  54.   int  Oldx, Oldy, Oldx2, Oldy2;
  55.   int  Shx1, Shy1, Shx2, Shy2;
  56.   int  Side1, Side2;
  57.   int  Len, Wid, OldWid, OldLen;
  58.   int  FGcolor, BKcolor;
  59.   int  Shadowed;
  60.   int  ShadDir;
  61.   int  Opened;
  62.   int  Wstyle;
  63.   int  Just;
  64.  
  65.   char title[130];
  66.   int  tPos;
  67.   int  tFGcolor, tBKcolor;
  68.   int  SolidHeader;
  69.  
  70.   int  Candrag, Canclose, Canexpand, Canresize;
  71.   int  Buttoncolor;
  72.   int  Expanded;
  73.  
  74.   int  MinWid, MinLen;
  75.   int  BoundX, BoundY, BoundX2, BoundY2;
  76.  
  77.   int  TxtStartx, TxtStarty;
  78.  
  79.   void drawshadow();
  80.   void hideshadow();
  81.   char *makewinstr(int x, int y, char *s, char *t);
  82.  
  83. public:
  84.  
  85.   oWindow(int x, int y, int w, int l, int fg, int bk, int style);
  86.   oWindow();
  87.   ~oWindow();
  88.  
  89.   void setwindow(int x, int y, int w, int l, int fg, int bk, int style);
  90.   void setshadow(int on, int dir) {Shadowed=on; ShadDir=dir;}
  91.   void settitle(char *s, int tpos, int fgcolor, int bkcolor);
  92.   void setbuttoncolors(int c) {Buttoncolor=c;}
  93.   void setjustify(windowjust j);
  94.   void setboundaries(int x, int y, int x2, int y2) {
  95.     BoundX=x; BoundY=y; BoundX2=x2; BoundY2=y2;
  96.   }
  97.   virtual void snaptocenter();
  98.   void openwin();
  99.   void closewin();
  100.   void disposewin();
  101.   void showtitle();
  102.   int  withinwindow();
  103.  
  104.   void dragging(int d);
  105.   void closing(int c)        {Canclose=c;}
  106.   void expanding(int e);
  107.   void resizing(int r);
  108.   void setsolidheader(int h) {SolidHeader=h;}
  109.   void setminlen(int m)      {MinLen=m;}
  110.   void setminwid(int m)      {MinWid=m;}
  111.  
  112.   int  getleft()     {return Startx;}
  113.   int  getright()    {return Endx;}
  114.   int  gettop()      {return Starty;}
  115.   int  getbottom()   {return Endy;}
  116.   int  getwid()      {return Wid;}
  117.   int  getlen()      {return Len;}
  118.   int  getfgcolor()  {return FGcolor;}
  119.   int  getbkcolor()  {return BKcolor;}
  120.   int  gettfgcolor() {return tFGcolor;}
  121.   int  gettbkcolor() {return tBKcolor;}
  122.   void setfgcolor(int fg)  {FGcolor=fg;}
  123.   void setbkcolor(int bk)  {BKcolor=bk;}
  124.   int  getstyle()    {return Wstyle;}
  125.   int  getsolidheader() {return SolidHeader;}
  126.   int  getshaddir()     {return ShadDir;}
  127.  
  128.   int  onclose();
  129.   int  onresize();
  130.   int  ondrag();
  131.   int  onexpand();
  132.  
  133.   void mDragwin();
  134.   void mSizewin();
  135.   void expandwin();
  136.   void contractwin();
  137.  
  138.   virtual void display_info();
  139.   virtual void display_help();
  140.  
  141.   int  handle_key_event();
  142.   int  handle_mouse_event();
  143.   void run();
  144.  
  145.   // Window Relative mouse routines
  146.  
  147.   void getmouse(int &x, int &y, int &b);
  148.  
  149.   // Window Writing Routines (Will Clip at the edge of the windows)
  150.  
  151.   void writeat(int x, int y, int fg, int bk, char *str);
  152.   void plainwriteat(int x, int y, char *str);
  153.   void chwriteat(int x, int y, int fg, int bk, unsigned char c);
  154.   void plainchwriteat(int x, int y, unsigned char c);
  155.   void writeshadow(int x, int y);
  156.   void movexy(int x, int y);
  157.   //void wherexy(int &x, int &y);
  158.   void attribln(int y, int x1, int x2, int fg, int bk);
  159.  
  160. };
  161.