]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/bmpbuttn.cpp
2044a4bea8516740dedfba19071674adb18ea62f
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/bmpbuttn.cpp
3 // Purpose: wxBitmapButton implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/wxprec.h"
27 #include "wx/bmpbuttn.h"
31 #include "wx/validate.h"
34 #include "wx/univ/renderer.h"
36 // ============================================================================
38 // ============================================================================
40 BEGIN_EVENT_TABLE(wxBitmapButton
, wxButton
)
41 EVT_SET_FOCUS(wxBitmapButton::OnSetFocus
)
42 EVT_KILL_FOCUS(wxBitmapButton::OnKillFocus
)
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 bool wxBitmapButton::Create(wxWindow
*parent
,
51 const wxBitmap
& bitmap
,
55 const wxValidator
& validator
,
58 // we add wxBU_EXACTFIT because the bitmap buttons are not the standard
59 // ones and so shouldn't be forced to be of the standard size which is
60 // typically too big for them
61 if ( !wxButton::Create(parent
, id
, bitmap
, wxEmptyString
,
62 pos
, size
, style
| wxBU_EXACTFIT
, validator
, name
) )
65 m_bitmaps
[State_Normal
] = bitmap
;
70 void wxBitmapButton::OnSetBitmap()
75 bmp
= GetBitmapDisabled();
77 else if ( IsPressed() )
79 bmp
= GetBitmapPressed();
81 else if ( IsFocused() )
83 bmp
= GetBitmapFocus();
85 //else: just leave it invalid, this means "normal" anyhow in ChangeBitmap()
90 bool wxBitmapButton::ChangeBitmap(const wxBitmap
& bmp
)
92 wxBitmap bitmap
= bmp
.IsOk() ? bmp
: GetBitmapLabel();
93 if ( bitmap
.IsSameAs(m_bitmap
) )
101 bool wxBitmapButton::Enable(bool enable
)
103 if ( !wxButton::Enable(enable
) )
106 if ( !enable
&& ChangeBitmap(GetBitmapDisabled()) )
112 bool wxBitmapButton::SetCurrent(bool doit
)
114 ChangeBitmap(doit
? GetBitmapFocus() : GetBitmapLabel());
116 return wxButton::SetCurrent(doit
);
119 void wxBitmapButton::OnSetFocus(wxFocusEvent
& event
)
121 if ( ChangeBitmap(GetBitmapFocus()) )
127 void wxBitmapButton::OnKillFocus(wxFocusEvent
& event
)
129 if ( ChangeBitmap(GetBitmapLabel()) )
135 void wxBitmapButton::Press()
137 ChangeBitmap(GetBitmapPressed());
142 void wxBitmapButton::Release()
144 ChangeBitmap(IsFocused() ? GetBitmapFocus() : GetBitmapLabel());
149 #endif // wxUSE_BMPBUTTON