#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)
- , m_pointSize(10)
- , m_family(wxDEFAULT)
- , m_style(wxNORMAL)
- , m_weight(wxNORMAL)
- , m_underlined(FALSE)
- , m_faceName(wxT("Geneva"))
- , m_encoding(wxFONTENCODING_DEFAULT)
+ : m_fontId(0)
{
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
wxT("Geneva"), wxFONTENCODING_DEFAULT);
}
wxFontRefData(const wxFontRefData& data)
- : wxGDIRefData()
- , m_fontId(data.m_fontId)
- , m_pointSize(data.m_pointSize)
- , m_family(data.m_family)
- , m_style(data.m_style)
- , m_weight(data.m_weight)
- , m_underlined(data.m_underlined)
- , m_faceName(data.m_faceName)
- , m_encoding(data.m_encoding)
+ : wxGDIRefData()
+ , m_fontId(data.m_fontId)
+ , m_info(data.m_info)
{
- Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
- data.m_underlined, data.m_faceName, data.m_encoding);
}
+ wxFontRefData(const wxNativeFontInfo& info)
+ : wxGDIRefData()
+ , m_fontId(0)
+ , m_info(info)
+ {}
+
wxFontRefData(int size,
int family,
int style,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
- : m_fontId(0)
- , m_pointSize(size)
- , m_family(family)
- , m_style(style)
- , m_weight(weight)
- , m_underlined(underlined)
- , m_faceName(faceName)
- , m_encoding(encoding)
+ : m_fontId(0)
{
Init(size, family, style, weight, underlined, faceName, encoding);
}
// font characterstics
int m_fontId;
- int m_pointSize;
- int m_family;
- int m_style;
- int m_weight;
- bool m_underlined;
- wxString m_faceName;
- wxFontEncoding m_encoding;
-
+ 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;
}