CFont.hpp

Go to the documentation of this file.
00001 #ifndef __CFont__
00002 #define __CFont__
00003 
00004 #include <Basics/CCountedObject.hpp>
00005 #include <Basics/CString.hpp>
00006 #include <Collections/TAutomaticPointer.hpp>
00007 #include "CFontReference.hpp"
00008 #include "../Windowing/CWindowTools.hpp"
00009 
00010 //  ===========================================================================
00011 
00012 using Exponent::Collections::TAutomaticPointer;
00013 using Exponent::Basics::CCountedObject;
00014 using Exponent::Basics::CString;
00015 using Exponent::GUI::Fonts::CFontReference;
00016 using Exponent::GUI::Windowing::CWindowTools;
00017 
00018 //  ===========================================================================
00019 
00020 namespace Exponent
00021 {
00022     namespace GUI
00023     {
00024         namespace Fonts
00025         {
00043             class CFont : public CCountedObject
00044             {
00046                 EXPONENT_CLASS_DECLARATION;
00049 //  ===========================================================================
00050 
00051             public: 
00052 
00053 //  ===========================================================================
00054 
00055                 static CFont *CFONT_SYSTEM_FONT;                        
00057 //  ===========================================================================
00058 
00064                 CFont(const CString &fontname = "Arial", const unsigned long height = 10);
00065 
00070                 CFont(const CFont &font);
00071 
00075                 virtual ~CFont();
00076 
00077 //  ===========================================================================
00078 
00083                 CFont &operator = (const CFont &font);
00084 
00085 //  ===========================================================================
00086 
00091                 void setFont(const CFontReference &font);
00092 
00103                 void setFont(const CString &fontName, const long height, const bool italic = false, const bool underline = false, const bool strike = false, const bool bold = false);
00104 
00109                 void setHeight(const unsigned long height);
00110 
00115                 void setFontName(const CString &fontname);
00116 
00117 //  ===========================================================================
00118 
00119                 #ifdef WIN32
00120 
00124                     HFONT getFont() const { return m_fontHandle; }
00125                 #endif
00126 
00131                 long getHeight() const;
00132 
00137                 long getFontSize() const;
00138 
00143                 long getWidth() const;
00144 
00149                 const CString &getFontName() const { return m_fontName; }
00150 
00151 //  ===========================================================================
00152                 
00159                 static long getStringLength(const CString &string, void *drawContext = NULL);
00160 
00161 //  ===========================================================================
00162 
00166                 static void createDefaultFont();
00167 
00171                 static void destroyDefaultFont();
00172 
00177                 static long getFontSizeFromPointSize(const long pointSize);
00178 
00179 //  ===========================================================================
00180 
00181             protected:
00182 
00183 //  ===========================================================================
00184 
00188                 void loadFont();
00189 
00193                 void unloadFont();
00194 
00195 //  ===========================================================================
00196 
00197                 #ifdef WIN32
00198                     HFONT m_fontHandle;     
00199                     LOGFONT m_logFont;      
00200                 #endif
00201 
00202                 CString m_fontName;         
00203                 long m_height;              
00204             };
00205         }
00206     }
00207 }
00208 #endif  // End of CFont.hpp

Infinity API - CFont.hpp Source File generated on 7 Mar 2007