- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macMinimumStatic = NULL ;
-
- m_lineSize = 1;
- m_tickFreq = 0;
-
- m_rangeMax = maxValue;
- m_rangeMin = minValue;
-
- m_pageSize = (int)((maxValue-minValue)/10);
- if ( m_width == -1 )
- {
- m_width = 20 ;
- if ( style & wxSL_LABELS && style & wxSL_VERTICAL )
- m_width += 24 ;
- bounds.right = bounds.left + m_width ;
- }
- if ( m_height == -1 )
- {
- m_height = 20 ;
- if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL )
- m_height += 24 ;
- bounds.bottom = bounds.top + m_height ;
- }
-
- if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL )
- {
- bounds.top += 12 ;
- bounds.right -= 24 ;
- }
-
- if ( style & wxSL_LABELS && style & wxSL_VERTICAL )
- {
- bounds.left += 24 ;
- bounds.top += 12 ;
- }
-
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , value , minValue , maxValue,
- kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ;
-
- wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
-
- ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ;
-
- MacPostControlCreate() ;
-
- if ( style & wxSL_LABELS )
- {
- if ( style & wxSL_HORIZONTAL )
- {
- wxSize size( 24 , 12 ) ;
- wxPoint leftpos( 0 , 0 ) ;
- wxPoint rightpos( m_width - 2 * 12 , 0 ) ;
- wxPoint valuepos( m_width - 12 , 20 ) ;
- wxString valuestring ;
-
- valuestring.Printf( "%d" , minValue ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , leftpos , size ) ;
- valuestring.Printf( "%d" , maxValue ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , rightpos , size ) ;
- valuestring.Printf( "%d" , value ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ;
- }
- else
- {
- wxSize size( 24 , 12 ) ;
- wxPoint toppos( 0 , 12 ) ;
- wxPoint bottompos( 0 , m_height - 12 ) ;
- wxPoint valuepos( 20 , 0 ) ;
- wxString valuestring ;
-
- valuestring.Printf( "%d" , minValue ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , bottompos , size ) ;
- valuestring.Printf( "%d" , maxValue ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , toppos , size ) ;
- valuestring.Printf( "%d" , value ) ;
- m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ;
- }
- }
-
- return TRUE;
+ m_macIsUserPane = FALSE ;
+
+ if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
+ return false;
+
+ SInt16 procID;
+
+ m_macMinimumStatic = NULL ;
+ m_macMaximumStatic = NULL ;
+ m_macValueStatic = NULL ;
+
+
+ m_lineSize = 1;
+ m_tickFreq = 0;
+
+ m_rangeMax = maxValue;
+ m_rangeMin = minValue;
+
+ m_pageSize = (int)((maxValue-minValue)/10);
+
+ Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+
+ procID = kControlSliderProc + kControlSliderLiveFeedback;
+ if(style & wxSL_AUTOTICKS) {
+ procID += kControlSliderHasTickMarks;
+ }
+
+
+ m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, "\p", true,
+ value, minValue, maxValue, procID, (long) this);
+
+ wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+
+ ::SetControlAction( (ControlRef) m_macControl , wxMacLiveScrollbarActionUPP ) ;
+
+ if(style & wxSL_VERTICAL) {
+ SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width
+ }
+ else {
+ SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height
+ }
+ // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the
+ // proper dimensions, it also means other people cannot bugger the slider with
+ // other values
+
+ if(style & wxSL_LABELS)
+ {
+ m_macMinimumStatic = new wxStaticText( parent, -1, wxEmptyString );
+ m_macMaximumStatic = new wxStaticText( parent, -1, wxEmptyString );
+ m_macValueStatic = new wxStaticText( parent, -1, wxEmptyString );
+ SetRange(minValue, maxValue);
+ SetValue(value);
+ }