Implement GetSizeFromTextSize() for wxSpinCtrl.
Implement it for the native MSW and GTK versions and the generic one used in the other ports and also for wxSpinCtrlDouble under MSW. Also test this function in the spin page of the widgets sample. Closes #14840. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -717,26 +717,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));
|
||||
|
||||
return sizeBtn;
|
||||
// Check if the user requested a non-standard height.
|
||||
if ( ylen > 0 )
|
||||
tsize.IncBy(0, ylen - y);
|
||||
|
||||
return tsize;
|
||||
}
|
||||
|
||||
void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
|
||||
|
Reference in New Issue
Block a user