+// Default OnSize resets scrollbars, if any
+void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
+{
+#if wxUSE_CONSTRAINTS
+ if (GetAutoLayout())
+ Layout();
+#endif
+
+ AdjustScrollbars();
+}
+
+// This calls OnDraw, having adjusted the origin according to the current
+// scroll position
+void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+ 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 wxScrolledWindow::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;
+ }
+
+ switch ( event.KeyCode() )
+ {
+ case WXK_PAGEUP:
+ case WXK_PRIOR:
+ Scroll(-1, sty - (5 * cliy / 6));
+ break;
+
+ case WXK_PAGEDOWN:
+ case WXK_NEXT:
+ Scroll(-1, sty + (5 * cliy / 6));
+ break;
+
+ // notice that handling of Ctrl-Home/End is asymmetrical: Home goes to
+ // the beginning of the current line, Ctrl-Home returns to the origin
+ // while End goes to the bottom without changing horizontal position
+ // and only Ctrl-End does go to the most rightmost position as well
+ case WXK_HOME:
+ Scroll(0, event.ControlDown() ? 0 : -1);
+ break;
+
+ case WXK_END:
+ Scroll(event.ControlDown() ? szx - clix : -1, szy - cliy);
+ 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();
+ }
+}