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:
@@ -55,6 +55,9 @@ public:
|
|||||||
// make the checkbox owner drawn or reset it to normal style
|
// make the checkbox owner drawn or reset it to normal style
|
||||||
void MSWMakeOwnerDrawn(bool ownerDrawn);
|
void MSWMakeOwnerDrawn(bool ownerDrawn);
|
||||||
|
|
||||||
|
// implementation only from now on
|
||||||
|
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
@@ -104,7 +104,18 @@ bool wxCheckBox::Create(wxWindow *parent,
|
|||||||
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
||||||
return false;
|
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 )
|
if ( style & wxCHK_3STATE )
|
||||||
msStyle |= BS_3STATE;
|
msStyle |= BS_3STATE;
|
||||||
@@ -116,9 +127,7 @@ bool wxCheckBox::Create(wxWindow *parent,
|
|||||||
msStyle |= BS_LEFTTEXT | BS_RIGHT;
|
msStyle |= BS_LEFTTEXT | BS_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
msStyle |= wxMSWButton::GetMultilineStyle(label);
|
return msStyle;
|
||||||
|
|
||||||
return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -61,25 +61,10 @@ bool wxRadioButton::Create(wxWindow *parent,
|
|||||||
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
long msStyle = WS_TABSTOP;
|
WXDWORD exstyle = 0;
|
||||||
if ( HasFlag(wxRB_GROUP) )
|
WXDWORD msStyle = MSWGetStyle(style, &exstyle);
|
||||||
msStyle |= WS_GROUP;
|
|
||||||
|
|
||||||
// we use BS_RADIOBUTTON and not BS_AUTORADIOBUTTON because the use of the
|
if ( !MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, exstyle) )
|
||||||
// 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) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// for compatibility with wxGTK, the first radio button in a group is
|
// 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 wxRadioButton::MSWGetStyle(long style, WXDWORD *exstyle) const
|
||||||
{
|
{
|
||||||
WXDWORD styleMSW = wxControl::MSWGetStyle(style, exstyle);
|
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
|
||||||
|
|
||||||
if ( style & wxRB_GROUP )
|
if ( HasFlag(wxRB_GROUP) )
|
||||||
styleMSW |= WS_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
|
#endif // wxUSE_RADIOBTN
|
||||||
|
Reference in New Issue
Block a user