Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Region.h

00001 /*
00002   File: Region.h
00003 
00004   Copyright(C) C. Kotterink, Computed Graphics
00005 */
00006 #ifndef REGION_H
00007 #define REGION_H
00008 
00009 #include<DynamicObject.h>
00010 #include<Event.h>
00011 
00012 #include<render.h>
00013 #include<string>
00014 
00038 class Region : public DynamicObject
00039 {
00040     DYNAMIC_OBJECT;
00041 public:
00043     Region(int i = 0);
00044 
00046     void setId(int i) {
00047         id = i;
00048     }
00049 
00051     short getX() { return x; }
00052 
00054     short getY() { return y; }
00055 
00057     short centerX() { return x + width/2; }
00058 
00060     short centerY() { return y + height/2; }
00061 
00063     short getWidth() { return width; }
00064 
00066     short getHeight() { return height; }
00067 
00069     void setParent(Region *p) {
00070         parent = p;
00071     }
00072 
00074     bool isParentOf(Region *p);
00075 
00077     void setPosition(short w, short h);
00078 
00080     void setSize(short w, short h) {
00081         width = w;
00082         height = h;
00083     }
00084 
00086     void center();
00087 
00089     void open(const string &name);
00090 
00092     Region *getFocus() {
00093         Region *w = focusWindow;
00094         focusWindow = this;
00095         return w;
00096     }
00097 
00099     Region *grabMouse() {
00100         Region *w = grabWindow;
00101         grabWindow = this;
00102         return w;
00103     }
00104 
00106     void releaseMouse() {
00107         if (grabWindow == this) grabWindow = NULL;
00108     }
00109 
00111     void drawCross();
00112 
00114     virtual bool accepts(Event &event);
00115 
00117     virtual Region *find(int id);
00118 
00120     virtual void refresh();
00121 
00123     virtual void move(short dx, short dy);
00124 
00126     virtual void resize(unsigned short w, unsigned short h);
00127 
00129     virtual bool event(int regionId, int evnt);
00130     
00132     virtual bool handleEvent(Event &event);
00133 
00134     // Inherited from DynamicObject
00135     void parseSymbol(Token &t, ObjectFile &file);
00136     void writeParams(ostream &stream);
00137 
00139     static Region *focusWindow;
00140 
00142     static Region *grabWindow;
00143 
00144 protected:
00146     void foreGround() {
00147         glColor3f(0, 0, .5);
00148     }
00149 
00151     void backGround() {
00152         glColor3f(.7, .7, .7);
00153     }
00154 
00156     void darkBorder() {
00157         glColor3f(.1, .1, .1);
00158     }
00159 
00161     void lightBorder() {
00162         glColor3f(.9, .9, .9);
00163     }
00164 
00166     void entryBackGround() {
00167         glColor3f(.8, .8, .8);
00168     }
00169 
00171     void drawBorder(short x, short y, short w, short h, bool sunken=true);
00172 
00173     // Inherited from DynamicObject
00174     void createSymbols();
00175 
00177     static const int lineWidth;
00178 
00180     Region *parent;
00181 
00183     int id;
00184 
00186     short x;
00187 
00189     short y;
00190 
00192     short width;
00193 
00195     short height;
00196 
00197 private:
00198     typedef DynamicObject super;
00199 };
00200 #endif

This documentation was generated using doxygen. If you have any comments or additions please mail me.