]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/osx/cocoa/choice.mm
Disable some wxWebView tests that fail on the buildbot but not locally.
[wxWidgets.git] / src / osx / cocoa / choice.mm
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/cocoa/choice.mm
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@interface wxNSPopUpButton : NSPopUpButton
26{
27}
28
29@end
30
31@implementation wxNSPopUpButton
32
33+ (void)initialize
34{
35 static BOOL initialized = NO;
36 if (!initialized)
37 {
38 initialized = YES;
39 wxOSXCocoaClassAddWXMethods( self );
40 }
41}
42
43- (int) intValue
44{
45 return [self indexOfSelectedItem];
46}
47
48- (void) setIntValue: (int) v
49{
50 [self selectItemAtIndex:v];
51}
52
53@end
54
55@interface NSView(PossibleSizeMethods)
56- (NSControlSize)controlSize;
57@end
58
59class wxChoiceCocoaImpl : public wxWidgetCocoaImpl
60{
61public:
62 wxChoiceCocoaImpl(wxWindowMac *wxpeer, wxNSPopUpButton *v)
63 : wxWidgetCocoaImpl(wxpeer, v)
64 {
65 }
66
67 void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
68 {
69 left = top = right = bottom = 0;
70 NSControlSize size = NSRegularControlSize;
71 if ( [m_osxView respondsToSelector:@selector(controlSize)] )
72 size = [m_osxView controlSize];
73 else if ([m_osxView respondsToSelector:@selector(cell)])
74 {
75 id cell = [(id)m_osxView cell];
76 if ([cell respondsToSelector:@selector(controlSize)])
77 size = [cell controlSize];
78 }
79
80 switch( size )
81 {
82 case NSRegularControlSize:
83 left = right = 3;
84 top = 2;
85 bottom = 4;
86 break;
87 case NSSmallControlSize:
88 left = right = 3;
89 top = 1;
90 bottom = 4;
91 break;
92 case NSMiniControlSize:
93 left = 1;
94 right = 2;
95 top = 0;
96 bottom = 0;
97 break;
98 }
99 }
100};
101
102wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
103 wxWindowMac* WXUNUSED(parent),
104 wxWindowID WXUNUSED(id),
105 wxMenu* menu,
106 const wxPoint& pos,
107 const wxSize& size,
108 long WXUNUSED(style),
109 long WXUNUSED(extraStyle))
110{
111 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
112 wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
113 [v setMenu: menu->GetHMenu()];
114 [v setAutoenablesItems:NO];
115 wxWidgetCocoaImpl* c = new wxChoiceCocoaImpl( wxpeer, v );
116 return c;
117}
118
119#endif // wxUSE_CHOICE