X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e565667d0f29605c948ad6e742310798e3b2d0d..1af67319a7c54373c85a15477f59a72f3e929268:/src/msw/spinctrl.cpp?ds=sidebyside diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index ea503b4c41..a034cda2ee 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -399,12 +399,11 @@ bool wxSpinCtrl::Create(wxWindow *parent, if ( value.ToLong(&initialFromText) ) initial = initialFromText; - SetValue(initial); - - m_oldValue = initial; - - // Set the range in the native control + // Set the range in the native control: notice that we must do it before + // calling SetValue() to use the correct validity checks for the initial + // value. SetRange(min, max); + SetValue(initial); // Also set the text part of the control if it was specified independently // but don't generate an event for this, it would be unexpected. @@ -717,26 +716,29 @@ bool wxSpinCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *re // ---------------------------------------------------------------------------- wxSize wxSpinCtrl::DoGetBestSize() const +{ + return DoGetSizeFromTextSize(DEFAULT_ITEM_WIDTH); +} + +wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const { wxSize sizeBtn = wxSpinButton::DoGetBestSize(); - sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN; int y; wxGetCharSize(GetHWND(), NULL, &y, GetFont()); - y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(y); - // JACS: we should always use the height calculated // from above, because otherwise we'll get a spin control // that's too big. So never use the height calculated // from wxSpinButton::DoGetBestSize(). - // if ( sizeBtn.y < y ) - { - // make the text tall enough - sizeBtn.y = y; - } + wxSize tsize(xlen + sizeBtn.x + MARGIN_BETWEEN + 0.3 * y + 10, + EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); + + // Check if the user requested a non-standard height. + if ( ylen > 0 ) + tsize.IncBy(0, ylen - y); - return sizeBtn; + return tsize; } void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)