X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f66f6a5b3583b02c34854556eb83e3a808524ce..e733c4ce1e24cf7e4b0b0d8362fc59aaa7a7641c:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index d90cd83ef0..d36e86116b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1021,7 +1021,7 @@ bool wxDataViewBitmapRenderer::GetValue( wxVariant& WXUNUSED(value) ) const bool wxDataViewBitmapRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) { if (m_bitmap.IsOk()) - dc->DrawBitmap( m_bitmap, cell.x, cell.y ); + dc->DrawBitmap( m_bitmap, cell.x, cell.y, true /* use mask */ ); else if (m_icon.IsOk()) dc->DrawIcon( m_icon, cell.x, cell.y ); @@ -2489,18 +2489,8 @@ bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item) bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int model_column ) { - 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) + int view_column = m_owner->GetModelColumnIndex(model_column); + if ( view_column == wxNOT_FOUND ) return false; // NOTE: to be valid, we cannot use e.g. INT_MAX - 1 @@ -4730,6 +4720,14 @@ void wxDataViewCtrl::OnColumnsCountChanged() void wxDataViewCtrl::DoSetExpanderColumn() { + wxDataViewColumn* column = GetExpanderColumn(); + if ( column ) + { + int index = GetColumnIndex(column); + if ( index != wxNOT_FOUND ) + InvalidateColBestWidth(index); + } + m_clientArea->UpdateDisplay(); } @@ -4780,6 +4778,18 @@ int wxDataViewCtrl::GetColumnIndex(const wxDataViewColumn *column) const return wxNOT_FOUND; } +int wxDataViewCtrl::GetModelColumnIndex( unsigned int model_column ) const +{ + const int count = GetColumnCount(); + for ( int index = 0; index < count; index++ ) + { + wxDataViewColumn* column = GetColumn(index); + if ( column->GetModelColumn() == model_column ) + return index; + } + return wxNOT_FOUND; +} + unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const { if ( m_colsBestWidths[idx].width != 0 ) @@ -4797,21 +4807,23 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const wxDataViewMainWindow *clientArea, wxDataViewRenderer *renderer, const wxDataViewModel *model, - unsigned column, + unsigned int model_column, int expanderSize) : m_width(0), m_dvc(dvc), m_clientArea(clientArea), m_renderer(renderer), m_model(model), - m_column(column), + m_model_column(model_column), m_expanderSize(expanderSize) { + int index = dvc->GetModelColumnIndex( model_column ); + wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index); m_isExpanderCol = !clientArea->IsList() && (column == 0 || - GetExpanderColumnOrFirstOne(const_cast(dvc)) == dvc->GetColumnAt(column)); + GetExpanderColumnOrFirstOne(const_cast(dvc)) == column ); } void UpdateWithWidth(int width) @@ -4835,7 +4847,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const item = m_clientArea->GetItemByRow(row); } - m_renderer->PrepareForItem(m_model, item, m_column); + m_renderer->PrepareForItem(m_model, item, m_model_column); m_width = wxMax(m_width, m_renderer->GetSize().x + indent); } @@ -4847,7 +4859,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const wxDataViewMainWindow *m_clientArea; wxDataViewRenderer *m_renderer; const wxDataViewModel *m_model; - unsigned m_column; + unsigned m_model_column; bool m_isExpanderCol; int m_expanderSize; };