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();
|
void OnColumnsCountChanged();
|
||||||
|
|
||||||
|
// Adjust last column to window size
|
||||||
|
void UpdateColumnSizes();
|
||||||
|
|
||||||
// Called by wxDataViewCtrl and our own OnRenameTimer() to start edit the
|
// Called by wxDataViewCtrl and our own OnRenameTimer() to start edit the
|
||||||
// specified item in the given column.
|
// specified item in the given column.
|
||||||
void StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col);
|
void StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col);
|
||||||
@@ -2591,6 +2594,7 @@ void wxDataViewMainWindow::OnInternalIdle()
|
|||||||
|
|
||||||
if (m_dirty)
|
if (m_dirty)
|
||||||
{
|
{
|
||||||
|
UpdateColumnSizes();
|
||||||
RecalculateDisplay();
|
RecalculateDisplay();
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
@@ -4494,6 +4498,39 @@ void wxDataViewMainWindow::OnColumnsCountChanged()
|
|||||||
UpdateDisplay();
|
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
|
// wxDataViewCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -4609,6 +4646,9 @@ wxSize wxDataViewCtrl::GetSizeAvailableForScrollTarget(const wxSize& size)
|
|||||||
|
|
||||||
void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
|
void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
|
if ( m_clientArea && GetColumnCount() )
|
||||||
|
m_clientArea->UpdateColumnSizes();
|
||||||
|
|
||||||
// We need to override OnSize so that our scrolled
|
// We need to override OnSize so that our scrolled
|
||||||
// window a) does call Layout() to use sizers for
|
// window a) does call Layout() to use sizers for
|
||||||
// positioning the controls but b) does not query
|
// positioning the controls but b) does not query
|
||||||
|
@@ -351,7 +351,7 @@ NSTableColumn* CreateNativeColumn(const wxDataViewColumn *column)
|
|||||||
int resizingMask;
|
int resizingMask;
|
||||||
if (column->IsResizeable())
|
if (column->IsResizeable())
|
||||||
{
|
{
|
||||||
resizingMask = NSTableColumnUserResizingMask;
|
resizingMask = NSTableColumnUserResizingMask | NSTableColumnAutoresizingMask;
|
||||||
[nativeColumn setMinWidth:column->GetMinWidth()];
|
[nativeColumn setMinWidth:column->GetMinWidth()];
|
||||||
[nativeColumn setMaxWidth:column->GetMaxWidth()];
|
[nativeColumn setMaxWidth:column->GetMaxWidth()];
|
||||||
}
|
}
|
||||||
@@ -1971,7 +1971,7 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer,
|
|||||||
void wxCocoaDataViewControl::InitOutlineView(long style)
|
void wxCocoaDataViewControl::InitOutlineView(long style)
|
||||||
{
|
{
|
||||||
[m_OutlineView setImplementation:this];
|
[m_OutlineView setImplementation:this];
|
||||||
[m_OutlineView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
|
[m_OutlineView setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
||||||
[m_OutlineView setIndentationPerLevel:GetDataViewCtrl()->GetIndent()];
|
[m_OutlineView setIndentationPerLevel:GetDataViewCtrl()->GetIndent()];
|
||||||
NSUInteger maskGridStyle(NSTableViewGridNone);
|
NSUInteger maskGridStyle(NSTableViewGridNone);
|
||||||
if (style & wxDV_HORIZ_RULES)
|
if (style & wxDV_HORIZ_RULES)
|
||||||
@@ -3152,6 +3152,7 @@ wxDataViewColumn::wxDataViewColumn(const wxString& title,
|
|||||||
if (renderer && !renderer->IsCustomRenderer() &&
|
if (renderer && !renderer->IsCustomRenderer() &&
|
||||||
(renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
|
(renderer->GetAlignment() == wxDVR_DEFAULT_ALIGNMENT))
|
||||||
renderer->SetAlignment(align);
|
renderer->SetAlignment(align);
|
||||||
|
SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap,
|
wxDataViewColumn::wxDataViewColumn(const wxBitmap& bitmap,
|
||||||
@@ -3236,7 +3237,7 @@ void wxDataViewColumn::SetResizeable(bool resizable)
|
|||||||
{
|
{
|
||||||
wxDataViewColumnBase::SetResizeable(resizable);
|
wxDataViewColumnBase::SetResizeable(resizable);
|
||||||
if (resizable)
|
if (resizable)
|
||||||
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnUserResizingMask];
|
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnUserResizingMask | NSTableColumnAutoresizingMask];
|
||||||
else
|
else
|
||||||
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnNoResizing];
|
[m_NativeDataPtr->GetNativeColumnPtr() setResizingMask:NSTableColumnNoResizing];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user