Respect styles translated to WS_EX_XXX in wxMSW wxCheckBox and wxRadioButton.

Take into account the window styles that translate to extended Windows styles
at MSW level.

Also override MSWGetStyle() in these classes, just as in most (all?) other
ones, for consistency instead of doing wx-to-MSW styles translation directly
in Create().

Notice that as a side effect of this change, border styles now work for
wxCheckBox which wasn't the case before. It's not clear if this is really
wanted but OTOH there doesn't seem to be any real reason to forbid them
neither.

Closes #14674.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72538 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-23 22:47:52 +00:00
parent 863dc042da
commit 687823a157
3 changed files with 38 additions and 26 deletions

View File

@@ -55,6 +55,9 @@ public:
// make the checkbox owner drawn or reset it to normal style
void MSWMakeOwnerDrawn(bool ownerDrawn);
// implementation only from now on
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
protected:
virtual wxSize DoGetBestSize() const;

View File

@@ -104,7 +104,18 @@ bool wxCheckBox::Create(wxWindow *parent,
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
long msStyle = WS_TABSTOP;
WXDWORD exstyle;
WXDWORD msStyle = MSWGetStyle(style, &exstyle);
msStyle |= wxMSWButton::GetMultilineStyle(label);
return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, exstyle);
}
WXDWORD wxCheckBox::MSWGetStyle(long style, WXDWORD *exstyle) const
{
// buttons never have an external border, they draw their own one
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
if ( style & wxCHK_3STATE )
msStyle |= BS_3STATE;
@@ -116,9 +127,7 @@ bool wxCheckBox::Create(wxWindow *parent,
msStyle |= BS_LEFTTEXT | BS_RIGHT;
}
msStyle |= wxMSWButton::GetMultilineStyle(label);
return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0);
return msStyle;
}
// ----------------------------------------------------------------------------

View File

@@ -61,25 +61,10 @@ bool wxRadioButton::Create(wxWindow *parent,
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
long msStyle = WS_TABSTOP;
if ( HasFlag(wxRB_GROUP) )
msStyle |= WS_GROUP;
WXDWORD exstyle = 0;
WXDWORD msStyle = MSWGetStyle(style, &exstyle);
// we use BS_RADIOBUTTON and not BS_AUTORADIOBUTTON because the use of the
// latter can easily result in the application entering an infinite loop
// inside IsDialogMessage()
//
// we used to use BS_RADIOBUTTON only for wxRB_SINGLE buttons but there
// doesn't seem to be any harm to always use it and it prevents some hangs,
// see #9786
msStyle |= BS_RADIOBUTTON;
if ( HasFlag(wxCLIP_SIBLINGS) )
msStyle |= WS_CLIPSIBLINGS;
if ( HasFlag(wxALIGN_RIGHT) )
msStyle |= BS_LEFTTEXT | BS_RIGHT;
if ( !MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0) )
if ( !MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, exstyle) )
return false;
// for compatibility with wxGTK, the first radio button in a group is
@@ -289,12 +274,27 @@ wxSize wxRadioButton::DoGetBestSize() const
WXDWORD wxRadioButton::MSWGetStyle(long style, WXDWORD *exstyle) const
{
WXDWORD styleMSW = wxControl::MSWGetStyle(style, exstyle);
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
if ( style & wxRB_GROUP )
styleMSW |= WS_GROUP;
if ( HasFlag(wxRB_GROUP) )
msStyle |= WS_GROUP;
return styleMSW;
// we use BS_RADIOBUTTON and not BS_AUTORADIOBUTTON because the use of the
// latter can easily result in the application entering an infinite loop
// inside IsDialogMessage()
//
// we used to use BS_RADIOBUTTON only for wxRB_SINGLE buttons but there
// doesn't seem to be any harm to always use it and it prevents some hangs,
// see #9786
msStyle |= BS_RADIOBUTTON;
if ( style & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS;
if ( style & wxALIGN_RIGHT )
msStyle |= BS_LEFTTEXT | BS_RIGHT;
return msStyle;
}
#endif // wxUSE_RADIOBTN