+wxInt32 wxScrollBar::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler), WXEVENTREF mevent )
+{
+ int position = m_peer->GetValue();
+ int minPos = m_peer->GetMinimum();
+ int maxPos = m_peer->GetMaximum();
+
+ 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
+ // NB: this may need to be reviewed in light of the fact that scroll wheel events
+ // aren't being handled properly
+ if ( controlpart != kControlIndicatorPart )
+ return eventNotHandledErr;
+
+ switch ( controlpart )
+ {
+ case kControlIndicatorPart:
+ nScrollInc = 0;
+ scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
+ break;
+
+ default:
+ wxFAIL_MSG(wxT("unknown scrollbar selector"));
+ break;
+ }
+
+ 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 );
+
+ return noErr;
+}
+
+
+wxSize wxScrollBar::DoGetBestSize() const
+{
+ int w = 100;
+ int h = 100;
+
+ if ( IsVertical() )
+ {
+ w = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+ }
+ else
+ {
+ h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
+ }
+
+ wxSize best(w, h);
+ CacheBestSize(best);
+ return best;
+}