]>
Commit | Line | Data |
---|---|---|
dbeddfb9 SC |
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 | { | |
dbeddfb9 SC |
27 | } |
28 | ||
dbeddfb9 SC |
29 | @end |
30 | ||
31 | @implementation wxNSPopUpButton | |
32 | ||
4dd9fdf8 | 33 | + (void)initialize |
dbeddfb9 | 34 | { |
4dd9fdf8 SC |
35 | static BOOL initialized = NO; |
36 | if (!initialized) | |
dbeddfb9 | 37 | { |
4dd9fdf8 SC |
38 | initialized = YES; |
39 | wxOSXCocoaClassAddWXMethods( self ); | |
dbeddfb9 SC |
40 | } |
41 | } | |
42 | ||
dbeddfb9 SC |
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* parent, | |
57 | wxWindowID id, | |
58 | wxMenu* menu, | |
59 | const wxPoint& pos, | |
60 | const wxSize& size, | |
61 | long style, | |
62 | long extraStylew) | |
63 | { | |
dbeddfb9 SC |
64 | NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; |
65 | wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO]; | |
dbeddfb9 SC |
66 | [v setMenu: menu->GetHMenu()]; |
67 | wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); | |
dbeddfb9 SC |
68 | return c; |
69 | } | |
70 | ||
71 | #endif // wxUSE_CHOICE |