]> git.saurik.com Git - wxWidgets.git/blame - src/os2/scrolbar.cpp
Remove tbarsmpl.cpp from the build list
[wxWidgets.git] / src / os2 / scrolbar.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: scrolbar.cpp
3// Purpose: wxScrollBar
409c9842 4// Author: David Webster
0e320a79 5// Modified by:
409c9842 6// Created: 10/15/99
0e320a79 7// RCS-ID: $Id$
409c9842
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
409c9842
DW
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"
0e320a79
DW
18#endif
19
20#include "wx/scrolbar.h"
409c9842 21#include "wx/os2/private.h"
0e320a79 22
0e320a79
DW
23IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
24
409c9842
DW
25BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
26#if WXWIN_COMPATIBILITY
27 EVT_SCROLL(wxScrollBar::OnScroll)
28#endif
29END_EVENT_TABLE()
30
0e320a79
DW
31
32// Scrollbar
33bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
34 const wxPoint& pos,
35 const wxSize& size, long style,
5d4b632b 36#if wxUSE_VALIDATORS
0e320a79 37 const wxValidator& validator,
5d4b632b 38#endif
0e320a79
DW
39 const wxString& name)
40{
41 if (!parent)
42 return FALSE;
43 parent->AddChild(this);
44 SetName(name);
5d4b632b 45#if wxUSE_VALIDATORS
409c9842 46 SetValidator(validator);
5d4b632b 47#endif
04701dd9 48
409c9842
DW
49 SetBackgroundColour(parent->GetBackgroundColour()) ;
50 SetForegroundColour(parent->GetForegroundColour()) ;
0e320a79
DW
51 m_windowStyle = style;
52
53 if ( id == -1 )
409c9842 54 m_windowId = (int)NewControlId();
0e320a79 55 else
409c9842
DW
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 }
0e320a79
DW
77
78 // TODO create scrollbar
409c9842
DW
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
04701dd9
DW
88 HWND scroll_bar = 0; // temporary
89
409c9842
DW
90 // Subclass again for purposes of dialog editing mode
91 SubclassWin((WXHWND) scroll_bar);
92
93 SetSize(x, y, width, height);
94
0e320a79
DW
95 return TRUE;
96}
97
98wxScrollBar::~wxScrollBar()
99{
100}
101
409c9842
DW
102bool 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
0e320a79
DW
187void wxScrollBar::SetThumbPosition(int viewStart)
188{
189 // TODO
190}
191
192int wxScrollBar::GetThumbPosition() const
193{
194 // TODO
195 return 0;
196}
197
198void 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
409c9842
DW
208#if WXWIN_COMPATIBILITY
209void wxScrollBar::SetPageSize(int pageLength)
210{
211 m_pageSize = pageLength;
212
213 // TODO:
214}
215
216void 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
227void wxScrollBar::SetViewLength(int viewLength)
228{
229 m_viewSize = viewLength;
230}
231
232void 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
245WXHBRUSH wxScrollBar::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
246 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
247{
248 return 0;
249}
0e320a79
DW
250
251void wxScrollBar::Command(wxCommandEvent& event)
252{
253 SetThumbPosition(event.m_commandInt);
254 ProcessCommand(event);
255}
256
409c9842
DW
257#if WXWIN_COMPATIBILITY
258// Backward compatibility
259void 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