update button style to include BS_MULTILINE when a multiline label is set
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -45,15 +45,16 @@ public:
|
|||||||
|
|
||||||
virtual wxWindow *SetDefault();
|
virtual wxWindow *SetDefault();
|
||||||
|
|
||||||
|
// overridden base class methods
|
||||||
|
virtual void SetLabel(const wxString& label);
|
||||||
|
virtual bool SetBackgroundColour(const wxColour &colour);
|
||||||
|
virtual bool SetForegroundColour(const wxColour &colour);
|
||||||
|
|
||||||
// implementation from now on
|
// implementation from now on
|
||||||
virtual void Command(wxCommandEvent& event);
|
virtual void Command(wxCommandEvent& event);
|
||||||
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||||
|
|
||||||
// coloured buttons support
|
|
||||||
virtual bool SetBackgroundColour(const wxColour &colour);
|
|
||||||
virtual bool SetForegroundColour(const wxColour &colour);
|
|
||||||
|
|
||||||
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
||||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||||
|
|
||||||
@@ -78,5 +79,4 @@ private:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxButton)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxButton)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _WX_BUTTON_H_
|
||||||
// _WX_BUTTON_H_
|
|
||||||
|
@@ -182,8 +182,7 @@ bool wxButton::Create(wxWindow *parent,
|
|||||||
// black boxes)
|
// black boxes)
|
||||||
//
|
//
|
||||||
// NB: we do it here and not in MSWGetStyle() because we need the label
|
// NB: we do it here and not in MSWGetStyle() because we need the label
|
||||||
// value and m_label is not set yet when MSWGetStyle() is called;
|
// value and the label is not set yet when MSWGetStyle() is called
|
||||||
// besides changing BS_MULTILINE during run-time is pointless anyhow
|
|
||||||
if ( label.find(_T('\n')) != wxString::npos )
|
if ( label.find(_T('\n')) != wxString::npos )
|
||||||
{
|
{
|
||||||
msStyle |= BS_MULTILINE;
|
msStyle |= BS_MULTILINE;
|
||||||
@@ -237,6 +236,25 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
return msStyle;
|
return msStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxButton::SetLabel(const wxString& label)
|
||||||
|
{
|
||||||
|
// update BS_MULTILINE style depending on the new label (resetting it
|
||||||
|
// doesn't seem to do anything very useful but it shouldn't hurt and we do
|
||||||
|
// have to set it whenever the label becomes multi line as otherwise it
|
||||||
|
// wouldn't be shown correctly)
|
||||||
|
long styleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE),
|
||||||
|
styleNew;
|
||||||
|
if ( label.find(_T('\n')) != wxString::npos )
|
||||||
|
styleNew = styleOld | BS_MULTILINE;
|
||||||
|
else
|
||||||
|
styleNew = styleOld & ~BS_MULTILINE;
|
||||||
|
|
||||||
|
if ( styleNew != styleOld )
|
||||||
|
::SetWindowLong(GetHwnd(), GWL_STYLE, styleNew);
|
||||||
|
|
||||||
|
wxButtonBase::SetLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// size management including autosizing
|
// size management including autosizing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user