added checks to wxFont accessors
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -85,7 +85,7 @@ public:
|
|||||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData(const wxNativeFontInfo& info)
|
wxFontRefData(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
Init(info);
|
Init(info);
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ protected:
|
|||||||
|
|
||||||
// Windows font handle
|
// Windows font handle
|
||||||
WXHFONT m_hFont;
|
WXHFONT m_hFont;
|
||||||
|
|
||||||
// Native font info
|
// Native font info
|
||||||
wxNativeFontInfo m_nativeFontInfo;
|
wxNativeFontInfo m_nativeFontInfo;
|
||||||
bool m_nativeFontInfoOk;
|
bool m_nativeFontInfoOk;
|
||||||
@@ -156,7 +156,7 @@ void wxFontRefData::Init(int pointSize,
|
|||||||
m_temporary = FALSE;
|
m_temporary = FALSE;
|
||||||
|
|
||||||
m_hFont = 0;
|
m_hFont = 0;
|
||||||
|
|
||||||
m_nativeFontInfoOk = FALSE;
|
m_nativeFontInfoOk = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,14 +229,14 @@ void wxFontRefData::Init(const wxNativeFontInfo& info)
|
|||||||
static const int ppInch = 96;
|
static const int ppInch = 96;
|
||||||
#endif
|
#endif
|
||||||
m_pointSize = (int) (((72.0*((double)height))/(double) ppInch) + 0.5);
|
m_pointSize = (int) (((72.0*((double)height))/(double) ppInch) + 0.5);
|
||||||
|
|
||||||
m_encoding = wxGetFontEncFromCharSet(info.lf.lfCharSet);
|
m_encoding = wxGetFontEncFromCharSet(info.lf.lfCharSet);
|
||||||
|
|
||||||
m_fontId = 0;
|
m_fontId = 0;
|
||||||
m_temporary = FALSE;
|
m_temporary = FALSE;
|
||||||
|
|
||||||
m_hFont = 0;
|
m_hFont = 0;
|
||||||
|
|
||||||
m_nativeFontInfoOk = TRUE;
|
m_nativeFontInfoOk = TRUE;
|
||||||
m_nativeFontInfo = info;
|
m_nativeFontInfo = info;
|
||||||
}
|
}
|
||||||
@@ -443,7 +443,7 @@ bool wxFont::RealizeResource()
|
|||||||
wxFillLogFont(&M_FONTDATA->m_nativeFontInfo.lf, this);
|
wxFillLogFont(&M_FONTDATA->m_nativeFontInfo.lf, this);
|
||||||
M_FONTDATA->m_nativeFontInfoOk = TRUE;
|
M_FONTDATA->m_nativeFontInfoOk = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
M_FONTDATA->m_hFont = (WXHFONT)::CreateFontIndirect(&M_FONTDATA->m_nativeFontInfo.lf);
|
M_FONTDATA->m_hFont = (WXHFONT)::CreateFontIndirect(&M_FONTDATA->m_nativeFontInfo.lf);
|
||||||
M_FONTDATA->m_faceName = M_FONTDATA->m_nativeFontInfo.lf.lfFaceName;
|
M_FONTDATA->m_faceName = M_FONTDATA->m_nativeFontInfo.lf.lfFaceName;
|
||||||
if ( !M_FONTDATA->m_hFont )
|
if ( !M_FONTDATA->m_hFont )
|
||||||
@@ -582,8 +582,8 @@ void wxFont::SetEncoding(wxFontEncoding encoding)
|
|||||||
void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
|
void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
Unshare();
|
Unshare();
|
||||||
|
|
||||||
FreeResource();
|
FreeResource();
|
||||||
|
|
||||||
M_FONTDATA->Init(info);
|
M_FONTDATA->Init(info);
|
||||||
|
|
||||||
@@ -596,44 +596,57 @@ void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
|
|||||||
|
|
||||||
int wxFont::GetPointSize() const
|
int wxFont::GetPointSize() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_pointSize;
|
return M_FONTDATA->m_pointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFont::GetFamily() const
|
int wxFont::GetFamily() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_family;
|
return M_FONTDATA->m_family;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFont::GetFontId() const
|
int wxFont::GetFontId() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_fontId;
|
return M_FONTDATA->m_fontId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFont::GetStyle() const
|
int wxFont::GetStyle() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_style;
|
return M_FONTDATA->m_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFont::GetWeight() const
|
int wxFont::GetWeight() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_weight;
|
return M_FONTDATA->m_weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::GetUnderlined() const
|
bool wxFont::GetUnderlined() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_underlined;
|
return M_FONTDATA->m_underlined;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFont::GetFaceName() const
|
wxString wxFont::GetFaceName() const
|
||||||
{
|
{
|
||||||
wxString str;
|
wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
|
||||||
if ( M_FONTDATA )
|
|
||||||
str = M_FONTDATA->m_faceName;
|
return M_FONTDATA->m_faceName;
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontEncoding wxFont::GetEncoding() const
|
wxFontEncoding wxFont::GetEncoding() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_encoding;
|
return M_FONTDATA->m_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +654,7 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
|||||||
{
|
{
|
||||||
if( M_FONTDATA->m_nativeFontInfoOk )
|
if( M_FONTDATA->m_nativeFontInfoOk )
|
||||||
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user