Files Classes Functions Hierarchy
00001 #ifndef MENUSYSTEM_H 00002 #define MENUSYSTEM_H 00003 00004 #include <vector> 00005 using namespace std; 00006 00007 #include <GL/glut.h> 00008 #include <GL/gl.h> 00009 00010 #include <point.h> 00011 #include <gobj.h> 00012 #include <textoverlay.h> 00013 #include <typedefs.h> 00014 00015 // TODO 00016 // http://stackoverflow.com/questions/538661/how-do-i-draw-text-with-glut-opengl-in-c 00017 // glutbitmapstring http://linux.die.net/man/3/glutbitmapstring 00018 // http://linux.die.net/man/3/glutstrokestring 00019 00026 class namefont : public gobj 00027 { 00028 public: 00029 00031 point2<GLint> X; 00033 string name; 00035 void* font; 00036 00040 namefont 00041 ( 00042 point2<GLint> const & X_, 00043 stringc & name_, 00044 void* font_=GLUT_BITMAP_HELVETICA_10 00045 ); 00046 00048 void draw(); 00049 }; 00050 00051 00052 00106 class menusystem : public textoverlay 00107 { 00108 public: 00109 00111 menusystem * current; 00113 menusystem * parent; 00115 vector<menusystem *> submenues; 00116 00120 bool readmodeimmediate; 00121 00123 gobjContainer visibleGraphics; 00124 00126 point2<GLint> X0; 00128 point2<GLint> X; 00130 GLint columnchange; 00131 00133 vector< point2<GLint> > Xstack; 00135 void Xpush(); 00137 void Xpop(); 00138 00140 vector<namefont*> vItems; 00141 00143 point4<float> fontcolor; 00146 void fontcolorenable(); 00147 00150 menusystem 00151 ( 00152 menusystem * current_, 00153 menusystem * parent_, 00154 bool readmodeimmediate_, 00155 point2<GLint> const & X0_, 00156 GLint const columnchange_ 00157 ); 00158 00161 menusystem 00162 ( 00163 bool readmodeimmediate_, 00164 point2<GLint> const & X0_, 00165 GLint const columnchange_ 00166 ); 00167 00168 menusystem 00169 ( 00170 point2<GLint> const & X0_, 00171 GLint const columnchange_ 00172 ); 00173 00175 ~menusystem(); 00176 00178 void draw(); 00180 void draw(menusystem *x); 00181 00183 void drawparent(); 00185 void drawparents(); 00190 void drawparentsnested(); 00191 00194 void read(charc ch); 00195 00196 // 00197 // Functionality to configure the display 00198 // 00199 00201 void reset() 00202 { X.x = X0.x; X.y = X0.y; } 00203 00205 void clear() 00206 { vItems.clear(); visibleGraphics.nuke(); reset(); } 00207 00209 void addnewline() 00210 { X.x = X0.x; X.y += columnchange; } 00212 void addnewline(uintc newlines) 00213 { X.x = X0.x; X.y += columnchange*newlines; } 00214 00216 void addfont10(stringc & s, point2<GLint> const & X2 ); 00218 void addfont10(stringc & s, uintc newlines=0); 00220 void addfont10(uint & index, stringc & s, uintc newlines=0); 00221 00223 void addfont12(stringc & s, point2<GLint> const & X2 ); 00225 void addfont12(stringc & s, uintc newlines=0); 00227 void addfont12(uint & index, stringc & s, uintc newlines=0); 00228 00230 void addfont10start(stringc & s, uintc newlines=0); 00232 void addfont12start(stringc & s, uintc newlines=0); 00233 00236 void addfont10paragraph 00237 ( 00238 stringc & s, 00239 uintc len, 00240 uintc newlines=0 00241 ); 00243 void addfont10paragraphstart 00244 ( 00245 stringc & s, 00246 uintc len, 00247 uintc newlines=0 00248 ); 00249 void addfont10blockstart 00250 ( 00251 stringc & s, 00252 uintc newlines=0 00253 ); 00255 void addfont10paragraphs 00256 ( 00257 stringc & s, 00258 uintc len, 00259 stringc & token="\n" 00260 ); 00261 00263 void scrolldown(); 00265 void scrollup(); 00267 void scroll(GLint const k); 00268 00269 // 00270 // Control menu tree. 00271 // 00272 // 00273 00275 void currentset() { current=this; } 00276 00278 void transfercontroltoroot(); 00280 void transfercontroltoparent(); 00282 void transfercontroltosubmenu(uint k); 00283 00285 void addsubmenu(menusystem* submenu); 00286 00287 protected: 00288 00291 virtual void readImmediate(charc ch) {} 00293 00294 00297 string readBufferedStringInit; 00299 uint readBufferedIndex; 00301 string readBufferedResult; 00302 00305 virtual void readBufferedTerminationAction() {}; 00306 00310 void readBufferedSet(uint index); 00314 void readBufferedString(uint index); 00317 virtual void readBuffered(charc ch); 00318 }; 00319 00320 00332 class menusystemOneShot : public menusystem 00333 { 00336 uintc index; 00337 public: 00338 00342 enum drawmenu { drawmenuthis, drawmenuparent, drawmenuparents}; 00343 00345 drawmenu drawchoice; 00346 00349 menusystemOneShot 00350 ( 00351 point2<int> const & p, 00352 uintc columnchange_, 00353 uintc index_, 00354 drawmenu drawchoice_=drawmenuthis 00355 ) 00356 : menusystem(true,p,columnchange_), index(index_), 00357 drawchoice(drawchoice_) {} 00358 00361 void draw(); 00362 00363 protected: 00364 00366 void readImmediate(charc ch) 00367 { 00368 readmodeimmediate=false; 00369 readBufferedSet(index); 00370 read(ch); 00371 } 00372 00374 void readBufferedTerminationAction() 00375 { 00376 readmodeimmediate=true; 00377 transfercontroltoparent(); 00378 } 00379 00380 }; 00381 00382 00383 00384 00385 #endif 00386
1.5.8