]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/button.cpp
use correct scale when drawing
[wxWidgets.git] / src / osx / carbon / button.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/button.cpp
489468fe
SC
3// Purpose: wxButton
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#include "wx/button.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/panel.h"
18 #include "wx/toplevel.h"
19 #include "wx/dcclient.h"
20#endif
21
22#include "wx/stockitem.h"
23
524c47aa 24#include "wx/osx/private.h"
489468fe 25
524c47aa
SC
26//
27//
28//
489468fe 29
ca910e1a
VZ
30wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
31 wxWindowMac* parent,
32 wxWindowID id,
524c47aa 33 const wxString& label,
ca910e1a 34 const wxPoint& pos,
524c47aa 35 const wxSize& size,
ca910e1a
VZ
36 long WXUNUSED(style),
37 long WXUNUSED(extraStyle))
489468fe 38{
524c47aa
SC
39 OSStatus err;
40 Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ;
41 wxMacControl* peer = new wxMacControl(wxpeer) ;
42 if ( id == wxID_HELP )
43 {
44 ControlButtonContentInfo info ;
45 info.contentType = kControlContentIconRef ;
46 GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef);
47 err = CreateRoundButtonControl(
48 MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
49 &bounds, kControlRoundButtonNormalSize,
50 &info, peer->GetControlRefAddr() );
51 }
52 else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
53 {
54 // Button height is static in Mac, can't be changed, so we need to force it here
55 int maxHeight;
ca910e1a 56 switch (wxpeer->GetWindowVariant() )
524c47aa 57 {
ca910e1a
VZ
58 default:
59 wxFAIL_MSG( "unknown window variant" );
60 // fall through
61
524c47aa
SC
62 case wxWINDOW_VARIANT_NORMAL:
63 case wxWINDOW_VARIANT_LARGE:
64 maxHeight = 20 ;
65 break;
66 case wxWINDOW_VARIANT_SMALL:
67 maxHeight = 17;
af8dcb5e 68 break;
524c47aa
SC
69 case wxWINDOW_VARIANT_MINI:
70 maxHeight = 15;
524c47aa
SC
71 }
72 bounds.bottom = bounds.top + maxHeight ;
73 wxpeer->SetMaxSize( wxSize( wxpeer->GetMaxWidth() , maxHeight ));
74 err = CreatePushButtonControl(
75 MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
76 &bounds, CFSTR(""), peer->GetControlRefAddr() );
77 }
78 else
79 {
80 ControlButtonContentInfo info ;
81 info.contentType = kControlNoContent ;
82 err = CreateBevelButtonControl(
83 MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""),
84 kControlBevelButtonLargeBevel, kControlBehaviorPushbutton,
85 &info, 0, 0, 0, peer->GetControlRefAddr() );
86 }
87 verify_noerr( err );
88 return peer;
489468fe
SC
89}
90
524c47aa 91void wxMacControl::SetDefaultButton( bool isDefault )
ca910e1a 92{
524c47aa 93 SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) isDefault ) ;
489468fe
SC
94}
95
ca910e1a
VZ
96wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
97 wxWindowMac* parent,
98 wxWindowID WXUNUSED(id),
524c47aa 99 const wxString& label,
ca910e1a 100 const wxPoint& pos,
524c47aa 101 const wxSize& size,
ca910e1a
VZ
102 long WXUNUSED(style),
103 long WXUNUSED(extraStyle))
489468fe 104{
524c47aa
SC
105 Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ;
106 wxMacControl* peer = new wxMacControl(wxpeer) ;
489468fe
SC
107
108 OSStatus err = CreateDisclosureTriangleControl(
ca910e1a 109 MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds,
489468fe
SC
110 kControlDisclosureTrianglePointDefault,
111 wxCFStringRef( label ),
112 0, // closed
113 TRUE, // draw title
114 TRUE, // auto toggle back and forth
524c47aa 115 peer->GetControlRefAddr() );
ca910e1a 116
489468fe 117 verify_noerr( err );
524c47aa 118 return peer;
489468fe 119}
ca910e1a 120
489468fe 121