Add digits property to wxSpinCtrlDoubleXmlHandler

This makes it possible to set the precision of the number
without changing the increment amount.

Closes #22470.
This commit is contained in:
Randalphwa
2022-05-29 06:20:30 -07:00
committed by Vadim Zeitlin
parent d9f36adc8f
commit 6ce81acda8
3 changed files with 9 additions and 1 deletions

View File

@@ -2088,6 +2088,8 @@ additional property:
@beginTable
@row3col{inc, float,
The amount by which the number is changed by a single arrow press.}
@row3col{digits, integer,
Sets the precision of the value of the spin control (default: 0). @since 3.1.7.}
@endTable
@since 3.1.1.

View File

@@ -1512,7 +1512,8 @@ wxSpinCtrlDouble =
[xrc:p="o"] element value {_, t_float }* &
[xrc:p="o"] element min {_, t_float }* &
[xrc:p="o"] element max {_, t_float }* &
[xrc:p="o"] element inc {_, t_float}*
[xrc:p="o"] element inc {_, t_float}* &
[xrc:p="o"] element digits {_, t_integer}*
}

View File

@@ -23,6 +23,7 @@ static const long DEFAULT_VALUE = 0;
static const long DEFAULT_MIN = 0;
static const long DEFAULT_MAX = 100;
static const int DEFAULT_INCREMENT = 1;
static const int DEFAULT_DIGITS = 0;
wxIMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler);
@@ -140,6 +141,10 @@ wxObject *wxSpinCtrlDoubleXmlHandler::DoCreateResource()
double(GetFloat(wxS("inc"), DEFAULT_INC)),
GetName());
int digits = GetLong("digits", DEFAULT_DIGITS);
if (digits != DEFAULT_DIGITS)
control->SetDigits(digits);
SetupWindow(control);
return control;