]>
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 // ----------------------------------------------------------------------------
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 // we add wxBU_EXACTFIT because the bitmap buttons are not the standard
65 // ones and so shouldn't be forced to be of the standard size which is
66 // typically too big for them
67 if ( !wxButton::Create(parent
, id
, bitmap
, _T(""),
68 pos
, size
, style
| wxBU_EXACTFIT
, validator
, name
) )
76 void wxBitmapButton::OnSetBitmap()
83 else if ( IsPressed() )
87 else if ( IsFocused() )
99 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
101 wxBitmap bitmap
= bmp
.Ok() ? bmp
: m_bmpNormal
;
102 if ( bitmap
!= m_bitmap
)
112 bool wxBitmapButton::Enable(bool enable
)
114 if ( !wxButton::Enable(enable
) )
117 if ( !enable
&& ChangeBitmap(m_bmpDisabled
) )
123 bool wxBitmapButton::SetCurrent(bool doit
)
125 ChangeBitmap(doit
? m_bmpFocus
: m_bmpNormal
);
127 return wxButton::SetCurrent(doit
);
130 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
132 if ( ChangeBitmap(m_bmpFocus
) )
138 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
140 if ( ChangeBitmap(m_bmpNormal
) )
146 void wxBitmapButton::Press()
148 ChangeBitmap(m_bmpSelected
);
153 void wxBitmapButton::Release()
155 ChangeBitmap(IsFocused() ? m_bmpFocus
: m_bmpNormal
);
160 #endif // wxUSE_BMPBUTTON