]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/private/button.h
support multiline labels in wxCheckBox (#9495)
[wxWidgets.git] / include / wx / msw / private / button.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/private/button.h
3 // Purpose: helper functions used with native BUTTON control
4 // Author: Vadim Zeitlin
5 // Created: 2008-06-07
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_MSW_PRIVATE_BUTTON_H_
12 #define _WX_MSW_PRIVATE_BUTTON_H_
13
14 namespace wxMSWButton
15 {
16
17 // returns BS_MULTILINE if the label contains new lines or 0 otherwise
18 inline int GetMultilineStyle(const wxString& label)
19 {
20 return label.find(_T('\n')) == wxString::npos ? 0 : BS_MULTILINE;
21 }
22
23 // update the style of the specified HWND to include or exclude BS_MULTILINE
24 // depending on whether the label contains the new lines
25 inline void UpdateMultilineStyle(HWND hwnd, const wxString& label)
26 {
27 // update BS_MULTILINE style depending on the new label (resetting it
28 // doesn't seem to do anything very useful but it shouldn't hurt and we do
29 // have to set it whenever the label becomes multi line as otherwise it
30 // wouldn't be shown correctly as we don't use BS_MULTILINE when creating
31 // the control unless it already has new lines in its label)
32 long styleOld = ::GetWindowLong(hwnd, GWL_STYLE),
33 styleNew;
34 if ( label.find(_T('\n')) != wxString::npos )
35 styleNew = styleOld | BS_MULTILINE;
36 else
37 styleNew = styleOld & ~BS_MULTILINE;
38
39 if ( styleNew != styleOld )
40 ::SetWindowLong(hwnd, GWL_STYLE, styleNew);
41 }
42
43 } // namespace wxMSWButton
44
45 #endif // _WX_MSW_PRIVATE_BUTTON_H_
46