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