Fix wxOSX wxDataViewRenderers' alignment handling

Don't override renderer's wxDVR_DEFAULT_ALIGNMENT alignment when
column's alignment is set. Call a method to recompute effective
alignment instead.

Related to a6be5bda that fixed a similar issue in wxGTK.
This commit is contained in:
Václav Slavík 2016-11-21 18:38:47 +01:00
parent f32362bc79
commit 818b084b4b
2 changed files with 12 additions and 4 deletions

View File

@ -76,6 +76,7 @@ public:
void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
void OSXUpdateAlignment();
#if wxOSX_USE_COCOA
// called when a value was edited by user

View File

@ -2645,7 +2645,14 @@ wxDataViewRenderer::~wxDataViewRenderer()
void wxDataViewRenderer::SetAlignment(int align)
{
m_alignment = align;
[GetNativeData()->GetColumnCell() setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
OSXUpdateAlignment();
}
void wxDataViewRenderer::OSXUpdateAlignment()
{
int align = GetEffectiveAlignment();
NSCell *cell = GetNativeData()->GetColumnCell();
[cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
}
void wxDataViewRenderer::SetMode(wxDataViewCellMode mode)
@ -3261,7 +3268,7 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title,
InitCommon(width, align, flags);
if (renderer && !renderer->IsCustomRenderer() &&
(renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
renderer->OSXUpdateAlignment();
SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
}
@ -3277,7 +3284,7 @@ wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap,
InitCommon(width, align, flags);
if (renderer && !renderer->IsCustomRenderer() &&
(renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
renderer->SetAlignment(align);
renderer->OSXUpdateAlignment();
}
wxDataViewColumn::~wxDataViewColumn()
@ -3302,7 +3309,7 @@ void wxDataViewColumn::SetAlignment(wxAlignment align)
[[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setAlignment:ConvertToNativeHorizontalTextAlignment(align)];
if (m_renderer && !m_renderer->IsCustomRenderer() &&
(m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
m_renderer->SetAlignment(align);
m_renderer->OSXUpdateAlignment();
}
void wxDataViewColumn::SetBitmap(const wxBitmap& bitmap)