]> git.saurik.com Git - wxWidgets.git/commitdiff
generate EVT_SCROLL events for the standalong scrollbars, not EVT_SCROLLWIN
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 May 2002 10:45:49 +0000 (10:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 May 2002 10:45:49 +0000 (10:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15579 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/scrolbar.h
src/univ/scrolbar.cpp

index e1ec962adf3e5291bb6baa4a833d034ca27313ee..f400d4aea8da957c5adfe12be99586089745cc03 100644 (file)
@@ -126,7 +126,7 @@ protected:
 
     // event handlers
     void OnIdle(wxIdleEvent& event);
-    
+
     // forces update of thumb's visual appearence (does nothing if m_dirty=FALSE)
     void UpdateThumb();
 
@@ -136,6 +136,9 @@ protected:
     // common part of all ctors
     void Init();
 
+    // is this scrollbar attached to a window or a standalone control?
+    bool IsStandalone() const;
+
 private:
     // total range of the scrollbar in logical units
     int m_range;
index 66d0d7a1735bc7d4c93c545a45bcd5ee0e1416dd..16fc367cdf389f1799e27ba48fe8e8ae46e38a02 100644 (file)
@@ -165,22 +165,26 @@ wxScrollBar::~wxScrollBar()
 {
 }
 
-bool wxScrollBar::AcceptsFocus() const
+// ----------------------------------------------------------------------------
+// misc accessors
+// ----------------------------------------------------------------------------
+
+bool wxScrollBar::IsStandalone() const
 {
-    if (!wxWindow::AcceptsFocus()) return FALSE;
-    
-    wxWindow *parent = (wxWindow*) GetParent();
-    
-    if (parent)
+    wxWindow *parent = GetParent();
+    if ( !parent )
     {
-        if ((parent->GetScrollbar( wxHORIZONTAL ) == this) ||
-            (parent->GetScrollbar( wxVERTICAL ) == this))
-        {
-            return FALSE;
-        }
+        return TRUE;
     }
-    
-    return TRUE;
+
+    return (parent->GetScrollbar(wxHORIZONTAL) != this) &&
+           (parent->GetScrollbar(wxVERTICAL) != this);
+}
+
+bool wxScrollBar::AcceptsFocus() const
+{
+    // the window scrollbars never accept focus
+    return wxScrollBarBase::AcceptsFocus() && IsStandalone();
 }
 
 // ----------------------------------------------------------------------------
@@ -543,6 +547,16 @@ bool wxScrollBar::PerformAction(const wxControlAction& action,
     bool changed = m_thumbPos != thumbOld;
     if ( notify || changed )
     {
+        if ( IsStandalone() )
+        {
+            // we should generate EVT_SCROLL events for the standalone
+            // scrollbars and not the EVT_SCROLLWIN ones
+            //
+            // NB: we assume that scrollbar events are sequentially numbered
+            //     but this should be ok as other code relies on this as well
+            scrollType += wxEVT_SCROLL_TOP - wxEVT_SCROLLWIN_TOP;
+        }
+
         wxScrollWinEvent event(scrollType, m_thumbPos,
                                IsVertical() ? wxVERTICAL : wxHORIZONTAL);
         event.SetEventObject(this);