Merge branch 'spinctrl-fixes'

Various improvements to wxSpinCtrl and wxGridCellNumberEditor, using it.

Closes https://github.com/wxWidgets/wxWidgets/pull/1588
This commit is contained in:
Vadim Zeitlin
2019-10-09 01:52:10 +02:00
9 changed files with 129 additions and 43 deletions

View File

@@ -115,6 +115,11 @@ public:
wxSize GetSizeFromTextSize(const wxSize& tsize) const
{ return DoGetSizeFromTextSize(tsize.x, tsize.y); }
wxSize GetSizeFromText(const wxString& text) const
{
return GetSizeFromTextSize(GetTextExtent(text).GetWidth());
}
// static utilities for mnemonics char (&) handling
// ------------------------------------------------

View File

@@ -116,6 +116,8 @@ public:
wxWindowID id,
wxEvtHandler* evtHandler) wxOVERRIDE;
virtual void SetSize(const wxRect& rect) wxOVERRIDE;
virtual bool IsAcceptedKey(wxKeyEvent& event) wxOVERRIDE;
virtual void BeginEdit(int row, int col, wxGrid* grid) wxOVERRIDE;
virtual bool EndEdit(int row, int col, const wxGrid* grid,

View File

@@ -168,6 +168,9 @@ private:
// (up-down control) and the text control (buddy window).
int GetOverlap() const;
// Calculate the best size for the number with the given number of digits.
wxSize GetBestSizeFromDigitsCount(int digitsCount) const;
wxDECLARE_DYNAMIC_CLASS(wxSpinCtrl);
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxSpinCtrl);

View File

@@ -143,6 +143,11 @@ namespace wxPrivate
// string containing hexadecimal representation of the given number.
extern wxString wxSpinCtrlFormatAsHex(long val, long maxVal);
// The helper function to determine the best size for the given control.
// We can't implement this function in the wxSpinCtrlBase because MSW implementation
// of wxSpinCtrl is derived from wxSpinButton but uses the same algorithm.
extern wxSize wxSpinCtrlGetBestSize(const wxControl* spin, int minVal, int maxVal, int base);
} // namespace wxPrivate
// old wxEVT_COMMAND_* constants