Take number of digits into account in GTK wxSpinCtrlDouble

When determining the entry width in wxSpinCtrlDouble, we need to account
not only for the width of the integer part, but also for the number of
digits that determines the width of the fractional part.

Do it in the overridden version of (now virtual) GtkSetEntryWidth().

See https://github.com/wxWidgets/wxWidgets/pull/1817

Closes #18734.
This commit is contained in:
Vadim Zeitlin
2020-04-21 17:23:13 +02:00
parent 3ab187f75f
commit d3b9686099
2 changed files with 34 additions and 14 deletions

View File

@@ -71,8 +71,9 @@ protected:
void GtkDisableEvents();
void GtkEnableEvents();
// Update the number of digits used to match our range (and base).
void GtkSetEntryWidth();
// Update the width of the entry field to fit the current range (and also
// base or number of digits depending on the derived class).
virtual void GtkSetEntryWidth() = 0;
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const wxOVERRIDE;
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const wxOVERRIDE;
@@ -136,6 +137,9 @@ public:
virtual int GetBase() const wxOVERRIDE { return m_base; }
virtual bool SetBase(int base) wxOVERRIDE;
protected:
virtual void GtkSetEntryWidth() wxOVERRIDE;
private:
// Common part of all ctors.
void Init()
@@ -201,6 +205,9 @@ public:
virtual int GetBase() const wxOVERRIDE { return 10; }
virtual bool SetBase(int WXUNUSED(base)) wxOVERRIDE { return false; }
protected:
virtual void GtkSetEntryWidth() wxOVERRIDE;
wxDECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble);
};