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:
@@ -183,10 +183,7 @@ public:
|
|||||||
@return
|
@return
|
||||||
@true if this item should be enabled, @false otherwise.
|
@true if this item should be enabled, @false otherwise.
|
||||||
|
|
||||||
@note Currently disabling items is fully implemented only for the
|
@note Currently disabling items is not supported by the wxOSX/Carbon
|
||||||
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
|
|
||||||
implementation.
|
implementation.
|
||||||
|
|
||||||
@since 2.9.2
|
@since 2.9.2
|
||||||
|
@@ -712,6 +712,8 @@ private:
|
|||||||
|
|
||||||
wxDataViewColumn *FindColumnForEditing(const wxDataViewItem& item, wxDataViewCellMode mode);
|
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 );
|
void DrawCellBackground( wxDataViewRenderer* cell, wxDC& dc, const wxRect& rect );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1023,9 +1025,6 @@ bool wxDataViewToggleRenderer::WXActivateCell(const wxRect& WXUNUSED(cell),
|
|||||||
unsigned int col,
|
unsigned int col,
|
||||||
const wxMouseEvent *mouseEvent)
|
const wxMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
if ( !model->IsEnabled(item, col) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( mouseEvent )
|
if ( mouseEvent )
|
||||||
{
|
{
|
||||||
// only react to clicks directly on the checkbox, not elsewhere in the same cell:
|
// 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)
|
const wxDataViewColumn* col)
|
||||||
{
|
{
|
||||||
wxDataViewRenderer* renderer = col->GetRenderer();
|
wxDataViewRenderer* renderer = col->GetRenderer();
|
||||||
if (renderer->GetMode() != wxDATAVIEW_CELL_EDITABLE)
|
if ( !IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxRect itemRect = GetItemRect(item, col);
|
const wxRect itemRect = GetItemRect(item, col);
|
||||||
@@ -3413,7 +3412,7 @@ wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataVie
|
|||||||
wxDataViewColumn *candidate = m_currentCol;
|
wxDataViewColumn *candidate = m_currentCol;
|
||||||
|
|
||||||
if ( candidate &&
|
if ( candidate &&
|
||||||
candidate->GetRenderer()->GetMode() != mode &&
|
!IsCellEditableInMode(item, candidate, mode) &&
|
||||||
!m_currentColSetByKeyboard )
|
!m_currentColSetByKeyboard )
|
||||||
{
|
{
|
||||||
// If current column was set by mouse to something not editable (in
|
// 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() )
|
if ( c->IsHidden() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( c->GetRenderer()->GetMode() == mode )
|
if ( IsCellEditableInMode(item, c, mode) )
|
||||||
{
|
{
|
||||||
candidate = c;
|
candidate = c;
|
||||||
break;
|
break;
|
||||||
@@ -3458,12 +3457,25 @@ wxDataViewMainWindow::FindColumnForEditing(const wxDataViewItem& item, wxDataVie
|
|||||||
if ( !candidate )
|
if ( !candidate )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( candidate->GetRenderer()->GetMode() != mode )
|
if ( !IsCellEditableInMode(item, candidate, mode) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return candidate;
|
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)
|
void wxDataViewMainWindow::OnCharHook(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
if ( m_editorCtrl )
|
if ( m_editorCtrl )
|
||||||
@@ -4062,7 +4074,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
if (m_lastOnSame && !ignore_other_columns)
|
if (m_lastOnSame && !ignore_other_columns)
|
||||||
{
|
{
|
||||||
if ((col == m_currentCol) && (current == m_currentRow) &&
|
if ((col == m_currentCol) && (current == m_currentRow) &&
|
||||||
(cell->GetMode() & wxDATAVIEW_CELL_EDITABLE) )
|
IsCellEditableInMode(item, col, wxDATAVIEW_CELL_EDITABLE) )
|
||||||
{
|
{
|
||||||
m_renameTimer->Start( 100, true );
|
m_renameTimer->Start( 100, true );
|
||||||
}
|
}
|
||||||
@@ -4181,7 +4193,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
(current == oldCurrentRow)) && oldWasSelected;
|
(current == oldCurrentRow)) && oldWasSelected;
|
||||||
|
|
||||||
// Call ActivateCell() after everything else as under GTK+
|
// 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
|
// notify cell about click
|
||||||
cell->PrepareForItem(model, item, col->GetModelColumn());
|
cell->PrepareForItem(model, item, col->GetModelColumn());
|
||||||
|
Reference in New Issue
Block a user