From: Robin Dunn Date: Wed, 19 Jan 2011 08:09:51 +0000 (+0000) Subject: On OSX don't propogate the alignment setting from column to renderer if it is a custo... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f8816e49e4bef97dd9b2d706536849239dcfe4a6?hp=4fe83b93a517ca229ff6503eacf81c1177d088e0 On OSX don't propogate the alignment setting from column to renderer if it is a custom renderer. This allows the Render function to deal with the alignment itself and brings the behavior into alignment (pun intended!) with the GTK and generic DV classes. Fixes #12883 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dvrenderers.h b/include/wx/dvrenderers.h index 717f73608a..97539bf19a 100644 --- a/include/wx/dvrenderers.h +++ b/include/wx/dvrenderers.h @@ -159,6 +159,9 @@ public: wxControl *GetEditorCtrl() { return m_editorCtrl; } + virtual bool IsCustomRenderer() const { return false; } + + protected: // Called from {Cancel,Finish}Editing() to cleanup m_editorCtrl void DestroyEditControl(); @@ -278,6 +281,8 @@ public: // Prepare DC to use attributes and call Render(). void WXCallRender(wxRect rect, wxDC *dc, int state); + virtual bool IsCustomRenderer() const { return true; } + protected: // helper for GetSize() implementations, respects attributes wxSize GetTextExtent(const wxString& str) const; diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index 680d368ea0..a981920486 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -2468,16 +2468,18 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title, wxDataViewRenderer* re :wxDataViewColumnBase(renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()), m_title(title) { InitCommon(width, align, flags); - if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) - renderer->SetAlignment(align); + if ((renderer != NULL) && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + renderer->SetAlignment(align); } wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width, wxAlignment align, int flags) :wxDataViewColumnBase(bitmap, renderer, model_column), m_NativeDataPtr(new wxDataViewColumnNativeData()) { InitCommon(width, align, flags); - if ((renderer != NULL) && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) - renderer->SetAlignment(align); + if ((renderer != NULL) && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + renderer->SetAlignment(align); } wxDataViewColumn::~wxDataViewColumn() diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index c2132ae534..7243ab2e03 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -3015,7 +3015,8 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title, m_title(title) { InitCommon(width, align, flags); - if (renderer && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + if (renderer && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) renderer->SetAlignment(align); } @@ -3029,7 +3030,8 @@ wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap, m_NativeDataPtr(new wxDataViewColumnNativeData()) { InitCommon(width, align, flags); - if (renderer && (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + if (renderer && !renderer->IsCustomRenderer() && + (renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) renderer->SetAlignment(align); } @@ -3053,7 +3055,8 @@ void wxDataViewColumn::SetAlignment(wxAlignment align) { m_alignment = align; [[m_NativeDataPtr->GetNativeColumnPtr() headerCell] setAlignment:ConvertToNativeHorizontalTextAlignment(align)]; - if (m_renderer && (m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) + if (m_renderer && !m_renderer->IsCustomRenderer() && + (m_renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT)) m_renderer->SetAlignment(align); }