using statically allocated font objects for speedup
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
cfb0ef701e
commit
7eb8aeb8b1
@ -27,7 +27,7 @@ enum wxOSXSystemFont
|
||||
wxOSX_SYSTEM_FONT_MINI,
|
||||
wxOSX_SYSTEM_FONT_MINI_BOLD,
|
||||
wxOSX_SYSTEM_FONT_LABELS,
|
||||
wxOSX_SYSTEM_FONT_VIEWS
|
||||
wxOSX_SYSTEM_FONT_VIEWS,
|
||||
};
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
||||
public:
|
||||
// ctors and such
|
||||
wxFont() { }
|
||||
|
||||
wxFont( wxOSXSystemFont systemFont );
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
wxFont(WX_NSFont nsfont);
|
||||
@ -94,8 +96,6 @@ public:
|
||||
|
||||
bool Create(const wxNativeFontInfo& info);
|
||||
|
||||
bool CreateSystemFont(wxOSXSystemFont font);
|
||||
|
||||
virtual ~wxFont();
|
||||
|
||||
// implement base class pure virtuals
|
||||
|
@ -4307,8 +4307,7 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded()
|
||||
);
|
||||
|
||||
#if defined( __WXMAC__ )
|
||||
wxFont font;
|
||||
font.CreateSystemFont( wxOSX_SYSTEM_FONT_SMALL );
|
||||
static wxFont font( wxOSX_SYSTEM_FONT_SMALL );
|
||||
m_headerWin->SetFont( font );
|
||||
#endif
|
||||
|
||||
|
@ -973,7 +973,7 @@ void wxGenericTreeCtrl::Init()
|
||||
m_lastOnSame = false;
|
||||
|
||||
#if defined( __WXMAC__ )
|
||||
m_normalFont.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
m_normalFont = wxFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
#else
|
||||
m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||
#endif
|
||||
|
@ -499,6 +499,11 @@ bool wxFont::Create(const wxNativeFontInfo& info)
|
||||
return true;
|
||||
}
|
||||
|
||||
wxFont::wxFont(wxOSXSystemFont font)
|
||||
{
|
||||
m_refData = new wxFontRefData( font, 0 );
|
||||
}
|
||||
|
||||
wxFont::wxFont(const wxString& fontdesc)
|
||||
{
|
||||
wxNativeFontInfo info;
|
||||
@ -557,15 +562,6 @@ bool wxFont::Create(int pointSize,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFont::CreateSystemFont(wxOSXSystemFont font)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxFontRefData( font, 0 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxFont::~wxFont()
|
||||
{
|
||||
}
|
||||
|
@ -59,12 +59,10 @@ const wxFont* wxStockGDIMac::GetFont(Item item)
|
||||
switch (item)
|
||||
{
|
||||
case FONT_NORMAL:
|
||||
font = new wxFont;
|
||||
font->CreateSystemFont(wxOSX_SYSTEM_FONT_NORMAL);
|
||||
font = new wxFont(wxOSX_SYSTEM_FONT_NORMAL);
|
||||
break;
|
||||
case FONT_SMALL:
|
||||
font = new wxFont;
|
||||
font->CreateSystemFont(wxOSX_SYSTEM_FONT_SMALL);
|
||||
font = new wxFont(wxOSX_SYSTEM_FONT_SMALL);
|
||||
break;
|
||||
default:
|
||||
font = const_cast<wxFont*>(super::GetFont(item));
|
||||
|
@ -797,7 +797,8 @@ wxListCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||
|
||||
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
||||
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
|
||||
attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
static wxFont font = wxFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
attr.font = font;
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
@ -614,7 +614,8 @@ wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||
|
||||
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
||||
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
|
||||
attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
static wxFont font = wxFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
attr.font = font;
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
@ -275,7 +275,8 @@ wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||
|
||||
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
||||
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
|
||||
attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
static wxFont font = wxFont(wxOSX_SYSTEM_FONT_VIEWS);
|
||||
attr.font = font;
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
@ -338,36 +338,33 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
|
||||
m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag, &size ) ;
|
||||
#endif
|
||||
|
||||
wxFont font ;
|
||||
|
||||
wxOSXSystemFont systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
|
||||
|
||||
|
||||
switch ( variant )
|
||||
{
|
||||
case wxWINDOW_VARIANT_NORMAL :
|
||||
systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
|
||||
static wxFont sysNormal(wxOSX_SYSTEM_FONT_NORMAL);
|
||||
SetFont(sysNormal) ;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_SMALL :
|
||||
systemFont = wxOSX_SYSTEM_FONT_SMALL ;
|
||||
static wxFont sysSmall(wxOSX_SYSTEM_FONT_SMALL);
|
||||
SetFont(sysSmall) ;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_MINI :
|
||||
systemFont = wxOSX_SYSTEM_FONT_MINI ;
|
||||
static wxFont sysMini(wxOSX_SYSTEM_FONT_MINI);
|
||||
SetFont(sysMini) ;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_LARGE :
|
||||
systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
|
||||
static wxFont sysLarge(wxOSX_SYSTEM_FONT_NORMAL);
|
||||
SetFont(sysLarge) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("unexpected window variant"));
|
||||
break ;
|
||||
}
|
||||
|
||||
font.CreateSystemFont( systemFont ) ;
|
||||
|
||||
SetFont( font ) ;
|
||||
}
|
||||
|
||||
void wxWindowMac::MacUpdateControlFont()
|
||||
|
Loading…
Reference in New Issue
Block a user