+public:
+ // constructors
+ wxFontRefData()
+ {
+ Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
+ FALSE, _T(""), wxFONTENCODING_DEFAULT);
+ }
+
+ wxFontRefData(int size,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)
+ {
+ Init(size, family, style, weight, underlined, faceName, encoding);
+ }
+
+ wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
+ {
+ Init(info, hFont);
+ }
+
+ wxFontRefData(const wxFontRefData& data)
+ {
+ if ( data.m_nativeFontInfoOk )
+ {
+ Init(data.m_nativeFontInfo);
+ }
+ else
+ {
+ Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
+ data.m_underlined, data.m_faceName, data.m_encoding);
+ }
+ }
+
+ virtual ~wxFontRefData();
+
+ // operations
+ bool Alloc(wxFont *font);
+
+ void Free();
+
+ // all wxFont accessors
+ int GetPointSize() const
+ {
+ return m_nativeFontInfoOk ? m_nativeFontInfo.GetPointSize()
+ : m_pointSize;
+ }
+
+ int GetFamily() const
+ {
+ return m_family;
+ }
+
+ int GetStyle() const
+ {
+ return m_nativeFontInfoOk ? m_nativeFontInfo.GetStyle()
+ : m_style;
+ }
+
+ int GetWeight() const
+ {
+ return m_nativeFontInfoOk ? m_nativeFontInfo.GetWeight()
+ : m_weight;
+ }
+
+ bool GetUnderlined() const
+ {
+ return m_nativeFontInfoOk ? m_nativeFontInfo.GetUnderlined()
+ : m_underlined;
+ }
+
+ wxString GetFaceName() const
+ {
+ wxString s;
+ if ( m_nativeFontInfoOk )
+ s = m_nativeFontInfo.GetFaceName();
+ else
+ s = m_faceName;
+
+ return s;
+ }
+
+ wxFontEncoding GetEncoding() const
+ {
+ return m_nativeFontInfoOk ? m_nativeFontInfo.GetEncoding()
+ : m_encoding;
+ }
+
+ WXHFONT GetHFONT() const { return m_hFont; }
+
+ // ... and setters
+ void SetPointSize(int pointSize)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetPointSize(pointSize);
+ else
+ m_pointSize = pointSize;
+ }
+
+ void SetFamily(int family)
+ {
+ m_family = family;
+ }
+
+ void SetStyle(int style)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetStyle((wxFontStyle)style);
+ else
+ m_style = style;
+ }
+
+ void SetWeight(int weight)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetWeight((wxFontWeight)weight);
+ else
+ m_weight = weight;
+ }
+
+ void SetFaceName(const wxString& faceName)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetFaceName(faceName);
+ else
+ m_faceName = faceName;
+ }
+
+ void SetUnderlined(bool underlined)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetUnderlined(underlined);
+ else
+ m_underlined = underlined;
+ }
+
+ void SetEncoding(wxFontEncoding encoding)
+ {
+ if ( m_nativeFontInfoOk )
+ m_nativeFontInfo.SetEncoding(encoding);
+ else
+ m_encoding = encoding;
+ }
+
+ // native font info tests
+ bool HasNativeFontInfo() const { return m_nativeFontInfoOk; }
+
+ const wxNativeFontInfo& GetNativeFontInfo() const
+ { return m_nativeFontInfo; }
+
+protected:
+ // common part of all ctors
+ void Init(int size,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding);
+
+ void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
+
+ // font characterstics
+ int m_pointSize;
+ int m_family;
+ int m_style;
+ int m_weight;
+ bool m_underlined;
+ wxString m_faceName;
+ wxFontEncoding m_encoding;
+
+ // Windows font handle
+ WXHFONT m_hFont;
+
+ // Native font info
+ wxNativeFontInfo m_nativeFontInfo;
+ bool m_nativeFontInfoOk;
+};
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxFontRefData
+// ----------------------------------------------------------------------------
+
+void wxFontRefData::Init(int pointSize,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)
+{
+ m_style = style;
+ m_pointSize = pointSize == -1 ? wxNORMAL_FONT->GetPointSize() : pointSize;
+ m_family = family;
+ m_style = style;
+ m_weight = weight;
+ m_underlined = underlined;
+ m_faceName = faceName;
+ m_encoding = encoding;
+
+ m_hFont = 0;
+
+ m_nativeFontInfoOk = FALSE;