]>
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 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
30 #include "wx/bmpbuttn.h"
31 #include "wx/validate.h"
34 #include "wx/univ/renderer.h"
36 // ============================================================================
38 // ============================================================================
40 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
, wxButton
)
42 BEGIN_EVENT_TABLE(wxBitmapButton
, wxButton
)
43 EVT_SET_FOCUS(wxBitmapButton::OnSetFocus
)
44 EVT_KILL_FOCUS(wxBitmapButton::OnKillFocus
)
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 bool wxBitmapButton::Create(wxWindow
*parent
,
53 const wxBitmap
& bitmap
,
57 const wxValidator
& validator
,
60 // we add wxBU_EXACTFIT because the bitmap buttons are not the standard
61 // ones and so shouldn't be forced to be of the standard size which is
62 // typically too big for them
63 if ( !wxButton::Create(parent
, id
, bitmap
, wxEmptyString
,
64 pos
, size
, style
| wxBU_EXACTFIT
, validator
, name
) )
72 void wxBitmapButton::OnSetBitmap()
79 else if ( IsPressed() )
83 else if ( IsFocused() )
95 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
97 wxBitmap bitmap
= bmp
.Ok() ? bmp
: m_bmpNormal
;
98 if ( bitmap
!= m_bitmap
)
108 bool wxBitmapButton::Enable(bool enable
)
110 if ( !wxButton::Enable(enable
) )
113 if ( !enable
&& ChangeBitmap(m_bmpDisabled
) )
119 bool wxBitmapButton::SetCurrent(bool doit
)
121 ChangeBitmap(doit
? m_bmpFocus
: m_bmpNormal
);
123 return wxButton::SetCurrent(doit
);
126 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
128 if ( ChangeBitmap(m_bmpFocus
) )
134 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
136 if ( ChangeBitmap(m_bmpNormal
) )
142 void wxBitmapButton::Press()
144 ChangeBitmap(m_bmpSelected
);
149 void wxBitmapButton::Release()
151 ChangeBitmap(IsFocused() ? m_bmpFocus
: m_bmpNormal
);
156 #endif // wxUSE_BMPBUTTON