X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/142b3bc26a6e93f5857bc053c7748b2c845c4a8e..949cb163a78520153dbdb3cd2e2dbaab075be9ca:/src/msw/font.cpp diff --git a/src/msw/font.cpp b/src/msw/font.cpp index 25ff0295e3..ae8752a780 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "font.h" #endif @@ -35,6 +35,7 @@ #include "wx/app.h" #include "wx/font.h" #include "wx/log.h" + #include "wx/encinfo.h" #endif // WX_PRECOMP #include "wx/msw/private.h" @@ -44,7 +45,51 @@ #include "wx/tokenzr.h" -IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) +#if wxUSE_EXTENDED_RTTI + +wxBEGIN_ENUM( wxFontFamily ) + wxENUM_MEMBER( wxDEFAULT ) + wxENUM_MEMBER( wxDECORATIVE ) + wxENUM_MEMBER( wxROMAN ) + wxENUM_MEMBER( wxSCRIPT ) + wxENUM_MEMBER( wxSWISS ) + wxENUM_MEMBER( wxMODERN ) + wxENUM_MEMBER( wxTELETYPE ) +wxEND_ENUM( wxFontFamily ) + +wxBEGIN_ENUM( wxFontStyle ) + wxENUM_MEMBER( wxNORMAL ) + wxENUM_MEMBER( wxITALIC ) + wxENUM_MEMBER( wxSLANT ) +wxEND_ENUM( wxFontStyle ) + +wxBEGIN_ENUM( wxFontWeight ) + wxENUM_MEMBER( wxNORMAL ) + wxENUM_MEMBER( wxLIGHT ) + wxENUM_MEMBER( wxBOLD ) +wxEND_ENUM( wxFontWeight ) + +IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI(wxFont, wxGDIObject,"wx/font.h") + +wxBEGIN_PROPERTIES_TABLE(wxFont) + wxPROPERTY( Size,int, SetPointSize, GetPointSize, 12 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Family, int , SetFamily, GetFamily, (int)wxDEFAULT , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontFamily + wxPROPERTY( Style, int , SetStyle, GetStyle, (int)wxNORMAL , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontStyle + wxPROPERTY( Weight, int , SetWeight, GetWeight, (int)wxNORMAL , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontWeight + wxPROPERTY( Underlined, bool , SetUnderlined, GetUnderlined, false , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Face, wxString , SetFaceName, GetFaceName, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY( Encoding, wxFontEncoding , SetEncoding, GetEncoding, wxFONTENCODING_DEFAULT , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +wxEND_PROPERTIES_TABLE() + +wxCONSTRUCTOR_6( wxFont , int , Size , int , Family , int , Style , int , Weight , bool , Underlined , wxString , Face ) + +wxBEGIN_HANDLERS_TABLE(wxFont) +wxEND_HANDLERS_TABLE() + +#else + IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) +#endif + // ---------------------------------------------------------------------------- // constants @@ -64,7 +109,7 @@ public: wxFontRefData() { Init(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, - FALSE, _T(""), wxFONTENCODING_DEFAULT); + FALSE, wxEmptyString, wxFONTENCODING_DEFAULT); } wxFontRefData(int size, @@ -281,6 +326,9 @@ void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont) m_nativeFontInfoOk = TRUE; m_nativeFontInfo = info; + // This is the best we can do since we don't have the + // correct information at this point. + m_family = wxSWISS; } wxFontRefData::~wxFontRefData() @@ -429,6 +477,7 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style) // fall through case wxFONTSTYLE_NORMAL: + lf.lfItalic = FALSE; break; case wxFONTSTYLE_ITALIC: @@ -632,7 +681,7 @@ wxString wxNativeFontInfo::ToString() const { wxString s; - s.Printf(_T("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s"), + s.Printf(_T("%d;%ld;%ld;%ld;%ld;%ld;%d;%d;%d;%d;%d;%d;%d;%d;%s"), 0, // version, in case we want to change the format later lf.lfHeight, lf.lfWidth, @@ -738,9 +787,9 @@ bool wxFont::FreeResource(bool WXUNUSED(force)) return FALSE; } -WXHANDLE wxFont::GetResourceHandle() +WXHANDLE wxFont::GetResourceHandle() const { - return GetHFONT(); + return (WXHANDLE)GetHFONT(); } WXHFONT wxFont::GetHFONT() const @@ -835,7 +884,7 @@ void wxFont::SetEncoding(wxFontEncoding encoding) RealizeResource(); } -void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info) +void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info) { Unshare(); @@ -887,7 +936,7 @@ bool wxFont::GetUnderlined() const wxString wxFont::GetFaceName() const { - wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); return M_FONTDATA->GetFaceName(); } @@ -899,12 +948,10 @@ wxFontEncoding wxFont::GetEncoding() const return M_FONTDATA->GetEncoding(); } -wxNativeFontInfo *wxFont::GetNativeFontInfo() const +const wxNativeFontInfo *wxFont::GetNativeFontInfo() const { - if ( M_FONTDATA->HasNativeFontInfo() ) - return new wxNativeFontInfo(M_FONTDATA->GetNativeFontInfo()); - - return 0; + return M_FONTDATA->HasNativeFontInfo() ? &(M_FONTDATA->GetNativeFontInfo()) + : NULL; } bool wxFont::IsFixedWidth() const