Add undetermined state to wxCheckBoxXmlHandler
3-state checkboxes can have their initial value set to checked or undetermined -- this adds support for the undetermined state to the handler (only allowed if the style includes wxCHK_3STATE). Closes #22468.
This commit is contained in:
committed by
Vadim Zeitlin
parent
070bc8bd29
commit
cb8c0dfb0d
@@ -946,8 +946,10 @@ No additional properties.
|
|||||||
@hdr3col{property, type, description}
|
@hdr3col{property, type, description}
|
||||||
@row3col{label, @ref overview_xrcformat_type_text,
|
@row3col{label, @ref overview_xrcformat_type_text,
|
||||||
Label to use for the checkbox (default: empty).}
|
Label to use for the checkbox (default: empty).}
|
||||||
@row3col{checked, @ref overview_xrcformat_type_bool,
|
@row3col{checked, integer,
|
||||||
Should the checkbox be checked initially (default: 0)?}
|
Sets the initial state of the checkbox. 0 is unchecked (default),
|
||||||
|
1 is checked, and since wxWidgets 3.1.7, 2 sets the undetermined
|
||||||
|
state of a 3-state checkbox.}
|
||||||
@endTable
|
@endTable
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ wxCheckBox =
|
|||||||
stdObjectNodeAttributes &
|
stdObjectNodeAttributes &
|
||||||
stdWindowProperties &
|
stdWindowProperties &
|
||||||
[xrc:p="important"] element label {_, t_text }* &
|
[xrc:p="important"] element label {_, t_text }* &
|
||||||
[xrc:p="o"] element checked {_, t_bool }*
|
[xrc:p="o"] element checked {_, t_integer }*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,38 @@ wxObject *wxCheckBoxXmlHandler::DoCreateResource()
|
|||||||
wxDefaultValidator,
|
wxDefaultValidator,
|
||||||
GetName());
|
GetName());
|
||||||
|
|
||||||
control->SetValue(GetBool( wxT("checked")));
|
switch (GetLong("checked", wxCHK_UNCHECKED))
|
||||||
|
{
|
||||||
|
case wxCHK_UNCHECKED:
|
||||||
|
// Nothing to do here, we could call SetValue() but the default state
|
||||||
|
// is unchecked anyhow.
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxCHK_CHECKED:
|
||||||
|
control->SetValue(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxCHK_UNDETERMINED:
|
||||||
|
// While just trying to set it would generate an assert if wxCHK_3STATE
|
||||||
|
// is not set, prefer to give an error here as we have more information
|
||||||
|
// about the problem.
|
||||||
|
if ( !control->HasFlag(wxCHK_3STATE) )
|
||||||
|
{
|
||||||
|
ReportParamError("checked",
|
||||||
|
"A checkbox must have wxCHK_3STATE style to use wxCHK_UNDETERMINED");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
control->Set3StateValue(wxCHK_UNDETERMINED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ReportParamError("checked",
|
||||||
|
wxString::Format("Unknown checkbox state: \"%s\"",
|
||||||
|
GetParamValue("checked")));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
SetupWindow(control);
|
SetupWindow(control);
|
||||||
|
|
||||||
return control;
|
return control;
|
||||||
|
|||||||
Reference in New Issue
Block a user