From 312ebad4cd1fad97a79aaed7102611df88806410 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 31 Aug 2004 13:59:07 +0000 Subject: [PATCH] some wxUSE_* macros not used consistently (patch #992456) with source cleaning (blind changes). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28975 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/choice.cpp | 19 +++--- src/mac/carbon/slider.cpp | 116 ++++++++++++++++++----------------- src/mac/carbon/spinbutt.cpp | 49 ++++++++------- src/mac/classic/choice.cpp | 11 +++- src/mac/classic/slider.cpp | 114 ++++++++++++++++++---------------- src/mac/classic/spinbutt.cpp | 51 ++++++++------- src/motif/choice.cpp | 28 +++++---- src/motif/slider.cpp | 11 +++- src/motif/spinbutt.cpp | 16 +++-- src/os2/choice.cpp | 18 ++++-- src/os2/slider.cpp | 11 ++-- src/os2/spinctrl.cpp | 26 ++++---- 12 files changed, 263 insertions(+), 207 deletions(-) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 72c34a84a7..c8554b81f0 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -14,6 +14,9 @@ #endif #include "wx/defs.h" + +#if wxUSE_CHOICE + #include "wx/choice.h" #include "wx/menu.h" #include "wx/mac/uma.h" @@ -60,17 +63,17 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_macIsUserPane = FALSE ; - + m_macIsUserPane = false ; + if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) ) return false; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl() ; - verify_noerr ( CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , + verify_noerr ( CreatePopupButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , -12345 , false /* no variable width */ , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) ); - + m_macPopUpMenuHandle = NewUniqueMenu() ; m_peer->SetData( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ; @@ -82,7 +85,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, Append(choices[i]); } SetBestSize(size); // Needed because it is a wxControlWithItems - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -178,7 +181,7 @@ int wxChoice::FindString(const wxString& s) const { for( int i = 0 ; i < GetCount() ; i++ ) { - if ( GetString( i ).IsSameAs(s, FALSE) ) + if ( GetString( i ).IsSameAs(s, false) ) return i ; } return wxNOT_FOUND ; @@ -229,7 +232,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const return (wxClientData *)DoGetItemClientData(n); } -wxInt32 wxChoice::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) +wxInt32 wxChoice::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); int n = GetSelection(); @@ -299,3 +302,5 @@ wxSize wxChoice::DoGetBestSize() const } return wxSize(lbWidth, lbHeight); } + +#endif // wxUSE_CHOICE diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index fb8d6a322a..0c73cb27bf 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -13,6 +13,10 @@ #pragma implementation "slider.h" #endif +#include "wx/defs.h" + +#if wxUSE_SLIDER + #include "wx/slider.h" #include "wx/mac/uma.h" @@ -27,15 +31,15 @@ END_EVENT_TABLE() #define wxSLIDER_DIMENSIONACROSS 15 #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 #define wxSLIDER_DIMENSIONACROSS_ARROW 18 - + // Distance between slider and text #define wxSLIDER_BORDERTEXT 5 - + /* NB! The default orientation for a slider is horizontal however if the user specifies * some slider styles but dosen't specify the orientation we have to assume he wants a * horizontal one. Therefore in this file when testing for the sliders orientation * vertical is tested for if this is not set then we use the horizontal one - * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> + * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> */ // Slider @@ -57,39 +61,39 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_macIsUserPane = FALSE ; - + m_macIsUserPane = false ; + 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 ) ; - + + Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; + UInt16 tickMarks = 0 ; if ( style & wxSL_AUTOTICKS ) - tickMarks = (maxValue - minValue); - + tickMarks = (maxValue - minValue); + if (tickMarks > 20) tickMarks = tickMarks/5; //keep the number of tickmarks from becoming unwieldly - + m_peer = new wxMacControl() ; - verify_noerr ( CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , + verify_noerr ( CreateSliderControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , value , minValue , maxValue , kControlSliderPointsDownOrRight , tickMarks , true /* liveTracking */ , wxMacLiveScrollbarActionUPP , m_peer->GetControlRefAddr() ) ); - - + + if(style & wxSL_VERTICAL) { SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width } @@ -99,18 +103,18 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, // 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 ); + 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); } MacPostControlCreate(pos,size) ; - + return true; } @@ -129,7 +133,7 @@ int wxSlider::GetValue() const void wxSlider::SetValue(int value) { wxString valuestring ; - valuestring.Printf( wxT("%d") , value ) ; + valuestring.Printf( wxT("%d") , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; m_peer->SetValue( value ) ; @@ -138,13 +142,13 @@ void wxSlider::SetValue(int value) void wxSlider::SetRange(int minValue, int maxValue) { wxString value; - + m_rangeMin = minValue; m_rangeMax = maxValue; - + m_peer->SetMinimum( m_rangeMin); m_peer->SetMaximum( m_rangeMax); - + if(m_macMinimumStatic) { value.Printf(wxT("%d"), m_rangeMin); m_macMinimumStatic->SetLabel(value); @@ -235,47 +239,47 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) +void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) { SInt16 value = m_peer->GetValue() ; - - SetValue( value ) ; - + + SetValue( value ) ; + wxEventType scrollEvent = wxEVT_NULL ; - + scrollEvent = wxEVT_SCROLL_THUMBTRACK; - + wxScrollEvent event(scrollEvent, m_windowId); event.SetPosition(value); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); - + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); cevent.SetInt( value ); cevent.SetEventObject( this ); - + GetEventHandler()->ProcessEvent( cevent ); } -wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) +wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) { SInt16 value = m_peer->GetValue() ; - - SetValue( value ) ; - + + SetValue( value ) ; + wxEventType scrollEvent = wxEVT_NULL ; - + scrollEvent = wxEVT_SCROLL_THUMBRELEASE; - + wxScrollEvent event(scrollEvent, m_windowId); event.SetPosition(value); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); - + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); cevent.SetInt( value ); cevent.SetEventObject( this ); - + GetEventHandler()->ProcessEvent( cevent ); return noErr ; } @@ -288,7 +292,7 @@ void wxSlider::SetSizeHints( int minW, int minH, int incW , int incH ) { wxSize size = GetBestSize(); - + if(GetWindowStyle() & wxSL_VERTICAL) { wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); } @@ -301,12 +305,12 @@ wxSize wxSlider::DoGetBestSize() const { wxSize size; int textwidth, textheight; - + if(GetWindowStyle() & wxSL_LABELS) { wxString text; int ht, wd; - + // Get maximum text label width and height text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &textwidth, &textheight); @@ -319,7 +323,7 @@ wxSize wxSlider::DoGetBestSize() const textwidth = wd; } } - + if(GetWindowStyle() & wxSL_VERTICAL) { if(GetWindowStyle() & wxSL_AUTOTICKS) { @@ -354,7 +358,7 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) int xborder, yborder; int minValWidth, maxValWidth, textwidth, textheight; int sliderBreadth; - + xborder = yborder = 0; if (GetWindowStyle() & wxSL_LABELS) @@ -365,10 +369,10 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) //relative to its parent in order to size properly, so //move the control first so we can use GetPosition() wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ; - + wxString text; int ht; - + // Get maximum text label width and height text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &minValWidth, &textheight); @@ -378,10 +382,10 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) textheight = ht; } textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); - + xborder = textwidth + wxSLIDER_BORDERTEXT; yborder = textheight + wxSLIDER_BORDERTEXT; - + // Get slider breadth if(GetWindowStyle() & wxSL_AUTOTICKS) { sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; @@ -389,11 +393,11 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) else { sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; } - + if(GetWindowStyle() & wxSL_VERTICAL) { h = h - yborder ; - + if ( m_macMinimumStatic ) m_macMinimumStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT, GetPosition().y + h - yborder); @@ -415,7 +419,7 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) } } //If the control has labels, we still need to call this again because - //the labels alter the control's w and h values. + //the labels alter the control's w and h values. wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ; } @@ -424,3 +428,5 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height) { wxControl::DoMoveWindow(x,y,width,height) ; } + +#endif // wxUSE_SLIDER diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 98272dc92a..20c43cef8f 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -14,6 +14,10 @@ #pragma implementation "spinbuttbase.h" #endif +#include "wx/defs.h" + +#if wxUSE_SPINBTN + #include "wx/spinbutt.h" #include "wx/mac/uma.h" @@ -40,30 +44,30 @@ wxSpinButton::wxSpinButton() bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - m_macIsUserPane = FALSE ; - + m_macIsUserPane = false ; + if ( !wxSpinButtonBase::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; m_min = 0; m_max = 100; - + if (!parent) - return FALSE; - + return false; + Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; - + m_peer = new wxMacControl() ; verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 , m_peer->GetControlRefAddr() ) ); - + m_peer->SetActionProc( wxMacLiveScrollbarActionUPP ) ; MacPostControlCreate(pos,size) ; - - return TRUE; + + return true; } - + wxSpinButton::~wxSpinButton() { } @@ -101,12 +105,12 @@ void wxSpinButton::SetRange(int minVal, int maxVal) void wxSpinButton::MacHandleValueChanged( int inc ) { - + wxEventType scrollEvent = wxEVT_NULL; int oldValue = m_value ; - + m_value = oldValue + inc; - + if (m_value < m_min) { if ( m_windowStyle & wxSP_WRAP ) @@ -114,7 +118,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) else m_value = m_min; } - + if (m_value > m_max) { if ( m_windowStyle & wxSP_WRAP ) @@ -122,16 +126,16 @@ void wxSpinButton::MacHandleValueChanged( int inc ) else m_value = m_max; } - + if ( m_value - oldValue == -1 ) scrollEvent = wxEVT_SCROLL_LINEDOWN ; else if ( m_value - oldValue == 1 ) scrollEvent = wxEVT_SCROLL_LINEUP ; else scrollEvent = wxEVT_SCROLL_THUMBTRACK ; - + wxSpinEvent event(scrollEvent, m_windowId); - + event.SetPosition(m_value); event.SetEventObject( this ); if ((GetEventHandler()->ProcessEvent( event )) && @@ -140,7 +144,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) m_value = oldValue ; } m_peer->SetValue( m_value ) ; - + /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) { @@ -152,10 +156,10 @@ void wxSpinButton::MacHandleValueChanged( int inc ) } } -void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) +void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) { int nScrollInc = 0; - + switch( controlpart ) { case kControlUpButtonPart : @@ -168,13 +172,13 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart MacHandleValueChanged( nScrollInc ) ; } -wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event ) +wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event ) { /* // these have been handled by the live action proc already int nScrollInc = 0; wxMacCarbonEvent cEvent( (EventRef) event ) ; - + switch( cEvent.GetParameter(kEventParamControlPart,typeControlPartCode) ) { case kControlUpButtonPart : @@ -198,3 +202,4 @@ wxSize wxSpinButton::DoGetBestSize() const return wxSize(16,24); } +#endif // wxUSE_SPINBTN diff --git a/src/mac/classic/choice.cpp b/src/mac/classic/choice.cpp index 2eafe3f433..f08d6b8a0d 100644 --- a/src/mac/classic/choice.cpp +++ b/src/mac/classic/choice.cpp @@ -14,6 +14,9 @@ #endif #include "wx/defs.h" + +#if wxUSE_CHOICE + #include "wx/choice.h" #include "wx/menu.h" #include "wx/mac/uma.h" @@ -82,7 +85,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, { Append(choices[i]); } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -178,7 +181,7 @@ int wxChoice::FindString(const wxString& s) const { for( int i = 0 ; i < GetCount() ; i++ ) { - if ( GetString( i ).IsSameAs(s, FALSE) ) + if ( GetString( i ).IsSameAs(s, false) ) return i ; } return wxNOT_FOUND ; @@ -229,7 +232,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const return (wxClientData *)DoGetItemClientData(n); } -void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) +void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); int n = GetSelection(); @@ -298,3 +301,5 @@ wxSize wxChoice::DoGetBestSize() const } return wxSize(lbWidth, lbHeight); } + +#endif // wxUSE_CHOICE diff --git a/src/mac/classic/slider.cpp b/src/mac/classic/slider.cpp index aa5b52847d..ec5b2de314 100644 --- a/src/mac/classic/slider.cpp +++ b/src/mac/classic/slider.cpp @@ -13,6 +13,10 @@ #pragma implementation "slider.h" #endif +#include "wx/defs.h" + +#if wxUSE_SLIDER + #include "wx/slider.h" #include "wx/mac/uma.h" @@ -27,15 +31,15 @@ END_EVENT_TABLE() #define wxSLIDER_DIMENSIONACROSS 15 #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 #define wxSLIDER_DIMENSIONACROSS_ARROW 18 - + // Distance between slider and text #define wxSLIDER_BORDERTEXT 5 - + /* NB! The default orientation for a slider is horizontal however if the user specifies * some slider styles but dosen't specify the orientation we have to assume he wants a * horizontal one. Therefore in this file when testing for the sliders orientation * vertical is tested for if this is not set then we use the horizontal one - * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> + * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> */ // Slider @@ -63,51 +67,51 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; 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); - + MacPreControlCreate( parent, id, wxEmptyString, pos, size, style, validator, name, &bounds, title ); - + procID = kControlSliderProc + kControlSliderLiveFeedback; if(style & wxSL_AUTOTICKS) { procID += kControlSliderHasTickMarks; } - - + + m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, value, minValue, maxValue, procID, (long) this); - + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; - + ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; - + if(style & wxSL_LABELS) { - m_macMinimumStatic = new wxStaticText( this, -1, wxEmptyString ); - m_macMaximumStatic = new wxStaticText( this, -1, wxEmptyString ); - m_macValueStatic = new wxStaticText( this, -1, wxEmptyString ); + m_macMinimumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString ); + m_macMaximumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString ); + m_macValueStatic = new wxStaticText( this, wxID_ANY, wxEmptyString ); SetRange(minValue, maxValue); SetValue(value); } - + else { m_macMinimumStatic = NULL ; m_macMaximumStatic = NULL ; m_macValueStatic = NULL ; } - + if(style & wxSL_VERTICAL) { SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width } @@ -117,9 +121,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, // 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 - + MacPostControlCreate() ; - + return true; } @@ -135,7 +139,7 @@ int wxSlider::GetValue() const void wxSlider::SetValue(int value) { wxString valuestring ; - valuestring.Printf( wxT("%d") , value ) ; + valuestring.Printf( wxT("%d") , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; SetControl32BitValue( (ControlHandle) m_macControl , value ) ; @@ -144,13 +148,13 @@ void wxSlider::SetValue(int value) void wxSlider::SetRange(int minValue, int maxValue) { wxString value; - + m_rangeMin = minValue; m_rangeMax = maxValue; - + SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); - + if(m_macMinimumStatic) { value.Printf(wxT("%d"), m_rangeMin); m_macMinimumStatic->SetLabel(value); @@ -241,28 +245,28 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) +void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown ) { SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; - - SetValue( value ) ; - + + SetValue( value ) ; + wxEventType scrollEvent = wxEVT_NULL ; - + if ( mouseStillDown ) scrollEvent = wxEVT_SCROLL_THUMBTRACK; else scrollEvent = wxEVT_SCROLL_THUMBRELEASE; - + wxScrollEvent event(scrollEvent, m_windowId); event.SetPosition(value); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); - + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); cevent.SetInt( value ); cevent.SetEventObject( this ); - + GetEventHandler()->ProcessEvent( cevent ); } @@ -273,7 +277,7 @@ void wxSlider::SetSizeHints( int minW, int minH, int incW , int incH ) { wxSize size = GetBestSize(); - + if(GetWindowStyle() & wxSL_VERTICAL) { wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); } @@ -286,12 +290,12 @@ wxSize wxSlider::DoGetBestSize() const { wxSize size; int textwidth, textheight; - + if(GetWindowStyle() & wxSL_LABELS) { wxString text; int ht, wd; - + // Get maximum text label width and height text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &textwidth, &textheight); @@ -304,7 +308,7 @@ wxSize wxSlider::DoGetBestSize() const textwidth = wd; } } - + if(GetWindowStyle() & wxSL_VERTICAL) { if(GetWindowStyle() & wxSL_AUTOTICKS) { @@ -339,32 +343,32 @@ void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxControl::DoSetSize( x, y , width , height ,sizeFlags ) ; } -void wxSlider::MacUpdateDimensions() +void wxSlider::MacUpdateDimensions() { // actually in the current systems this should never be possible, but later reparenting // may become a reality - + if ( (ControlHandle) m_macControl == NULL ) return ; - + if ( GetParent() == NULL ) return ; - + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) return ; - + int xborder, yborder; int minValWidth, maxValWidth, textwidth, textheight; int sliderBreadth; - + xborder = yborder = 0; - + if (GetWindowStyle() & wxSL_LABELS) { wxString text; int ht; - + // Get maximum text label width and height text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &minValWidth, &textheight); @@ -374,10 +378,10 @@ void wxSlider::MacUpdateDimensions() textheight = ht; } textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); - + xborder = textwidth + wxSLIDER_BORDERTEXT; yborder = textheight + wxSLIDER_BORDERTEXT; - + // Get slider breadth if(GetWindowStyle() & wxSL_AUTOTICKS) { sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; @@ -385,7 +389,7 @@ void wxSlider::MacUpdateDimensions() else { sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; } - + if(GetWindowStyle() & wxSL_VERTICAL) { m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, @@ -401,15 +405,15 @@ void wxSlider::MacUpdateDimensions() m_macValueStatic->Move(m_width - textwidth, 0); } } - - Rect oldBounds ; - GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; - + + Rect oldBounds ; + GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; + int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ; int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ; int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ; int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ; - + GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; @@ -431,3 +435,5 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height) { wxControl::DoMoveWindow(x,y,width,height) ; } + +#endif // wxUSE_SLIDER diff --git a/src/mac/classic/spinbutt.cpp b/src/mac/classic/spinbutt.cpp index a4e47edc17..3d1cd44c21 100644 --- a/src/mac/classic/spinbutt.cpp +++ b/src/mac/classic/spinbutt.cpp @@ -14,6 +14,10 @@ #pragma implementation "spinbuttbase.h" #endif +#include "wx/defs.h" + +#if wxUSE_SPINBTN + #include "wx/spinbutt.h" #include "wx/mac/uma.h" @@ -44,25 +48,25 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c m_min = 0; m_max = 100; - + if (!parent) - return FALSE; - + return false; + Rect bounds ; Str255 title ; - + MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; - - m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, + + m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, kControlLittleArrowsProc , (long) this ) ; - + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; - + MacPostControlCreate() ; - - return TRUE; + + return true; } - + wxSpinButton::~wxSpinButton() { } @@ -100,12 +104,12 @@ void wxSpinButton::SetRange(int minVal, int maxVal) void wxSpinButton::MacHandleValueChanged( int inc ) { - + wxEventType scrollEvent = wxEVT_NULL; int oldValue = m_value ; - + m_value = oldValue + inc; - + if (m_value < m_min) { if ( m_windowStyle & wxSP_WRAP ) @@ -113,7 +117,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) else m_value = m_min; } - + if (m_value > m_max) { if ( m_windowStyle & wxSP_WRAP ) @@ -121,16 +125,16 @@ void wxSpinButton::MacHandleValueChanged( int inc ) else m_value = m_max; } - + if ( m_value - oldValue == -1 ) scrollEvent = wxEVT_SCROLL_LINEDOWN ; else if ( m_value - oldValue == 1 ) scrollEvent = wxEVT_SCROLL_LINEUP ; else scrollEvent = wxEVT_SCROLL_THUMBTRACK ; - + wxSpinEvent event(scrollEvent, m_windowId); - + event.SetPosition(m_value); event.SetEventObject( this ); if ((GetEventHandler()->ProcessEvent( event )) && @@ -139,7 +143,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) m_value = oldValue ; } SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; - + /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) { @@ -151,13 +155,13 @@ void wxSpinButton::MacHandleValueChanged( int inc ) } } -void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) +void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { if ( (ControlHandle) m_macControl == NULL ) return ; - + int nScrollInc = 0; - + switch( controlpart ) { case kControlUpButtonPart : @@ -168,7 +172,7 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart break ; } MacHandleValueChanged( nScrollInc ) ; - + } // ---------------------------------------------------------------------------- @@ -180,3 +184,4 @@ wxSize wxSpinButton::DoGetBestSize() const return wxSize(16,24); } +#endif // wxUSE_SPINBTN diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 6a24190b8e..87e7eb7880 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -6,7 +6,7 @@ // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) @@ -23,6 +23,8 @@ #include "wx/defs.h" +#if wxUSE_CHOICE + #include "wx/choice.h" #include "wx/utils.h" #include "wx/arrstr.h" @@ -71,7 +73,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxString& name) { if ( !CreateControl(parent, id, pos, size, style, validator, name) ) - return FALSE; + return false; Widget parentWidget = (Widget) parent->GetClientWidget(); @@ -138,13 +140,13 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); - ChangeFont(FALSE); + ChangeFont(false); ChangeBackgroundColour(); AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, bestSize.x, bestSize.y); - return TRUE; + return true; } bool wxChoice::Create(wxWindow *parent, wxWindowID id, @@ -226,7 +228,7 @@ int wxChoice::DoAppend(const wxString& item) int wxChoice::DoInsert(const wxString& item, int pos) { - wxCHECK_MSG(FALSE, -1, wxT("insert not implemented")); + wxCHECK_MSG(false, -1, wxT("insert not implemented")); // wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index")); // if (pos == GetCount()) return DoAppend(item); @@ -300,7 +302,7 @@ int wxChoice::GetSelection() const void wxChoice::SetSelection(int n) { - m_inSetValue = TRUE; + m_inSetValue = true; wxStringList::compatibility_iterator node = m_stringList.Item(n); if (node) @@ -327,7 +329,7 @@ void wxChoice::SetSelection(int n) XmNmenuHistory, (Widget) m_widgetArray[n], NULL); #endif } - m_inSetValue = FALSE; + m_inSetValue = false; } int wxChoice::FindString(const wxString& s) const @@ -342,7 +344,7 @@ int wxChoice::FindString(const wxString& s) const i++; } - return -1; + return wxNOT_FOUND; } wxString wxChoice::GetString(int n) const @@ -471,11 +473,11 @@ void wxChoice::ChangeFont(bool keepOriginalSize) XtVaSetValues( (Widget)m_widgetArray[i], fontTag, fontType, NULL ); - + GetSize(& width1, & height1); if (keepOriginalSize && (width != width1 || height != height1)) { - SetSize(-1, -1, width, height); + SetSize(wxDefaultCoord, wxDefaultCoord, width, height); } } } @@ -507,7 +509,7 @@ int wxChoice::GetCount() const void wxChoice::DoSetItemClientData(int n, void* clientData) { - m_clientDataDict.Set(n, (wxClientData*)clientData, FALSE); + m_clientDataDict.Set(n, (wxClientData*)clientData, false); } void* wxChoice::DoGetItemClientData(int n) const @@ -518,7 +520,7 @@ void* wxChoice::DoGetItemClientData(int n) const void wxChoice::DoSetItemClientObject(int n, wxClientData* clientData) { // don't delete, wxItemContainer does that for us - m_clientDataDict.Set(n, clientData, FALSE); + m_clientDataDict.Set(n, clientData, false); } wxClientData* wxChoice::DoGetItemClientObject(int n) const @@ -557,3 +559,5 @@ wxSize wxChoice::DoGetBestSize() const return wxSize( ( items.x ? items.x + WIDTH_OVERHEAD : 120 ), items.y + HEIGHT_OVERHEAD ); } + +#endif // wxUSE_CHOICE diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index e11f1bb9ce..fdd2ff7358 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -6,7 +6,7 @@ // Created: 17/09/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) @@ -16,6 +16,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/defs.h" + +#if wxUSE_SLIDER + #include "wx/slider.h" #include "wx/utils.h" @@ -106,12 +110,12 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); - ChangeFont(FALSE); + ChangeFont(false); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); - return TRUE; + return true; } wxSlider::~wxSlider() @@ -242,3 +246,4 @@ void wxSliderCallback (Widget widget, XtPointer clientData, slider->GetEventHandler()->ProcessEvent(event2); } +#endif // wxUSE_SLIDER diff --git a/src/motif/spinbutt.cpp b/src/motif/spinbutt.cpp index ca3a6e2af1..cdded68c3a 100644 --- a/src/motif/spinbutt.cpp +++ b/src/motif/spinbutt.cpp @@ -16,6 +16,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/defs.h" + +#if wxUSE_SPINBTN + #include "wx/spinbutt.h" #include "wx/spinctrl.h" #include "wx/timer.h" @@ -77,7 +81,7 @@ class wxArrowButton : public wxControl { friend class wxArrowButtonTimer; public: - wxArrowButton( int increment ) + wxArrowButton( int increment ) : m_increment( increment ), m_timer( 0 ) {} @@ -230,7 +234,7 @@ bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID id, SetForegroundColour( parent->GetBackgroundColour() ); - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -272,12 +276,12 @@ bool wxSpinButton::Create( wxWindow *parent, wxWindowID id, if( !wxControl::Create( parent, id, pos, newSize, style ) ) { - return FALSE; + return false; } SetName(name); - m_windowId = ( id == -1 ) ? NewControlId() : id; + m_windowId = ( id == wxID_ANY ) ? NewControlId() : id; bool isVert = IsVertical(); wxPoint pt1, pt2; @@ -289,7 +293,7 @@ bool wxSpinButton::Create( wxWindow *parent, wxWindowID id, isVert ? wxARROW_DOWN : wxARROW_LEFT, pt2, sz2, -1 ); - return TRUE; + return true; } wxSpinButton::~wxSpinButton() @@ -403,3 +407,5 @@ void wxSpinButton::ChangeForegroundColour() { // TODO } + +#endif // wxUSE_SPINBTN diff --git a/src/os2/choice.cpp b/src/os2/choice.cpp index 2bb70c0599..5e4d3e4ad2 100644 --- a/src/os2/choice.cpp +++ b/src/os2/choice.cpp @@ -12,6 +12,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/defs.h" + +#if wxUSE_CHOICE + #ifndef WX_PRECOMP #include "wx/choice.h" #include "wx/utils.h" @@ -62,7 +66,7 @@ bool wxChoice::Create( ,rValidator ,rsName )) - return FALSE; + return false; lSstyle = CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE; @@ -79,7 +83,7 @@ bool wxChoice::Create( if (!OS2CreateControl( wxT("COMBOBOX") ,lSstyle )) - return FALSE; + return false; // // A choice/combobox normally has a white background (or other, depending @@ -102,7 +106,7 @@ bool wxChoice::Create( ,rSize.y ); delete pTextFont; - return TRUE; + return true; } // end of wxChoice::Create // ---------------------------------------------------------------------------- @@ -419,7 +423,7 @@ bool wxChoice::OS2Command( // // "selection changed" is the only event we're after // - return FALSE; + return false; } int n = GetSelection(); @@ -438,7 +442,7 @@ bool wxChoice::OS2Command( vEvent.SetClientData(GetClientData(n)); ProcessCommand(vEvent); } - return TRUE; + return true; } // end of wxChoice::OS2Command void wxChoice::Free() @@ -452,4 +456,6 @@ void wxChoice::Free() delete GetClientObject(n); } } -} // end of wxhoice::Free +} // end of wxChoice::Free + +#endif // wxUSE_CHOICE diff --git a/src/os2/slider.cpp b/src/os2/slider.cpp index db9beff768..b97747f687 100644 --- a/src/os2/slider.cpp +++ b/src/os2/slider.cpp @@ -23,6 +23,8 @@ #include #endif +#if wxUSE_SLIDER + #include "wx/slider.h" #include "wx/os2/private.h" @@ -460,7 +462,7 @@ bool wxSlider::Create( ,(PVOID)&lColor ); SetValue(nValue); - return TRUE; + return true; } // end of wxSlider::Create void wxSlider::DoSetSize( @@ -941,7 +943,7 @@ bool wxSlider::OS2OnScroll( break; default: - return FALSE; + return false; } int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() @@ -970,7 +972,7 @@ bool wxSlider::OS2OnScroll( // // Out of range - but we did process it // - return TRUE; + return true; } SetValue(nNewPos); @@ -1168,6 +1170,7 @@ bool wxSlider::Show( ::WinShowWindow((HWND)m_hStaticMin, bShow); if(m_hStaticMax) ::WinShowWindow((HWND)m_hStaticMax, bShow); - return TRUE; + return true; } // end of wxSlider::Show +#endif // wxUSE_SLIDER diff --git a/src/os2/spinctrl.cpp b/src/os2/spinctrl.cpp index 6c44693285..5328a895ea 100644 --- a/src/os2/spinctrl.cpp +++ b/src/os2/spinctrl.cpp @@ -31,7 +31,7 @@ #include "wx/wx.h" #endif -#if wxUSE_SPINBTN +#if wxUSE_SPINCTRL #include "wx/spinctrl.h" #include "wx/os2/private.h" @@ -50,7 +50,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton) EVT_CHAR(wxSpinCtrl::OnChar) - EVT_SPIN(-1, wxSpinCtrl::OnSpinChange) + EVT_SPIN(wxID_ANY, wxSpinCtrl::OnSpinChange) EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -132,7 +132,7 @@ bool wxSpinCtrl::Create( { SWP vSwp; - if (vId == -1) + if (vId == wxID_ANY) m_windowId = NewControlId(); else m_windowId = vId; @@ -174,7 +174,7 @@ bool wxSpinCtrl::Create( ); if (m_hWnd == 0) { - return FALSE; + return false; } m_hWndBuddy = m_hWnd; // One in the same for OS/2 if(pParent) @@ -207,7 +207,7 @@ bool wxSpinCtrl::Create( fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc); m_svAllSpins.Add(this); delete pTextFont; - return TRUE; + return true; } // end of wxSpinCtrl::Create wxSize wxSpinCtrl::DoGetBestSize() const @@ -301,10 +301,10 @@ bool wxSpinCtrl::Enable( { if (!wxControl::Enable(bEnable)) { - return FALSE; + return false; } ::WinEnableWindow(GetHwnd(), bEnable); - return TRUE; + return true; } // end of wxSpinCtrl::Enable wxSpinCtrl* wxSpinCtrl::GetSpinForTextCtrl( @@ -455,7 +455,7 @@ bool wxSpinCtrl::ProcessTextCommand( // // Not processed // - return FALSE; + return false; } // end of wxSpinCtrl::ProcessTextCommand void wxSpinCtrl::SetFocus() @@ -470,13 +470,13 @@ bool wxSpinCtrl::SetFont( if (!wxWindowBase::SetFont(rFont)) { // nothing to do - return FALSE; + return false; } wxOS2SetFont( m_hWnd ,rFont ); - return TRUE; + return true; } // end of wxSpinCtrl::SetFont void wxSpinCtrl::SetValue( @@ -495,9 +495,9 @@ bool wxSpinCtrl::Show( { if (!wxControl::Show(bShow)) { - return FALSE; + return false; } - return TRUE; + return true; } // end of wxSpinCtrl::Show void wxSpinCtrl::SetSelection ( @@ -516,4 +516,4 @@ void wxSpinCtrl::SetSelection ( ::WinSendMsg(m_hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), (MPARAM)0); } // end of wxSpinCtrl::SetSelection -#endif //wxUSE_SPINBTN +#endif //wxUSE_SPINCTRL -- 2.45.2