From 3cf883a26a5d4ab8dd7e593264d84ee637f87076 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 24 Dec 2001 14:15:11 +0000 Subject: [PATCH] really fixed GetRenderer() and GetEditor() methods, they were both broken in some strange and twisted (and different) ways git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 6 ++- src/generic/grid.cpp | 105 +++++++++++++++++++++++++++++-------------- 2 files changed, 76 insertions(+), 35 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2ed7d11e9e..8459ba4df4 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -63,12 +63,16 @@ Unix ports: 2.3.3 ----- -All: +wxBase: - fixes to the command line parsing error and usage messages - modified wxFileName::CreateTempFileName() to open the file atomically (if possible) and, especially, not to leak the file descriptors under Unix +All (GUI): + +- fixed using custom renderers in wxGrid which was broken in 2.3.2 + wxMSW: - huge (40*) speed up in wxMask::Create() (=> much faster toolbar creation) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index e2b9e35807..d727920a5d 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2018,59 +2018,96 @@ void wxGridCellAttr::GetAlignment(int *hAlign, int *vAlign) const wxGridCellRenderer* wxGridCellAttr::GetRenderer(wxGrid* grid, int row, int col) const { - wxGridCellRenderer* renderer = NULL; + wxGridCellRenderer *renderer; - if ( m_defGridAttr == this || grid == NULL ) + if ( m_renderer && this != m_defGridAttr ) { - renderer = m_renderer; // use local attribute - if ( renderer ) - renderer->IncRef(); + // use the cells renderer if it has one + renderer = m_renderer; + renderer->IncRef(); } - - if ( !renderer && grid ) // get renderer for the data type + else // no non default cell renderer { - // GetDefaultRendererForCell() will do IncRef() for us - renderer = grid->GetDefaultRendererForCell(row, col); - } + // get default renderer for the data type + if ( grid ) + { + // GetDefaultRendererForCell() will do IncRef() for us + renderer = grid->GetDefaultRendererForCell(row, col); + } + else + { + renderer = NULL; + } - if ( !renderer ) - { - // if we still don't have one then use the grid default - // (no need for IncRef() here neither) - renderer = m_defGridAttr->GetRenderer(NULL,0,0); + if ( !renderer ) + { + if ( this != m_defGridAttr ) + { + // if we still don't have one then use the grid default + // (no need for IncRef() here neither) + renderer = m_defGridAttr->GetRenderer(NULL, 0, 0); + } + else // default grid attr + { + // use m_renderer which we had decided not to use initially + renderer = m_renderer; + if ( renderer ) + renderer->IncRef(); + } + } } - if ( !renderer) - { - wxFAIL_MSG(wxT("Missing default cell attribute")); - } + // we're supposed to always find something + wxASSERT_MSG(renderer, wxT("Missing default cell renderer")); return renderer; } +// same as above, except for s/renderer/editor/g wxGridCellEditor* wxGridCellAttr::GetEditor(wxGrid* grid, int row, int col) const { - wxGridCellEditor* editor = NULL; + wxGridCellEditor *editor; - if ( m_defGridAttr != this || grid == NULL ) + if ( m_editor && this != m_defGridAttr ) { - editor = m_editor; // use local attribute - if ( editor ) - editor->IncRef(); + // use the cells editor if it has one + editor = m_editor; + editor->IncRef(); } - - if ( !editor && grid ) // get renderer for the data type - editor = grid->GetDefaultEditorForCell(row, col); - - if ( !editor ) - // if we still don't have one then use the grid default - editor = m_defGridAttr->GetEditor(NULL,0,0); - - if ( !editor ) + else // no non default cell editor { - wxFAIL_MSG(wxT("Missing default cell attribute")); + // get default editor for the data type + if ( grid ) + { + // GetDefaultEditorForCell() will do IncRef() for us + editor = grid->GetDefaultEditorForCell(row, col); + } + else + { + editor = NULL; + } + + if ( !editor ) + { + if ( this != m_defGridAttr ) + { + // if we still don't have one then use the grid default + // (no need for IncRef() here neither) + editor = m_defGridAttr->GetEditor(NULL, 0, 0); + } + else // default grid attr + { + // use m_editor which we had decided not to use initially + editor = m_editor; + if ( editor ) + editor->IncRef(); + } + } } + // we're supposed to always find something + wxASSERT_MSG(editor, wxT("Missing default cell editor")); + return editor; } -- 2.45.2