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