Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

glt/cursor.cpp

Go to the documentation of this file.
00001 #include "cursor.h"
00002 
00015 #include <glt/font.h>
00016 #include <glt/viewport.h>
00017 #include <glt/error.h>
00018 
00019 using namespace std;
00020 
00021 GltCursor::GltCursor(const GltFont &font,const GltViewport &area)
00022 : _font(font), _area(area) // , _y(0)
00023 {
00024     GLERROR
00025 
00026     glMatrixMode(GL_PROJECTION);
00027     glPushMatrix();
00028     glMatrixMode(GL_MODELVIEW);
00029     glPushMatrix();
00030     glPushAttrib(GL_VIEWPORT_BIT);
00031 
00032         GLERROR
00033 
00034         _area.set();
00035 
00036         glMatrixMode(GL_PROJECTION);
00037         glLoadIdentity();
00038         glOrtho(0.0,GLdouble(area.width()),GLdouble(area.height()-1),-1.0,-1.0,1.0);
00039 
00040         GLERROR
00041 
00042         glMatrixMode(GL_MODELVIEW);
00043         glLoadIdentity();
00044 
00045         GLERROR
00046 
00047 //      _y = 0;
00048         glRasterPos2i(0,0);
00049 
00050         GLERROR
00051 }
00052 
00053 GltCursor::~GltCursor()
00054 {
00055     GLERROR
00056 
00057     glPopAttrib();
00058     glPopMatrix();
00059     glMatrixMode(GL_PROJECTION);
00060     glPopMatrix();
00061     glMatrixMode(GL_MODELVIEW);
00062 
00063     GLERROR
00064 }
00065 
00066 void
00067 GltCursor::print(const string &str)
00068 {
00069     wstring s;
00070     string2wstring(s,str);
00071     print(s);
00072 }
00073 
00074 void
00075 GltCursor::print(const wstring &str)
00076 {
00077     wstring s;
00078     dos2unix(s,str);
00079     
00080     wstring::size_type i=0;
00081     wstring::size_type j=0;
00082     
00083     do
00084     {
00085         j = s.find('\n',i);
00086         if (j==wstring::npos)
00087         {
00088             printLine(s.substr(i));
00089             return;
00090         }
00091 
00092         printLine(s.substr(i,j-i));
00093         i = j+1;
00094 
00095     } while (j!=wstring::npos);
00096 }
00097 
00098 void 
00099 GltCursor::printLine(const wstring &str)
00100 {
00101     GLERROR
00102 
00103     // We set the raster position before drawing
00104     // any text because we want to apply the 
00105     // current color.
00106 
00107 //  glRasterPos2i(0,_y);
00108     _font.print(str);
00109 //  _y += _font.vStep();
00110 //  glRasterPos2i(0,_y);
00111 
00112     // We set the raster position after drawing 
00113     // so that other routines can make use of the
00114     // current position.
00115 
00116     GLERROR
00117 }
00118 

Generated on Tue Nov 5 11:11:03 2002 for GLT by doxygen1.2.18