Merge branch 'dvc-colsize-vert-scroll'

Fix issues with generic wxDVC last column size when using
wxPersistentDVC.

See https://github.com/wxWidgets/wxWidgets/pull/1832
This commit is contained in:
Vadim Zeitlin
2020-05-06 18:44:28 +02:00
4 changed files with 47 additions and 21 deletions

View File

@@ -514,6 +514,12 @@ public:
virtual void SetBitmap( const wxBitmap& bitmap ) wxOVERRIDE { m_bitmap = bitmap; }
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
// Special accessor for use by wxWidgets only returning the width that was
// explicitly set, either by the application, using SetWidth(), or by the
// user, resizing the column interactively. It is usually the same as
// GetWidth(), but can be different for the last column.
virtual int WXGetSpecifiedWidth() const { return GetWidth(); }
protected:
wxDataViewRenderer *m_renderer;
int m_model_column;

View File

@@ -137,15 +137,6 @@ public:
if ( width == m_width )
return;
// Normally we don't update it here as this method is called by
// UpdateColumnSizes() which resizes the column automatically, and not
// "manually", but if it's the first time the width is being set for a
// column created with the default width, do set m_manuallySetWidth in
// order to prevent the column from becoming narrower than its initial
// size when the control is resized, as this is unexpected.
if ( m_width == -1 )
m_manuallySetWidth = width;
m_width = width;
UpdateWidth();
}
@@ -154,7 +145,7 @@ public:
// user interactively.
void WXOnResize(int width);
int WXGetManuallySetWidth() const { return m_manuallySetWidth; }
virtual int WXGetSpecifiedWidth() const wxOVERRIDE;
private:
// common part of all ctors
@@ -166,6 +157,11 @@ private:
void UpdateDisplay();
void UpdateWidth();
// Return the effective value corresponding to the given width, handling
// its negative values such as wxCOL_WIDTH_DEFAULT.
int DoGetEffectiveWidth(int width) const;
wxString m_title;
int m_width,
m_manuallySetWidth,

View File

@@ -61,7 +61,15 @@ public:
SaveValue(columnPrefix + wxPERSIST_DVC_HIDDEN, column->IsHidden());
SaveValue(columnPrefix + wxPERSIST_DVC_POS,
control->GetColumnPosition(column));
SaveValue(columnPrefix + wxPERSIST_DVC_WIDTH, column->GetWidth());
// We take special care to save only the specified width instead of
// the currently used one. Usually they're one and the same, but
// they can be different for the last column, whose size can be
// greater than specified, as it's always expanded to fill the
// entire control width.
const int width = column->WXGetSpecifiedWidth();
if ( width > 0 )
SaveValue(columnPrefix + wxPERSIST_DVC_WIDTH, width);
// Check if this column is the current sort key.
if ( column->IsSortKey() )