]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/spinbutt.mm
Fix compilation with MinGW -std=c++11 option.
[wxWidgets.git] / src / cocoa / spinbutt.mm
CommitLineData
768d9ec8 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/cocoa/spinbutt.mm
768d9ec8
DE
3// Purpose: wxSpinButton
4// Author: David Elliott
5// Modified by:
6// Created: 2003/07/14
7// RCS-ID: $Id$
8// Copyright: (c) 2003 David Elliott
526954c5 9// Licence: wxWindows licence
768d9ec8
DE
10/////////////////////////////////////////////////////////////////////////////
11
449c5673 12#include "wx/wxprec.h"
768d9ec8
DE
13#if wxUSE_SPINBTN
14
449c5673
DE
15#ifndef WX_PRECOMP
16 #include "wx/app.h"
17#endif //WX_PRECOMP
768d9ec8
DE
18#include "wx/spinbutt.h"
19
20#import <AppKit/NSStepper.h>
21
768d9ec8
DE
22BEGIN_EVENT_TABLE(wxSpinButton, wxSpinButtonBase)
23END_EVENT_TABLE()
24// WX_IMPLEMENT_COCOA_OWNER(wxSpinButton,NSStepper,NSControl,NSView)
25
26bool wxSpinButton::Create(wxWindow *parent, wxWindowID winid,
27 const wxPoint& pos, const wxSize& size, long style,
28 const wxString& name)
29{
571b0b13
RN
30 //bad flag checking
31 wxASSERT_MSG( !(style & wxSP_HORIZONTAL), wxT("Horizontal wxSpinButton not supported in cocoa"));
768d9ec8
DE
32 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
33 return false;
8d656ea9 34 SetNSControl([[NSStepper alloc] initWithFrame: MakeDefaultNSRect(size)]);
768d9ec8 35 [m_cocoaNSView release];
519fa773 36
571b0b13 37 //flag handling
519fa773
RN
38 [(NSStepper*)m_cocoaNSView setValueWraps:style & wxSP_WRAP]; //default == true, evidently
39
40 //final setup
11573ad8
DE
41 [(NSStepper*)m_cocoaNSView setTarget: sm_cocoaTarget];
42 [(NSStepper*)m_cocoaNSView setAction:@selector(wxNSControlAction:)];
768d9ec8
DE
43 if(m_parent)
44 m_parent->CocoaAddChild(this);
8d656ea9
DE
45 SetInitialFrameRect(pos,size);
46
768d9ec8
DE
47 return true;
48}
49
50wxSpinButton::~wxSpinButton()
51{
11573ad8
DE
52 [(NSStepper*)m_cocoaNSView setTarget: nil];
53 [(NSStepper*)m_cocoaNSView setAction: nil];
54}
55
56int wxSpinButton::GetValue() const
57{
58 return [(NSStepper*)m_cocoaNSView intValue];
59}
60
61void wxSpinButton::SetValue(int value)
62{
c041438d 63 [(NSStepper*)m_cocoaNSView setIntValue:value];
11573ad8
DE
64}
65
66void wxSpinButton::SetRange(int minValue, int maxValue)
67{
68 [(NSStepper*)m_cocoaNSView setMinValue:minValue];
69 [(NSStepper*)m_cocoaNSView setMaxValue:maxValue];
70 wxSpinButtonBase::SetRange(minValue,maxValue);
71}
72
73void wxSpinButton::CocoaTarget_action()
74{
75 /* TODO: up/down events */
76 /* This sends the changed event (not specific on up or down) */
77 wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, GetId());
78 event.SetPosition(GetValue());
79 event.SetEventObject(this);
937013e0 80 HandleWindowEvent(event);
768d9ec8
DE
81}
82
83#endif // wxUSE_SPINBTN