]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/scrolwin.cpp
Some but not all compile fixes for typetest (VC++ 1.5); added datetime.cpp
[wxWidgets.git] / src / generic / scrolwin.cpp
index 513cb292f225dcf9da449d04cb32ff048c8adb56..5dd7c93d2d067e7293211abf22bdaa47aaa35061 100644 (file)
@@ -58,7 +58,7 @@ BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
     EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
     EVT_SIZE(wxScrolledWindow::OnSize)
     EVT_PAINT(wxScrolledWindow::OnPaint)
     EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
     EVT_SIZE(wxScrolledWindow::OnSize)
     EVT_PAINT(wxScrolledWindow::OnPaint)
-    EVT_KEY_DOWN(wxScrolledWindow::OnKeyDown)
+    EVT_CHAR(wxScrolledWindow::OnChar)
 END_EVENT_TABLE()
 
 IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
 END_EVENT_TABLE()
 
 IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
@@ -613,8 +613,11 @@ void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
     OnDraw(dc);
 }
 
     OnDraw(dc);
 }
 
-// kbd handling
-void wxScrolledWindow::OnKeyDown(wxKeyEvent& event)
+// 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)
 {
     int stx, sty,       // view origin
         szx, szy,       // view size (total)
@@ -622,11 +625,28 @@ void wxScrolledWindow::OnKeyDown(wxKeyEvent& event)
 
     ViewStart(&stx, &sty);
     GetClientSize(&clix, &cliy);
 
     ViewStart(&stx, &sty);
     GetClientSize(&clix, &cliy);
-    clix /= m_xScrollPixelsPerLine;
-    cliy /= m_yScrollPixelsPerLine;
     GetVirtualSize(&szx, &szy);
     GetVirtualSize(&szx, &szy);
-    szx /= m_xScrollPixelsPerLine;
-    szy /= m_yScrollPixelsPerLine;
+
+    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() )
     {
 
     switch ( event.KeyCode() )
     {
@@ -640,16 +660,12 @@ void wxScrolledWindow::OnKeyDown(wxKeyEvent& event)
             Scroll(-1, sty + (5 * cliy / 6));
             break;
 
             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:
         case WXK_HOME:
             Scroll(0, event.ControlDown() ? 0 : -1);
             break;
 
         case WXK_END:
-            Scroll(event.ControlDown() ? szx - clix : -1, szy - cliy);
+            Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
             break;
 
         case WXK_UP:
             break;
 
         case WXK_UP: