gfx_font_opengl.hh

Go to the documentation of this file.
00001 /*
00012  * LEGAL:   COPYRIGHT (C) 2004 JIM E. BROOKS
00013  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00014  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00015  ******************************************************************************/
00016 
00017 #ifndef GFX_FONT_OPENGL_HH
00018 #define GFX_FONT_OPENGL_HH 1
00019 
00020 #include "gfx_targa.hh"
00021 
00022 namespace gfx {
00023 
00024 class Gui;
00025 class Texture;
00026 
00032 class Font : public FontBase
00033 {
00034 typedef FontBase Parent;
00035 friend class GuiButton;
00036 
00037 public:
00038     class PrintArgs
00039     {
00040     friend class Font;
00041     public:
00042                         PrintArgs( void );
00043         Rect<fp>        GetRect( void ) { ASSERT(mRectValid); return mRect; }
00044     private:
00045         const char*     mText;
00046         uint            mTextLen;
00047         Vector2         mPos;
00048         eFontMode       mFontMode;
00049         fp              mZoom2;
00050         fp              xz;
00051         fp              yz;
00052         Rect<fp>        mRect;
00053     #if DEBUG
00054         bool            mRectValid;
00055     #endif
00056     };
00057 
00058 public:
00059                     Font( const FontDesc& desc, SafePtr<Gui> gui );
00060                     ~Font();
00061     void            SetZoom( fp z );
00062     void            Print( const string& text, fp x, fp y, eFontMode mode );
00063     void            Print( const string& text, fp x, fp y, eFontMode mode, const RGBA rgba );
00064     void            Print( const char* text, uint textLen, fp x, fp y, eFontMode mode );
00065     void            Print( const char* text, uint textLen, fp x, fp y, eFontMode mode, const RGBA rgba );
00066     void            PrintBuildArgs( PrintArgs& args /*OUT*/,
00067                                     const char* text, uint textLen, fp x, fp y, eFontMode fontMode );
00068     void            Print( PrintArgs& args, bool draw = true );
00069 
00070 private:
00071     void            PostProcess( Targa& targa /*IN/OUT*/ );
00072     bool            IsPixel( const Targa& targa, int x, int y );
00073     void            ExtractLetters( const Targa& targa );
00074     void            SetPadding( int padding ) { mPadding = padding; }
00075     enum            eFontPad { eFontPad_DEFAULT = 4 };
00076 
00077 private:
00078     SafePtr<Gui>    mGui;
00079     int             mPadding;       
00080     int             mHeight;        
00081     char            mStart;         
00082     fp              mZoom;          
00083     int             mLetters;       
00084     vector<short>   mLetterx;       
00085     vector<short>   mLettery;       
00086     vector<short>   mLetterw;       
00087     shptr<Texture>  mTexture;       
00088 };
00089 
00090 } // namespace gfx
00091 
00092 #endif // GFX_FONT_OPENGL_HH
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:10 2007