]>
Commit | Line | Data |
---|---|---|
30954328 | 1 | ///////////////////////////////////////////////////////////////////////////// |
e1437456 | 2 | // Name: gtk/scrolwin.cpp |
30954328 | 3 | // Purpose: wxScrolledWindow implementation |
47a3ff38 | 4 | // Author: Robert Roebling |
566d84a7 | 5 | // Modified by: Ron Lee |
30954328 RR |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
47a3ff38 | 8 | // Copyright: (c) Robert Roebling |
65571936 | 9 | // Licence: wxWindows licence |
30954328 RR |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
30954328 RR |
21 | #pragma implementation "scrolwin.h" |
22 | #endif | |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
e1bf3ad3 | 31 | #include "wx/scrolwin.h" |
30954328 RR |
32 | #include "wx/utils.h" |
33 | #include "wx/dcclient.h" | |
30954328 | 34 | #include "wx/panel.h" |
30486297 | 35 | #include "wx/sizer.h" |
30954328 | 36 | |
9e691f46 | 37 | #include "wx/gtk/private.h" |
30954328 RR |
38 | #include "wx/gtk/win_gtk.h" |
39 | ||
40 | // ---------------------------------------------------------------------------- | |
41 | // event tables | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
44 | BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel) | |
d9a4f620 | 45 | EVT_SCROLLWIN(wxScrolledWindow::OnScroll) |
30954328 RR |
46 | EVT_SIZE(wxScrolledWindow::OnSize) |
47 | EVT_PAINT(wxScrolledWindow::OnPaint) | |
48 | EVT_CHAR(wxScrolledWindow::OnChar) | |
49 | END_EVENT_TABLE() | |
50 | ||
51 | IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel) | |
52 | ||
53 | // ============================================================================ | |
54 | // implementation | |
55 | // ============================================================================ | |
56 | ||
57 | //----------------------------------------------------------------------------- | |
58 | // data | |
59 | //----------------------------------------------------------------------------- | |
60 | ||
61 | extern bool g_blockEventsOnDrag; | |
cf19b0bd | 62 | extern bool g_blockEventsOnScroll; |
30954328 RR |
63 | |
64 | //----------------------------------------------------------------------------- | |
65 | // idle system | |
66 | //----------------------------------------------------------------------------- | |
67 | ||
68 | extern void wxapp_install_idle_handler(); | |
69 | extern bool g_isIdle; | |
70 | ||
71 | //----------------------------------------------------------------------------- | |
72 | // "value_changed" from m_vAdjust | |
73 | //----------------------------------------------------------------------------- | |
74 | ||
9e691f46 VZ |
75 | static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, |
76 | SCROLLBAR_CBACK_ARG | |
77 | wxScrolledWindow *win ) | |
30954328 RR |
78 | { |
79 | if (g_isIdle) | |
80 | wxapp_install_idle_handler(); | |
81 | ||
82 | if (g_blockEventsOnDrag) return; | |
83 | ||
84 | if (!win->m_hasVMT) return; | |
47a3ff38 | 85 | |
9e691f46 VZ |
86 | win->GtkVScroll( adjust->value, |
87 | GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->vscrollbar) ); | |
30954328 RR |
88 | } |
89 | ||
90 | //----------------------------------------------------------------------------- | |
91 | // "value_changed" from m_hAdjust | |
92 | //----------------------------------------------------------------------------- | |
93 | ||
9e691f46 VZ |
94 | static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, |
95 | SCROLLBAR_CBACK_ARG | |
96 | wxScrolledWindow *win ) | |
30954328 RR |
97 | { |
98 | if (g_isIdle) | |
99 | wxapp_install_idle_handler(); | |
100 | ||
101 | if (g_blockEventsOnDrag) return; | |
102 | if (!win->m_hasVMT) return; | |
103 | ||
9e691f46 VZ |
104 | win->GtkHScroll( adjust->value, |
105 | GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->hscrollbar) ); | |
30954328 RR |
106 | } |
107 | ||
cf19b0bd RR |
108 | //----------------------------------------------------------------------------- |
109 | // "button_press_event" from scrollbar | |
110 | //----------------------------------------------------------------------------- | |
111 | ||
112 | static gint gtk_scrollbar_button_press_callback( GtkRange *widget, | |
113 | GdkEventButton *gdk_event, | |
114 | wxWindowGTK *win) | |
115 | { | |
116 | if (g_isIdle) | |
117 | wxapp_install_idle_handler(); | |
118 | ||
119 | g_blockEventsOnScroll = TRUE; | |
9e691f46 VZ |
120 | |
121 | // FIXME: there is no slider field any more, what was meant here? | |
122 | #ifndef __WXGTK20__ | |
cf19b0bd | 123 | win->m_isScrolling = (gdk_event->window == widget->slider); |
9e691f46 | 124 | #endif |
cf19b0bd RR |
125 | |
126 | return FALSE; | |
127 | } | |
128 | ||
129 | //----------------------------------------------------------------------------- | |
130 | // "button_release_event" from scrollbar | |
131 | //----------------------------------------------------------------------------- | |
132 | ||
133 | static gint gtk_scrollbar_button_release_callback( GtkRange *widget, | |
134 | GdkEventButton *WXUNUSED(gdk_event), | |
135 | wxWindowGTK *win) | |
136 | { | |
137 | // don't test here as we can release the mouse while being over | |
138 | // a different window than the slider | |
139 | // | |
140 | // if (gdk_event->window != widget->slider) return FALSE; | |
141 | ||
142 | g_blockEventsOnScroll = FALSE; | |
143 | ||
144 | if (win->m_isScrolling) | |
145 | { | |
146 | wxEventType command = wxEVT_SCROLLWIN_THUMBRELEASE; | |
147 | int value = -1; | |
148 | int dir = -1; | |
149 | ||
150 | GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); | |
151 | if (widget == GTK_RANGE(scrolledWindow->hscrollbar)) | |
152 | { | |
153 | value = (int)(win->m_hAdjust->value+0.5); | |
154 | dir = wxHORIZONTAL; | |
155 | } | |
156 | if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) | |
157 | { | |
158 | value = (int)(win->m_vAdjust->value+0.5); | |
159 | dir = wxVERTICAL; | |
160 | } | |
161 | ||
162 | wxScrollWinEvent event( command, value, dir ); | |
163 | event.SetEventObject( win ); | |
164 | win->GetEventHandler()->ProcessEvent( event ); | |
165 | } | |
166 | ||
167 | win->m_isScrolling = FALSE; | |
168 | ||
169 | return FALSE; | |
170 | } | |
171 | ||
30954328 RR |
172 | //----------------------------------------------------------------------------- |
173 | // InsertChild for wxScrolledWindow | |
174 | //----------------------------------------------------------------------------- | |
175 | ||
176 | static void wxInsertChildInScrolledWindow( wxWindow* parent, wxWindow* child ) | |
177 | { | |
830ed6d9 RR |
178 | // The window might have been scrolled already, do we |
179 | // have to adapt the position. | |
30954328 RR |
180 | GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow); |
181 | child->m_x += pizza->xoffset; | |
182 | child->m_y += pizza->yoffset; | |
183 | ||
184 | gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), | |
185 | GTK_WIDGET(child->m_widget), | |
186 | child->m_x, | |
187 | child->m_y, | |
188 | child->m_width, | |
189 | child->m_height ); | |
190 | } | |
191 | ||
192 | // ---------------------------------------------------------------------------- | |
193 | // wxScrolledWindow creation | |
194 | // ---------------------------------------------------------------------------- | |
195 | ||
830ed6d9 | 196 | void wxScrolledWindow::Init() |
30954328 RR |
197 | { |
198 | m_xScrollPixelsPerLine = 0; | |
199 | m_yScrollPixelsPerLine = 0; | |
200 | m_xScrollingEnabled = TRUE; | |
201 | m_yScrollingEnabled = TRUE; | |
202 | m_xScrollPosition = 0; | |
203 | m_yScrollPosition = 0; | |
30954328 RR |
204 | m_xScrollLinesPerPage = 0; |
205 | m_yScrollLinesPerPage = 0; | |
206 | m_targetWindow = (wxWindow*) NULL; | |
d9a4f620 RR |
207 | m_scaleX = 1.0; |
208 | m_scaleY = 1.0; | |
e1437456 | 209 | m_hasScrolling = TRUE; |
30954328 RR |
210 | } |
211 | ||
212 | bool wxScrolledWindow::Create(wxWindow *parent, | |
213 | wxWindowID id, | |
214 | const wxPoint& pos, | |
215 | const wxSize& size, | |
216 | long style, | |
217 | const wxString& name) | |
218 | { | |
830ed6d9 RR |
219 | Init(); |
220 | ||
30954328 RR |
221 | if (!PreCreation( parent, pos, size ) || |
222 | !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
223 | { | |
224 | wxFAIL_MSG( wxT("wxWindow creation failed") ); | |
225 | return FALSE; | |
226 | } | |
227 | ||
228 | m_insertCallback = wxInsertChildInScrolledWindow; | |
39c869a6 | 229 | |
30954328 RR |
230 | m_targetWindow = this; |
231 | ||
232 | m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); | |
233 | GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); | |
234 | ||
235 | GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget); | |
236 | ||
237 | GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) ); | |
238 | scroll_class->scrollbar_spacing = 0; | |
239 | ||
240 | gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); | |
241 | ||
242 | m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->hscrollbar) ); | |
243 | m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->vscrollbar) ); | |
244 | ||
245 | m_wxwindow = gtk_pizza_new(); | |
246 | ||
247 | gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); | |
248 | ||
249 | GtkPizza *pizza = GTK_PIZZA(m_wxwindow); | |
250 | ||
251 | if (HasFlag(wxRAISED_BORDER)) | |
252 | { | |
253 | gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT ); | |
254 | } | |
255 | else if (HasFlag(wxSUNKEN_BORDER)) | |
256 | { | |
257 | gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_IN ); | |
258 | } | |
259 | else if (HasFlag(wxSIMPLE_BORDER)) | |
260 | { | |
261 | gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_THIN ); | |
262 | } | |
263 | else | |
264 | { | |
265 | gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE ); | |
266 | } | |
267 | ||
268 | GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); | |
269 | m_acceptsFocus = TRUE; | |
270 | ||
271 | // I _really_ don't want scrollbars in the beginning | |
272 | m_vAdjust->lower = 0.0; | |
273 | m_vAdjust->upper = 1.0; | |
274 | m_vAdjust->value = 0.0; | |
275 | m_vAdjust->step_increment = 1.0; | |
4ca24f18 | 276 | m_vAdjust->page_increment = 2.0; |
30954328 RR |
277 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); |
278 | m_hAdjust->lower = 0.0; | |
279 | m_hAdjust->upper = 1.0; | |
280 | m_hAdjust->value = 0.0; | |
281 | m_hAdjust->step_increment = 1.0; | |
4ca24f18 | 282 | m_hAdjust->page_increment = 2.0; |
30954328 RR |
283 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); |
284 | ||
830ed6d9 RR |
285 | // Handlers for new scrollbar values |
286 | GtkVConnectEvent(); | |
287 | GtkHConnectEvent(); | |
30954328 | 288 | |
cf19b0bd | 289 | // these handlers block mouse events to any window during scrolling such as |
77ffb593 | 290 | // motion events and prevent GTK and wxWidgets from fighting over where the |
cf19b0bd RR |
291 | // slider should be |
292 | ||
293 | gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event", | |
294 | (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); | |
295 | ||
296 | gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_press_event", | |
297 | (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); | |
298 | ||
299 | gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_release_event", | |
300 | (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); | |
301 | ||
302 | gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_release_event", | |
303 | (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); | |
304 | ||
30954328 RR |
305 | gtk_widget_show( m_wxwindow ); |
306 | ||
307 | if (m_parent) | |
308 | m_parent->DoAddChild( this ); | |
30486297 | 309 | |
c9c4b3a0 | 310 | m_focusWidget = m_wxwindow; |
30954328 RR |
311 | |
312 | PostCreation(); | |
313 | ||
314 | Show( TRUE ); | |
2b5f62a0 | 315 | |
30954328 RR |
316 | return TRUE; |
317 | } | |
318 | ||
30954328 RR |
319 | // ---------------------------------------------------------------------------- |
320 | // setting scrolling parameters | |
321 | // ---------------------------------------------------------------------------- | |
322 | ||
566d84a7 RL |
323 | void wxScrolledWindow::DoSetVirtualSize( int x, int y ) |
324 | { | |
325 | wxPanel::DoSetVirtualSize( x, y ); | |
326 | AdjustScrollbars(); | |
92aff599 | 327 | |
92aff599 RL |
328 | if (GetAutoLayout()) |
329 | Layout(); | |
566d84a7 RL |
330 | } |
331 | ||
844adaa4 JS |
332 | // wxWindow's GetBestVirtualSize returns the actual window size, |
333 | // whereas we want to return the virtual size | |
334 | wxSize wxScrolledWindow::GetBestVirtualSize() const | |
335 | { | |
336 | wxSize clientSize( GetClientSize() ); | |
337 | if (GetSizer()) | |
338 | { | |
339 | wxSize minSize( GetSizer()->CalcMin() ); | |
340 | ||
341 | return wxSize( wxMax( clientSize.x, minSize.x ), wxMax( clientSize.y, minSize.y ) ); | |
342 | } | |
343 | else | |
344 | return clientSize; | |
345 | } | |
346 | ||
347 | // return the size best suited for the current window | |
348 | // (this isn't a virtual size, this is a sensible size for the window) | |
349 | wxSize wxScrolledWindow::DoGetBestSize() const | |
350 | { | |
351 | wxSize best; | |
352 | ||
353 | if ( GetSizer() ) | |
354 | { | |
355 | wxSize b = GetSizer()->GetMinSize(); | |
356 | ||
357 | // Only use the content to set the window size in the direction | |
358 | // where there's no scrolling; otherwise we're going to get a huge | |
359 | // window in the direction in which scrolling is enabled | |
360 | int ppuX, ppuY; | |
361 | GetScrollPixelsPerUnit(& ppuX, & ppuY); | |
362 | ||
363 | wxSize minSize; | |
364 | if ( GetMinSize().IsFullySpecified() ) | |
365 | minSize = GetMinSize(); | |
366 | else | |
367 | minSize = GetSize(); | |
368 | ||
369 | if (ppuX > 0) | |
370 | b.x = minSize.x; | |
371 | if (ppuY > 0) | |
372 | b.y = minSize.y; | |
373 | best = b; | |
374 | } | |
375 | else | |
376 | return wxWindow::DoGetBestSize(); | |
377 | ||
378 | // Add any difference between size and client size | |
379 | wxSize diff = GetSize() - GetClientSize(); | |
380 | best.x += wxMax(0, diff.x); | |
381 | best.y += wxMax(0, diff.y); | |
382 | ||
383 | return best; | |
384 | } | |
385 | ||
30954328 RR |
386 | /* |
387 | * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line) | |
388 | * noUnitsX/noUnitsY: : no. units per scrollbar | |
389 | */ | |
566d84a7 RL |
390 | void wxScrolledWindow::SetScrollbars( int pixelsPerUnitX, int pixelsPerUnitY, |
391 | int noUnitsX, int noUnitsY, | |
392 | int xPos, int yPos, bool noRefresh ) | |
30954328 | 393 | { |
1adff2f5 JS |
394 | int xs, ys; |
395 | GetViewStart (& xs, & ys); | |
396 | ||
397 | int old_x = m_xScrollPixelsPerLine * xs; | |
398 | int old_y = m_yScrollPixelsPerLine * ys; | |
30486297 | 399 | |
30954328 RR |
400 | m_xScrollPixelsPerLine = pixelsPerUnitX; |
401 | m_yScrollPixelsPerLine = pixelsPerUnitY; | |
39c869a6 | 402 | |
566d84a7 RL |
403 | m_hAdjust->value = m_xScrollPosition = xPos; |
404 | m_vAdjust->value = m_yScrollPosition = yPos; | |
30954328 | 405 | |
2b5f62a0 VZ |
406 | // Setting hints here should arguably be deprecated, but without it |
407 | // a sizer might override this manual scrollbar setting in old code. | |
878ddad5 | 408 | // m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); |
30486297 | 409 | |
f18f464c VZ |
410 | int w = noUnitsX * pixelsPerUnitX; |
411 | int h = noUnitsY * pixelsPerUnitY; | |
412 | m_targetWindow->SetVirtualSize( w ? w : wxDefaultCoord, | |
413 | h ? h : wxDefaultCoord); | |
2b5f62a0 | 414 | |
ec7482df RR |
415 | if (!noRefresh) |
416 | { | |
417 | int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; | |
418 | int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; | |
30486297 | 419 | |
566d84a7 | 420 | m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y ); |
ec7482df | 421 | } |
30954328 RR |
422 | } |
423 | ||
424 | void wxScrolledWindow::AdjustScrollbars() | |
425 | { | |
426 | int w, h; | |
566d84a7 RL |
427 | int vw, vh; |
428 | ||
30954328 | 429 | m_targetWindow->GetClientSize( &w, &h ); |
566d84a7 | 430 | m_targetWindow->GetVirtualSize( &vw, &vh ); |
878ddad5 | 431 | |
30954328 | 432 | if (m_xScrollPixelsPerLine == 0) |
4ca24f18 RR |
433 | { |
434 | m_hAdjust->upper = 1.0; | |
47a3ff38 | 435 | m_hAdjust->page_increment = 1.0; |
30954328 | 436 | m_hAdjust->page_size = 1.0; |
4ca24f18 | 437 | } |
30954328 | 438 | else |
4ca24f18 | 439 | { |
878ddad5 RR |
440 | m_hAdjust->upper = (vw+m_xScrollPixelsPerLine-1) / m_xScrollPixelsPerLine; |
441 | m_hAdjust->page_size = w / m_xScrollPixelsPerLine; | |
bf67b135 | 442 | m_hAdjust->page_increment = w / m_xScrollPixelsPerLine; |
39c869a6 | 443 | |
878ddad5 RR |
444 | // Special case. When client and virtual size are very close but |
445 | // the client is big enough, kill scrollbar. | |
446 | ||
447 | if ((m_hAdjust->page_size < m_hAdjust->upper) && (w >= vw)) | |
448 | m_hAdjust->page_size += 1.0; | |
449 | ||
566d84a7 RL |
450 | // If the scrollbar hits the right side, move the window |
451 | // right to keep it from over extending. | |
4ca24f18 | 452 | |
2b5f62a0 | 453 | if ((m_hAdjust->value != 0.0) && (m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper)) |
566d84a7 | 454 | { |
2b5f62a0 VZ |
455 | m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size; |
456 | if (m_hAdjust->value < 0.0) | |
457 | m_hAdjust->value = 0.0; | |
458 | ||
b03f81b7 | 459 | if (GetChildren().GetCount() == 0) |
2b5f62a0 VZ |
460 | m_xScrollPosition = (int)m_hAdjust->value; // This is enough without child windows |
461 | else | |
462 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); // Actually scroll window | |
566d84a7 | 463 | } |
4ca24f18 RR |
464 | } |
465 | ||
30954328 | 466 | if (m_yScrollPixelsPerLine == 0) |
4ca24f18 RR |
467 | { |
468 | m_vAdjust->upper = 1.0; | |
47a3ff38 | 469 | m_vAdjust->page_increment = 1.0; |
30954328 | 470 | m_vAdjust->page_size = 1.0; |
4ca24f18 | 471 | } |
30954328 | 472 | else |
4ca24f18 | 473 | { |
878ddad5 RR |
474 | m_vAdjust->upper = (vh+m_yScrollPixelsPerLine-1) / m_yScrollPixelsPerLine; |
475 | m_vAdjust->page_size = h / m_yScrollPixelsPerLine; | |
bf67b135 | 476 | m_vAdjust->page_increment = h / m_yScrollPixelsPerLine; |
878ddad5 RR |
477 | |
478 | if ((m_vAdjust->page_size < m_vAdjust->upper) && (h >= vh)) | |
479 | m_vAdjust->page_size += 1.0; | |
39c869a6 | 480 | |
2b5f62a0 | 481 | if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper)) |
566d84a7 | 482 | { |
2b5f62a0 VZ |
483 | m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size; |
484 | if (m_vAdjust->value < 0.0) | |
485 | m_vAdjust->value = 0.0; | |
486 | ||
b03f81b7 | 487 | if (GetChildren().GetCount() == 0) |
2b5f62a0 VZ |
488 | m_yScrollPosition = (int)m_vAdjust->value; |
489 | else | |
490 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); | |
566d84a7 | 491 | } |
4ca24f18 RR |
492 | } |
493 | ||
47a3ff38 RR |
494 | m_xScrollLinesPerPage = (int)(m_hAdjust->page_increment + 0.5); |
495 | m_yScrollLinesPerPage = (int)(m_vAdjust->page_increment + 0.5); | |
39c869a6 | 496 | |
30954328 RR |
497 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); |
498 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); | |
499 | } | |
500 | ||
566d84a7 | 501 | |
30954328 RR |
502 | // ---------------------------------------------------------------------------- |
503 | // target window handling | |
504 | // ---------------------------------------------------------------------------- | |
505 | ||
13ff9344 | 506 | void wxScrolledWindow::SetTargetWindow( wxWindow *target, bool WXUNUSED(pushEventHandler) ) |
30954328 RR |
507 | { |
508 | wxASSERT_MSG( target, wxT("target window must not be NULL") ); | |
509 | m_targetWindow = target; | |
510 | } | |
511 | ||
bfe35776 | 512 | wxWindow *wxScrolledWindow::GetTargetWindow() const |
30954328 RR |
513 | { |
514 | return m_targetWindow; | |
515 | } | |
516 | ||
517 | // Override this function if you don't want to have wxScrolledWindow | |
518 | // automatically change the origin according to the scroll position. | |
5de9f492 | 519 | void wxScrolledWindow::DoPrepareDC(wxDC& dc) |
30954328 RR |
520 | { |
521 | dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine, | |
522 | -m_yScrollPosition * m_yScrollPixelsPerLine ); | |
523 | } | |
524 | ||
566d84a7 RL |
525 | void wxScrolledWindow::SetScrollRate( int xstep, int ystep ) |
526 | { | |
527 | int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; | |
528 | int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; | |
529 | ||
530 | m_xScrollPixelsPerLine = xstep; | |
531 | m_yScrollPixelsPerLine = ystep; | |
532 | ||
533 | int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; | |
534 | int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; | |
535 | ||
536 | m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y ); | |
537 | ||
538 | AdjustScrollbars(); | |
539 | } | |
540 | ||
30954328 RR |
541 | void wxScrolledWindow::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const |
542 | { | |
543 | if ( x_unit ) | |
544 | *x_unit = m_xScrollPixelsPerLine; | |
545 | if ( y_unit ) | |
546 | *y_unit = m_yScrollPixelsPerLine; | |
547 | } | |
548 | ||
549 | int wxScrolledWindow::GetScrollPageSize(int orient) const | |
550 | { | |
551 | if ( orient == wxHORIZONTAL ) | |
552 | return m_xScrollLinesPerPage; | |
553 | else | |
554 | return m_yScrollLinesPerPage; | |
555 | } | |
556 | ||
557 | void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize) | |
558 | { | |
559 | if ( orient == wxHORIZONTAL ) | |
560 | m_xScrollLinesPerPage = pageSize; | |
561 | else | |
562 | m_yScrollLinesPerPage = pageSize; | |
563 | } | |
564 | ||
d9a4f620 RR |
565 | void wxScrolledWindow::OnScroll(wxScrollWinEvent& event) |
566 | { | |
567 | int orient = event.GetOrientation(); | |
0bc0cd5d | 568 | |
d9a4f620 RR |
569 | int nScrollInc = CalcScrollInc(event); |
570 | if (nScrollInc == 0) return; | |
571 | ||
572 | if (orient == wxHORIZONTAL) | |
573 | { | |
574 | int newPos = m_xScrollPosition + nScrollInc; | |
575 | SetScrollPos(wxHORIZONTAL, newPos, TRUE ); | |
576 | } | |
577 | else | |
578 | { | |
579 | int newPos = m_yScrollPosition + nScrollInc; | |
580 | SetScrollPos(wxVERTICAL, newPos, TRUE ); | |
581 | } | |
582 | ||
583 | if (orient == wxHORIZONTAL) | |
584 | { | |
585 | m_xScrollPosition += nScrollInc; | |
586 | } | |
587 | else | |
588 | { | |
589 | m_yScrollPosition += nScrollInc; | |
590 | } | |
591 | ||
592 | if (orient == wxHORIZONTAL) | |
593 | { | |
594 | if (m_xScrollingEnabled) | |
595 | m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL); | |
596 | else | |
597 | m_targetWindow->Refresh(); | |
598 | } | |
599 | else | |
600 | { | |
601 | if (m_yScrollingEnabled) | |
602 | m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL); | |
603 | else | |
604 | m_targetWindow->Refresh(); | |
605 | } | |
606 | } | |
607 | ||
30954328 RR |
608 | void wxScrolledWindow::Scroll( int x_pos, int y_pos ) |
609 | { | |
566d84a7 | 610 | wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); |
30954328 RR |
611 | |
612 | if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && | |
613 | ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; | |
614 | ||
30954328 RR |
615 | if ((x_pos != -1) && (m_xScrollPixelsPerLine)) |
616 | { | |
830ed6d9 RR |
617 | int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); |
618 | if (max < 0) max = 0; | |
619 | if (x_pos > max) x_pos = max; | |
620 | if (x_pos < 0) x_pos = 0; | |
39c869a6 | 621 | |
30954328 RR |
622 | int old_x = m_xScrollPosition; |
623 | m_xScrollPosition = x_pos; | |
aafe4488 | 624 | m_hAdjust->value = x_pos; |
39c869a6 | 625 | |
aafe4488 | 626 | m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 ); |
39c869a6 | 627 | |
77ffb593 | 628 | // Just update the scrollbar, don't send any wxWidgets event |
830ed6d9 | 629 | GtkHDisconnectEvent(); |
aafe4488 | 630 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); |
830ed6d9 | 631 | GtkHConnectEvent(); |
30954328 | 632 | } |
39c869a6 | 633 | |
30954328 RR |
634 | if ((y_pos != -1) && (m_yScrollPixelsPerLine)) |
635 | { | |
830ed6d9 RR |
636 | int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); |
637 | if (max < 0) max = 0; | |
638 | if (y_pos > max) y_pos = max; | |
639 | if (y_pos < 0) y_pos = 0; | |
39c869a6 | 640 | |
30954328 RR |
641 | int old_y = m_yScrollPosition; |
642 | m_yScrollPosition = y_pos; | |
aafe4488 | 643 | m_vAdjust->value = y_pos; |
39c869a6 | 644 | |
aafe4488 | 645 | m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine ); |
39c869a6 | 646 | |
77ffb593 | 647 | // Just update the scrollbar, don't send any wxWidgets event |
830ed6d9 | 648 | GtkVDisconnectEvent(); |
aafe4488 | 649 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); |
830ed6d9 | 650 | GtkVConnectEvent(); |
30954328 RR |
651 | } |
652 | } | |
653 | ||
9e691f46 VZ |
654 | // TODO: [VH]Scroll functions should be combined |
655 | ||
656 | void wxScrolledWindow::GtkVScroll( float value, unsigned int scroll_type ) | |
30954328 | 657 | { |
566d84a7 | 658 | wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); |
aafe4488 RR |
659 | |
660 | if (m_yScrollPixelsPerLine == 0) | |
661 | return; | |
39c869a6 | 662 | |
aafe4488 | 663 | int y_pos = (int)(value+0.5); |
39c869a6 | 664 | |
aafe4488 RR |
665 | if (y_pos == m_yScrollPosition) |
666 | return; | |
39c869a6 | 667 | |
9e691f46 | 668 | wxEventType command = GtkScrollWinTypeToWx(scroll_type); |
d9a4f620 | 669 | |
0bc0cd5d | 670 | wxScrollWinEvent event( command, y_pos, wxVERTICAL ); |
d9a4f620 RR |
671 | event.SetEventObject( this ); |
672 | GetEventHandler()->ProcessEvent( event ); | |
30954328 RR |
673 | } |
674 | ||
9e691f46 | 675 | void wxScrolledWindow::GtkHScroll( float value, unsigned int scroll_type ) |
30954328 | 676 | { |
566d84a7 | 677 | wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); |
39c869a6 | 678 | |
aafe4488 RR |
679 | if (m_xScrollPixelsPerLine == 0) |
680 | return; | |
39c869a6 | 681 | |
aafe4488 | 682 | int x_pos = (int)(value+0.5); |
0bc0cd5d | 683 | |
aafe4488 RR |
684 | if (x_pos == m_xScrollPosition) |
685 | return; | |
aafe4488 | 686 | |
9e691f46 | 687 | wxEventType command = GtkScrollWinTypeToWx(scroll_type); |
d9a4f620 | 688 | |
0bc0cd5d | 689 | wxScrollWinEvent event( command, x_pos, wxHORIZONTAL ); |
d9a4f620 RR |
690 | event.SetEventObject( this ); |
691 | GetEventHandler()->ProcessEvent( event ); | |
30954328 RR |
692 | } |
693 | ||
694 | void wxScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll) | |
695 | { | |
696 | m_xScrollingEnabled = x_scroll; | |
697 | m_yScrollingEnabled = y_scroll; | |
698 | } | |
699 | ||
30954328 RR |
700 | // Where the current view starts from |
701 | void wxScrolledWindow::GetViewStart (int *x, int *y) const | |
702 | { | |
703 | if ( x ) | |
704 | *x = m_xScrollPosition; | |
705 | if ( y ) | |
706 | *y = m_yScrollPosition; | |
707 | } | |
708 | ||
8c2f3797 | 709 | void wxScrolledWindow::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const |
30954328 | 710 | { |
1adff2f5 JS |
711 | int xs, ys; |
712 | GetViewStart (& xs, & ys); | |
713 | ||
30954328 | 714 | if ( xx ) |
1adff2f5 | 715 | *xx = x - xs * m_xScrollPixelsPerLine; |
30954328 | 716 | if ( yy ) |
1adff2f5 | 717 | *yy = y - ys * m_yScrollPixelsPerLine; |
30954328 RR |
718 | } |
719 | ||
8c2f3797 | 720 | void wxScrolledWindow::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const |
30954328 | 721 | { |
1adff2f5 JS |
722 | int xs, ys; |
723 | GetViewStart (& xs, & ys); | |
724 | ||
30954328 | 725 | if ( xx ) |
1adff2f5 | 726 | *xx = x + xs * m_xScrollPixelsPerLine; |
30954328 | 727 | if ( yy ) |
1adff2f5 | 728 | *yy = y + ys * m_yScrollPixelsPerLine; |
30954328 RR |
729 | } |
730 | ||
d9a4f620 RR |
731 | int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event) |
732 | { | |
733 | int pos = event.GetPosition(); | |
734 | int orient = event.GetOrientation(); | |
735 | ||
736 | int nScrollInc = 0; | |
737 | if (event.GetEventType() == wxEVT_SCROLLWIN_TOP) | |
738 | { | |
739 | if (orient == wxHORIZONTAL) | |
740 | nScrollInc = - m_xScrollPosition; | |
741 | else | |
742 | nScrollInc = - m_yScrollPosition; | |
743 | } else | |
744 | if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM) | |
745 | { | |
746 | if (orient == wxHORIZONTAL) | |
566d84a7 | 747 | nScrollInc = GetVirtualSize().GetWidth() / m_xScrollPixelsPerLine - m_xScrollPosition; |
d9a4f620 | 748 | else |
566d84a7 | 749 | nScrollInc = GetVirtualSize().GetHeight() / m_yScrollPixelsPerLine - m_yScrollPosition; |
d9a4f620 RR |
750 | } else |
751 | if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP) | |
752 | { | |
753 | nScrollInc = -1; | |
754 | } else | |
755 | if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN) | |
756 | { | |
757 | nScrollInc = 1; | |
758 | } else | |
759 | if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP) | |
760 | { | |
761 | if (orient == wxHORIZONTAL) | |
762 | nScrollInc = -GetScrollPageSize(wxHORIZONTAL); | |
763 | else | |
764 | nScrollInc = -GetScrollPageSize(wxVERTICAL); | |
765 | } else | |
766 | if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) | |
767 | { | |
768 | if (orient == wxHORIZONTAL) | |
769 | nScrollInc = GetScrollPageSize(wxHORIZONTAL); | |
770 | else | |
771 | nScrollInc = GetScrollPageSize(wxVERTICAL); | |
772 | } else | |
773 | if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) || | |
774 | (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE)) | |
775 | { | |
776 | if (orient == wxHORIZONTAL) | |
777 | nScrollInc = pos - m_xScrollPosition; | |
778 | else | |
779 | nScrollInc = pos - m_yScrollPosition; | |
780 | } | |
781 | ||
782 | if (orient == wxHORIZONTAL) | |
783 | { | |
784 | if (m_xScrollPixelsPerLine > 0) | |
785 | { | |
830ed6d9 RR |
786 | int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); |
787 | if (max < 0) max = 0; | |
d9a4f620 RR |
788 | |
789 | if ( (m_xScrollPosition + nScrollInc) < 0 ) | |
790 | nScrollInc = -m_xScrollPosition; // As -ve as we can go | |
830ed6d9 RR |
791 | else if ( (m_xScrollPosition + nScrollInc) > max ) |
792 | nScrollInc = max - m_xScrollPosition; // As +ve as we can go | |
d9a4f620 RR |
793 | } |
794 | else | |
795 | m_targetWindow->Refresh(); | |
796 | } | |
797 | else | |
798 | { | |
799 | if (m_yScrollPixelsPerLine > 0) | |
800 | { | |
830ed6d9 RR |
801 | int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); |
802 | if (max < 0) max = 0; | |
d9a4f620 RR |
803 | |
804 | if ( (m_yScrollPosition + nScrollInc) < 0 ) | |
805 | nScrollInc = -m_yScrollPosition; // As -ve as we can go | |
830ed6d9 RR |
806 | else if ( (m_yScrollPosition + nScrollInc) > max ) |
807 | nScrollInc = max - m_yScrollPosition; // As +ve as we can go | |
d9a4f620 RR |
808 | } |
809 | else | |
810 | m_targetWindow->Refresh(); | |
811 | } | |
812 | ||
813 | return nScrollInc; | |
814 | } | |
815 | ||
f47ae6e7 | 816 | void wxScrolledWindow::SetScrollPos( int orient, int pos, bool refresh ) |
0bc0cd5d RR |
817 | { |
818 | wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); | |
819 | ||
820 | wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); | |
821 | ||
822 | if (orient == wxHORIZONTAL) | |
823 | { | |
830ed6d9 RR |
824 | int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); |
825 | if (max < 0) max = 0; | |
39c869a6 | 826 | |
830ed6d9 RR |
827 | if (pos > max) pos = 0; |
828 | if (pos < 0) pos = 0; | |
39c869a6 | 829 | |
830ed6d9 RR |
830 | if (pos == (int)(m_hAdjust->value+0.5)) return; |
831 | m_hAdjust->value = pos; | |
0bc0cd5d RR |
832 | } |
833 | else | |
834 | { | |
830ed6d9 RR |
835 | int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); |
836 | if (max < 0) max = 0; | |
39c869a6 | 837 | |
830ed6d9 RR |
838 | if (pos > max) pos = 0; |
839 | if (pos < 0) pos = 0; | |
39c869a6 | 840 | |
830ed6d9 RR |
841 | if (pos == (int)(m_vAdjust->value+0.5)) return; |
842 | m_vAdjust->value = pos; | |
0bc0cd5d RR |
843 | } |
844 | ||
845 | if (m_wxwindow->window) | |
846 | { | |
847 | if (orient == wxHORIZONTAL) | |
848 | { | |
77ffb593 | 849 | // Just update the scrollbar, don't send any wxWidgets event |
830ed6d9 | 850 | GtkHDisconnectEvent(); |
0bc0cd5d | 851 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); |
830ed6d9 | 852 | GtkHConnectEvent(); |
0bc0cd5d RR |
853 | } |
854 | else | |
855 | { | |
77ffb593 | 856 | // Just update the scrollbar, don't send any wxWidgets event |
830ed6d9 | 857 | GtkVDisconnectEvent(); |
0bc0cd5d | 858 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); |
830ed6d9 | 859 | GtkVConnectEvent(); |
0bc0cd5d RR |
860 | } |
861 | } | |
862 | } | |
863 | ||
830ed6d9 RR |
864 | void wxScrolledWindow::GtkVConnectEvent() |
865 | { | |
866 | gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed", | |
867 | (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); | |
868 | } | |
869 | ||
870 | void wxScrolledWindow::GtkHConnectEvent() | |
871 | { | |
872 | gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed", | |
873 | (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this ); | |
874 | } | |
875 | ||
876 | void wxScrolledWindow::GtkHDisconnectEvent() | |
877 | { | |
878 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_hAdjust), | |
879 | (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this ); | |
880 | } | |
881 | ||
882 | void wxScrolledWindow::GtkVDisconnectEvent() | |
883 | { | |
884 | gtk_signal_disconnect_by_func( GTK_OBJECT(m_vAdjust), | |
885 | (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); | |
886 | } | |
887 | ||
30486297 RD |
888 | bool wxScrolledWindow::Layout() |
889 | { | |
566d84a7 | 890 | if (GetSizer() && m_targetWindow == this) |
30486297 | 891 | { |
566d84a7 RL |
892 | // If we're the scroll target, take into account the |
893 | // virtual size and scrolled position of the window. | |
894 | ||
30486297 RD |
895 | int x, y, w, h; |
896 | CalcScrolledPosition(0,0, &x,&y); | |
897 | GetVirtualSize(&w, &h); | |
898 | GetSizer()->SetDimension(x, y, w, h); | |
899 | return TRUE; | |
900 | } | |
901 | else | |
902 | return wxPanel::Layout(); // fall back to default for LayoutConstraints | |
903 | } | |
904 | ||
30954328 RR |
905 | // ---------------------------------------------------------------------------- |
906 | // event handlers | |
907 | // ---------------------------------------------------------------------------- | |
908 | ||
909 | // Default OnSize resets scrollbars, if any | |
910 | void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) | |
911 | { | |
c376d80f | 912 | if ( m_targetWindow->GetAutoLayout() ) |
2b5f62a0 | 913 | { |
c376d80f RR |
914 | wxSize size = m_targetWindow->GetBestVirtualSize(); |
915 | ||
916 | // This will call ::Layout() and ::AdjustScrollbars() | |
917 | SetVirtualSize( size ); | |
2b5f62a0 VZ |
918 | } |
919 | else | |
920 | { | |
921 | AdjustScrollbars(); | |
922 | } | |
30954328 RR |
923 | } |
924 | ||
925 | // This calls OnDraw, having adjusted the origin according to the current | |
926 | // scroll position | |
927 | void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
928 | { | |
929 | wxPaintDC dc(this); | |
930 | PrepareDC(dc); | |
931 | ||
932 | OnDraw(dc); | |
933 | } | |
934 | ||
935 | // kbd handling: notice that we use OnChar() and not OnKeyDown() for | |
936 | // compatibility here - if we used OnKeyDown(), the programs which process | |
937 | // arrows themselves in their OnChar() would never get the message and like | |
938 | // this they always have the priority | |
939 | void wxScrolledWindow::OnChar(wxKeyEvent& event) | |
940 | { | |
941 | int stx, sty, // view origin | |
942 | szx, szy, // view size (total) | |
943 | clix, cliy; // view size (on screen) | |
944 | ||
2b5f62a0 | 945 | GetViewStart(&stx, &sty); |
30954328 RR |
946 | GetClientSize(&clix, &cliy); |
947 | GetVirtualSize(&szx, &szy); | |
948 | ||
949 | if( m_xScrollPixelsPerLine ) | |
950 | { | |
951 | clix /= m_xScrollPixelsPerLine; | |
952 | szx /= m_xScrollPixelsPerLine; | |
953 | } | |
954 | else | |
955 | { | |
956 | clix = 0; | |
957 | szx = -1; | |
958 | } | |
959 | if( m_yScrollPixelsPerLine ) | |
960 | { | |
961 | cliy /= m_yScrollPixelsPerLine; | |
962 | szy /= m_yScrollPixelsPerLine; | |
963 | } | |
964 | else | |
965 | { | |
966 | cliy = 0; | |
967 | szy = -1; | |
968 | } | |
969 | ||
39c869a6 VZ |
970 | int xScrollOld = GetScrollPos(wxHORIZONTAL), |
971 | yScrollOld = GetScrollPos(wxVERTICAL); | |
972 | ||
30954328 | 973 | int dsty; |
12a3f227 | 974 | switch ( event.GetKeyCode() ) |
30954328 RR |
975 | { |
976 | case WXK_PAGEUP: | |
977 | case WXK_PRIOR: | |
978 | dsty = sty - (5 * cliy / 6); | |
979 | Scroll(-1, (dsty == -1) ? 0 : dsty); | |
980 | break; | |
981 | ||
982 | case WXK_PAGEDOWN: | |
983 | case WXK_NEXT: | |
984 | Scroll(-1, sty + (5 * cliy / 6)); | |
985 | break; | |
986 | ||
987 | case WXK_HOME: | |
988 | Scroll(0, event.ControlDown() ? 0 : -1); | |
989 | break; | |
990 | ||
991 | case WXK_END: | |
992 | Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1); | |
993 | break; | |
994 | ||
995 | case WXK_UP: | |
996 | Scroll(-1, sty - 1); | |
997 | break; | |
998 | ||
999 | case WXK_DOWN: | |
1000 | Scroll(-1, sty + 1); | |
1001 | break; | |
1002 | ||
1003 | case WXK_LEFT: | |
1004 | Scroll(stx - 1, -1); | |
1005 | break; | |
1006 | ||
1007 | case WXK_RIGHT: | |
1008 | Scroll(stx + 1, -1); | |
1009 | break; | |
1010 | ||
1011 | default: | |
1012 | // not for us | |
1013 | event.Skip(); | |
39c869a6 VZ |
1014 | return; |
1015 | } | |
1016 | ||
1017 | int xScroll = GetScrollPos(wxHORIZONTAL); | |
1018 | if ( xScroll != xScrollOld ) | |
1019 | { | |
1020 | wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, | |
1021 | wxHORIZONTAL); | |
1022 | event.SetEventObject(this); | |
1023 | GetEventHandler()->ProcessEvent(event); | |
1024 | } | |
1025 | ||
1026 | int yScroll = GetScrollPos(wxVERTICAL); | |
1027 | if ( yScroll != yScrollOld ) | |
1028 | { | |
1029 | wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, | |
1030 | wxVERTICAL); | |
1031 | event.SetEventObject(this); | |
1032 | GetEventHandler()->ProcessEvent(event); | |
30954328 RR |
1033 | } |
1034 | } | |
3379ed37 | 1035 | |
566d84a7 RL |
1036 | |
1037 | // vi:sts=4:sw=4:et |