wxMac: Fixed wxListCtrl to respect items' non-default fonts.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52243 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-03-02 10:43:48 +00:00
parent fff10a73bf
commit 17dd3f27e0
3 changed files with 33 additions and 5 deletions

View File

@@ -163,6 +163,7 @@ wxGTK:
wxMac: wxMac:
- Fixed cursor for wxBusyCursor and wxContextHelp. - Fixed cursor for wxBusyCursor and wxContextHelp.
- Fixed wxListCtrl to respect items' non-default fonts.
2.8.7 2.8.7

View File

@@ -365,6 +365,17 @@ class WXDLLEXPORT wxListCtrl: public wxControl
void MacSetDrawingContext(void* context) { m_cgContext = context; } void MacSetDrawingContext(void* context) { m_cgContext = context; }
void* MacGetDrawingContext() { return m_cgContext; } void* MacGetDrawingContext() { return m_cgContext; }
#if wxABI_VERSION >= 20808
virtual wxVisualAttributes GetDefaultAttributes() const
{
return GetClassDefaultAttributes(GetWindowVariant());
}
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
#endif // wxABI_VERSION >= 20808
protected: protected:
// protected overrides needed for pimpl approach // protected overrides needed for pimpl approach

View File

@@ -752,6 +752,12 @@ bool wxListCtrl::Create(wxWindow *parent,
(EventHandlerRef *)&m_macListCtrlEventHandler); (EventHandlerRef *)&m_macListCtrlEventHandler);
} }
// set the default font to slightly smaller font that the native
// DataBrowser control uses:
wxFont font;
font.MacCreateThemeFont(kThemeViewsFont);
m_font = font;
return true; return true;
} }
@@ -772,6 +778,18 @@ wxListCtrl::~wxListCtrl()
delete m_renameTimer; delete m_renameTimer;
} }
/*static*/
wxVisualAttributes wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
{
wxVisualAttributes attr;
attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
attr.font.MacCreateThemeFont(kThemeViewsFont);
return attr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// set/get/change style // set/get/change style
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -2707,9 +2725,8 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
if (bgColor == wxNullColour) if (bgColor == wxNullColour)
bgColor = listBgColor; bgColor = listBgColor;
wxFont listFont = list->GetFont(); if (!font.Ok())
if (font == wxNullFont) font = list->GetFont();
font = listFont;
wxMacCFStringHolder cfString; wxMacCFStringHolder cfString;
cfString.Assign( text, wxLocale::GetSystemEncoding() ); cfString.Assign( text, wxLocale::GetSystemEncoding() );
@@ -2832,8 +2849,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
if (font.Ok()) if (font.Ok())
{ {
if (font.GetFamily() != wxFONTFAMILY_DEFAULT) info.fontID = font.MacGetThemeFontID();
info.fontID = font.MacGetThemeFontID();
::TextSize( (short)(font.MacGetFontSize()) ) ; ::TextSize( (short)(font.MacGetFontSize()) ) ;
::TextFace( font.MacGetFontStyle() ) ; ::TextFace( font.MacGetFontStyle() ) ;