]> git.saurik.com Git - wxWidgets.git/blame - src/mac/slider.cpp
Changed system colours for better default display of wxGrid. Please revert
[wxWidgets.git] / src / mac / slider.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: slider.cpp
3// Purpose: wxSlider
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "slider.h"
14#endif
15
16#include "wx/slider.h"
519cb848 17#include "wx/mac/uma.h"
e9576ca5 18
e9576ca5
SC
19IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
20
21BEGIN_EVENT_TABLE(wxSlider, wxControl)
22END_EVENT_TABLE()
e9576ca5
SC
23
24
25
26// Slider
27wxSlider::wxSlider()
28{
29 m_pageSize = 1;
30 m_lineSize = 1;
31 m_rangeMax = 0;
32 m_rangeMin = 0;
33 m_tickFreq = 0;
34}
35
519cb848
SC
36extern ControlActionUPP wxMacLiveScrollbarActionUPP ;
37
e9576ca5
SC
38bool wxSlider::Create(wxWindow *parent, wxWindowID id,
39 int value, int minValue, int maxValue,
40 const wxPoint& pos,
41 const wxSize& size, long style,
42 const wxValidator& validator,
43 const wxString& name)
44{
519cb848
SC
45 Rect bounds ;
46 Str255 title ;
47
48 MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
e9576ca5 49
519cb848 50 m_macMinimumStatic = NULL ;
e9576ca5 51
519cb848
SC
52 m_lineSize = 1;
53 m_tickFreq = 0;
e9576ca5 54
519cb848
SC
55 m_rangeMax = maxValue;
56 m_rangeMin = minValue;
57
58 m_pageSize = (int)((maxValue-minValue)/10);
59 if ( m_width == -1 )
60 {
61 m_width = 20 ;
62 if ( style & wxSL_LABELS && style & wxSL_VERTICAL )
63 m_width += 24 ;
64 bounds.right = bounds.left + m_width ;
65 }
66 if ( m_height == -1 )
67 {
68 m_height = 20 ;
69 if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL )
70 m_height += 24 ;
71 bounds.bottom = bounds.top + m_height ;
72 }
73
74 if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL )
75 {
76 bounds.top += 12 ;
77 bounds.right -= 24 ;
78 }
79
80 if ( style & wxSL_LABELS && style & wxSL_VERTICAL )
81 {
82 bounds.left += 24 ;
83 bounds.top += 12 ;
84 }
85
86 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , value , minValue , maxValue,
87 kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ;
88
89 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
90
91 ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ;
92
93 MacPostControlCreate() ;
94
95 if ( style & wxSL_LABELS )
96 {
97 if ( style & wxSL_HORIZONTAL )
98 {
99 wxSize size( 24 , 12 ) ;
100 wxPoint leftpos( 0 , 0 ) ;
101 wxPoint rightpos( m_width - 2 * 12 , 0 ) ;
102 wxPoint valuepos( m_width - 12 , 20 ) ;
103 wxString valuestring ;
104
105 valuestring.Printf( "%d" , minValue ) ;
106 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , leftpos , size ) ;
107 valuestring.Printf( "%d" , maxValue ) ;
108 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , rightpos , size ) ;
109 valuestring.Printf( "%d" , value ) ;
110 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ;
111 }
112 else
113 {
114 wxSize size( 24 , 12 ) ;
115 wxPoint toppos( 0 , 12 ) ;
116 wxPoint bottompos( 0 , m_height - 12 ) ;
117 wxPoint valuepos( 20 , 0 ) ;
118 wxString valuestring ;
119
120 valuestring.Printf( "%d" , minValue ) ;
121 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , bottompos , size ) ;
122 valuestring.Printf( "%d" , maxValue ) ;
123 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , toppos , size ) ;
124 valuestring.Printf( "%d" , value ) ;
125 m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ;
126 }
127 }
128
129 return TRUE;
e9576ca5 130
e9576ca5
SC
131}
132
133wxSlider::~wxSlider()
134{
135}
136
137int wxSlider::GetValue() const
138{
519cb848 139 return GetControlValue( m_macControl) ;
e9576ca5
SC
140}
141
142void wxSlider::SetValue(int value)
143{
519cb848
SC
144 wxString valuestring ;
145 valuestring.Printf( "%d" , value ) ;
146 if ( m_macMinimumStatic )
147 m_macMinimumStatic->SetLabel( valuestring ) ;
148 SetControlValue( m_macControl , value ) ;
e9576ca5
SC
149}
150
151void wxSlider::SetRange(int minValue, int maxValue)
152{
153 m_rangeMin = minValue;
154 m_rangeMax = maxValue;
155
156 // TODO
157}
158
159// For trackbars only
160void wxSlider::SetTickFreq(int n, int pos)
161{
162 // TODO
163 m_tickFreq = n;
164}
165
166void wxSlider::SetPageSize(int pageSize)
167{
168 // TODO
169 m_pageSize = pageSize;
170}
171
172int wxSlider::GetPageSize() const
173{
174 return m_pageSize;
175}
176
177void wxSlider::ClearSel()
178{
179 // TODO
180}
181
182void wxSlider::ClearTicks()
183{
184 // TODO
185}
186
187void wxSlider::SetLineSize(int lineSize)
188{
189 m_lineSize = lineSize;
190 // TODO
191}
192
193int wxSlider::GetLineSize() const
194{
195 // TODO
196 return 0;
197}
198
199int wxSlider::GetSelEnd() const
200{
201 // TODO
202 return 0;
203}
204
205int wxSlider::GetSelStart() const
206{
207 // TODO
208 return 0;
209}
210
211void wxSlider::SetSelection(int minPos, int maxPos)
212{
213 // TODO
214}
215
216void wxSlider::SetThumbLength(int len)
217{
218 // TODO
219}
220
221int wxSlider::GetThumbLength() const
222{
223 // TODO
224 return 0;
225}
226
227void wxSlider::SetTick(int tickPos)
228{
229 // TODO
230}
231
232void wxSlider::Command (wxCommandEvent & event)
233{
234 SetValue (event.GetInt());
235 ProcessCommand (event);
236}
237
519cb848 238bool wxSlider::Show( bool show )
e9576ca5 239{
519cb848 240 return wxWindow::Show( show ) ;
e9576ca5
SC
241}
242
519cb848
SC
243void wxSlider::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
244{
245 SInt16 value = ::GetControlValue( m_macControl ) ;
246
247 SetValue( value ) ;
248
249 wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId);
250 event.SetPosition(GetControlValue( m_macControl) );
251 event.SetEventObject( this );
252
253#if WXWIN_COMPATIBILITY
254
255 wxEventType oldEvent = event.GetEventType();
256 event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED );
257 if ( !GetEventHandler()->ProcessEvent(event) )
258 {
259 event.SetEventType( oldEvent );
260 if (!GetParent()->GetEventHandler()->ProcessEvent(event))
261 event.Skip();
262 }
263#else
264 GetEventHandler()->ProcessEvent(event);
265#endif
266}