X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/21c3670fecfba15df37ade5fd4fb47829e399caa..005198fa7d8e244f9c9c28263c8eca5a9ced8e16:/src/univ/scrolbar.cpp?ds=inline diff --git a/src/univ/scrolbar.cpp b/src/univ/scrolbar.cpp index e2f146b7d4..8626070f0d 100644 --- a/src/univ/scrolbar.cpp +++ b/src/univ/scrolbar.cpp @@ -6,7 +6,7 @@ // Created: 20.08.00 // RCS-ID: $Id$ // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "univscrolbar.h" #endif @@ -42,6 +42,7 @@ #include "wx/univ/renderer.h" #include "wx/univ/inphand.h" #include "wx/univ/theme.h" +#include "wx/log.h" #define WXDEBUG_SCROLLBAR @@ -82,7 +83,6 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) BEGIN_EVENT_TABLE(wxScrollBar, wxScrollBarBase) - EVT_IDLE(wxScrollBar::OnIdle) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -147,7 +147,7 @@ bool wxScrollBar::Create(wxWindow *parent, // the scrollbars never have the border style &= ~wxBORDER_MASK; - if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) + if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return FALSE; SetBestSize(size); @@ -164,6 +164,28 @@ wxScrollBar::~wxScrollBar() { } +// ---------------------------------------------------------------------------- +// misc accessors +// ---------------------------------------------------------------------------- + +bool wxScrollBar::IsStandalone() const +{ + wxWindow *parent = GetParent(); + if ( !parent ) + { + 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(); +} + // ---------------------------------------------------------------------------- // scrollbar API // ---------------------------------------------------------------------------- @@ -299,10 +321,10 @@ wxScrollArrows::Arrow wxScrollBar::HitTest(const wxPoint& pt) const // drawing // ---------------------------------------------------------------------------- -void wxScrollBar::OnIdle(wxIdleEvent& event) +void wxScrollBar::OnInternalIdle() { UpdateThumb(); - event.Skip(); + wxControl::OnInternalIdle(); } void wxScrollBar::UpdateThumb() @@ -370,7 +392,7 @@ void wxScrollBar::UpdateThumb() } #endif // WXDEBUG_SCROLLBAR - Refresh(TRUE, &rect); + Refresh(FALSE, &rect); } m_elementsState[n] &= ~wxCONTROL_DIRTY; @@ -524,6 +546,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);