]>
Commit | Line | Data |
---|---|---|
533171c2 | 1 | /////////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/msw/private/button.h |
533171c2 VZ |
3 | // Purpose: helper functions used with native BUTTON control |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2008-06-07 | |
533171c2 VZ |
6 | // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org> |
7 | // Licence: wxWindows licence | |
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_MSW_PRIVATE_BUTTON_H_ | |
11 | #define _WX_MSW_PRIVATE_BUTTON_H_ | |
12 | ||
9016f3ad VZ |
13 | // define some standard button constants which may be missing in the headers |
14 | #ifndef BS_PUSHLIKE | |
15 | #define BS_PUSHLIKE 0x00001000L | |
16 | #endif | |
17 | ||
18 | #ifndef BST_UNCHECKED | |
19 | #define BST_UNCHECKED 0x0000 | |
20 | #endif | |
21 | ||
22 | #ifndef BST_CHECKED | |
23 | #define BST_CHECKED 0x0001 | |
24 | #endif | |
25 | ||
26 | #ifndef BST_INDETERMINATE | |
27 | #define BST_INDETERMINATE 0x0002 | |
28 | #endif | |
29 | ||
533171c2 VZ |
30 | namespace wxMSWButton |
31 | { | |
32 | ||
33 | // returns BS_MULTILINE if the label contains new lines or 0 otherwise | |
34 | inline int GetMultilineStyle(const wxString& label) | |
35 | { | |
9a83f860 | 36 | return label.find(wxT('\n')) == wxString::npos ? 0 : BS_MULTILINE; |
533171c2 VZ |
37 | } |
38 | ||
39 | // update the style of the specified HWND to include or exclude BS_MULTILINE | |
40 | // depending on whether the label contains the new lines | |
4af4dec6 | 41 | void UpdateMultilineStyle(HWND hwnd, const wxString& label); |
533171c2 | 42 | |
f2d7fdf7 VZ |
43 | // flags for ComputeBestSize() and GetFittingSize() |
44 | enum | |
45 | { | |
b18ebec9 VZ |
46 | Size_AuthNeeded = 1, |
47 | Size_ExactFit = 2 | |
f2d7fdf7 VZ |
48 | }; |
49 | ||
1e43584a | 50 | // NB: All the functions below are implemented in src/msw/button.cpp |
9016f3ad | 51 | |
1e43584a | 52 | // Compute the button size (as if wxBU_EXACTFIT were specified, i.e. without |
433aca2d | 53 | // adjusting it to be of default size if it's smaller) for the given label size |
c6d4b3ce VZ |
54 | WXDLLIMPEXP_CORE wxSize |
55 | GetFittingSize(wxWindow *win, const wxSize& sizeLabel, int flags = 0); | |
433aca2d | 56 | |
1e43584a VZ |
57 | // Compute the button size (as if wxBU_EXACTFIT were specified) by computing |
58 | // its label size and then calling GetFittingSize(). | |
59 | wxSize ComputeBestFittingSize(wxControl *btn, int flags = 0); | |
60 | ||
61 | // Increase the size passed as parameter to be at least the standard button | |
62 | // size if the control doesn't have wxBU_EXACTFIT style and also cache it as | |
63 | // the best size and return its value -- this is used in DoGetBestSize() | |
64 | // implementation. | |
65 | wxSize IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size); | |
66 | ||
67 | // helper of wxToggleButton::DoGetBestSize() | |
68 | inline wxSize ComputeBestSize(wxControl *btn, int flags = 0) | |
69 | { | |
70 | return IncreaseToStdSizeAndCache(btn, ComputeBestFittingSize(btn, flags)); | |
71 | } | |
72 | ||
533171c2 VZ |
73 | } // namespace wxMSWButton |
74 | ||
75 | #endif // _WX_MSW_PRIVATE_BUTTON_H_ | |
76 |