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