00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _WG_RENDEREDSTRING_H_
00027 #define _WG_RENDEREDSTRING_H_
00028
00029 #include "wg_fontengine.h"
00030 #include <vector>
00031 #include "wg_rect.h"
00032 #include "wg_color.h"
00033 #include "SDL.h"
00034 #include "std_ex.h"
00035
00036
00037 namespace wGui
00038 {
00039
00040 #ifdef WIN32
00041 #pragma warning(push)
00042 #pragma warning(disable: 4512)
00043 #endif // WIN32
00044
00047
00048 class CRenderedString
00049 {
00050 public:
00052 enum EVAlign
00053 {
00054 VALIGN_NORMAL,
00055 VALIGN_CENTER,
00056 VALIGN_TOP,
00057 VALIGN_BOTTOM
00058 };
00059
00061 enum EHAlign
00062 {
00063 HALIGN_LEFT,
00064 HALIGN_CENTER,
00065 HALIGN_RIGHT
00066 };
00067
00073 CRenderedString(CFontEngine* pFontEngine, const std::wstring& sString, EVAlign eVertAlign = VALIGN_NORMAL, EHAlign eHorzAlign = HALIGN_LEFT);
00074
00080 void Draw(SDL_Surface* pSurface, const CRect& BoundingRect, const CPoint& OriginPoint, const CRGBColor& FontColor = DEFAULT_LINE_COLOR) const;
00081
00086 void GetMetrics(CPoint* pBoundedDimensions = 0, CPoint* pOriginOffset = 0, std::vector<CRect>* pCharacterRects = 0) const;
00087
00090 unsigned int GetLength(void) const { return stdex::safe_static_cast<unsigned int>(m_sString.size()); }
00091
00094 unsigned int GetMaxFontHeight(void);
00095
00098 unsigned int GetMaxFontWidth(void);
00099
00102 void SetMaskChar(wchar_t MaskChar) { m_MaskChar = MaskChar; }
00103
00106 wchar_t GetMaskChar(void) const { return m_MaskChar; }
00107
00108
00109 protected:
00110 CFontEngine* m_pFontEngine;
00111 std::wstring m_sString;
00112 wchar_t m_MaskChar;
00113
00114
00115 private:
00116 EVAlign m_eVertAlign;
00117 EHAlign m_eHorzAlign;
00118 mutable CPoint m_CachedBoundedDimensions;
00119 mutable CPoint m_OriginOffset;
00120 mutable std::vector<CRect> m_CachedCharacterRects;
00121 mutable bool m_bCachedMetricsValid;
00122 int m_MaxFontHeight;
00123 int m_MaxFontWidth;
00124 };
00125
00126 #ifdef WIN32
00127 #pragma warning(pop)
00128 #endif // WIN32
00129
00130 }
00131
00132 #endif // _WG_RENDEREDSTRING_H_