X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/737883f20a97658d4d94f8dfbcf2062209c39a28..1cea736e035f7bf6dbe696d5e724cfdb17c35686:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index a8bd2239a7..d026036799 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -145,7 +145,6 @@ protected: return *(GetOwner()->GetColumn(idx)); } - // FIXME: currently unused virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle) { wxDataViewCtrl * const owner = GetOwner(); @@ -435,7 +434,7 @@ public: bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemChanged( const wxDataViewItem &item ); - bool ValueChanged( const wxDataViewItem &item, unsigned int col ); + bool ValueChanged( const wxDataViewItem &item, unsigned int model_column ); bool Cleared(); void Resort() { @@ -845,7 +844,8 @@ bool wxDataViewToggleRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state int flags = 0; if (m_toggle) flags |= wxCONTROL_CHECKED; - if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE) + if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE || + GetEnabled() == false) flags |= wxCONTROL_DISABLED; // check boxes we draw must always have the same, standard size (if it's @@ -868,7 +868,10 @@ void wxDataViewToggleRenderer::WXOnActivate(wxDataViewModel *model, const wxDataViewItem & item, unsigned int col) { - model->ChangeValue(!valueOld.GetBool(), item, col); + if (model->IsEnabled(item, col)) + { + model->ChangeValue(!valueOld.GetBool(), item, col); + } } wxSize wxDataViewToggleRenderer::GetSize() const @@ -2069,9 +2072,23 @@ bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item) return true; } -bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int col ) +bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int model_column ) { - GetOwner()->InvalidateColBestWidth(col); + int view_column = -1; + unsigned int n_col = m_owner->GetColumnCount(); + for (unsigned i = 0; i < n_col; i++) + { + wxDataViewColumn *column = m_owner->GetColumn( i ); + if (column->GetModelColumn() == model_column) + { + view_column = (int) i; + break; + } + } + if (view_column == -1) + return false; + + GetOwner()->InvalidateColBestWidth(view_column); // NOTE: to be valid, we cannot use e.g. INT_MAX - 1 /*#define MAX_VIRTUAL_WIDTH 100000 @@ -2091,8 +2108,8 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i le.SetEventObject(parent); le.SetModel(GetOwner()->GetModel()); le.SetItem(item); - le.SetColumn(col); - le.SetDataViewColumn(GetOwner()->GetColumn(col)); + le.SetColumn(view_column); + le.SetDataViewColumn(GetOwner()->GetColumn(view_column)); parent->GetEventHandler()->ProcessEvent(le); return true; @@ -2150,6 +2167,8 @@ void wxDataViewMainWindow::RecalculateDisplay() void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) { + m_underMouse = NULL; + wxWindow::ScrollWindow( dx, dy, rect ); if (GetOwner()->m_headerArea) @@ -2158,6 +2177,8 @@ void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) void wxDataViewMainWindow::ScrollTo( int rows, int column ) { + m_underMouse = NULL; + int x, y; m_owner->GetScrollPixelsPerUnit( &x, &y ); int sy = GetLineStart( rows )/y; @@ -4216,7 +4237,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const calculator.UpdateWithRow(row); } - // row is the first unmeasured item now; that's out value of N/2 + // row is the first unmeasured item now; that's our value of N/2 if ( row < count ) { @@ -4256,8 +4277,6 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const const_cast(this)->m_colsBestWidths[idx] = max_width; return max_width; - - #undef MEASURE_ITEM } void wxDataViewCtrl::ColumnMoved(wxDataViewColumn * WXUNUSED(col), @@ -4305,8 +4324,9 @@ void wxDataViewCtrl::InvalidateColBestWidths() if ( m_headerArea ) { - // this updates visual appearance of columns 0 and up, not just 0 - m_headerArea->UpdateColumn(0); + const unsigned cols = m_headerArea->GetColumnCount(); + for ( unsigned i = 0; i < cols; i++ ) + m_headerArea->UpdateColumn(i); } } @@ -4612,7 +4632,8 @@ void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int colu wxRect itemRect = GetItemRect(item, col); wxDataViewRenderer* renderer = col->GetRenderer(); - renderer->StartEditing(item, itemRect); + if (renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE) + renderer->StartEditing(item, itemRect); } #endif // !wxUSE_GENERICDATAVIEWCTRL