]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/bmpbuttn.cpp
f21e6aa2f72ac8499f27bec2f44698c2a4c1028b
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/bmpbuttn.cpp
3 // Purpose: wxBitmapButton implementation
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
28 #include "wx/bmpbuttn.h"
32 #include "wx/validate.h"
35 #include "wx/univ/renderer.h"
37 // ============================================================================
39 // ============================================================================
41 BEGIN_EVENT_TABLE(wxBitmapButton
, wxButton
)
42 EVT_SET_FOCUS(wxBitmapButton::OnSetFocus
)
43 EVT_KILL_FOCUS(wxBitmapButton::OnKillFocus
)
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 bool wxBitmapButton::Create(wxWindow
*parent
,
52 const wxBitmap
& bitmap
,
56 const wxValidator
& validator
,
59 // we add wxBU_EXACTFIT because the bitmap buttons are not the standard
60 // ones and so shouldn't be forced to be of the standard size which is
61 // typically too big for them
62 if ( !wxButton::Create(parent
, id
, bitmap
, wxEmptyString
,
63 pos
, size
, style
| wxBU_EXACTFIT
, validator
, name
) )
66 m_bitmaps
[State_Normal
] = bitmap
;
71 void wxBitmapButton::OnSetBitmap()
76 bmp
= GetBitmapDisabled();
78 else if ( IsPressed() )
80 bmp
= GetBitmapPressed();
82 else if ( IsFocused() )
84 bmp
= GetBitmapFocus();
86 //else: just leave it invalid, this means "normal" anyhow in ChangeBitmap()
91 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
93 wxBitmap bitmap
= bmp
.IsOk() ? bmp
: GetBitmapLabel();
94 if ( bitmap
.IsSameAs(m_bitmap
) )
102 bool wxBitmapButton::Enable(bool enable
)
104 if ( !wxButton::Enable(enable
) )
107 if ( !enable
&& ChangeBitmap(GetBitmapDisabled()) )
113 bool wxBitmapButton::SetCurrent(bool doit
)
115 ChangeBitmap(doit
? GetBitmapFocus() : GetBitmapLabel());
117 return wxButton::SetCurrent(doit
);
120 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
122 if ( ChangeBitmap(GetBitmapFocus()) )
128 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
130 if ( ChangeBitmap(GetBitmapLabel()) )
136 void wxBitmapButton::Press()
138 ChangeBitmap(GetBitmapPressed());
143 void wxBitmapButton::Release()
145 ChangeBitmap(IsFocused() ? GetBitmapFocus() : GetBitmapLabel());
150 #endif // wxUSE_BMPBUTTON