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