+ wxPaintDC dc(this);
+ PrepareDC(dc);
+
+ OnDraw(dc);
+}
+
+// kbd handling: notice that we use OnChar() and not OnKeyDown() for
+// compatibility here - if we used OnKeyDown(), the programs which process
+// arrows themselves in their OnChar() would never get the message and like
+// this they always have the priority
+void wxGenericScrolledWindow::OnChar(wxKeyEvent& event)
+{
+ int stx, sty, // view origin
+ szx, szy, // view size (total)
+ clix, cliy; // view size (on screen)
+
+ ViewStart(&stx, &sty);
+ GetClientSize(&clix, &cliy);
+ GetVirtualSize(&szx, &szy);
+
+ if( m_xScrollPixelsPerLine )
+ {
+ clix /= m_xScrollPixelsPerLine;
+ szx /= m_xScrollPixelsPerLine;
+ }
+ else
+ {
+ clix = 0;
+ szx = -1;
+ }
+ if( m_yScrollPixelsPerLine )
+ {
+ cliy /= m_yScrollPixelsPerLine;
+ szy /= m_yScrollPixelsPerLine;
+ }
+ else
+ {
+ cliy = 0;
+ szy = -1;
+ }
+
+ int dsty;
+ switch ( event.KeyCode() )
+ {
+ case WXK_PAGEUP:
+ case WXK_PRIOR:
+ dsty = sty - (5 * cliy / 6);
+ Scroll(-1, (dsty == -1) ? 0 : dsty);
+ break;
+
+ case WXK_PAGEDOWN:
+ case WXK_NEXT:
+ Scroll(-1, sty + (5 * cliy / 6));
+ break;
+
+ case WXK_HOME:
+ Scroll(0, event.ControlDown() ? 0 : -1);
+ break;
+
+ case WXK_END:
+ Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
+ break;
+
+ case WXK_UP:
+ Scroll(-1, sty - 1);
+ break;
+
+ case WXK_DOWN:
+ Scroll(-1, sty + 1);
+ break;
+
+ case WXK_LEFT:
+ Scroll(stx - 1, -1);
+ break;
+
+ case WXK_RIGHT:
+ Scroll(stx + 1, -1);
+ break;
+
+ default:
+ // not for us
+ event.Skip();
+ }