+wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent )
+{
+ int position = GetControl32BitValue( (ControlRef) m_macControl) ;
+ int minPos = GetControl32BitMinimum( (ControlRef) m_macControl) ;
+ int maxPos = GetControl32BitMaximum( (ControlRef) m_macControl) ;
+
+ wxEventType scrollEvent = wxEVT_NULL;
+ int nScrollInc = 0;
+
+ wxMacCarbonEvent cEvent( (EventRef) mevent ) ;
+ ControlPartCode controlpart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) ;
+
+ // all events have already been reported during mouse down, except for THUMBRELEASE
+ if ( controlpart !=kControlIndicatorPart )
+ return eventNotHandledErr ;
+
+ switch( controlpart )
+ {
+ case kControlIndicatorPart :
+ nScrollInc = 0 ;
+ scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+ break ;
+ default :
+ wxFAIL_MSG(wxT("illegal scrollbar selector"));
+ break ;
+ }
+
+ int new_pos = position + nScrollInc;
+
+ if (new_pos < minPos)
+ new_pos = minPos;
+ 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
+ GetEventHandler()->ProcessEvent(event);
+ return noErr ;
+}
+
+