]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/bmpbuttn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: univ/bmpbuttn.cpp
3 // Purpose: wxBitmapButton implementation
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "univbmpbuttn.h"
24 #include "wx/wxprec.h"
34 #include "wx/bmpbuttn.h"
35 #include "wx/validate.h"
38 #include "wx/univ/renderer.h"
40 // ============================================================================
42 // ============================================================================
44 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
, wxButton
)
46 BEGIN_EVENT_TABLE(wxBitmapButton
, wxButton
)
47 EVT_SET_FOCUS(wxBitmapButton::OnSetFocus
)
48 EVT_KILL_FOCUS(wxBitmapButton::OnKillFocus
)
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 bool wxBitmapButton::Create(wxWindow
*parent
,
57 const wxBitmap
& bitmap
,
61 const wxValidator
& validator
,
64 if ( !wxButton::Create(parent
, id
, bitmap
, _T(""),
65 pos
, size
, style
, validator
, name
) )
73 void wxBitmapButton::OnSetBitmap()
80 else if ( IsPressed() )
84 else if ( IsFocused() )
96 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
98 wxBitmap bitmap
= bmp
.Ok() ? bmp
: m_bmpNormal
;
99 if ( bitmap
!= m_bitmap
)
109 bool wxBitmapButton::Enable(bool enable
)
111 if ( !wxButton::Enable(enable
) )
114 if ( !enable
&& ChangeBitmap(m_bmpDisabled
) )
120 bool wxBitmapButton::SetCurrent(bool doit
)
122 ChangeBitmap(doit
? m_bmpFocus
: m_bmpNormal
);
124 return wxButton::SetCurrent(doit
);
127 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
129 if ( ChangeBitmap(m_bmpFocus
) )
135 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
137 if ( ChangeBitmap(m_bmpNormal
) )
143 void wxBitmapButton::Press()
145 ChangeBitmap(m_bmpSelected
);
150 void wxBitmapButton::Release()
152 ChangeBitmap(IsFocused() ? m_bmpFocus
: m_bmpNormal
);
157 #endif // wxUSE_BMPBUTTON