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