]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/choice.mm
Small code cleanup in wxWindowGTK::PostCreation().
[wxWidgets.git] / src / osx / cocoa / choice.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/choice.mm
3 // Purpose: wxChoice
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id: choice.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_CHOICE
15
16 #include "wx/choice.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/menu.h"
20 #include "wx/dcclient.h"
21 #endif
22
23 #include "wx/osx/private.h"
24
25 @interface wxNSPopUpButton : NSPopUpButton
26 {
27 }
28
29 @end
30
31 @implementation wxNSPopUpButton
32
33 + (void)initialize
34 {
35 static BOOL initialized = NO;
36 if (!initialized)
37 {
38 initialized = YES;
39 wxOSXCocoaClassAddWXMethods( self );
40 }
41 }
42
43 - (int) intValue
44 {
45 return [self indexOfSelectedItem];
46 }
47
48 - (void) setIntValue: (int) v
49 {
50 [self selectItemAtIndex:v];
51 }
52
53 @end
54
55 wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
56 wxWindowMac* WXUNUSED(parent),
57 wxWindowID WXUNUSED(id),
58 wxMenu* menu,
59 const wxPoint& pos,
60 const wxSize& size,
61 long WXUNUSED(style),
62 long WXUNUSED(extraStyle))
63 {
64 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
65 wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
66 [v setMenu: menu->GetHMenu()];
67 [v setAutoenablesItems:NO];
68 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
69 return c;
70 }
71
72 #endif // wxUSE_CHOICE