Don't keep out of date column widths in generic wxDataViewCtrl.

The cached widths need to be invalidated whenever an item is expanded or
collapsed, whether it's done programmatically (which was already handled) or
interactively by the user (which wasn't).

Closes #16678.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-12-05 22:15:28 +00:00
parent f0c6aa2478
commit 70f3c3023d
2 changed files with 9 additions and 6 deletions

View File

@@ -596,6 +596,7 @@ wxMSW:
- Fix initial text value of wxSpinCtrlDouble (Laurent Poujoulat). - Fix initial text value of wxSpinCtrlDouble (Laurent Poujoulat).
- Fix best size calculation for bitmaps with buttons (Artur Wieczorek). - Fix best size calculation for bitmaps with buttons (Artur Wieczorek).
- Fix size of the icon returned from wxFSVolume::GetIcon() (troelsk). - Fix size of the icon returned from wxFSVolume::GetIcon() (troelsk).
- Fix autosize after expanding/collapsing items in wxDataViewCtrl (ciglesias).
3.0.2: (released 2014-10-06) 3.0.2: (released 2014-10-06)

View File

@@ -3208,6 +3208,11 @@ void wxDataViewMainWindow::Expand( unsigned int row )
ChangeCurrentRow(m_currentRow + rowAdjustment); ChangeCurrentRow(m_currentRow + rowAdjustment);
m_count = -1; m_count = -1;
// Expanding this item means the previously cached column widths could
// have become invalid as new items are now visible.
GetOwner()->InvalidateColBestWidths();
UpdateDisplay(); UpdateDisplay();
// Send the expanded event // Send the expanded event
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem()); SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem());
@@ -3283,6 +3288,9 @@ void wxDataViewMainWindow::Collapse(unsigned int row)
} }
m_count = -1; m_count = -1;
GetOwner()->InvalidateColBestWidths();
UpdateDisplay(); UpdateDisplay();
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem()); SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
} }
@@ -5293,20 +5301,14 @@ void wxDataViewCtrl::Expand( const wxDataViewItem & item )
int row = m_clientArea->GetRowByItem( item ); int row = m_clientArea->GetRowByItem( item );
if (row != -1) if (row != -1)
{
m_clientArea->Expand(row); m_clientArea->Expand(row);
InvalidateColBestWidths();
}
} }
void wxDataViewCtrl::Collapse( const wxDataViewItem & item ) void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
{ {
int row = m_clientArea->GetRowByItem( item ); int row = m_clientArea->GetRowByItem( item );
if (row != -1) if (row != -1)
{
m_clientArea->Collapse(row); m_clientArea->Collapse(row);
InvalidateColBestWidths();
}
} }
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const