diff --git a/docs/changes.txt b/docs/changes.txt index 76e48afd50..2bdfa69c28 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -163,6 +163,7 @@ wxGTK: wxMac: - Fixed cursor for wxBusyCursor and wxContextHelp. +- Fixed wxListCtrl to respect items' non-default fonts. 2.8.7 diff --git a/include/wx/mac/carbon/listctrl.h b/include/wx/mac/carbon/listctrl.h index 067cda6f73..6b5b7e4fbc 100644 --- a/include/wx/mac/carbon/listctrl.h +++ b/include/wx/mac/carbon/listctrl.h @@ -365,6 +365,17 @@ class WXDLLEXPORT wxListCtrl: public wxControl void MacSetDrawingContext(void* context) { m_cgContext = context; } 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 overrides needed for pimpl approach diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 3674a3aabe..fb45f51744 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -752,6 +752,12 @@ bool wxListCtrl::Create(wxWindow *parent, (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; } @@ -772,6 +778,18 @@ wxListCtrl::~wxListCtrl() 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 // ---------------------------------------------------------------------------- @@ -2707,9 +2725,8 @@ void wxMacDataBrowserListCtrlControl::DrawItem( if (bgColor == wxNullColour) bgColor = listBgColor; - wxFont listFont = list->GetFont(); - if (font == wxNullFont) - font = listFont; + if (!font.Ok()) + font = list->GetFont(); wxMacCFStringHolder cfString; cfString.Assign( text, wxLocale::GetSystemEncoding() ); @@ -2832,8 +2849,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem( if (font.Ok()) { - if (font.GetFamily() != wxFONTFAMILY_DEFAULT) - info.fontID = font.MacGetThemeFontID(); + info.fontID = font.MacGetThemeFontID(); ::TextSize( (short)(font.MacGetFontSize()) ) ; ::TextFace( font.MacGetFontStyle() ) ;