diff --git a/include/wx/osx/cocoa/dataview.h b/include/wx/osx/cocoa/dataview.h index d483ab6bca..142fe28a49 100644 --- a/include/wx/osx/cocoa/dataview.h +++ b/include/wx/osx/cocoa/dataview.h @@ -204,6 +204,10 @@ public: // Set the line break mode for the given cell using our m_ellipsizeMode void ApplyLineBreakMode(NSCell *cell); + // Does the rendered use a font that the control can't override? + void SetHasCustomFont(bool has) { m_hasCustomFont = has; } + bool HasCustomFont() const { return m_hasCustomFont; } + private: // common part of all ctors void Init(); @@ -224,6 +228,8 @@ private: NSColor *m_origTextColour; wxEllipsizeMode m_ellipsizeMode; + + bool m_hasCustomFont; }; // ============================================================================ @@ -519,6 +525,8 @@ public: // Cocoa-specific helpers id GetItemAtRow(int row) const; + virtual void SetFont(const wxFont& font, const wxColour& foreground, long windowStyle, bool ignoreBlack = true); + private: void InitOutlineView(long style); int GetDefaultRowHeight() const; diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 02103f7606..3f49769f10 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -392,6 +392,10 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column) [[nativeColumn dataCell] setWraps:NO]; // setting the default data cell: [nativeColumn setDataCell:renderData->GetColumnCell()]; + + if (!renderData->HasCustomFont()) + [renderData->GetColumnCell() setFont:column->GetOwner()->GetFont().OSXGetNSFont()]; + // setting the editablility: const bool isEditable = renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE; @@ -2547,6 +2551,13 @@ id wxCocoaDataViewControl::GetItemAtRow(int row) const return [m_OutlineView itemAtRow:row]; } +void wxCocoaDataViewControl::SetFont(const wxFont& font, const wxColour& foreground, long windowStyle, bool ignoreBlack) +{ + wxWidgetCocoaImpl::SetFont(font, foreground, windowStyle, ignoreBlack); + SetRowHeight(0/*will use default/minimum height*/); +} + + // ---------------------------------------------------------------------------- // wxDataViewRendererNativeData // ---------------------------------------------------------------------------- @@ -2556,6 +2567,7 @@ void wxDataViewRendererNativeData::Init() m_origFont = NULL; m_origTextColour = NULL; m_ellipsizeMode = wxELLIPSIZE_MIDDLE; + m_hasCustomFont = false; if ( m_ColumnCell ) ApplyLineBreakMode(m_ColumnCell); @@ -2890,7 +2902,9 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer(const wxArrayString& choices, [cell setFont:[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]]; for (size_t i=0; iSetHasCustomFont(true); + SetNativeData(data); [cell release]; }