]> git.saurik.com Git - wxWidgets.git/blob - src/osx/anybutton_osx.cpp
wxRTC: save and load the 'shown' status in case there's a situation where layout...
[wxWidgets.git] / src / osx / anybutton_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/anybutton_osx.cpp
3 // Purpose: wxAnyButton
4 // Author: Stefan Csomor
5 // Created: 1998-01-01 (extracted from button_osx.cpp)
6 // Copyright: (c) Stefan Csomor
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/wxprec.h"
11
12 #include "wx/anybutton.h"
13
14 #ifndef WX_PRECOMP
15 #include "wx/panel.h"
16 #include "wx/toplevel.h"
17 #include "wx/dcclient.h"
18 #include "wx/stattext.h"
19 #endif
20
21 #include "wx/stockitem.h"
22
23 #include "wx/osx/private.h"
24
25 BEGIN_EVENT_TABLE(wxAnyButton, wxControl)
26 EVT_ENTER_WINDOW(wxAnyButton::OnEnterWindow)
27 EVT_LEAVE_WINDOW(wxAnyButton::OnLeaveWindow)
28 END_EVENT_TABLE()
29
30 void wxAnyButton::SetLabel(const wxString& label)
31 {
32 if ( HasFlag(wxBU_NOTEXT) )
33 {
34 // just store the label internally but don't really use it for the
35 // button
36 m_labelOrig =
37 m_label = label;
38 return;
39 }
40
41 wxAnyButtonBase::SetLabel(label);
42 }
43
44 wxBitmap wxAnyButton::DoGetBitmap(State which) const
45 {
46 return m_bitmaps[which];
47 }
48
49 void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
50 {
51 m_bitmaps[which] = bitmap;
52
53 if ( which == State_Normal )
54 GetPeer()->SetBitmap(bitmap);
55 else if ( which == State_Pressed )
56 {
57 wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (GetPeer());
58 if ( bi )
59 bi->SetPressedBitmap(bitmap);
60 }
61 InvalidateBestSize();
62 }
63
64 void wxAnyButton::DoSetBitmapPosition(wxDirection dir)
65 {
66 GetPeer()->SetBitmapPosition(dir);
67 InvalidateBestSize();
68 }
69
70 #if wxUSE_MARKUP && wxOSX_USE_COCOA
71
72 bool wxAnyButton::DoSetLabelMarkup(const wxString& markup)
73 {
74 if ( !wxAnyButtonBase::DoSetLabelMarkup(markup) )
75 return false;
76
77 GetPeer()->SetLabelMarkup(markup);
78
79 return true;
80 }
81
82 #endif // wxUSE_MARKUP && wxOSX_USE_COCOA
83
84 void wxAnyButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
85 {
86 if ( DoGetBitmap( State_Current ).IsOk() )
87 GetPeer()->SetBitmap( DoGetBitmap( State_Current ) );
88 }
89
90 void wxAnyButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
91 {
92 if ( DoGetBitmap( State_Current ).IsOk() )
93 GetPeer()->SetBitmap( DoGetBitmap( State_Normal ) );
94 }