]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/slider.mm
Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / src / osx / iphone / slider.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/slider.mm
3 // Purpose: wxSlider
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_SLIDER
14
15 #include "wx/slider.h"
16 #include "wx/osx/private.h"
17
18 @interface wxUISlider : UISlider
19 {
20 }
21 @end
22
23 @implementation wxUISlider
24
25 + (void)initialize
26 {
27 static BOOL initialized = NO;
28 if (!initialized)
29 {
30 initialized = YES;
31 wxOSXIPhoneClassAddWXMethods(self);
32 }
33 }
34
35 @end
36
37 class wxSliderIPhoneImpl : public wxWidgetIPhoneImpl
38 {
39 public :
40 wxSliderIPhoneImpl(wxWindowMac* peer , UISlider* w) :
41 wxWidgetIPhoneImpl(peer, w)
42 {
43 m_control=w;
44 }
45
46 ~wxSliderIPhoneImpl()
47 {
48 }
49
50 void controlAction(void* sender, wxUint32 controlEvent, WX_UIEvent rawEvent)
51 {
52 if ( controlEvent == UIControlEventValueChanged )
53 GetWXPeer()->TriggerScrollEvent(wxEVT_SCROLL_THUMBTRACK);
54 else
55 wxWidgetIPhoneImpl::controlAction(sender,controlEvent,rawEvent);
56 }
57
58 void SetMaximum(wxInt32 m)
59 {
60 [m_control setMaximumValue:m];
61 }
62
63 void SetMinimum(wxInt32 m)
64 {
65 [m_control setMinimumValue:m];
66 }
67
68 void SetValue(wxInt32 n)
69 {
70 [m_control setValue:n];
71 }
72
73 wxInt32 GetValue() const
74 {
75 return [m_control value];
76 }
77
78 private:
79 UISlider* m_control;
80 };
81
82 wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
83 wxWindowMac* WXUNUSED(parent),
84 wxWindowID WXUNUSED(id),
85 wxInt32 value,
86 wxInt32 minimum,
87 wxInt32 maximum,
88 const wxPoint& pos,
89 const wxSize& size,
90 long style,
91 long WXUNUSED(extraStyle))
92 {
93 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
94 UISlider* v = [[UISlider alloc] initWithFrame:r];
95
96 [v setMinimumValue: minimum];
97 [v setMaximumValue: maximum];
98 [v setValue: (double) value];
99
100 wxWidgetIPhoneImpl* c = new wxSliderIPhoneImpl( wxpeer, v );
101 return c;
102 }
103
104 #endif // wxUSE_SLIDER