X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c1a4c41800b628d2fbd034da8a9cb45e3eec0bf..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/cocoa/radiobox.mm diff --git a/src/cocoa/radiobox.mm b/src/cocoa/radiobox.mm index 2eacb188f9..54bff0019c 100644 --- a/src/cocoa/radiobox.mm +++ b/src/cocoa/radiobox.mm @@ -7,7 +7,7 @@ // RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott // (c) 2007 Software 2000 Ltd. -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -24,6 +24,7 @@ #include "wx/cocoa/string.h" #include "wx/cocoa/autorelease.h" +#import #include "wx/cocoa/objc/NSView.h" #import #import @@ -32,7 +33,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) BEGIN_EVENT_TABLE(wxRadioBox, wxControl) END_EVENT_TABLE() -// WX_IMPLEMENT_COCOA_OWNER(wxRadioBox,NSTextField,NSControl,NSView) + +void wxRadioBox::AssociateNSBox(WX_NSBox cocoaObjcClass) +{ + NSMatrix *radioBox = [(WX_NSBox)cocoaObjcClass contentView]; + // Associate the NSMatrix (the NSBox's contentView) with the wxCocoaNSControl MI base class. + AssociateNSControl(radioBox); + // Set the target/action.. we don't really need to unset these + [radioBox setTarget:wxCocoaNSControl::sm_cocoaTarget]; + [radioBox setAction:@selector(wxNSControlAction:)]; +} + +void wxRadioBox::DisassociateNSBox(WX_NSBox cocoaObjcClass) +{ + DisassociateNSControl([(WX_NSBox)cocoaObjcClass contentView]); +} + +WX_IMPLEMENT_COCOA_OWNER(wxRadioBox,NSBox,NSView,NSView) bool wxRadioBox::Create(wxWindow *parent, wxWindowID winid, const wxString& title, @@ -79,7 +96,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID winid, NSMutableArray *allCells = [NSMutableArray arrayWithCapacity:n]; for(int i=0; i 0) + SetSelection(0); + if(m_parent) m_parent->CocoaAddChild(this); @@ -159,6 +184,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID winid, wxRadioBox::~wxRadioBox() { + DisassociateNSBox(GetNSBox()); } WX_NSMatrix wxRadioBox::GetNSMatrix() const @@ -208,7 +234,7 @@ void wxRadioBox::SetString(unsigned int n, const wxString& label) { int r = GetRowForIndex(n); int c = GetColumnForIndex(n); - [[GetNSMatrix() cellAtRow:r column:c] setTitle:wxNSStringWithWxString(wxStripMenuCodes(label, wxStrip_Mnemonics))]; + CocoaSetLabelForObject(label, [GetNSMatrix() cellAtRow:r column:c]); } // change the individual radio button state @@ -229,7 +255,7 @@ bool wxRadioBox::Show(unsigned int n, bool show) // TODO // NOTE: Cocoa has no visible state for cells so we'd need to replace the // cell with a dummy one to hide it or alternatively subclass NSButtonCell - // and add the behavior. + // and add the behaviour. return false; } @@ -240,4 +266,12 @@ wxSize wxRadioBox::DoGetBestSize() const return wxControl::DoGetBestSize(); } +void wxRadioBox::CocoaTarget_action(void) +{ + wxCommandEvent event(wxEVT_RADIOBOX, GetId()); + InitCommandEvent(event); + event.SetInt(GetSelection()); // i.e. SetSelection. + Command(event); +} + #endif