]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/choice.cpp
using #ifdef wxABORT_ON_CONFIG_ERROR not just #if as elsewhere
[wxWidgets.git] / src / osx / carbon / choice.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/choice.cpp
3 // Purpose: wxChoice
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
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
22 #include "wx/osx/private.h"
23
24 // adapt the number offset (mac menu are 1 based)
25
26 class wxMacChoiceCarbonControl : public wxMacControl
27 {
28 public :
29 wxMacChoiceCarbonControl( wxWindowMac* peer ) : wxMacControl( peer )
30 {
31 }
32
33 void SetValue(wxInt32 v)
34 {
35 wxMacControl::SetValue( v + 1 );
36 }
37
38 wxInt32 GetValue() const
39 {
40 return wxMacControl::GetValue() - 1;
41 }
42 };
43
44 wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
45 wxWindowMac* parent,
46 wxWindowID WXUNUSED(id),
47 wxMenu* menu,
48 const wxPoint& pos,
49 const wxSize& size,
50 long WXUNUSED(style),
51 long WXUNUSED(extraStyle))
52 {
53 Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size );
54
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 );
60
61 peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) menu->GetHMenu() ) ;
62 return peer;
63 }
64
65 #endif // wxUSE_CHOICE