]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/scrarrow.cpp
Need to use the same instance handles
[wxWidgets.git] / src / univ / scrarrow.cpp
index fe892e27c37f74c3dffdde1eb8a2b4784159fd32..9680ecc27715f272b5b63b7aa6cdf5750f5b8a1c 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     22.01.01
 // RCS-ID:      $Id$
-// Copyright:   (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "univscrarrow.h"
 #endif
 
@@ -134,17 +134,18 @@ void wxScrollArrows::DrawArrow(Arrow arrow,
         { wxUP,   wxDOWN  }
     };
 
-    void (wxRenderer::*pfn)(wxDC&, wxDirection, const wxRect&, int) =
-        scrollbarLike ? &wxRenderer::DrawScrollbarArrow
-                      : &wxRenderer::DrawArrow;
-
-    (m_control->GetRenderer()->*pfn)
-    (
-        dc,
-        arrowDirs[m_control->IsVertical()][arrow],
-        rect,
-        m_control->GetArrowState(arrow)
-    );
+    if ( scrollbarLike )
+        m_control->GetRenderer()->DrawScrollbarArrow(
+            dc,
+            arrowDirs[m_control->IsVertical()][arrow],
+            rect,
+            m_control->GetArrowState(arrow));
+    else
+        m_control->GetRenderer()->DrawArrow(
+            dc,
+            arrowDirs[m_control->IsVertical()][arrow],
+            rect,
+            m_control->GetArrowState(arrow));
 }
 
 // ----------------------------------------------------------------------------
@@ -169,7 +170,7 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
         arrow = m_control->HitTest(event.GetPosition());
     }
 
-    if ( m_captureData )
+    if ( m_captureData && m_captureData->m_timerScroll)
     {
         // the mouse is captured, we may want to pause scrolling if it goes
         // outside the arrow or to resume it if we had paused it before
@@ -186,7 +187,7 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
                 return TRUE;
             }
         }
-        else if ( 1 ) //FIXME: m_control->ShouldPauseScrolling() )
+        else // if ( 1 ) FIXME: m_control->ShouldPauseScrolling() )
         {
             // we may want to stop it
             if ( arrow != m_captureData->m_arrowPressed )
@@ -245,11 +246,23 @@ bool wxScrollArrows::HandleMouse(const wxMouseEvent& event) const
             m_captureData->m_window = m_control->GetWindow();
             m_captureData->m_window->CaptureMouse();
 
-            // start scrolling
-            m_captureData->m_timerScroll =
+            // start scrolling                       
+            wxScrollArrowTimer *tmpTimerScroll =
                 new wxScrollArrowTimer(m_control, arrow);
 
-            m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, TRUE);
+            // Because in some cases wxScrollArrowTimer can cause 
+            // m_captureData to be destructed we need to test if it 
+            // is still valid before using.
+            if (m_captureData)
+            {
+                m_captureData->m_timerScroll = tmpTimerScroll;
+
+                m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, TRUE);
+            }
+            else
+            {
+                delete tmpTimerScroll;
+            }
         }
         //else: mouse already captured, nothing to do
     }