]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/bmpbuttn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/bmpbuttn.cpp
3 // Purpose: wxBitmapButton
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/bmpbuttn.h"
25 #include "wx/dcmemory.h"
29 #include "wx/msw/private.h"
30 #include "wx/msw/dc.h" // for wxDCTemp
32 #include "wx/msw/uxtheme.h"
35 // no need to include tmschema.h
37 #define BP_PUSHBUTTON 1
42 #define PBS_DISABLED 4
43 #define PBS_DEFAULTED 5
45 #define TMT_CONTENTMARGINS 3602
47 #endif // wxUSE_UXTHEME
49 #ifndef ODS_NOFOCUSRECT
50 #define ODS_NOFOCUSRECT 0x0200
53 // ----------------------------------------------------------------------------
55 // ----------------------------------------------------------------------------
57 BEGIN_EVENT_TABLE(wxBitmapButton
, wxBitmapButtonBase
)
58 EVT_SYS_COLOUR_CHANGED(wxBitmapButton::OnSysColourChanged
)
64 long "style" , wxBU_AUTODRAW
71 bool wxBitmapButton::Create(wxWindow
*parent
,
73 const wxBitmap
& bitmap
,
75 const wxSize
& size
, long style
,
76 const wxValidator
& validator
,
79 if ( !wxBitmapButtonBase::Create(parent
, id
, pos
, size
, style
,
83 SetBitmapLabel(bitmap
);
85 if ( !size
.IsFullySpecified() )
87 // As our bitmap has just changed, our best size has changed as well so
88 // reset the initial size using the new value.
95 void wxBitmapButton::DoSetBitmap(const wxBitmap
& bitmap
, State which
)
103 if ( !HasFlag(wxBU_AUTODRAW
) && !m_disabledSetByUser
)
105 wxImage
img(bitmap
.ConvertToImage().ConvertToGreyscale());
106 wxBitmapButtonBase::DoSetBitmap(img
, State_Disabled
);
109 #endif // wxUSE_IMAGE
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
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
)
121 wxBitmapButtonBase::DoSetBitmap(bitmap
, State_Current
);
125 // don't overwrite it with the focused bitmap
126 m_hoverSetByUser
= true;
130 // don't overwrite it with the version automatically created
131 // from the normal one
132 m_disabledSetByUser
= true;
136 // nothing special to do but include the default clause to
137 // suppress gcc warnings
142 wxBitmapButtonBase::DoSetBitmap(bitmap
, which
);
145 #endif // wxUSE_BMPBUTTON