Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

StatusBar.H

Go to the documentation of this file.
00001 
00010 #ifndef STATUSBAR_H
00011 #define STATUSBAR_H
00012 
00013 #define OUTSIDE_GLUE_CORE
00014 #include <std/strings.H>
00015 #include <config/config.H>
00016 
00017 #include "DrawObj.H"
00018 #include "Color.H"
00019 #include "FPS.H"
00020 #include "FontMgr.H"
00021 
00022 class StatusBar : public DrawObj
00023 {
00024  public:
00025   StatusBar(cXYpt screenLoc, const bool showFPS, 
00026         const Color col=Color(1,1,0), const int font=0,
00027         float fontScaleFactor=0.025) :
00028     DrawObj("StatusBar") {
00029     _loc = screenLoc;
00030     _showfps = showFPS;
00031     _col = col;
00032     _font = font;
00033     _scale = fontScaleFactor;
00034     
00035     DRAWMGR::register2DObj(this);
00036   }
00037 
00038   virtual ~StatusBar() {}
00039 
00040   void setMessage(str_ptr s) { _msg = s; }
00041   void clearMessage() { _msg = str_ptr::null_str(); }
00042 
00043   void draw() {
00044     glMatrixMode(GL_PROJECTION);
00045     glPushMatrix();
00046     glLoadIdentity();
00047     
00048     glMatrixMode(GL_MODELVIEW);
00049     glPushMatrix();
00050     glLoadIdentity();
00051     
00052     str_ptr fpsstr;
00053 
00054     if (_showfps) {
00055       char s[64];
00056       sprintf(s, "%3.1f fps", (float)FPS::fps());
00057       fpsstr = str_ptr(s);
00058     }
00059 
00060     // project onto the screen
00061     Wvec posonscreen = Wvec(_loc[0],_loc[1],0.0);
00062     Wtransf m = Wtransf::translation(posonscreen) * Wtransf::scaling(_scale);
00063     glMultMatrixd(m.matrix());
00064 
00065     glDisable(GL_LIGHTING);
00066     glDisable(GL_COLOR_MATERIAL);
00067     glDisable(GL_TEXTURE_2D);
00068     glColor4fv(_col.array());
00069 
00070     str_ptr text = fpsstr + str_ptr(" ") + _msg;
00071     FONTMGR::render(**text, 0,0,0, _font);
00072     
00073     glMatrixMode(GL_MODELVIEW);
00074     glPopMatrix();  // pop modelview
00075     glMatrixMode(GL_PROJECTION);
00076     glPopMatrix();  // pop projection
00077   }
00078 
00079  protected: 
00080   str_ptr _msg;
00081   XYpt    _loc;
00082   bool    _showfps;
00083   Color   _col;
00084   int     _font;
00085   float   _scale;
00086 };
00087 
00088 #endif

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18