Auto grow the last wxDataViewCtrl column on all platforms.
The GTK+ implementation always did this and it doesn't make much sense to let the space be wasted, so do as GTK+ does: expand the last column to cover the remaining unused space in the OS X and generic implementations too. Don't do anything if the space is insufficient. Respect the last column's minimal width. See #13904. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75347 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -802,6 +802,9 @@ public:
|
||||
|
||||
void OnColumnsCountChanged();
|
||||
|
||||
// Adjust last column to window size
|
||||
void UpdateColumnSizes();
|
||||
|
||||
// Called by wxDataViewCtrl and our own OnRenameTimer() to start edit the
|
||||
// specified item in the given column.
|
||||
void StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col);
|
||||
@@ -2591,6 +2594,7 @@ void wxDataViewMainWindow::OnInternalIdle()
|
||||
|
||||
if (m_dirty)
|
||||
{
|
||||
UpdateColumnSizes();
|
||||
RecalculateDisplay();
|
||||
m_dirty = false;
|
||||
}
|
||||
@@ -4494,6 +4498,39 @@ void wxDataViewMainWindow::OnColumnsCountChanged()
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void wxDataViewMainWindow::UpdateColumnSizes()
|
||||
{
|
||||
int colsCount = GetOwner()->GetColumnCount();
|
||||
if ( !colsCount )
|
||||
return;
|
||||
|
||||
wxDataViewCtrl *owner = GetOwner();
|
||||
|
||||
int fullWinWidth = GetSize().x;
|
||||
|
||||
wxDataViewColumn *lastCol = owner->GetColumn(colsCount - 1);
|
||||
int colswidth = GetEndOfLastCol();
|
||||
int lastColX = colswidth - lastCol->GetWidth();
|
||||
if ( lastColX < fullWinWidth )
|
||||
{
|
||||
int desiredWidth = wxMax(fullWinWidth - lastColX, lastCol->GetMinWidth());
|
||||
lastCol->SetWidth(desiredWidth);
|
||||
|
||||
// All columns fit on screen, so we don't need horizontal scrolling.
|
||||
// To prevent flickering scrollbar when resizing the window to be
|
||||
// narrower, force-set the virtual width to 0 here. It will eventually
|
||||
// be corrected at idle time.
|
||||
SetVirtualSize(0, m_virtualSize.y);
|
||||
|
||||
RefreshRect(wxRect(lastColX, 0, fullWinWidth - lastColX, GetSize().y));
|
||||
}
|
||||
else
|
||||
{
|
||||
// else: don't bother, the columns won't fit anyway
|
||||
SetVirtualSize(colswidth, m_virtualSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDataViewCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -4609,6 +4646,9 @@ wxSize wxDataViewCtrl::GetSizeAvailableForScrollTarget(const wxSize& size)
|
||||
|
||||
void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
if ( m_clientArea && GetColumnCount() )
|
||||
m_clientArea->UpdateColumnSizes();
|
||||
|
||||
// We need to override OnSize so that our scrolled
|
||||
// window a) does call Layout() to use sizers for
|
||||
// positioning the controls but b) does not query
|
||||
|
Reference in New Issue
Block a user