From: David Surovell Date: Mon, 2 Jan 2006 00:12:55 +0000 (+0000) Subject: added runtime protection for no SL_LABEL style case X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1d731fcdb9ff2238754fdb40914ece2459d94ccb?ds=inline added runtime protection for no SL_LABEL style case git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36619 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index bbf97a3d9f..187b651bcc 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -44,6 +44,10 @@ END_EVENT_TABLE() m_rangeMax = 0; m_rangeMin = 0; m_tickFreq = 0; + + m_macMinimumStatic = NULL ; + m_macMaximumStatic = NULL ; + m_macValueStatic = NULL ; } bool wxSlider::Create(wxWindow *parent, wxWindowID id, @@ -55,6 +59,18 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, { m_macIsUserPane = false ; + 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); + // our styles are redundant: wxSL_LEFT/RIGHT imply wxSL_VERTICAL and // wxSL_TOP/BOTTOM imply wxSL_HORIZONTAL, but for backwards compatibility // reasons we can't really change it, instead try to infer the orientation @@ -72,13 +88,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, break; case 0: + default: // no specific direction, do we have at least the orientation? if ( !(style & (wxSL_HORIZONTAL | wxSL_VERTICAL)) ) { // no, choose default style |= wxSL_BOTTOM | wxSL_HORIZONTAL; } - }; + break; + } wxASSERT_MSG( !(style & wxSL_VERTICAL) || !(style & wxSL_HORIZONTAL), _T("incompatible slider direction and orientation") ); @@ -86,18 +104,6 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return false; - 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 ) ; // @@ -131,10 +137,11 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, m_macMinimumStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString ); m_macMaximumStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString ); m_macValueStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString ); - SetRange(minValue, maxValue); - SetValue(value); } + SetRange(minValue, maxValue); + SetValue(value); + MacPostControlCreate(pos,size) ; return true; @@ -160,10 +167,12 @@ int wxSlider::GetValue() const void wxSlider::SetValue(int value) { - wxString valuestring ; - valuestring.Printf( wxT("%d") , value ) ; if ( m_macValueStatic ) + { + wxString valuestring ; + valuestring.Printf( wxT("%d") , value ) ; m_macValueStatic->SetLabel( valuestring ) ; + } // We only invert for the setting of the actual native widget m_peer->SetValue( ValueInvertOrNot ( value ) ) ;