]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
1e6feb95 | 2 | // Name: src/msw/bmpbuttn.cpp |
2bda0e17 KB |
3 | // Purpose: wxBitmapButton |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
2bda0e17 KB |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
1e6feb95 | 16 | #pragma hdrstop |
2bda0e17 KB |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_BMPBUTTON |
20 | ||
910b0053 WS |
21 | #include "wx/bmpbuttn.h" |
22 | ||
2bda0e17 | 23 | #ifndef WX_PRECOMP |
84f19880 | 24 | #include "wx/log.h" |
47e92c41 | 25 | #include "wx/dcmemory.h" |
155ecd4c | 26 | #include "wx/image.h" |
2bda0e17 KB |
27 | #endif |
28 | ||
29 | #include "wx/msw/private.h" | |
025f7d77 | 30 | #include "wx/msw/dc.h" // for wxDCTemp |
4e9da8b7 | 31 | |
37005692 | 32 | #include "wx/msw/uxtheme.h" |
4e9da8b7 | 33 | |
37005692 | 34 | #if wxUSE_UXTHEME |
4e9da8b7 RD |
35 | // no need to include tmschema.h |
36 | #ifndef BP_PUSHBUTTON | |
37 | #define BP_PUSHBUTTON 1 | |
38 | ||
39 | #define PBS_NORMAL 1 | |
40 | #define PBS_HOT 2 | |
41 | #define PBS_PRESSED 3 | |
42 | #define PBS_DISABLED 4 | |
43 | #define PBS_DEFAULTED 5 | |
44 | ||
45 | #define TMT_CONTENTMARGINS 3602 | |
46 | #endif | |
47 | #endif // wxUSE_UXTHEME | |
48 | ||
49 | #ifndef ODS_NOFOCUSRECT | |
50 | #define ODS_NOFOCUSRECT 0x0200 | |
51 | #endif | |
2bda0e17 | 52 | |
bc9fb572 JS |
53 | // ---------------------------------------------------------------------------- |
54 | // macros | |
55 | // ---------------------------------------------------------------------------- | |
56 | ||
a6fd0fde VZ |
57 | BEGIN_EVENT_TABLE(wxBitmapButton, wxBitmapButtonBase) |
58 | EVT_SYS_COLOUR_CHANGED(wxBitmapButton::OnSysColourChanged) | |
59 | END_EVENT_TABLE() | |
60 | ||
066f1b7a SC |
61 | /* |
62 | TODO PROPERTIES : | |
63 | ||
64 | long "style" , wxBU_AUTODRAW | |
65 | bool "default" , 0 | |
66 | bitmap "selected" , | |
67 | bitmap "focus" , | |
68 | bitmap "disabled" , | |
69 | */ | |
70 | ||
56c74796 VZ |
71 | bool wxBitmapButton::Create(wxWindow *parent, |
72 | wxWindowID id, | |
73 | const wxBitmap& bitmap, | |
74 | const wxPoint& pos, | |
75 | const wxSize& size, long style, | |
b4bde7a7 | 76 | const wxValidator& validator, |
56c74796 | 77 | const wxString& name) |
2bda0e17 | 78 | { |
8e4c2912 | 79 | if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style, |
a2117591 | 80 | validator, name) ) |
56c74796 | 81 | return false; |
2bda0e17 | 82 | |
56c74796 | 83 | SetBitmapLabel(bitmap); |
2bda0e17 | 84 | |
e9f935cb VZ |
85 | if ( !size.IsFullySpecified() ) |
86 | { | |
87 | // As our bitmap has just changed, our best size has changed as well so | |
88 | // reset the initial size using the new value. | |
89 | SetInitialSize(size); | |
90 | } | |
91 | ||
d50dbf7c VZ |
92 | return true; |
93 | } | |
94 | ||
2352862a | 95 | void wxBitmapButton::DoSetBitmap(const wxBitmap& bitmap, State which) |
5f1f21d2 | 96 | { |
2352862a | 97 | if ( bitmap.IsOk() ) |
5f1f21d2 | 98 | { |
2352862a VZ |
99 | switch ( which ) |
100 | { | |
101 | #if wxUSE_IMAGE | |
102 | case State_Normal: | |
103 | if ( !HasFlag(wxBU_AUTODRAW) && !m_disabledSetByUser ) | |
104 | { | |
105 | wxImage img(bitmap.ConvertToImage().ConvertToGreyscale()); | |
a6fd73d3 | 106 | wxBitmapButtonBase::DoSetBitmap(img, State_Disabled); |
2352862a VZ |
107 | } |
108 | break; | |
5f1f21d2 VZ |
109 | #endif // wxUSE_IMAGE |
110 | ||
2352862a VZ |
111 | case State_Focused: |
112 | // if the focus bitmap is specified but current one isn't, use | |
113 | // the focus bitmap for hovering as well if this is consistent | |
114 | // with the current Windows version look and feel | |
115 | // | |
116 | // rationale: this is compatible with the old wxGTK behaviour | |
117 | // and also makes it much easier to do "the right thing" for | |
118 | // all platforms (some of them, such as Windows XP, have "hot" | |
119 | // buttons while others don't) | |
120 | if ( !m_hoverSetByUser ) | |
a6fd73d3 | 121 | wxBitmapButtonBase::DoSetBitmap(bitmap, State_Current); |
2352862a VZ |
122 | break; |
123 | ||
124 | case State_Current: | |
125 | // don't overwrite it with the focused bitmap | |
126 | m_hoverSetByUser = true; | |
127 | break; | |
128 | ||
129 | case State_Disabled: | |
130 | // don't overwrite it with the version automatically created | |
131 | // from the normal one | |
132 | m_disabledSetByUser = true; | |
133 | break; | |
4d51143c VZ |
134 | |
135 | default: | |
136 | // nothing special to do but include the default clause to | |
137 | // suppress gcc warnings | |
138 | ; | |
2352862a VZ |
139 | } |
140 | } | |
5f1f21d2 | 141 | |
2352862a | 142 | wxBitmapButtonBase::DoSetBitmap(bitmap, which); |
7996ff80 VZ |
143 | } |
144 | ||
1e6feb95 | 145 | #endif // wxUSE_BMPBUTTON |