1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/tglbtn.mm
3 // Purpose: Definition of the wxToggleButton class, which implements a
4 // toggle button under wxMac.
5 // Author: Stefan Csomor
9 // Copyright: (c) Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 #include "wx/wxprec.h"
25 #include "wx/tglbtn.h"
26 #include "wx/osx/private.h"
30 extern "C" void SetBezelStyleFromBorderFlags(NSButton *v,
32 wxWindowID winid = wxID_ANY,
33 const wxString& label = wxString(),
34 const wxBitmap& bitmap = wxBitmap());
36 wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
37 wxWindowMac* WXUNUSED(parent),
39 const wxString& label,
43 long WXUNUSED(extraStyle))
45 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
46 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
48 SetBezelStyleFromBorderFlags(v, style, winid, label);
50 [v setButtonType:NSOnOffButton];
51 wxWidgetCocoaImpl* c = new wxButtonCocoaImpl( wxpeer, v );
55 wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
56 wxWindowMac* WXUNUSED(parent),
58 const wxBitmap& label,
62 long WXUNUSED(extraStyle))
64 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
65 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
67 SetBezelStyleFromBorderFlags(v, style, winid, wxString(), label);
70 [v setImage:label.GetNSImage() ];
72 [v setButtonType:NSOnOffButton];
73 wxWidgetCocoaImpl* c = new wxButtonCocoaImpl( wxpeer, v );
77 #endif // wxUSE_TOGGLEBTN