removed src/gtk/eggtrayicon.h
[wxWidgets.git] / src / univ / scrarrow.cpp
index c3db2abdf8298e1ea24ffd7b9bad1e0dc71498ad..83ad8228370084302385b6478183ddf33dc1e369 100644 (file)
@@ -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
@@ -180,27 +181,27 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
             if ( arrow == m_captureData->m_arrowPressed )
             {
                 // resume now
-                m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, TRUE);
+                m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, true);
                 timer->Start();
 
-                return TRUE;
+                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 )
             {
                 // stop as the mouse left the arrow
                 m_control->SetArrowFlag(m_captureData->m_arrowPressed,
-                                        wxCONTROL_PRESSED, FALSE);
+                                        wxCONTROL_PRESSED, false);
                 timer->Stop();
 
-                return TRUE;
+                return true;
             }
         }
 
-        return FALSE;
+        return false;
     }
 
     // reset the wxCONTROL_CURRENT flag for the arrows which don't have the
@@ -208,7 +209,7 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
     UpdateCurrentFlag(Arrow_First, arrow);
     UpdateCurrentFlag(Arrow_Second, arrow);
 
-    // return TRUE if it was really an event for an arrow
+    // return true if it was really an event for an arrow
     return !event.Leaving() && arrow != Arrow_None;
 }
 
@@ -218,7 +219,7 @@ bool wxScrollArrows::HandleMouse(const wxMouseEvent& event) const
     if ( btn == -1 )
     {
         // we only care about button press/release events
-        return FALSE;
+        return false;
     }
 
     if ( event.ButtonDown() || event.ButtonDClick() )
@@ -229,13 +230,13 @@ bool wxScrollArrows::HandleMouse(const wxMouseEvent& event) const
             if ( arrow == Arrow_None )
             {
                 // mouse pressed over something else
-                return FALSE;
+                return false;
             }
 
             if ( m_control->GetArrowState(arrow) & wxCONTROL_DISABLED )
             {
                 // don't allow to press disabled arrows
-                return TRUE;
+                return true;
             }
 
             wxConstCast(this, wxScrollArrows)->m_captureData =
@@ -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
     }
@@ -261,14 +274,14 @@ bool wxScrollArrows::HandleMouse(const wxMouseEvent& event) const
         delete m_captureData;
         wxConstCast(this, wxScrollArrows)->m_captureData = NULL;
 
-        m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, FALSE);
+        m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, false);
     }
     else
     {
         // we don't process this
-        return FALSE;
+        return false;
     }
 
-    return TRUE;
+    return true;
 }