#include "wx/gdicmn.h"
#endif
+#include "wx/fontutil.h"
#include "wx/encinfo.h"
+class WXDLLEXPORT wxFontRefData: public wxGDIRefData
+{
+ friend class WXDLLIMPEXP_FWD_CORE wxFont;
+public:
+ wxFontRefData()
+ : m_fontId(0)
+ {
+ Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
+ wxT("Geneva"), wxFONTENCODING_DEFAULT);
+ }
+
+ wxFontRefData(const wxFontRefData& data)
+ : wxGDIRefData()
+ , m_fontId(data.m_fontId)
+ , m_info(data.m_info)
+ {
+ }
+
+ wxFontRefData(const wxNativeFontInfo& info)
+ : wxGDIRefData()
+ , m_fontId(0)
+ , m_info(info)
+ {}
+
+ wxFontRefData(int size,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)
+ : m_fontId(0)
+ {
+ Init(size, family, style, weight, underlined, faceName, encoding);
+ }
+
+ virtual ~wxFontRefData();
+protected:
+ // common part of all ctors
+ void Init(int size,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding);
+
+ // font characterstics
+ int m_fontId;
+ wxNativeFontInfo m_info;
+
+public:
+};
+
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
{
- m_family = family;
- m_style = style;
- m_weight = weight;
- m_underlined = underlined;
- m_faceName = faceName;
- m_encoding = encoding;
+ m_info.pointSize = size;
+ m_info.family = static_cast<wxFontFamily>(family);
+ m_info.style = static_cast<wxFontStyle>(style);
+ m_info.weight = static_cast<wxFontWeight>(weight);
+ m_info.underlined = underlined;
+ m_info.faceName = faceName;
+ m_info.encoding = encoding;
}
wxFontRefData::~wxFontRefData()
#define M_FONTDATA ((wxFontRefData*)m_refData)
-bool wxFont::Create(const wxNativeFontInfo&)
+bool wxFont::Create(const wxNativeFontInfo& nativeFontInfo)
{
- return false;
+ UnRef();
+ m_refData = new wxFontRefData(nativeFontInfo);
+
+ return true;
}
void wxFont::SetEncoding(wxFontEncoding)
int wxFont::GetPointSize() const
{
- return 0;
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+ return M_FONTDATA->m_info.pointSize;
}
bool wxFont::GetUnderlined() const
{
if(M_FONTDATA)
- return M_FONTDATA->m_underlined;
+ return M_FONTDATA->m_info.underlined;
else
return false;
}
int wxFont::GetStyle() const
{
- return 0;
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+ return M_FONTDATA->m_info.style;
}
int wxFont::GetFamily() const
{
- return 0;
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+ return M_FONTDATA->m_info.family;
}
int wxFont::GetWeight() const
{
- return 0;
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+ return M_FONTDATA->m_info.weight;
}
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
- return NULL;
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+ return &M_FONTDATA->m_info;
}
-void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
-
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
{
UnRef();
- m_refData = new wxFontRefData;
-
- M_FONTDATA->m_family = family;
- M_FONTDATA->m_style = style;
- M_FONTDATA->m_weight = weight;
- M_FONTDATA->m_pointSize = pointSize;
- M_FONTDATA->m_underlined = underlined;
- M_FONTDATA->m_faceName = faceName;
+ m_refData = new wxFontRefData(pointSize, family, style, weight, underlined, faceName, encoding);
RealizeResource();
{
Unshare();
- M_FONTDATA->m_pointSize = pointSize;
+ M_FONTDATA->m_info.pointSize = pointSize;
RealizeResource();
}
{
Unshare();
- M_FONTDATA->m_family = family;
+ M_FONTDATA->m_info.family = static_cast<wxFontFamily>(family);
RealizeResource();
}
{
Unshare();
- M_FONTDATA->m_style = style;
+ M_FONTDATA->m_info.style = static_cast<wxFontStyle>(style);
RealizeResource();
}
{
Unshare();
- M_FONTDATA->m_weight = weight;
+ M_FONTDATA->m_info.weight = static_cast<wxFontWeight>(weight);
RealizeResource();
}
{
Unshare();
- M_FONTDATA->m_faceName = faceName;
+ M_FONTDATA->m_info.faceName = faceName;
RealizeResource();
{
Unshare();
- M_FONTDATA->m_underlined = underlined;
+ M_FONTDATA->m_info.underlined = underlined;
RealizeResource();
}
{
wxString str;
if (M_FONTDATA)
- str = M_FONTDATA->m_faceName ;
+ str = M_FONTDATA->m_info.faceName;
return str;
}