support for toggle bitmap button

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2010-04-03 09:10:38 +00:00
parent 2439f1d968
commit 7f08aa6ce9
2 changed files with 15 additions and 4 deletions

View File

@@ -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 // set bezel style depending on the wxBORDER_XXX flags specified by the style
void SetBezelStyleFromBorderFlags(NSButton *v, long style) void SetBezelStyleFromBorderFlags(NSButton *v, long style)
{ {

View File

@@ -25,6 +25,10 @@
#include "wx/tglbtn.h" #include "wx/tglbtn.h"
#include "wx/osx/private.h" #include "wx/osx/private.h"
// from button.mm
extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style);
wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer, wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
wxWindowMac* WXUNUSED(parent), wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id), wxWindowID WXUNUSED(id),
@@ -37,7 +41,8 @@ wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r]; wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
[v setBezelStyle:NSSmallSquareBezelStyle]; SetBezelStyleFromBorderFlags(v, style);
[v setButtonType:NSOnOffButton]; [v setButtonType:NSOnOffButton];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
return c; return c;
@@ -46,16 +51,20 @@ wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer, wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
wxWindowMac* WXUNUSED(parent), wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id), wxWindowID WXUNUSED(id),
const wxBitmap& WXUNUSED(label), const wxBitmap& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long WXUNUSED(style), long style,
long WXUNUSED(extraStyle)) long WXUNUSED(extraStyle))
{ {
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r]; wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
[v setBezelStyle:NSRegularSquareBezelStyle]; if (label.Ok())
[v setImage:label.GetNSImage() ];
SetBezelStyleFromBorderFlags(v, style);
[v setButtonType:NSOnOffButton]; [v setButtonType:NSOnOffButton];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
return c; return c;