diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h index 6835acb8e2..b02f2e6bc0 100644 --- a/docs/doxygen/overviews/xrc_format.h +++ b/docs/doxygen/overviews/xrc_format.h @@ -946,8 +946,10 @@ No additional properties. @hdr3col{property, type, description} @row3col{label, @ref overview_xrcformat_type_text, Label to use for the checkbox (default: empty).} -@row3col{checked, @ref overview_xrcformat_type_bool, - Should the checkbox be checked initially (default: 0)?} +@row3col{checked, integer, + 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 diff --git a/misc/schema/xrc_schema.rnc b/misc/schema/xrc_schema.rnc index 65d6899a7c..153b76fc5b 100644 --- a/misc/schema/xrc_schema.rnc +++ b/misc/schema/xrc_schema.rnc @@ -765,7 +765,7 @@ wxCheckBox = stdObjectNodeAttributes & stdWindowProperties & [xrc:p="important"] element label {_, t_text }* & - [xrc:p="o"] element checked {_, t_bool }* + [xrc:p="o"] element checked {_, t_integer }* } diff --git a/src/xrc/xh_chckb.cpp b/src/xrc/xh_chckb.cpp index 6f74b7325c..e13d48a853 100644 --- a/src/xrc/xh_chckb.cpp +++ b/src/xrc/xh_chckb.cpp @@ -43,7 +43,38 @@ wxObject *wxCheckBoxXmlHandler::DoCreateResource() wxDefaultValidator, 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); return control;