]>
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 #if wxUSE_EXTENDED_RTTI
59 WX_DEFINE_FLAGS( wxBitmapButtonStyle
)
61 wxBEGIN_FLAGS( wxBitmapButtonStyle
)
62 // new style border flags, we put them first to
63 // use them for streaming out
64 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
65 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
66 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
67 wxFLAGS_MEMBER(wxBORDER_RAISED
)
68 wxFLAGS_MEMBER(wxBORDER_STATIC
)
69 wxFLAGS_MEMBER(wxBORDER_NONE
)
71 // old style border flags
72 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
73 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
74 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
75 wxFLAGS_MEMBER(wxRAISED_BORDER
)
76 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
77 wxFLAGS_MEMBER(wxBORDER
)
79 // standard window styles
80 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
81 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
82 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
83 wxFLAGS_MEMBER(wxWANTS_CHARS
)
84 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
85 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
86 wxFLAGS_MEMBER(wxVSCROLL
)
87 wxFLAGS_MEMBER(wxHSCROLL
)
89 wxFLAGS_MEMBER(wxBU_AUTODRAW
)
90 wxFLAGS_MEMBER(wxBU_LEFT
)
91 wxFLAGS_MEMBER(wxBU_RIGHT
)
92 wxFLAGS_MEMBER(wxBU_TOP
)
93 wxFLAGS_MEMBER(wxBU_BOTTOM
)
94 wxEND_FLAGS( wxBitmapButtonStyle
)
96 IMPLEMENT_DYNAMIC_CLASS_XTI(wxBitmapButton
, wxButton
,"wx/bmpbuttn.h")
98 wxBEGIN_PROPERTIES_TABLE(wxBitmapButton
)
99 wxPROPERTY_FLAGS( WindowStyle
, wxBitmapButtonStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
100 wxEND_PROPERTIES_TABLE()
102 wxBEGIN_HANDLERS_TABLE(wxBitmapButton
)
103 wxEND_HANDLERS_TABLE()
105 wxCONSTRUCTOR_5( wxBitmapButton
, wxWindow
* , Parent
, wxWindowID
, Id
, wxBitmap
, Bitmap
, wxPoint
, Position
, wxSize
, Size
)
108 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
, wxButton
)
111 BEGIN_EVENT_TABLE(wxBitmapButton
, wxBitmapButtonBase
)
112 EVT_SYS_COLOUR_CHANGED(wxBitmapButton::OnSysColourChanged
)
118 long "style" , wxBU_AUTODRAW
125 bool wxBitmapButton::Create(wxWindow
*parent
,
127 const wxBitmap
& bitmap
,
129 const wxSize
& size
, long style
,
130 const wxValidator
& validator
,
131 const wxString
& name
)
133 if ( !wxBitmapButtonBase::Create(parent
, id
, pos
, size
, style
,
137 SetBitmapLabel(bitmap
);
139 if ( !size
.IsFullySpecified() )
141 // As our bitmap has just changed, our best size has changed as well so
142 // reset the initial size using the new value.
143 SetInitialSize(size
);
149 void wxBitmapButton::DoSetBitmap(const wxBitmap
& bitmap
, State which
)
157 if ( !HasFlag(wxBU_AUTODRAW
) && !m_disabledSetByUser
)
159 wxImage
img(bitmap
.ConvertToImage().ConvertToGreyscale());
160 wxBitmapButtonBase::DoSetBitmap(img
, State_Disabled
);
163 #endif // wxUSE_IMAGE
166 // if the focus bitmap is specified but current one isn't, use
167 // the focus bitmap for hovering as well if this is consistent
168 // with the current Windows version look and feel
170 // rationale: this is compatible with the old wxGTK behaviour
171 // and also makes it much easier to do "the right thing" for
172 // all platforms (some of them, such as Windows XP, have "hot"
173 // buttons while others don't)
174 if ( !m_hoverSetByUser
)
175 wxBitmapButtonBase::DoSetBitmap(bitmap
, State_Current
);
179 // don't overwrite it with the focused bitmap
180 m_hoverSetByUser
= true;
184 // don't overwrite it with the version automatically created
185 // from the normal one
186 m_disabledSetByUser
= true;
190 // nothing special to do but include the default clause to
191 // suppress gcc warnings
196 wxBitmapButtonBase::DoSetBitmap(bitmap
, which
);
199 #endif // wxUSE_BMPBUTTON