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

CascadeFont.h

Go to the documentation of this file.
00001 //
00002 // CascadeFont.h - header file for class CascadeFont
00003 //
00004 // Copyright (c) 2003, Roku, LLC.  All rights reserved.
00005 //
00008 
00009 #ifndef _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADEFONT_H
00010 #define _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADEFONT_H
00011 
00012 #include <cascade/CascadeObject.h>
00013 #include <cascade/graphics/CascadeDims.h>
00014 #include <cascade/util/CascadeString.h>
00015 
00032 class CascadeFont : public CascadeObject
00033 {
00034 public:
00035     enum WeightFlags {
00036         kNormal = 0,                
00037         kBold = (1 << 0),           
00038         kItalic = (1 << 1)          
00039     };
00046 
00047     enum {
00048         kMaxFaceName = 48,                  
00049         kMaxFaceNameLen = kMaxFaceName - 1  
00050     };
00051     
00052 public:
00053     class Attributes    // Use this class to specify the font you want.
00054     {
00055     public:
00056         char            m_faceName[kMaxFaceName];
00060         WeightFlags     m_weightFlags;
00065         u16             m_nPointSize;
00069     public: // constructing, copying and comparing
00070         Attributes();
00074         Attributes(const char * pFaceName, const WeightFlags & weightFlags, u16 nPointSize);
00082         Attributes(const Attributes & that);
00086         Attributes & operator = (const Attributes & that);
00090         bool operator == (const Attributes & that) const;
00094         inline bool operator != (const Attributes & that) const { return (*this == that) ? false : true; }
00098     };
00106     
00107     
00108 public:
00109     class Metrics
00110     {
00111     public:
00112         u16 m_nCharWidth;
00117         u16 m_nCharHeight;
00122         u16 m_nAscent;
00126         u16 m_nDescent;
00131     };
00138     
00139 public:
00140         CascadeFont();
00145     CascadeFont(const CascadeFont & font);
00150     virtual ~CascadeFont();
00154 public:
00155     bool operator == (const CascadeFont & that) const;
00159     bool operator != (const CascadeFont & that) const;
00163 public:
00164     void GetAttributes(Attributes & attributesToSet);
00169     bool SetAttributes(const Attributes & attributes);
00179     typedef bool (EnumProc)(const Attributes & attributes, void * pClientData);
00189     bool EnumFonts(EnumProc * pEnumProc, void * pClientData);
00200     CascadeDims GetTextExtent(const CascadeString & string);
00206     void GetFontMetrics(Metrics & metricsToSet);
00211 
00212     enum TruncationType
00213     {
00214         kTruncateRight = 0,
00215         kTruncateLeft = 1,
00216         kTruncateCenter = 2
00217     };
00222 
00223     bool TruncateText(const CascadeString & text, const CascadeString & ellipsis, const CascadeDims & dims,  CascadeString & truncatedTextToSet, TruncationType truncationType = kTruncateRight);
00236         
00237 private:
00238 
00239 #ifndef DOXY_SKIP
00240     friend class CascadeBitmap;
00241     friend class CascadeScreen;
00242 #endif
00243 
00244     void * m_pFontInternal;
00245 };
00246 
00247 #endif // #ifndef _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADEFONT_H
00248 
00250 //  LOG
00252 //  20-Jan-03   dwoodward       created
00253 //  20-Jan-03   dwoodward       1.0 STATUS: ~20% complete - need to consult w/ Patrick
00254 //  05-May-03   dwoodward   doxygenated
00255 //      11-May-03       pellis          added TruncateText, doxygenated.
00256 //  18-Aug-03   mjkobb      Added TextTruncateLocation enum and truncation
00257 //                          parameter to TruncateText
00258 //  09-Nov-04   dwoodward   added operator == and operator !=

Generated on Sun Jul 24 14:27:17 2005 for Cascade Library by  doxygen 1.4.1