Implement wxDataViewModel::IsEnabled() support in generic implementation.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2011-12-30 14:28:13 +00:00
parent 50e55c13ea
commit cf5d4c76af
2 changed files with 22 additions and 13 deletions

View File

@@ -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());