From 7f08aa6ce9c7d079b247963a3cb66193780603a3 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 3 Apr 2010 09:10:38 +0000 Subject: [PATCH] support for toggle bitmap button git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/button.mm | 2 ++ src/osx/cocoa/tglbtn.mm | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/button.mm b/src/osx/cocoa/button.mm index 355b77707a..5e4d5db404 100644 --- a/src/osx/cocoa/button.mm +++ b/src/osx/cocoa/button.mm @@ -130,6 +130,8 @@ private: } }; +extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style); + // set bezel style depending on the wxBORDER_XXX flags specified by the style void SetBezelStyleFromBorderFlags(NSButton *v, long style) { diff --git a/src/osx/cocoa/tglbtn.mm b/src/osx/cocoa/tglbtn.mm index 8b4fe03b96..8f752de7d2 100644 --- a/src/osx/cocoa/tglbtn.mm +++ b/src/osx/cocoa/tglbtn.mm @@ -25,6 +25,10 @@ #include "wx/tglbtn.h" #include "wx/osx/private.h" +// from button.mm + +extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style); + wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), @@ -37,7 +41,8 @@ wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer, NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSButton* v = [[wxNSButton alloc] initWithFrame:r]; - [v setBezelStyle:NSSmallSquareBezelStyle]; + SetBezelStyleFromBorderFlags(v, style); + [v setButtonType:NSOnOffButton]; wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); return c; @@ -46,16 +51,20 @@ wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer, wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), - const wxBitmap& WXUNUSED(label), + const wxBitmap& label, const wxPoint& pos, const wxSize& size, - long WXUNUSED(style), + long style, long WXUNUSED(extraStyle)) { NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSButton* v = [[wxNSButton alloc] initWithFrame:r]; - [v setBezelStyle:NSRegularSquareBezelStyle]; + if (label.Ok()) + [v setImage:label.GetNSImage() ]; + + SetBezelStyleFromBorderFlags(v, style); + [v setButtonType:NSOnOffButton]; wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); return c; -- 2.45.2