]> git.saurik.com Git - wxWidgets.git/blob - src/os2/scrolbar.cpp
fix in fontspec parsing
[wxWidgets.git] / src / os2 / scrolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: scrolbar.cpp
3 // Purpose: wxScrollBar
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/15/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/defs.h"
17 #include "wx/utils.h"
18 #endif
19
20 #include "wx/scrolbar.h"
21 #include "wx/os2/private.h"
22
23 IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
24
25 BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
26 #if WXWIN_COMPATIBILITY
27 EVT_SCROLL(wxScrollBar::OnScroll)
28 #endif
29 END_EVENT_TABLE()
30
31
32 // Scrollbar
33 bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
34 const wxPoint& pos,
35 const wxSize& size, long style,
36 #if wxUSE_VALIDATORS
37 const wxValidator& validator,
38 #endif
39 const wxString& name)
40 {
41 if (!parent)
42 return FALSE;
43 parent->AddChild(this);
44 SetName(name);
45 #if wxUSE_VALIDATORS
46 SetValidator(validator);
47 #endif
48
49 SetBackgroundColour(parent->GetBackgroundColour()) ;
50 SetForegroundColour(parent->GetForegroundColour()) ;
51 m_windowStyle = style;
52
53 if ( id == -1 )
54 m_windowId = (int)NewControlId();
55 else
56 m_windowId = id;
57
58 int x = pos.x;
59 int y = pos.y;
60 int width = size.x;
61 int height = size.y;
62
63 if (width == -1)
64 {
65 if (style & wxHORIZONTAL)
66 width = 140;
67 else
68 width = 14;
69 }
70 if (height == -1)
71 {
72 if (style & wxVERTICAL)
73 height = 140;
74 else
75 height = 14;
76 }
77
78 // TODO create scrollbar
79
80 m_pageSize = 1;
81 m_viewSize = 1;
82 m_objectSize = 1;
83
84 SetFont(parent->GetFont());
85
86 m_hWnd = 0; // TODO: (WXHWND)scroll_bar;
87
88 HWND scroll_bar = 0; // temporary
89
90 // Subclass again for purposes of dialog editing mode
91 SubclassWin((WXHWND) scroll_bar);
92
93 SetSize(x, y, width, height);
94
95 return TRUE;
96 }
97
98 wxScrollBar::~wxScrollBar()
99 {
100 }
101
102 bool wxScrollBar::OS2OnScroll(int WXUNUSED(orientation), WXWORD wParam,
103 WXWORD pos, WXHWND control)
104 {
105 // TODO:
106 /*
107 int position = ::GetScrollPos((HWND) control, SB_CTL);
108 int minPos, maxPos;
109 ::GetScrollRange((HWND) control, SB_CTL, &minPos, &maxPos);
110
111 #if defined(__WIN95__)
112 // A page size greater than one has the effect of reducing the effective
113 // range, therefore the range has already been boosted artificially - so
114 // reduce it again.
115 if ( m_pageSize > 1 )
116 maxPos -= (m_pageSize - 1);
117 #endif // __WIN95__
118
119 wxEventType scrollEvent = wxEVT_NULL;
120
121 int nScrollInc;
122 switch ( wParam )
123 {
124 case SB_TOP:
125 nScrollInc = maxPos - position;
126 scrollEvent = wxEVT_SCROLL_TOP;
127 break;
128
129 case SB_BOTTOM:
130 nScrollInc = - position;
131 scrollEvent = wxEVT_SCROLL_BOTTOM;
132 break;
133
134 case SB_LINEUP:
135 nScrollInc = -1;
136 scrollEvent = wxEVT_SCROLL_LINEUP;
137 break;
138
139 case SB_LINEDOWN:
140 nScrollInc = 1;
141 scrollEvent = wxEVT_SCROLL_LINEDOWN;
142 break;
143
144 case SB_PAGEUP:
145 nScrollInc = -GetPageSize();
146 scrollEvent = wxEVT_SCROLL_PAGEUP;
147 break;
148
149 case SB_PAGEDOWN:
150 nScrollInc = GetPageSize();
151 scrollEvent = wxEVT_SCROLL_PAGEDOWN;
152 break;
153
154 case SB_THUMBTRACK:
155 case SB_THUMBPOSITION:
156 nScrollInc = pos - position;
157 scrollEvent = wxEVT_SCROLL_THUMBTRACK;
158 break;
159
160 default:
161 nScrollInc = 0;
162 }
163
164 if ( nScrollInc == 0 )
165 {
166 // no event to process, so don't process it
167 return FALSE;
168 }
169
170 int new_pos = position + nScrollInc;
171
172 if (new_pos < 0)
173 new_pos = 0;
174 if (new_pos > maxPos)
175 new_pos = maxPos;
176
177 SetThumbPosition(new_pos);
178 wxScrollEvent event(scrollEvent, m_windowId);
179 event.SetPosition(new_pos);
180 event.SetEventObject( this );
181
182 return GetEventHandler()->ProcessEvent(event);
183 */
184 return FALSE;
185 }
186
187 void wxScrollBar::SetThumbPosition(int viewStart)
188 {
189 // TODO
190 }
191
192 int wxScrollBar::GetThumbPosition() const
193 {
194 // TODO
195 return 0;
196 }
197
198 void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
199 bool refresh)
200 {
201 m_viewSize = pageSize;
202 m_pageSize = thumbSize;
203 m_objectSize = range;
204
205 // TODO
206 }
207
208 #if WXWIN_COMPATIBILITY
209 void wxScrollBar::SetPageSize(int pageLength)
210 {
211 m_pageSize = pageLength;
212
213 // TODO:
214 }
215
216 void wxScrollBar::SetObjectLength(int objectLength)
217 {
218 m_objectSize = objectLength;
219
220 // The range (number of scroll steps) is the
221 // object length minus the view size.
222 int range = wxMax((objectLength - m_viewSize), 0) ;
223
224 // TODO:
225 }
226
227 void wxScrollBar::SetViewLength(int viewLength)
228 {
229 m_viewSize = viewLength;
230 }
231
232 void wxScrollBar::GetValues(int *viewStart, int *viewLength, int *objectLength,
233 int *pageLength) const
234 {
235 // TODO:
236 /*
237 *viewStart = ::GetScrollPos((HWND)m_hWnd, SB_CTL);
238 *viewLength = m_viewSize;
239 *objectLength = m_objectSize;
240 *pageLength = m_pageSize;
241 */
242 }
243 #endif
244
245 WXHBRUSH wxScrollBar::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
246 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
247 {
248 return 0;
249 }
250
251 void wxScrollBar::Command(wxCommandEvent& event)
252 {
253 SetThumbPosition(event.m_commandInt);
254 ProcessCommand(event);
255 }
256
257 #if WXWIN_COMPATIBILITY
258 // Backward compatibility
259 void wxScrollBar::OnScroll(wxScrollEvent& event)
260 {
261 // TODO:
262 /*
263 wxEventType oldEvent = event.GetEventType();
264 event.SetEventType( wxEVT_COMMAND_SCROLLBAR_UPDATED );
265 if ( !GetEventHandler()->ProcessEvent(event) )
266 {
267 event.SetEventType( oldEvent );
268 if (!GetParent()->GetEventHandler()->ProcessEvent(event))
269 event.Skip();
270 }
271 */
272 }
273 #endif