]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/osx/carbon/choice.cpp | |
3 | // Purpose: wxChoice | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
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 | // adapt the number offset (mac menu are 1 based) | |
26 | ||
27 | class wxMacChoiceCarbonControl : public wxMacControl | |
28 | { | |
29 | public : | |
30 | wxMacChoiceCarbonControl( wxWindowMac* peer ) : wxMacControl( peer ) | |
31 | { | |
32 | } | |
33 | ||
34 | void SetValue(wxInt32 v) | |
35 | { | |
36 | wxMacControl::SetValue( v + 1 ); | |
37 | } | |
38 | ||
39 | wxInt32 GetValue() const | |
40 | { | |
41 | return wxMacControl::GetValue() - 1; | |
42 | } | |
43 | }; | |
44 | ||
45 | wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer, | |
46 | wxWindowMac* parent, | |
47 | wxWindowID WXUNUSED(id), | |
48 | wxMenu* menu, | |
49 | const wxPoint& pos, | |
50 | const wxSize& size, | |
51 | long WXUNUSED(style), | |
52 | long WXUNUSED(extraStyle)) | |
53 | { | |
54 | Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ); | |
55 | ||
56 | wxMacControl* peer = new wxMacChoiceCarbonControl( wxpeer ) ; | |
57 | OSStatus err = CreatePopupButtonControl( | |
58 | MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , | |
59 | -12345 , false /* no variable width */ , 0 , 0 , 0 , peer->GetControlRefAddr() ); | |
60 | verify_noerr( err ); | |
61 | ||
62 | peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) menu->GetHMenu() ) ; | |
63 | return peer; | |
64 | } | |
65 | ||
66 | #endif // wxUSE_CHOICE |