]> git.saurik.com Git - wxWidgets.git/blob - src/generic/scrolwin.cpp
Did the unmap/map trick for wxFrame::IsIconized().
[wxWidgets.git] / src / generic / scrolwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: generic/scrolwin.cpp
3 // Purpose: wxScrolledWindow implementation
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "scrolwin.h"
22 #endif
23
24 #ifdef __VMS
25 #define XtDisplay XTDISPLAY
26 #endif
27
28 // For compilers that support precompilation, includes "wx.h".
29 #include "wx/wxprec.h"
30
31 #ifdef __BORLANDC__
32 #pragma hdrstop
33 #endif
34
35 #include "wx/utils.h"
36 #include "wx/dcclient.h"
37
38 #include "wx/generic/scrolwin.h"
39 #include "wx/panel.h"
40
41 #ifdef __WXMSW__
42 #include "windows.h"
43 #endif
44
45 #ifdef __WXMOTIF__
46 // For wxRETAINED implementation
47 #ifdef __VMS__ //VMS's Xm.h is not (yet) compatible with C++
48 //This code switches off the compiler warnings
49 # pragma message disable nosimpint
50 #endif
51 #include <Xm/Xm.h>
52 #ifdef __VMS__
53 # pragma message enable nosimpint
54 #endif
55 #endif
56
57 // ----------------------------------------------------------------------------
58 // event tables
59 // ----------------------------------------------------------------------------
60
61 BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
62 EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
63 EVT_SIZE(wxScrolledWindow::OnSize)
64 EVT_PAINT(wxScrolledWindow::OnPaint)
65 EVT_CHAR(wxScrolledWindow::OnChar)
66 END_EVENT_TABLE()
67
68 IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
69
70 // ============================================================================
71 // implementation
72 // ============================================================================
73
74 // ----------------------------------------------------------------------------
75 // wxScrolledWindow creation
76 // ----------------------------------------------------------------------------
77
78 wxScrolledWindow::wxScrolledWindow()
79 {
80 m_xScrollPixelsPerLine = 0;
81 m_yScrollPixelsPerLine = 0;
82 m_xScrollingEnabled = TRUE;
83 m_yScrollingEnabled = TRUE;
84 m_xScrollPosition = 0;
85 m_yScrollPosition = 0;
86 m_xScrollLines = 0;
87 m_yScrollLines = 0;
88 m_xScrollLinesPerPage = 0;
89 m_yScrollLinesPerPage = 0;
90 m_scaleX = 1.0;
91 m_scaleY = 1.0;
92 m_targetWindow = (wxWindow*) NULL;
93 }
94
95 bool wxScrolledWindow::Create(wxWindow *parent,
96 wxWindowID id,
97 const wxPoint& pos,
98 const wxSize& size,
99 long style,
100 const wxString& name)
101 {
102 m_xScrollPixelsPerLine = 0;
103 m_yScrollPixelsPerLine = 0;
104 m_xScrollingEnabled = TRUE;
105 m_yScrollingEnabled = TRUE;
106 m_xScrollPosition = 0;
107 m_yScrollPosition = 0;
108 m_xScrollLines = 0;
109 m_yScrollLines = 0;
110 m_xScrollLinesPerPage = 0;
111 m_yScrollLinesPerPage = 0;
112 m_scaleX = 1.0;
113 m_scaleY = 1.0;
114
115 m_targetWindow = this;
116
117 bool ok = wxPanel::Create(parent, id, pos, size, style, name);
118
119 #ifdef __WXMSW__
120 // we need to process arrows ourselves for scrolling
121 m_lDlgCode |= DLGC_WANTARROWS;
122 #endif // __WXMSW__
123
124 return ok;
125 }
126
127 wxScrolledWindow::~wxScrolledWindow()
128 {
129 }
130
131 // ----------------------------------------------------------------------------
132 // setting scrolling parameters
133 // ----------------------------------------------------------------------------
134
135 /*
136 * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
137 * noUnitsX/noUnitsY: : no. units per scrollbar
138 */
139 void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
140 int noUnitsX, int noUnitsY,
141 int xPos, int yPos, bool noRefresh )
142 {
143 int xpos, ypos;
144
145 CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
146 bool do_refresh =
147 (
148 (noUnitsX != 0 && m_xScrollLines == 0) ||
149 (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX*noUnitsX) ||
150
151 (noUnitsY != 0 && m_yScrollLines == 0) ||
152 (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY*noUnitsY) ||
153 (xPos != m_xScrollPosition) ||
154 (yPos != m_yScrollPosition)
155 // (pixelsPerUnitX != m_xScrollPixelsPerLine) ||
156 // (pixelsPerUnitY != m_yScrollPixelsPerLine)
157 );
158
159 m_xScrollPixelsPerLine = pixelsPerUnitX;
160 m_yScrollPixelsPerLine = pixelsPerUnitY;
161 m_xScrollPosition = xPos;
162 m_yScrollPosition = yPos;
163 m_xScrollLines = noUnitsX;
164 m_yScrollLines = noUnitsY;
165
166 #ifdef __WXMOTIF__
167 // Sorry, some Motif-specific code to implement a backing pixmap
168 // for the wxRETAINED style. Implementing a backing store can't
169 // be entirely generic because it relies on the wxWindowDC implementation
170 // to duplicate X drawing calls for the backing pixmap.
171
172 if ((m_windowStyle & wxRETAINED) == wxRETAINED)
173 {
174 Display* dpy = XtDisplay((Widget) GetMainWidget());
175
176 int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
177 int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
178 if (m_backingPixmap &&
179 !((m_pixmapWidth == totalPixelWidth) &&
180 (m_pixmapHeight == totalPixelHeight)))
181 {
182 XFreePixmap (dpy, (Pixmap) m_backingPixmap);
183 m_backingPixmap = (WXPixmap) 0;
184 }
185
186 if (!m_backingPixmap &&
187 (noUnitsX != 0) && (noUnitsY != 0))
188 {
189 int depth = wxDisplayDepth();
190 m_pixmapWidth = totalPixelWidth;
191 m_pixmapHeight = totalPixelHeight;
192 m_backingPixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
193 m_pixmapWidth, m_pixmapHeight, depth);
194 }
195
196 }
197 #endif // Motif
198
199 AdjustScrollbars();
200
201 if (do_refresh && !noRefresh)
202 m_targetWindow->Refresh();
203
204 #ifdef __WXMSW__
205 // GRG: if this turns out to be really necessary, we could
206 // at least move it to the above if { ... } so that it is
207 // only done if noRefresh = FALSE (the default). OTOH, if
208 // this doesn't break anything, which seems to be the
209 // case, we could just leave it out.
210
211 // Necessary?
212 // UpdateWindow ((HWND) m_targetWindow->GetHWND());
213 #endif
214 #ifdef __WXMAC__
215 m_targetWindow->MacUpdateImmediately() ;
216 #endif
217 }
218
219 // ----------------------------------------------------------------------------
220 // target window handling
221 // ----------------------------------------------------------------------------
222
223 void wxScrolledWindow::SetTargetWindow( wxWindow *target )
224 {
225 wxASSERT_MSG( target, wxT("target window must not be NULL") );
226 m_targetWindow = target;
227 }
228
229 wxWindow *wxScrolledWindow::GetTargetWindow()
230 {
231 return m_targetWindow;
232 }
233
234 // ----------------------------------------------------------------------------
235 // scrolling implementation itself
236 // ----------------------------------------------------------------------------
237
238 void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
239 {
240 int orient = event.GetOrientation();
241
242 int nScrollInc = CalcScrollInc(event);
243 if (nScrollInc == 0) return;
244
245 if (orient == wxHORIZONTAL)
246 {
247 int newPos = m_xScrollPosition + nScrollInc;
248 SetScrollPos(wxHORIZONTAL, newPos, TRUE );
249 }
250 else
251 {
252 int newPos = m_yScrollPosition + nScrollInc;
253 SetScrollPos(wxVERTICAL, newPos, TRUE );
254 }
255
256 if (orient == wxHORIZONTAL)
257 {
258 m_xScrollPosition += nScrollInc;
259 }
260 else
261 {
262 m_yScrollPosition += nScrollInc;
263 }
264
265 if (orient == wxHORIZONTAL)
266 {
267 if (m_xScrollingEnabled)
268 m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL);
269 else
270 m_targetWindow->Refresh();
271 }
272 else
273 {
274 if (m_yScrollingEnabled)
275 m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL);
276 else
277 m_targetWindow->Refresh();
278 }
279 #ifdef __WXMAC__
280 m_targetWindow->MacUpdateImmediately() ;
281 #endif
282 }
283
284 int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
285 {
286 int pos = event.GetPosition();
287 int orient = event.GetOrientation();
288
289 int nScrollInc = 0;
290 switch (event.GetEventType())
291 {
292 case wxEVT_SCROLLWIN_TOP:
293 {
294 if (orient == wxHORIZONTAL)
295 nScrollInc = - m_xScrollPosition;
296 else
297 nScrollInc = - m_yScrollPosition;
298 break;
299 }
300 case wxEVT_SCROLLWIN_BOTTOM:
301 {
302 if (orient == wxHORIZONTAL)
303 nScrollInc = m_xScrollLines - m_xScrollPosition;
304 else
305 nScrollInc = m_yScrollLines - m_yScrollPosition;
306 break;
307 }
308 case wxEVT_SCROLLWIN_LINEUP:
309 {
310 nScrollInc = -1;
311 break;
312 }
313 case wxEVT_SCROLLWIN_LINEDOWN:
314 {
315 nScrollInc = 1;
316 break;
317 }
318 case wxEVT_SCROLLWIN_PAGEUP:
319 {
320 if (orient == wxHORIZONTAL)
321 nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
322 else
323 nScrollInc = -GetScrollPageSize(wxVERTICAL);
324 break;
325 }
326 case wxEVT_SCROLLWIN_PAGEDOWN:
327 {
328 if (orient == wxHORIZONTAL)
329 nScrollInc = GetScrollPageSize(wxHORIZONTAL);
330 else
331 nScrollInc = GetScrollPageSize(wxVERTICAL);
332 break;
333 }
334 case wxEVT_SCROLLWIN_THUMBTRACK:
335 case wxEVT_SCROLLWIN_THUMBRELEASE:
336 {
337 if (orient == wxHORIZONTAL)
338 nScrollInc = pos - m_xScrollPosition;
339 else
340 nScrollInc = pos - m_yScrollPosition;
341 break;
342 }
343 default:
344 {
345 break;
346 }
347 }
348
349 if (orient == wxHORIZONTAL)
350 {
351 if (m_xScrollPixelsPerLine > 0)
352 {
353 int w, h;
354 m_targetWindow->GetClientSize(&w, &h);
355
356 int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
357 int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
358 if (noPositions < 0)
359 noPositions = 0;
360
361 if ( (m_xScrollPosition + nScrollInc) < 0 )
362 nScrollInc = -m_xScrollPosition; // As -ve as we can go
363 else if ( (m_xScrollPosition + nScrollInc) > noPositions )
364 nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
365 }
366 else
367 m_targetWindow->Refresh();
368 }
369 else
370 {
371 if (m_yScrollPixelsPerLine > 0)
372 {
373 int w, h;
374 m_targetWindow->GetClientSize(&w, &h);
375
376 int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
377 int noPositions = (int) ( ((nMaxHeight - h)/(double)m_yScrollPixelsPerLine) + 0.5 );
378 if (noPositions < 0)
379 noPositions = 0;
380
381 if ( (m_yScrollPosition + nScrollInc) < 0 )
382 nScrollInc = -m_yScrollPosition; // As -ve as we can go
383 else if ( (m_yScrollPosition + nScrollInc) > noPositions )
384 nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
385 }
386 else
387 m_targetWindow->Refresh();
388 }
389
390 return nScrollInc;
391 }
392
393 // Adjust the scrollbars - new version.
394 void wxScrolledWindow::AdjustScrollbars()
395 {
396 int w, h;
397 m_targetWindow->GetClientSize(&w, &h);
398
399 int oldXScroll = m_xScrollPosition;
400 int oldYScroll = m_yScrollPosition;
401
402 if (m_xScrollLines > 0)
403 {
404 // Calculate page size i.e. number of scroll units you get on the
405 // current client window
406 int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
407 if (noPagePositions < 1) noPagePositions = 1;
408
409 // Correct position if greater than extent of canvas minus
410 // the visible portion of it or if below zero
411 m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition);
412 m_xScrollPosition = wxMax( 0, m_xScrollPosition );
413
414 SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
415 // The amount by which we scroll when paging
416 SetScrollPageSize(wxHORIZONTAL, noPagePositions);
417 }
418 else
419 {
420 m_xScrollPosition = 0;
421 SetScrollbar (wxHORIZONTAL, 0, 0, 0, FALSE);
422 }
423
424 if (m_yScrollLines > 0)
425 {
426 // Calculate page size i.e. number of scroll units you get on the
427 // current client window
428 int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
429 if (noPagePositions < 1) noPagePositions = 1;
430
431 // Correct position if greater than extent of canvas minus
432 // the visible portion of it or if below zero
433 m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
434 m_yScrollPosition = wxMax( 0, m_yScrollPosition );
435
436 SetScrollbar(wxVERTICAL, m_yScrollPosition, noPagePositions, m_yScrollLines);
437 // The amount by which we scroll when paging
438 SetScrollPageSize(wxVERTICAL, noPagePositions);
439 }
440 else
441 {
442 m_yScrollPosition = 0;
443 SetScrollbar (wxVERTICAL, 0, 0, 0, FALSE);
444 }
445
446 if (oldXScroll != m_xScrollPosition)
447 {
448 if (m_xScrollingEnabled)
449 m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll-m_xScrollPosition), 0, (const wxRect *) NULL );
450 else
451 m_targetWindow->Refresh();
452 }
453
454 if (oldYScroll != m_yScrollPosition)
455 {
456 if (m_yScrollingEnabled)
457 m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition), (const wxRect *) NULL );
458 else
459 m_targetWindow->Refresh();
460 }
461 }
462
463 // Override this function if you don't want to have wxScrolledWindow
464 // automatically change the origin according to the scroll position.
465 void wxScrolledWindow::PrepareDC(wxDC& dc)
466 {
467 dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine,
468 -m_yScrollPosition * m_yScrollPixelsPerLine );
469 dc.SetUserScale( m_scaleX, m_scaleY );
470 }
471
472 #if WXWIN_COMPATIBILITY
473 void wxScrolledWindow::GetScrollUnitsPerPage (int *x_page, int *y_page) const
474 {
475 *x_page = GetScrollPageSize(wxHORIZONTAL);
476 *y_page = GetScrollPageSize(wxVERTICAL);
477 }
478
479 void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const
480 {
481 if ( xx )
482 *xx = (float)(x + m_xScrollPosition * m_xScrollPixelsPerLine);
483 if ( yy )
484 *yy = (float)(y + m_yScrollPosition * m_yScrollPixelsPerLine);
485 }
486 #endif // WXWIN_COMPATIBILITY
487
488 void wxScrolledWindow::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
489 {
490 if ( x_unit )
491 *x_unit = m_xScrollPixelsPerLine;
492 if ( y_unit )
493 *y_unit = m_yScrollPixelsPerLine;
494 }
495
496 int wxScrolledWindow::GetScrollPageSize(int orient) const
497 {
498 if ( orient == wxHORIZONTAL )
499 return m_xScrollLinesPerPage;
500 else
501 return m_yScrollLinesPerPage;
502 }
503
504 void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize)
505 {
506 if ( orient == wxHORIZONTAL )
507 m_xScrollLinesPerPage = pageSize;
508 else
509 m_yScrollLinesPerPage = pageSize;
510 }
511
512 /*
513 * Scroll to given position (scroll position, not pixel position)
514 */
515 void wxScrolledWindow::Scroll( int x_pos, int y_pos )
516 {
517 if (!m_targetWindow)
518 return;
519
520 if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
521 ((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
522
523 int w, h;
524 m_targetWindow->GetClientSize(&w, &h);
525
526 if ((x_pos != -1) && (m_xScrollPixelsPerLine))
527 {
528 int old_x = m_xScrollPosition;
529 m_xScrollPosition = x_pos;
530
531 // Calculate page size i.e. number of scroll units you get on the
532 // current client window
533 int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
534 if (noPagePositions < 1) noPagePositions = 1;
535
536 // Correct position if greater than extent of canvas minus
537 // the visible portion of it or if below zero
538 m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
539 m_xScrollPosition = wxMax( 0, m_xScrollPosition );
540
541 if (old_x != m_xScrollPosition) {
542 m_targetWindow->SetScrollPos( wxHORIZONTAL, m_xScrollPosition, TRUE );
543 m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
544 }
545 }
546 if ((y_pos != -1) && (m_yScrollPixelsPerLine))
547 {
548 int old_y = m_yScrollPosition;
549 m_yScrollPosition = y_pos;
550
551 // Calculate page size i.e. number of scroll units you get on the
552 // current client window
553 int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
554 if (noPagePositions < 1) noPagePositions = 1;
555
556 // Correct position if greater than extent of canvas minus
557 // the visible portion of it or if below zero
558 m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
559 m_yScrollPosition = wxMax( 0, m_yScrollPosition );
560
561 if (old_y != m_yScrollPosition) {
562 m_targetWindow->SetScrollPos( wxVERTICAL, m_yScrollPosition, TRUE );
563 m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
564 }
565 }
566
567 #ifdef __WXMAC__
568 m_targetWindow->MacUpdateImmediately();
569 #endif
570 }
571
572 void wxScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll)
573 {
574 m_xScrollingEnabled = x_scroll;
575 m_yScrollingEnabled = y_scroll;
576 }
577
578 void wxScrolledWindow::GetVirtualSize (int *x, int *y) const
579 {
580 if ( x )
581 *x = m_xScrollPixelsPerLine * m_xScrollLines;
582 if ( y )
583 *y = m_yScrollPixelsPerLine * m_yScrollLines;
584 }
585
586 // Where the current view starts from
587 void wxScrolledWindow::GetViewStart (int *x, int *y) const
588 {
589 if ( x )
590 *x = m_xScrollPosition;
591 if ( y )
592 *y = m_yScrollPosition;
593 }
594
595 void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) const
596 {
597 if ( xx )
598 *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
599 if ( yy )
600 *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
601 }
602
603 void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
604 {
605 if ( xx )
606 *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
607 if ( yy )
608 *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
609 }
610
611 // ----------------------------------------------------------------------------
612 // event handlers
613 // ----------------------------------------------------------------------------
614
615 // Default OnSize resets scrollbars, if any
616 void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
617 {
618 #if wxUSE_CONSTRAINTS
619 if (GetAutoLayout())
620 Layout();
621 #endif
622
623 AdjustScrollbars();
624 }
625
626 // This calls OnDraw, having adjusted the origin according to the current
627 // scroll position
628 void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
629 {
630 wxPaintDC dc(this);
631 PrepareDC(dc);
632
633 OnDraw(dc);
634 }
635
636 // kbd handling: notice that we use OnChar() and not OnKeyDown() for
637 // compatibility here - if we used OnKeyDown(), the programs which process
638 // arrows themselves in their OnChar() would never get the message and like
639 // this they always have the priority
640 void wxScrolledWindow::OnChar(wxKeyEvent& event)
641 {
642 int stx, sty, // view origin
643 szx, szy, // view size (total)
644 clix, cliy; // view size (on screen)
645
646 ViewStart(&stx, &sty);
647 GetClientSize(&clix, &cliy);
648 GetVirtualSize(&szx, &szy);
649
650 if( m_xScrollPixelsPerLine )
651 {
652 clix /= m_xScrollPixelsPerLine;
653 szx /= m_xScrollPixelsPerLine;
654 }
655 else
656 {
657 clix = 0;
658 szx = -1;
659 }
660 if( m_yScrollPixelsPerLine )
661 {
662 cliy /= m_yScrollPixelsPerLine;
663 szy /= m_yScrollPixelsPerLine;
664 }
665 else
666 {
667 cliy = 0;
668 szy = -1;
669 }
670
671 int dsty;
672 switch ( event.KeyCode() )
673 {
674 case WXK_PAGEUP:
675 case WXK_PRIOR:
676 dsty = sty - (5 * cliy / 6);
677 Scroll(-1, (dsty == -1) ? 0 : dsty);
678 break;
679
680 case WXK_PAGEDOWN:
681 case WXK_NEXT:
682 Scroll(-1, sty + (5 * cliy / 6));
683 break;
684
685 case WXK_HOME:
686 Scroll(0, event.ControlDown() ? 0 : -1);
687 break;
688
689 case WXK_END:
690 Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
691 break;
692
693 case WXK_UP:
694 Scroll(-1, sty - 1);
695 break;
696
697 case WXK_DOWN:
698 Scroll(-1, sty + 1);
699 break;
700
701 case WXK_LEFT:
702 Scroll(stx - 1, -1);
703 break;
704
705 case WXK_RIGHT:
706 Scroll(stx + 1, -1);
707 break;
708
709 default:
710 // not for us
711 event.Skip();
712 }
713 }