From cf5d4c76af8d7bea5b2dcb5755dc6efd1bffcd58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 30 Dec 2011 14:28:13 +0000 Subject: [PATCH] Implement wxDataViewModel::IsEnabled() support in generic implementation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/dataview.h | 5 +---- src/generic/datavgen.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 1acce35939..026fecb853 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -183,10 +183,7 @@ public: @return @true if this item should be enabled, @false otherwise. - @note Currently disabling items is fully implemented only for the - native control implementation in wxOSX/Cocoa and wxGTK. - This feature is only partially supported in the generic - version (used by wxMSW) and not supported by the wxOSX/Carbon + @note Currently disabling items is not supported by the wxOSX/Carbon implementation. @since 2.9.2 diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 60ebbc4b3b..86bcadf928 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -712,6 +712,8 @@ private: wxDataViewColumn *FindColumnForEditing(const wxDataViewItem& item, wxDataViewCellMode mode); + bool IsCellEditableInMode(const wxDataViewItem& item, const wxDataViewColumn *col, wxDataViewCellMode mode) const; + void DrawCellBackground( wxDataViewRenderer* cell, wxDC& dc, const wxRect& rect ); private: @@ -1023,9 +1025,6 @@ bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cell), unsigned int col, const wxMouseEvent *mouseEvent) { - if ( !model->IsEnabled(item, col) ) - return false; - if ( mouseEvent ) { // only react to clicks directly on the checkbox, not elsewhere in the same cell: @@ -2057,7 +2056,7 @@ wxDataViewMainWindow::StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col) { wxDataViewRenderer* renderer = col->GetRenderer(); - if (renderer->GetMode() != wxDATAVIEW_CELL_EDITABLE) + if ( !IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) ) return; const wxRect itemRect = GetItemRect(item, col); @@ -3413,7 +3412,7 @@ wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataVie wxDataViewColumn *candidate = m_currentCol; if ( candidate && - candidate->GetRenderer()->GetMode() != mode && + !IsCellEditableInMode(item, candidate, mode) && !m_currentColSetByKeyboard ) { // If current column was set by mouse to something not editable (in @@ -3437,7 +3436,7 @@ wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataVie if ( c->IsHidden() ) continue; - if ( c->GetRenderer()->GetMode() == mode ) + if ( IsCellEditableInMode(item, c, mode) ) { candidate = c; break; @@ -3458,12 +3457,25 @@ wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataVie if ( !candidate ) return NULL; - if ( candidate->GetRenderer()->GetMode() != mode ) + if ( !IsCellEditableInMode(item, candidate, mode) ) return NULL; return candidate; } +bool wxDataViewMainWindow::IsCellEditableInMode(const wxDataViewItem& item, + const wxDataViewColumn *col, + wxDataViewCellMode mode) const +{ + if ( col->GetRenderer()->GetMode() != mode ) + return false; + + if ( !GetModel()->IsEnabled(item, col->GetModelColumn()) ) + return false; + + return true; +} + void wxDataViewMainWindow::OnCharHook(wxKeyEvent& event) { if ( m_editorCtrl ) @@ -4062,7 +4074,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) if (m_lastOnSame && !ignore_other_columns) { if ((col == m_currentCol) && (current == m_currentRow) && - (cell->GetMode() & wxDATAVIEW_CELL_EDITABLE) ) + IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) ) { m_renameTimer->Start( 100, true ); } @@ -4181,7 +4193,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) (current == oldCurrentRow)) && oldWasSelected; // Call ActivateCell() after everything else as under GTK+ - if (cell->GetMode() & wxDATAVIEW_CELL_ACTIVATABLE) + if ( IsCellEditableInMode(item, col, wxDATAVIEW_CELL_ACTIVATABLE) ) { // notify cell about click cell->PrepareForItem(model, item, col->GetModelColumn()); -- 2.45.2