X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..50f12a63130b81796ea531c59af97f0544cf158d:/src/osx/scrolbar_osx.cpp diff --git a/src/osx/scrolbar_osx.cpp b/src/osx/scrolbar_osx.cpp index f9e695b48b..9b71f0e436 100644 --- a/src/osx/scrolbar_osx.cpp +++ b/src/osx/scrolbar_osx.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/scrolbar.cpp +// Name: src/osx/scrolbar_osx.cpp // Purpose: wxScrollBar // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: scrolbar.cpp 54129 2008-06-11 19:30:52Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,7 +21,7 @@ #include "wx/osx/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) +#if wxUSE_SCROLLBAR BEGIN_EVENT_TABLE(wxScrollBar, wxControl) END_EVENT_TABLE() @@ -34,13 +34,13 @@ bool wxScrollBar::Create( wxWindow *parent, long style, const wxValidator& validator, const wxString& name ) -{ - m_macIsUserPane = false; - +{ + DontCreatePeer(); + if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) ) return false; - - m_peer = wxWidgetImpl::CreateScrollBar( this, parent, id, pos, size, style, GetExtraStyle() ); + + SetPeer(wxWidgetImpl::CreateScrollBar( this, parent, id, pos, size, style, GetExtraStyle() )); MacPostControlCreate( pos, size ); @@ -53,12 +53,12 @@ wxScrollBar::~wxScrollBar() void wxScrollBar::SetThumbPosition( int viewStart ) { - m_peer->SetScrollThumb( viewStart, m_viewSize ); + GetPeer()->SetScrollThumb( viewStart, m_viewSize ); } int wxScrollBar::GetThumbPosition() const { - return m_peer->GetValue(); + return GetPeer()->GetValue(); } void wxScrollBar::SetScrollbar( int position, @@ -72,9 +72,9 @@ void wxScrollBar::SetScrollbar( int position, m_objectSize = range; int range1 = wxMax( (m_objectSize - m_viewSize), 0 ); - - m_peer->SetMaximum( range1 ); - m_peer->SetScrollThumb( position, m_viewSize ); + + GetPeer()->SetMaximum( range1 ); + GetPeer()->SetScrollThumb( position, m_viewSize ); } void wxScrollBar::Command( wxCommandEvent& event ) @@ -83,9 +83,9 @@ void wxScrollBar::Command( wxCommandEvent& event ) ProcessCommand( event ); } -bool wxScrollBar::HandleClicked( double timestampsec ) +bool wxScrollBar::OSXHandleClicked( double WXUNUSED(timestampsec) ) { - int new_pos = m_peer->GetValue(); + int new_pos = GetPeer()->GetValue(); wxScrollEvent event( wxEVT_SCROLL_THUMBRELEASE, m_windowId ); if ( m_windowStyle & wxHORIZONTAL ) @@ -124,3 +124,56 @@ wxSize wxScrollBar::DoGetBestSize() const CacheBestSize(best); return best; } + +void wxScrollBar::TriggerScrollEvent( wxEventType scrollEvent ) +{ + int position = GetPeer()->GetValue(); + int minPos = 0 ; + int maxPos = GetPeer()->GetMaximum(); + int nScrollInc = 0; + + if ( scrollEvent == wxEVT_SCROLL_LINEUP ) + { + nScrollInc = -1; + } + else if ( scrollEvent == wxEVT_SCROLL_LINEDOWN ) + { + nScrollInc = 1; + } + else if ( scrollEvent == wxEVT_SCROLL_PAGEUP ) + { + nScrollInc = -m_pageSize; + } + else if ( scrollEvent == wxEVT_SCROLL_PAGEDOWN ) + { + nScrollInc = m_pageSize; + } + + int new_pos = position + nScrollInc; + + if (new_pos < minPos) + new_pos = minPos; + else if (new_pos > maxPos) + new_pos = maxPos; + + if ( nScrollInc ) + SetThumbPosition( new_pos ); + + wxScrollEvent event( scrollEvent, m_windowId ); + if ( m_windowStyle & wxHORIZONTAL ) + event.SetOrientation( wxHORIZONTAL ); + else + event.SetOrientation( wxVERTICAL ); + + event.SetPosition( new_pos ); + event.SetEventObject( this ); + + wxWindow* window = GetParent(); + if (window && window->MacIsWindowScrollbar( this )) + // this is hardcoded + window->MacOnScroll( event ); + else + HandleWindowEvent( event ); +} + +#endif