]> git.saurik.com Git - wxWidgets.git/commitdiff
wxScrolledWindow now emits wxScrollWinEvents. Something
authorRobert Roebling <robert@roebling.de>
Tue, 1 May 2001 14:32:41 +0000 (14:32 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 1 May 2001 14:32:41 +0000 (14:32 +0000)
     does not work yet as desried, though.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/src/gizmos/splittree.cpp
include/wx/gtk/scrolwin.h
include/wx/gtk1/scrolwin.h
src/gtk/scrolwin.cpp
src/gtk1/scrolwin.cpp

index a99b6733c8198c6c625c0bd191b4a07cb1c3e1d9..d1911ee8e3076f9a8c05e23385fd187bea6f4f85 100644 (file)
@@ -573,7 +573,7 @@ void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
     if (inOnScroll)
         return;
     inOnScroll = TRUE;
-
+    
     int orient = event.GetOrientation();
 
     int nScrollInc = CalcScrollInc(event);
index 391dadb28e0fa5210db2765f9ffc4d18e07adf8e..98fb2c2335c68a570dfcb8832a28bf6ebb09f59a 100644 (file)
@@ -111,7 +111,13 @@ public:
     // Adjust the scrollbars
     virtual void AdjustScrollbars();
     
+    // Set the scale factor, used in PrepareDC
+    void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
+    double GetScaleX() const { return m_scaleX; }
+    double GetScaleY() const { return m_scaleY; }
+
     // implementation from now on
+    void OnScroll(wxScrollWinEvent& event);
     void OnSize(wxSizeEvent& event);
     void OnPaint(wxPaintEvent& event);
     void OnChar(wxKeyEvent& event);
@@ -119,6 +125,9 @@ public:
     void GtkVScroll( float value );
     void GtkHScroll( float value );
 
+    // Calculate scroll increment
+    virtual int CalcScrollInc(wxScrollWinEvent& event);
+    
 protected:
     wxWindow             *m_targetWindow;
     int                   m_xScrollPixelsPerLine;
@@ -131,6 +140,8 @@ protected:
     int                   m_yScrollLines;
     int                   m_xScrollLinesPerPage;
     int                   m_yScrollLinesPerPage;
+    
+    double                m_scaleY,m_scaleX;
 
 private:
     DECLARE_EVENT_TABLE()
index 391dadb28e0fa5210db2765f9ffc4d18e07adf8e..98fb2c2335c68a570dfcb8832a28bf6ebb09f59a 100644 (file)
@@ -111,7 +111,13 @@ public:
     // Adjust the scrollbars
     virtual void AdjustScrollbars();
     
+    // Set the scale factor, used in PrepareDC
+    void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
+    double GetScaleX() const { return m_scaleX; }
+    double GetScaleY() const { return m_scaleY; }
+
     // implementation from now on
+    void OnScroll(wxScrollWinEvent& event);
     void OnSize(wxSizeEvent& event);
     void OnPaint(wxPaintEvent& event);
     void OnChar(wxKeyEvent& event);
@@ -119,6 +125,9 @@ public:
     void GtkVScroll( float value );
     void GtkHScroll( float value );
 
+    // Calculate scroll increment
+    virtual int CalcScrollInc(wxScrollWinEvent& event);
+    
 protected:
     wxWindow             *m_targetWindow;
     int                   m_xScrollPixelsPerLine;
@@ -131,6 +140,8 @@ protected:
     int                   m_yScrollLines;
     int                   m_xScrollLinesPerPage;
     int                   m_yScrollLinesPerPage;
+    
+    double                m_scaleY,m_scaleX;
 
 private:
     DECLARE_EVENT_TABLE()
index 548a400065da6d55d3e3d5f9d193a139fc194477..40fd6bed32ab7435b89bb0849e5a7220dd678618 100644 (file)
@@ -42,6 +42,7 @@
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
+    EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
     EVT_SIZE(wxScrolledWindow::OnSize)
     EVT_PAINT(wxScrolledWindow::OnPaint)
     EVT_CHAR(wxScrolledWindow::OnChar)
@@ -134,6 +135,8 @@ wxScrolledWindow::wxScrolledWindow()
     m_xScrollLinesPerPage = 0;
     m_yScrollLinesPerPage = 0;
     m_targetWindow = (wxWindow*) NULL;
+    m_scaleX = 1.0;
+    m_scaleY = 1.0;
 }
 
 bool wxScrolledWindow::Create(wxWindow *parent,
@@ -342,9 +345,49 @@ void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize)
         m_yScrollLinesPerPage = pageSize;
 }
 
-/*
- * Scroll to given position (scroll position, not pixel position)
- */
+void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
+{
+    int orient = event.GetOrientation();
+    
+    int nScrollInc = CalcScrollInc(event);
+    if (nScrollInc == 0) return;
+
+    if (orient == wxHORIZONTAL)
+    {
+        int newPos = m_xScrollPosition + nScrollInc;
+        SetScrollPos(wxHORIZONTAL, newPos, TRUE );
+    }
+    else
+    {
+        int newPos = m_yScrollPosition + nScrollInc;
+        SetScrollPos(wxVERTICAL, newPos, TRUE );
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        m_xScrollPosition += nScrollInc;
+    }
+    else
+    {
+        m_yScrollPosition += nScrollInc;
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+       if (m_xScrollingEnabled)
+            m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL);
+       else
+            m_targetWindow->Refresh();
+    }
+    else
+    {
+        if (m_yScrollingEnabled)
+            m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL);
+        else
+            m_targetWindow->Refresh();
+    }
+}
+
 void wxScrolledWindow::Scroll( int x_pos, int y_pos )
 {
     if (!m_targetWindow)
@@ -359,6 +402,11 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
         m_xScrollPosition = x_pos;
         m_hAdjust->value = x_pos;
         
+        wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+        wxScrollWinEvent event( command, m_xScrollPosition, wxHORIZONTAL );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    
         m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
         
         gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" );
@@ -370,6 +418,11 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
         m_yScrollPosition = y_pos;
         m_vAdjust->value = y_pos;
         
+        wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+        wxScrollWinEvent event( command, m_yScrollPosition, wxVERTICAL );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    
         m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
         
         gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
@@ -392,6 +445,19 @@ void wxScrolledWindow::GtkVScroll( float value )
     int old_y = m_yScrollPosition;
     m_yScrollPosition = y_pos;
 
+    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
+    GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
+    
+    wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLLWIN_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+    wxScrollWinEvent event( command, m_yScrollPosition, wxVERTICAL );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+    
     m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
 }
 
@@ -411,6 +477,19 @@ void wxScrolledWindow::GtkHScroll( float value )
     int old_x = m_xScrollPosition;
     m_xScrollPosition = x_pos;
 
+    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
+    GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
+    
+    wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLLWIN_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+    wxScrollWinEvent event( command, m_xScrollPosition, wxHORIZONTAL );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+    
     m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
 }
 
@@ -453,6 +532,101 @@ void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) co
         *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
 }
 
+int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
+{
+    int pos = event.GetPosition();
+    int orient = event.GetOrientation();
+
+    int nScrollInc = 0;
+    if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = - m_xScrollPosition;
+            else
+                nScrollInc = - m_yScrollPosition;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = m_xScrollLines - m_xScrollPosition;
+            else
+                nScrollInc = m_yScrollLines - m_yScrollPosition;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
+    {
+            nScrollInc = -1;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
+    {
+            nScrollInc = 1;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
+            else
+                nScrollInc = -GetScrollPageSize(wxVERTICAL);
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = GetScrollPageSize(wxHORIZONTAL);
+            else
+                nScrollInc = GetScrollPageSize(wxVERTICAL);
+    } else
+    if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
+        (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = pos - m_xScrollPosition;
+            else
+                nScrollInc = pos - m_yScrollPosition;
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        if (m_xScrollPixelsPerLine > 0)
+        {
+            int w, h;
+            m_targetWindow->GetClientSize(&w, &h);
+
+            int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
+            int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
+            if (noPositions < 0)
+                noPositions = 0;
+
+            if ( (m_xScrollPosition + nScrollInc) < 0 )
+                nScrollInc = -m_xScrollPosition; // As -ve as we can go
+            else if ( (m_xScrollPosition + nScrollInc) > noPositions )
+                nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
+        }
+        else
+            m_targetWindow->Refresh();
+    }
+    else
+    {
+        if (m_yScrollPixelsPerLine > 0)
+        {
+            int w, h;
+            m_targetWindow->GetClientSize(&w, &h);
+
+            int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
+            int noPositions = (int) ( ((nMaxHeight - h)/(double)m_yScrollPixelsPerLine) + 0.5 );
+            if (noPositions < 0)
+                noPositions = 0;
+
+            if ( (m_yScrollPosition + nScrollInc) < 0 )
+                nScrollInc = -m_yScrollPosition; // As -ve as we can go
+            else if ( (m_yScrollPosition + nScrollInc) > noPositions )
+                nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
+        }
+        else
+            m_targetWindow->Refresh();
+    }
+
+    return nScrollInc;
+}
+
 // ----------------------------------------------------------------------------
 // event handlers
 // ----------------------------------------------------------------------------
index 548a400065da6d55d3e3d5f9d193a139fc194477..40fd6bed32ab7435b89bb0849e5a7220dd678618 100644 (file)
@@ -42,6 +42,7 @@
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
+    EVT_SCROLLWIN(wxScrolledWindow::OnScroll)
     EVT_SIZE(wxScrolledWindow::OnSize)
     EVT_PAINT(wxScrolledWindow::OnPaint)
     EVT_CHAR(wxScrolledWindow::OnChar)
@@ -134,6 +135,8 @@ wxScrolledWindow::wxScrolledWindow()
     m_xScrollLinesPerPage = 0;
     m_yScrollLinesPerPage = 0;
     m_targetWindow = (wxWindow*) NULL;
+    m_scaleX = 1.0;
+    m_scaleY = 1.0;
 }
 
 bool wxScrolledWindow::Create(wxWindow *parent,
@@ -342,9 +345,49 @@ void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize)
         m_yScrollLinesPerPage = pageSize;
 }
 
-/*
- * Scroll to given position (scroll position, not pixel position)
- */
+void wxScrolledWindow::OnScroll(wxScrollWinEvent& event)
+{
+    int orient = event.GetOrientation();
+    
+    int nScrollInc = CalcScrollInc(event);
+    if (nScrollInc == 0) return;
+
+    if (orient == wxHORIZONTAL)
+    {
+        int newPos = m_xScrollPosition + nScrollInc;
+        SetScrollPos(wxHORIZONTAL, newPos, TRUE );
+    }
+    else
+    {
+        int newPos = m_yScrollPosition + nScrollInc;
+        SetScrollPos(wxVERTICAL, newPos, TRUE );
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        m_xScrollPosition += nScrollInc;
+    }
+    else
+    {
+        m_yScrollPosition += nScrollInc;
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+       if (m_xScrollingEnabled)
+            m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL);
+       else
+            m_targetWindow->Refresh();
+    }
+    else
+    {
+        if (m_yScrollingEnabled)
+            m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL);
+        else
+            m_targetWindow->Refresh();
+    }
+}
+
 void wxScrolledWindow::Scroll( int x_pos, int y_pos )
 {
     if (!m_targetWindow)
@@ -359,6 +402,11 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
         m_xScrollPosition = x_pos;
         m_hAdjust->value = x_pos;
         
+        wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+        wxScrollWinEvent event( command, m_xScrollPosition, wxHORIZONTAL );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    
         m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
         
         gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" );
@@ -370,6 +418,11 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
         m_yScrollPosition = y_pos;
         m_vAdjust->value = y_pos;
         
+        wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+        wxScrollWinEvent event( command, m_yScrollPosition, wxVERTICAL );
+        event.SetEventObject( this );
+        GetEventHandler()->ProcessEvent( event );
+    
         m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
         
         gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" );
@@ -392,6 +445,19 @@ void wxScrolledWindow::GtkVScroll( float value )
     int old_y = m_yScrollPosition;
     m_yScrollPosition = y_pos;
 
+    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
+    GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
+    
+    wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLLWIN_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+    wxScrollWinEvent event( command, m_yScrollPosition, wxVERTICAL );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+    
     m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
 }
 
@@ -411,6 +477,19 @@ void wxScrolledWindow::GtkHScroll( float value )
     int old_x = m_xScrollPosition;
     m_xScrollPosition = x_pos;
 
+    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
+    GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
+    
+    wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLLWIN_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
+
+    wxScrollWinEvent event( command, m_xScrollPosition, wxHORIZONTAL );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+    
     m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
 }
 
@@ -453,6 +532,101 @@ void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) co
         *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
 }
 
+int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
+{
+    int pos = event.GetPosition();
+    int orient = event.GetOrientation();
+
+    int nScrollInc = 0;
+    if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = - m_xScrollPosition;
+            else
+                nScrollInc = - m_yScrollPosition;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = m_xScrollLines - m_xScrollPosition;
+            else
+                nScrollInc = m_yScrollLines - m_yScrollPosition;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
+    {
+            nScrollInc = -1;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
+    {
+            nScrollInc = 1;
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
+            else
+                nScrollInc = -GetScrollPageSize(wxVERTICAL);
+    } else
+    if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = GetScrollPageSize(wxHORIZONTAL);
+            else
+                nScrollInc = GetScrollPageSize(wxVERTICAL);
+    } else
+    if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
+        (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
+    {
+            if (orient == wxHORIZONTAL)
+                nScrollInc = pos - m_xScrollPosition;
+            else
+                nScrollInc = pos - m_yScrollPosition;
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        if (m_xScrollPixelsPerLine > 0)
+        {
+            int w, h;
+            m_targetWindow->GetClientSize(&w, &h);
+
+            int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
+            int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
+            if (noPositions < 0)
+                noPositions = 0;
+
+            if ( (m_xScrollPosition + nScrollInc) < 0 )
+                nScrollInc = -m_xScrollPosition; // As -ve as we can go
+            else if ( (m_xScrollPosition + nScrollInc) > noPositions )
+                nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
+        }
+        else
+            m_targetWindow->Refresh();
+    }
+    else
+    {
+        if (m_yScrollPixelsPerLine > 0)
+        {
+            int w, h;
+            m_targetWindow->GetClientSize(&w, &h);
+
+            int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine;
+            int noPositions = (int) ( ((nMaxHeight - h)/(double)m_yScrollPixelsPerLine) + 0.5 );
+            if (noPositions < 0)
+                noPositions = 0;
+
+            if ( (m_yScrollPosition + nScrollInc) < 0 )
+                nScrollInc = -m_yScrollPosition; // As -ve as we can go
+            else if ( (m_yScrollPosition + nScrollInc) > noPositions )
+                nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go
+        }
+        else
+            m_targetWindow->Refresh();
+    }
+
+    return nScrollInc;
+}
+
 // ----------------------------------------------------------------------------
 // event handlers
 // ----------------------------------------------------------------------------