Improve validation of wxCheckBox styles.

Detect when incompatible styles are used (this required changing the value of
wxCHK_2STATE to be non-null) and sanitize the styles (after asserting) in this
case.

Put the validation code in wxCheckBoxBase instead of having slightly different
versions of it in port-specific wxCheckBox implementations.

Add a unit test checking that the expected asserts are indeed generated.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65824 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-10-16 18:10:42 +00:00
parent a9df18b4e4
commit f254e2424a
7 changed files with 91 additions and 23 deletions

View File

@@ -105,6 +105,7 @@ bool wxCheckBox::Create(wxWindow *parent,
const wxValidator& validator,
const wxString &name )
{
WXValidateStyle( &style );
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
@@ -112,11 +113,6 @@ bool wxCheckBox::Create(wxWindow *parent,
return false;
}
wxASSERT_MSG( (style & wxCHK_ALLOW_3RD_STATE_FOR_USER) == 0 ||
(style & wxCHK_3STATE) != 0,
wxT("Using wxCHK_ALLOW_3RD_STATE_FOR_USER")
wxT(" style flag for a 2-state checkbox is useless") );
if ( style & wxALIGN_RIGHT )
{
// VZ: as I don't know a way to create a right aligned checkbox with