]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/choice.cpp |
489468fe SC |
3 | // Purpose: wxChoice |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
489468fe SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #if wxUSE_CHOICE | |
14 | ||
15 | #include "wx/choice.h" | |
16 | ||
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/menu.h" | |
19 | #include "wx/dcclient.h" | |
20 | #endif | |
21 | ||
524c47aa | 22 | #include "wx/osx/private.h" |
489468fe | 23 | |
524c47aa | 24 | // adapt the number offset (mac menu are 1 based) |
489468fe | 25 | |
524c47aa | 26 | class wxMacChoiceCarbonControl : public wxMacControl |
489468fe | 27 | { |
524c47aa SC |
28 | public : |
29 | wxMacChoiceCarbonControl( wxWindowMac* peer ) : wxMacControl( peer ) | |
489468fe | 30 | { |
489468fe | 31 | } |
03647350 | 32 | |
524c47aa | 33 | void SetValue(wxInt32 v) |
489468fe | 34 | { |
524c47aa | 35 | wxMacControl::SetValue( v + 1 ); |
489468fe | 36 | } |
03647350 | 37 | |
aaf37267 | 38 | wxInt32 GetValue() const |
489468fe | 39 | { |
524c47aa | 40 | return wxMacControl::GetValue() - 1; |
489468fe | 41 | } |
524c47aa | 42 | }; |
489468fe | 43 | |
03647350 VZ |
44 | wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer, |
45 | wxWindowMac* parent, | |
46 | wxWindowID WXUNUSED(id), | |
524c47aa | 47 | wxMenu* menu, |
03647350 | 48 | const wxPoint& pos, |
524c47aa | 49 | const wxSize& size, |
03647350 | 50 | long WXUNUSED(style), |
a4fec5b4 | 51 | long WXUNUSED(extraStyle)) |
489468fe | 52 | { |
524c47aa | 53 | Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ); |
489468fe | 54 | |
524c47aa SC |
55 | wxMacControl* peer = new wxMacChoiceCarbonControl( wxpeer ) ; |
56 | OSStatus err = CreatePopupButtonControl( | |
57 | MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , | |
58 | -12345 , false /* no variable width */ , 0 , 0 , 0 , peer->GetControlRefAddr() ); | |
59 | verify_noerr( err ); | |
489468fe | 60 | |
524c47aa SC |
61 | peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) menu->GetHMenu() ) ; |
62 | return peer; | |
489468fe SC |
63 | } |
64 | ||
65 | #endif // wxUSE_CHOICE |