]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/tglbtn.mm
10.4 compatibility
[wxWidgets.git] / src / osx / cocoa / tglbtn.mm
CommitLineData
f033830e
SC
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
a9a4f229 8// RCS-ID: $Id$
f033830e 9// Copyright: (c) Stefan Csomor
526954c5 10// Licence: wxWindows licence
f033830e
SC
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
7f08aa6c
SC
28// from button.mm
29
30extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style);
31
03647350
VZ
32wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
33 wxWindowMac* WXUNUSED(parent),
34 wxWindowID WXUNUSED(id),
d8207702 35 const wxString& WXUNUSED(label),
03647350 36 const wxPoint& pos,
f033830e 37 const wxSize& size,
7e04f44c 38 long style,
d8207702 39 long WXUNUSED(extraStyle))
f033830e 40{
dbeddfb9 41 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
f033830e 42 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
03647350 43
7f08aa6c
SC
44 SetBezelStyleFromBorderFlags(v, style);
45
f033830e 46 [v setButtonType:NSOnOffButton];
f033830e 47 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
f033830e
SC
48 return c;
49}
50
03647350
VZ
51wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
52 wxWindowMac* WXUNUSED(parent),
53 wxWindowID WXUNUSED(id),
7f08aa6c 54 const wxBitmap& label,
03647350 55 const wxPoint& pos,
f033830e 56 const wxSize& size,
7f08aa6c 57 long style,
d8207702 58 long WXUNUSED(extraStyle))
03647350 59{
dbeddfb9 60 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
f033830e 61 wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
03647350 62
a1b806b9 63 if (label.IsOk())
7f08aa6c
SC
64 [v setImage:label.GetNSImage() ];
65
66 SetBezelStyleFromBorderFlags(v, style);
67
f033830e 68 [v setButtonType:NSOnOffButton];
f033830e 69 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
f033830e
SC
70 return c;
71}
72
73#endif // wxUSE_TOGGLEBTN
74