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
 
   8 // Copyright:   (c) Stefan Csomor
 
   9 // Licence:     wxWindows licence
 
  10 /////////////////////////////////////////////////////////////////////////////
 
  12 // ============================================================================
 
  14 // ============================================================================
 
  16 // ----------------------------------------------------------------------------
 
  18 // ----------------------------------------------------------------------------
 
  20 #include "wx/wxprec.h"
 
  24 #include "wx/tglbtn.h"
 
  25 #include "wx/osx/private.h"
 
  29 extern "C" void SetBezelStyleFromBorderFlags(NSButton *v,
 
  31                                              wxWindowID winid = wxID_ANY,
 
  32                                              const wxString& label = wxString(),
 
  33                                              const wxBitmap& bitmap = wxBitmap());
 
  35 wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
 
  36                                     wxWindowMac* WXUNUSED(parent),
 
  38                                     const wxString& label,
 
  42                                     long WXUNUSED(extraStyle))
 
  44     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
 
  45     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
 
  47     SetBezelStyleFromBorderFlags(v, style, winid, label);
 
  49     [v setButtonType:NSOnOffButton];
 
  50     wxWidgetCocoaImpl* c = new wxButtonCocoaImpl( wxpeer, v );
 
  54 wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
 
  55                                     wxWindowMac* WXUNUSED(parent),
 
  57                                     const wxBitmap& label,
 
  61                                     long WXUNUSED(extraStyle))
 
  63     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
 
  64     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
 
  66     SetBezelStyleFromBorderFlags(v, style, winid, wxString(), label);
 
  69         [v setImage:label.GetNSImage() ];
 
  71     [v setButtonType:NSOnOffButton];
 
  72     wxWidgetCocoaImpl* c = new wxButtonCocoaImpl( wxpeer, v );
 
  76 #endif // wxUSE_TOGGLEBTN