]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/choice.cpp
use correct scale when drawing
[wxWidgets.git] / src / osx / carbon / choice.cpp
CommitLineData
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
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
524c47aa 23#include "wx/osx/private.h"
489468fe 24
524c47aa 25// adapt the number offset (mac menu are 1 based)
489468fe 26
524c47aa 27class wxMacChoiceCarbonControl : public wxMacControl
489468fe 28{
524c47aa
SC
29public :
30 wxMacChoiceCarbonControl( wxWindowMac* peer ) : wxMacControl( peer )
489468fe 31 {
489468fe 32 }
03647350 33
524c47aa 34 void SetValue(wxInt32 v)
489468fe 35 {
524c47aa 36 wxMacControl::SetValue( v + 1 );
489468fe 37 }
03647350 38
aaf37267 39 wxInt32 GetValue() const
489468fe 40 {
524c47aa 41 return wxMacControl::GetValue() - 1;
489468fe 42 }
524c47aa 43 };
489468fe 44
03647350
VZ
45wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
46 wxWindowMac* parent,
47 wxWindowID WXUNUSED(id),
524c47aa 48 wxMenu* menu,
03647350 49 const wxPoint& pos,
524c47aa 50 const wxSize& size,
03647350 51 long WXUNUSED(style),
a4fec5b4 52 long WXUNUSED(extraStyle))
489468fe 53{
524c47aa 54 Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size );
489468fe 55
524c47aa
SC
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 );
489468fe 61
524c47aa
SC
62 peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) menu->GetHMenu() ) ;
63 return peer;
489468fe
SC
64}
65
66#endif // wxUSE_CHOICE