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