Allow increasing the size of the last column in wxDataViewCtrl
Previously, the last column couldn't be effectively resized at all, as its size was always automatically set to the remaining width of the window after subtracting the widths of all the previous columns. Now this is only done if this remaining width is greater than the width given to the column by the user or by the program. Effectively, this means that the user can now drag-resize the column to increase its size (at the price of showing the horizontal scrollbar). See #18295.
This commit is contained in:
@@ -74,6 +74,11 @@ public:
|
||||
// UpdateWidth() if the width didn't really change, even if we don't
|
||||
// care about its return value.
|
||||
(void)WXUpdateWidth(width);
|
||||
|
||||
// Do remember the last explicitly set width: this is used to prevent
|
||||
// UpdateColumnSizes() from resizing the last column to be smaller than
|
||||
// this size.
|
||||
m_manuallySetWidth = width;
|
||||
}
|
||||
virtual int GetWidth() const wxOVERRIDE;
|
||||
|
||||
@@ -137,9 +142,15 @@ public:
|
||||
m_width = width;
|
||||
UpdateWidth();
|
||||
|
||||
// We must not update m_manuallySetWidth here as this method is called by
|
||||
// UpdateColumnSizes() which resizes the column automatically, and not
|
||||
// "manually".
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int WXGetManuallySetWidth() const { return m_manuallySetWidth; }
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init(int width, wxAlignment align, int flags);
|
||||
@@ -152,6 +163,7 @@ private:
|
||||
|
||||
wxString m_title;
|
||||
int m_width,
|
||||
m_manuallySetWidth,
|
||||
m_minWidth;
|
||||
wxAlignment m_align;
|
||||
int m_flags;
|
||||
|
@@ -793,7 +793,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
lc->AppendColumn(colRadio, "bool");
|
||||
|
||||
lc->AppendTextColumn( "Text" );
|
||||
lc->AppendProgressColumn( "Progress" );
|
||||
lc->AppendProgressColumn( "Progress" )->SetMinWidth(100);
|
||||
|
||||
wxVector<wxVariant> data;
|
||||
for (unsigned int i=0; i<10; i++)
|
||||
|
@@ -180,7 +180,8 @@ wxTextCtrl *CreateEditorTextCtrl(wxWindow *parent, const wxRect& labelRect, cons
|
||||
|
||||
void wxDataViewColumn::Init(int width, wxAlignment align, int flags)
|
||||
{
|
||||
m_width = width;
|
||||
m_width =
|
||||
m_manuallySetWidth = width;
|
||||
m_minWidth = 0;
|
||||
m_align = align;
|
||||
m_flags = flags;
|
||||
@@ -5022,20 +5023,25 @@ void wxDataViewMainWindow::UpdateColumnSizes()
|
||||
int lastColX = colswidth - lastCol->GetWidth();
|
||||
if ( lastColX < fullWinWidth )
|
||||
{
|
||||
int desiredWidth = wxMax(fullWinWidth - lastColX, lastCol->GetMinWidth());
|
||||
if ( !lastCol->WXUpdateWidth(desiredWidth) )
|
||||
const int availableWidth = fullWinWidth - lastColX;
|
||||
|
||||
// Never make the column automatically smaller than the last width it
|
||||
// was explicitly given nor its minimum width.
|
||||
if ( availableWidth <= wxMax(lastCol->GetMinWidth(),
|
||||
lastCol->WXGetManuallySetWidth()) )
|
||||
{
|
||||
// The column width didn't change, no need to do anything else.
|
||||
return;
|
||||
}
|
||||
|
||||
lastCol->WXUpdateWidth(availableWidth);
|
||||
|
||||
// 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));
|
||||
RefreshRect(wxRect(lastColX, 0, availableWidth, GetSize().y));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user