X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3b9f782ef3949f583e8ac53795d36787f044fc3..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/gtk1/font.cpp?ds=sidebyside diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index 8257f5bf64..735585d3d3 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -23,8 +23,8 @@ #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/settings.h" - #include "wx/cmndata.h" #include "wx/gdicmn.h" + #include "wx/encinfo.h" #endif #include "wx/fontutil.h" @@ -91,32 +91,9 @@ public: bool SetFaceName(const wxString& facename); void SetEncoding(wxFontEncoding encoding); - void SetNoAntiAliasing( bool no = true ) { m_noAA = no; } - bool GetNoAntiAliasing() const { return m_noAA; } - // and this one also modifies all the other font data fields void SetNativeFontInfo(const wxNativeFontInfo& info); - // debugger helper: shows what the font really is - // - // VZ: I need this as my gdb either shows wildly wrong values or crashes - // when I ask it to "p fontRefData" :-( -#if defined(__WXDEBUG__) - void Dump() const - { - wxPrintf(_T("%s-%s-%s-%d-%d\n"), - m_faceName.c_str(), - m_weight == wxFONTWEIGHT_NORMAL - ? _T("normal") - : m_weight == wxFONTWEIGHT_BOLD - ? _T("bold") - : _T("light"), - m_style == wxFONTSTYLE_NORMAL ? _T("regular") : _T("italic"), - m_pointSize, - m_encoding); - } -#endif // Debug - protected: // common part of all ctors void Init(int pointSize, @@ -144,7 +121,6 @@ private: bool m_underlined; wxString m_faceName; wxFontEncoding m_encoding; // Unused under GTK 2.0 - bool m_noAA; // No anti-aliasing // The native font info, basicly an XFLD under GTK 1.2 and // the pango font description under GTK 2.0. @@ -183,14 +159,10 @@ void wxFontRefData::Init(int pointSize, m_underlined = underlined; m_encoding = encoding; - - m_noAA = false; } void wxFontRefData::InitFromNative() { - m_noAA = false; - // get the font parameters from the XLFD // ------------------------------------- @@ -199,17 +171,17 @@ void wxFontRefData::InitFromNative() m_weight = wxFONTWEIGHT_NORMAL; wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper(); - if ( !w.empty() && w != _T('*') ) + if ( !w.empty() && w != wxT('*') ) { // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD // and BLACK - if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) || + if ( ((w[0u] == wxT('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) || !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) || - wxStrstr(w.c_str() + 1, _T("BOLD")) ) + wxStrstr(w.c_str() + 1, wxT("BOLD")) ) { m_weight = wxFONTWEIGHT_BOLD; } - else if ( w == _T("LIGHT") || w == _T("THIN") ) + else if ( w == wxT("LIGHT") || w == wxT("THIN") ) { m_weight = wxFONTWEIGHT_LIGHT; } @@ -218,11 +190,11 @@ void wxFontRefData::InitFromNative() switch ( wxToupper(m_nativeFontInfo. GetXFontComponent(wxXLFD_SLANT)[0u]).GetValue() ) { - case _T('I'): // italique + case wxT('I'): // italique m_style = wxFONTSTYLE_ITALIC; break; - case _T('O'): // oblique + case wxT('O'): // oblique m_style = wxFONTSTYLE_SLANT; break; @@ -244,7 +216,7 @@ void wxFontRefData::InitFromNative() // examine the spacing: if the font is monospaced, assume wxTELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() - if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == _T('M') ) + if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) { m_family = wxFONTFAMILY_TELETYPE; } @@ -263,7 +235,7 @@ void wxFontRefData::InitFromNative() registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(), encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper(); - if ( registry == _T("ISO8859") ) + if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) @@ -271,7 +243,7 @@ void wxFontRefData::InitFromNative() m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } - else if ( registry == _T("MICROSOFT") ) + else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) @@ -279,7 +251,7 @@ void wxFontRefData::InitFromNative() m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } - else if ( registry == _T("KOI8") ) + else if ( registry == wxT("KOI8") ) { m_encoding = wxFONTENCODING_KOI8; } @@ -303,8 +275,6 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data ) m_faceName = data.m_faceName; m_encoding = data.m_encoding; - m_noAA = data.m_noAA; - // Forces a copy of the internal data. wxNativeFontInfo should probably // have a copy ctor and assignment operator to fix this properly but that // would break binary compatibility... @@ -357,9 +327,9 @@ void wxFontRefData::SetPointSize(int pointSize) { wxString size; if ( pointSize == -1 ) - size = _T('*'); + size = wxT('*'); else - size.Printf(_T("%d"), 10*pointSize); + size.Printf(wxT("%d"), 10*pointSize); m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size); } @@ -382,19 +352,19 @@ void wxFontRefData::SetStyle(wxFontStyle style) switch ( style ) { case wxFONTSTYLE_ITALIC: - slant = _T('i'); + slant = wxT('i'); break; case wxFONTSTYLE_SLANT: - slant = _T('o'); + slant = wxT('o'); break; default: - wxFAIL_MSG( _T("unknown font style") ); + wxFAIL_MSG( wxT("unknown font style") ); // fall through case wxFONTSTYLE_NORMAL: - slant = _T('r'); + slant = wxT('r'); } m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant); @@ -411,20 +381,20 @@ void wxFontRefData::SetWeight(wxFontWeight weight) switch ( weight ) { case wxFONTWEIGHT_BOLD: - boldness = _T("bold"); + boldness = wxT("bold"); break; case wxFONTWEIGHT_LIGHT: - boldness = _T("light"); + boldness = wxT("light"); break; default: - wxFAIL_MSG( _T("unknown font weight") ); + wxFAIL_MSG( wxT("unknown font weight") ); // fall through case wxFONTWEIGHT_NORMAL: // unspecified - boldness = _T("medium"); + boldness = wxT("medium"); } m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness); @@ -480,8 +450,6 @@ void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) // wxFont creation // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) - wxFont::wxFont(const wxNativeFontInfo& info) { (void) Create(info.GetXFontName()); @@ -552,64 +520,55 @@ wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const int wxFont::GetPointSize() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), 0, wxT("invalid font") ); return M_FONTDATA->m_pointSize; } wxString wxFont::GetFaceName() const { - wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") ); return M_FONTDATA->m_faceName; } -wxFontFamily wxFont::GetFamily() const +wxFontFamily wxFont::DoGetFamily() const { - wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") ); - return M_FONTDATA->m_family; } wxFontStyle wxFont::GetStyle() const { - wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX, wxT("invalid font") ); return M_FONTDATA->m_style; } wxFontWeight wxFont::GetWeight() const { - wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") ); return M_FONTDATA->m_weight; } bool wxFont::GetUnderlined() const { - wxCHECK_MSG( Ok(), false, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), false, wxT("invalid font") ); return M_FONTDATA->m_underlined; } wxFontEncoding wxFont::GetEncoding() const { - wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); // m_encoding is unused in wxGTK2, return encoding that the user set. return M_FONTDATA->m_encoding; } -bool wxFont::GetNoAntiAliasing() const -{ - wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); - - return M_FONTDATA->m_noAA; -} - const wxNativeFontInfo *wxFont::GetNativeFontInfo() const { - wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") ); if ( !M_FONTDATA->HasNativeFont() ) { @@ -624,7 +583,7 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const bool wxFont::IsFixedWidth() const { - wxCHECK_MSG( Ok(), false, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), false, wxT("invalid font") ); if ( M_FONTDATA->HasNativeFont() ) { @@ -632,7 +591,7 @@ bool wxFont::IsFixedWidth() const wxString spacing = M_FONTDATA-> m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING); - return spacing.Upper() == _T('M'); + return spacing.Upper() == wxT('M'); } return wxFontBase::IsFixedWidth(); @@ -699,20 +658,13 @@ void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& info ) M_FONTDATA->SetNativeFontInfo( info ); } -void wxFont::SetNoAntiAliasing( bool no ) -{ - Unshare(); - - M_FONTDATA->SetNoAntiAliasing( no ); -} - // ---------------------------------------------------------------------------- // get internal representation of font // ---------------------------------------------------------------------------- static GdkFont *g_systemDefaultGuiFont = NULL; -// this is also used from tbargtk.cpp and tooltip.cpp, hence extern +// this is also used from toolbar.cpp and tooltip.cpp, hence extern extern GdkFont *GtkGetDefaultGuiFont() { if (!g_systemDefaultGuiFont) @@ -744,7 +696,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const { GdkFont *font = NULL; - wxCHECK_MSG( Ok(), font, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), font, wxT("invalid font") ); long int_scale = long(scale * 100.0 + 0.5); // key for fontlist int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);