X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a17a79bac3f7742a351b719a4692c5e6d5641969..7848088476db284a94f19eeb24411b45d676ac46:/src/univ/scrolbar.cpp diff --git a/src/univ/scrolbar.cpp b/src/univ/scrolbar.cpp index 66d0d7a173..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 @@ -83,7 +83,6 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) BEGIN_EVENT_TABLE(wxScrollBar, wxScrollBarBase) - EVT_IDLE(wxScrollBar::OnIdle) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -148,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); @@ -165,22 +164,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(); } // ---------------------------------------------------------------------------- @@ -318,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() @@ -543,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);