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
31 @implementation wxNSPopUpButton
35 static BOOL initialized = NO;
39 wxOSXCocoaClassAddWXMethods( self );
45 return [self indexOfSelectedItem];
48 - (void) setIntValue: (int) v
50 [self selectItemAtIndex:v];
55 @interface NSView(PossibleSizeMethods)
56 - (NSControlSize)controlSize;
59 class wxChoiceCocoaImpl : public wxWidgetCocoaImpl
62 wxChoiceCocoaImpl(wxWindowMac *wxpeer, wxNSPopUpButton *v)
63 : wxWidgetCocoaImpl(wxpeer, v)
67 void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
69 left = top = right = bottom = 0;
70 NSControlSize size = NSRegularControlSize;
71 if ( [m_osxView respondsToSelector:@selector(controlSize)] )
72 size = [m_osxView controlSize];
73 else if ([m_osxView respondsToSelector:@selector(cell)])
75 id cell = [(id)m_osxView cell];
76 if ([cell respondsToSelector:@selector(controlSize)])
77 size = [cell controlSize];
82 case NSRegularControlSize:
87 case NSSmallControlSize:
92 case NSMiniControlSize:
102 wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
103 wxWindowMac* WXUNUSED(parent),
104 wxWindowID WXUNUSED(id),
108 long WXUNUSED(style),
109 long WXUNUSED(extraStyle))
111 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
112 wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
113 [v setMenu: menu->GetHMenu()];
114 [v setAutoenablesItems:NO];
115 wxWidgetCocoaImpl* c = new wxChoiceCocoaImpl( wxpeer, v );
119 #endif // wxUSE_CHOICE