]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/spinbutt.mm
removed multiple duplicate copies (with subtly different behaviour) of SetStringSelec...
[wxWidgets.git] / src / cocoa / spinbutt.mm
CommitLineData
768d9ec8
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: cocoa/spinbutt.mm
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
065e208e 9// Licence: wxWidgets 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
7cc28452
DE
22IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent)
23
768d9ec8
DE
24IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
25BEGIN_EVENT_TABLE(wxSpinButton, wxSpinButtonBase)
26END_EVENT_TABLE()
27// WX_IMPLEMENT_COCOA_OWNER(wxSpinButton,NSStepper,NSControl,NSView)
28
29bool wxSpinButton::Create(wxWindow *parent, wxWindowID winid,
30 const wxPoint& pos, const wxSize& size, long style,
31 const wxString& name)
32{
33 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
34 return false;
8d656ea9 35 SetNSControl([[NSStepper alloc] initWithFrame: MakeDefaultNSRect(size)]);
768d9ec8 36 [m_cocoaNSView release];
11573ad8
DE
37 [(NSStepper*)m_cocoaNSView setTarget: sm_cocoaTarget];
38 [(NSStepper*)m_cocoaNSView setAction:@selector(wxNSControlAction:)];
768d9ec8
DE
39 if(m_parent)
40 m_parent->CocoaAddChild(this);
8d656ea9
DE
41 SetInitialFrameRect(pos,size);
42
768d9ec8
DE
43 return true;
44}
45
46wxSpinButton::~wxSpinButton()
47{
11573ad8
DE
48 [(NSStepper*)m_cocoaNSView setTarget: nil];
49 [(NSStepper*)m_cocoaNSView setAction: nil];
50}
51
52int wxSpinButton::GetValue() const
53{
54 return [(NSStepper*)m_cocoaNSView intValue];
55}
56
57void wxSpinButton::SetValue(int value)
58{
c041438d 59 [(NSStepper*)m_cocoaNSView setIntValue:value];
11573ad8
DE
60}
61
62void wxSpinButton::SetRange(int minValue, int maxValue)
63{
64 [(NSStepper*)m_cocoaNSView setMinValue:minValue];
65 [(NSStepper*)m_cocoaNSView setMaxValue:maxValue];
66 wxSpinButtonBase::SetRange(minValue,maxValue);
67}
68
69void wxSpinButton::CocoaTarget_action()
70{
71 /* TODO: up/down events */
72 /* This sends the changed event (not specific on up or down) */
73 wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, GetId());
74 event.SetPosition(GetValue());
75 event.SetEventObject(this);
76 GetEventHandler()->ProcessEvent(event);
768d9ec8
DE
77}
78
79#endif // wxUSE_SPINBTN