]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 wxBitmapButtonBase::wxBitmapButtonBase()
65 wxBitmapButton::wxBitmapButton()
69 wxBitmapButton::wxBitmapButton(wxWindow
*parent
,
71 const wxBitmap
& bitmap
,
75 const wxValidator
& validator
,
78 Create(parent
, id
, bitmap
, pos
, size
, style
, validator
, name
);
81 bool wxBitmapButton::Create(wxWindow
*parent
,
83 const wxBitmap
& bitmap
,
87 const wxValidator
& validator
,
90 // we add wxBU_EXACTFIT because the bitmap buttons are not the standard
91 // ones and so shouldn't be forced to be of the standard size which is
92 // typically too big for them
93 if ( !wxButton::Create(parent
, id
, bitmap
, _T(""),
94 pos
, size
, style
| wxBU_EXACTFIT
, validator
, name
) )
102 void wxBitmapButton::OnSetBitmap()
109 else if ( IsPressed() )
113 else if ( IsFocused() )
125 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
127 wxBitmap bitmap
= bmp
.Ok() ? bmp
: m_bmpNormal
;
128 if ( bitmap
!= m_bitmap
)
138 bool wxBitmapButton::Enable(bool enable
)
140 if ( !wxButton::Enable(enable
) )
143 if ( !enable
&& ChangeBitmap(m_bmpDisabled
) )
149 bool wxBitmapButton::SetCurrent(bool doit
)
151 ChangeBitmap(doit
? m_bmpFocus
: m_bmpNormal
);
153 return wxButton::SetCurrent(doit
);
156 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
158 if ( ChangeBitmap(m_bmpFocus
) )
164 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
166 if ( ChangeBitmap(m_bmpNormal
) )
172 void wxBitmapButton::Press()
174 ChangeBitmap(m_bmpSelected
);
179 void wxBitmapButton::Release()
181 ChangeBitmap(IsFocused() ? m_bmpFocus
: m_bmpNormal
);
186 #endif // wxUSE_BMPBUTTON