Implement wxDataViewCtrl::SetFont() on OS X
wxDataViewCtrl now behaves consistently with other ports on OS X: calling SetFont() sets the default font used by renderers and adjusts row height to fit.
This commit is contained in:
@@ -204,6 +204,10 @@ public:
|
|||||||
// Set the line break mode for the given cell using our m_ellipsizeMode
|
// Set the line break mode for the given cell using our m_ellipsizeMode
|
||||||
void ApplyLineBreakMode(NSCell *cell);
|
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:
|
private:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
@@ -224,6 +228,8 @@ private:
|
|||||||
NSColor *m_origTextColour;
|
NSColor *m_origTextColour;
|
||||||
|
|
||||||
wxEllipsizeMode m_ellipsizeMode;
|
wxEllipsizeMode m_ellipsizeMode;
|
||||||
|
|
||||||
|
bool m_hasCustomFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -519,6 +525,8 @@ public:
|
|||||||
// Cocoa-specific helpers
|
// Cocoa-specific helpers
|
||||||
id GetItemAtRow(int row) const;
|
id GetItemAtRow(int row) const;
|
||||||
|
|
||||||
|
virtual void SetFont(const wxFont& font, const wxColour& foreground, long windowStyle, bool ignoreBlack = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitOutlineView(long style);
|
void InitOutlineView(long style);
|
||||||
int GetDefaultRowHeight() const;
|
int GetDefaultRowHeight() const;
|
||||||
|
@@ -392,6 +392,10 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column)
|
|||||||
[[nativeColumn dataCell] setWraps:NO];
|
[[nativeColumn dataCell] setWraps:NO];
|
||||||
// setting the default data cell:
|
// setting the default data cell:
|
||||||
[nativeColumn setDataCell:renderData->GetColumnCell()];
|
[nativeColumn setDataCell:renderData->GetColumnCell()];
|
||||||
|
|
||||||
|
if (!renderData->HasCustomFont())
|
||||||
|
[renderData->GetColumnCell() setFont:column->GetOwner()->GetFont().OSXGetNSFont()];
|
||||||
|
|
||||||
// setting the editablility:
|
// setting the editablility:
|
||||||
const bool isEditable = renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE;
|
const bool isEditable = renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE;
|
||||||
|
|
||||||
@@ -2547,6 +2551,13 @@ id wxCocoaDataViewControl::GetItemAtRow(int row) const
|
|||||||
return [m_OutlineView itemAtRow:row];
|
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
|
// wxDataViewRendererNativeData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -2556,6 +2567,7 @@ void wxDataViewRendererNativeData::Init()
|
|||||||
m_origFont = NULL;
|
m_origFont = NULL;
|
||||||
m_origTextColour = NULL;
|
m_origTextColour = NULL;
|
||||||
m_ellipsizeMode = wxELLIPSIZE_MIDDLE;
|
m_ellipsizeMode = wxELLIPSIZE_MIDDLE;
|
||||||
|
m_hasCustomFont = false;
|
||||||
|
|
||||||
if ( m_ColumnCell )
|
if ( m_ColumnCell )
|
||||||
ApplyLineBreakMode(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]]];
|
[cell setFont:[NSFont fontWithName:[[cell font] fontName] size:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]];
|
||||||
for (size_t i=0; i<choices.GetCount(); ++i)
|
for (size_t i=0; i<choices.GetCount(); ++i)
|
||||||
[cell addItemWithTitle:wxCFStringRef(choices[i]).AsNSString()];
|
[cell addItemWithTitle:wxCFStringRef(choices[i]).AsNSString()];
|
||||||
SetNativeData(new wxDataViewRendererNativeData(cell));
|
wxDataViewRendererNativeData *data = new wxDataViewRendererNativeData(cell);
|
||||||
|
data->SetHasCustomFont(true);
|
||||||
|
SetNativeData(data);
|
||||||
[cell release];
|
[cell release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user