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