]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/tglbtn.mm
af184af177e5460b11ad7dab691dc9f3fcd2fe5b
[wxWidgets.git] / src / osx / cocoa / tglbtn.mm
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
6 // Modified by:
7 // Created: 08.02.01
8 // RCS-ID: $Id$
9 // Copyright: (c) Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 // ============================================================================
14 // declatations
15 // ============================================================================
16
17 // ----------------------------------------------------------------------------
18 // headers
19 // ----------------------------------------------------------------------------
20
21 #include "wx/wxprec.h"
22
23 #if wxUSE_TOGGLEBTN
24
25 #include "wx/tglbtn.h"
26 #include "wx/osx/private.h"
27
28 // from button.mm
29
30 extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style);
31
32 wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
33 wxWindowMac* WXUNUSED(parent),
34 wxWindowID WXUNUSED(id),
35 const wxString& WXUNUSED(label),
36 const wxPoint& pos,
37 const wxSize& size,
38 long style,
39 long WXUNUSED(extraStyle))
40 {
41 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
42 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
43
44 SetBezelStyleFromBorderFlags(v, style);
45
46 [v setButtonType:NSOnOffButton];
47 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
48 return c;
49 }
50
51 wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
52 wxWindowMac* WXUNUSED(parent),
53 wxWindowID WXUNUSED(id),
54 const wxBitmap& label,
55 const wxPoint& pos,
56 const wxSize& size,
57 long style,
58 long WXUNUSED(extraStyle))
59 {
60 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
61 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
62
63 if (label.Ok())
64 [v setImage:label.GetNSImage() ];
65
66 SetBezelStyleFromBorderFlags(v, style);
67
68 [v setButtonType:NSOnOffButton];
69 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
70 return c;
71 }
72
73 #endif // wxUSE_TOGGLEBTN
74