1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/choice.mm
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: choice.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/choice.h"
20 #include "wx/dcclient.h"
23 #include "wx/osx/private.h"
25 @interface wxNSPopUpButton : NSPopUpButton
30 - (void)setImplementation: (wxWidgetImpl *) theImplementation;
31 - (wxWidgetImpl*) implementation;
33 - (void) clickedAction: (id) sender;
37 @implementation wxNSPopUpButton
39 - (id)initWithFrame:(NSRect)frame pullsDown:(BOOL) pd
41 [super initWithFrame:frame pullsDown:pd];
43 [self setTarget: self];
44 [self setAction: @selector(clickedAction:)];
48 - (void) clickedAction: (id) sender
52 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
54 wxpeer->HandleClicked(0);
58 - (void)setImplementation: (wxWidgetImpl *) theImplementation
60 impl = theImplementation;
63 - (wxWidgetImpl*) implementation
75 return [self indexOfSelectedItem];
78 - (void) setIntValue: (int) v
80 [self selectItemAtIndex:v];
85 wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
94 NSView* sv = (wxpeer->GetParent()->GetHandle() );
96 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
97 wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
99 [v setMenu: menu->GetHMenu()];
100 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
101 [v setImplementation:c];
105 #endif // wxUSE_CHOICE