From 8292017ce0c67bc3c759d7c681a690b6c493150e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 9 Apr 2002 22:25:57 +0000 Subject: [PATCH] added support for the multiline button labels git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++-- src/msw/button.cpp | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 8ae00ccaa9..be561d78ff 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -170,8 +170,8 @@ wxMSW: - the separators are not seen behind the controls added to the toolbar any more - wxLB_SORT style can be used with wxCheckListBox - wxWindowDC and wxClientDC::GetSize() works correctly now -- Added wxTB_NODIVIDER and wxTB_NOALIGN so native toolbar can - be used in FL +- Added wxTB_NODIVIDER and wxTB_NOALIGN so native toolbar can be used in FL +- Multiline labels in buttons are now supoprted (simply use "\n" in the label) wxGTK: diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 5cb83273d7..2cafeca17e 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -71,7 +71,24 @@ bool wxButton::Create(wxWindow *parent, if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return FALSE; - return MSWCreateControl(_T("BUTTON"), label, pos, size, style); + WXDWORD exstyle; + WXDWORD msStyle = MSWGetStyle(style, &exstyle); + +#ifdef __WIN32__ + // if the label contains several lines we must explicitly tell the button + // about it or it wouldn't draw it correctly ("\n"s would just appear as + // black boxes) + // + // 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; + // besides changing BS_MULTILINE during run-time is pointless anyhow + if ( label.find(_T('\n')) != wxString::npos ) + { + msStyle |= BS_MULTILINE; + } +#endif // __WIN32__ + + return MSWCreateControl(_T("BUTTON"), msStyle, pos, size, label, exstyle); } wxButton::~wxButton()