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
This commit is contained in:
Włodzimierz Skiba
2004-08-31 13:59:07 +00:00
parent 118322a3df
commit 312ebad4cd
12 changed files with 263 additions and 207 deletions

View File

@@ -14,6 +14,9 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -60,17 +63,17 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ; m_macIsUserPane = false ;
if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) ) if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_peer = new wxMacControl() ; 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() ) ); -12345 , false /* no variable width */ , 0 , 0 , 0 , m_peer->GetControlRefAddr() ) );
m_macPopUpMenuHandle = NewUniqueMenu() ; m_macPopUpMenuHandle = NewUniqueMenu() ;
m_peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ; m_peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ;
@@ -82,7 +85,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
Append(choices[i]); Append(choices[i]);
} }
SetBestSize(size); // Needed because it is a wxControlWithItems 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++ ) for( int i = 0 ; i < GetCount() ; i++ )
{ {
if ( GetString( i ).IsSameAs(s, FALSE) ) if ( GetString( i ).IsSameAs(s, false) )
return i ; return i ;
} }
return wxNOT_FOUND ; return wxNOT_FOUND ;
@@ -229,7 +232,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const
return (wxClientData *)DoGetItemClientData(n); 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 ); wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
int n = GetSelection(); int n = GetSelection();
@@ -299,3 +302,5 @@ wxSize wxChoice::DoGetBestSize() const
} }
return wxSize(lbWidth, lbHeight); return wxSize(lbWidth, lbHeight);
} }
#endif // wxUSE_CHOICE

View File

@@ -13,6 +13,10 @@
#pragma implementation "slider.h" #pragma implementation "slider.h"
#endif #endif
#include "wx/defs.h"
#if wxUSE_SLIDER
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -27,15 +31,15 @@ END_EVENT_TABLE()
#define wxSLIDER_DIMENSIONACROSS 15 #define wxSLIDER_DIMENSIONACROSS 15
#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
#define wxSLIDER_DIMENSIONACROSS_ARROW 18 #define wxSLIDER_DIMENSIONACROSS_ARROW 18
// Distance between slider and text // Distance between slider and text
#define wxSLIDER_BORDERTEXT 5 #define wxSLIDER_BORDERTEXT 5
/* NB! The default orientation for a slider is horizontal however if the user specifies /* 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 * 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 * 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 * 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 // Slider
@@ -57,39 +61,39 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_macIsUserPane = FALSE ; m_macIsUserPane = false ;
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
m_macMinimumStatic = NULL ; m_macMinimumStatic = NULL ;
m_macMaximumStatic = NULL ; m_macMaximumStatic = NULL ;
m_macValueStatic = NULL ; m_macValueStatic = NULL ;
m_lineSize = 1; m_lineSize = 1;
m_tickFreq = 0; m_tickFreq = 0;
m_rangeMax = maxValue; m_rangeMax = maxValue;
m_rangeMin = minValue; m_rangeMin = minValue;
m_pageSize = (int)((maxValue-minValue)/10); m_pageSize = (int)((maxValue-minValue)/10);
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
UInt16 tickMarks = 0 ; UInt16 tickMarks = 0 ;
if ( style & wxSL_AUTOTICKS ) if ( style & wxSL_AUTOTICKS )
tickMarks = (maxValue - minValue); tickMarks = (maxValue - minValue);
if (tickMarks > 20) if (tickMarks > 20)
tickMarks = tickMarks/5; //keep the number of tickmarks from becoming unwieldly tickMarks = tickMarks/5; //keep the number of tickmarks from becoming unwieldly
m_peer = new wxMacControl() ; 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 */ , value , minValue , maxValue , kControlSliderPointsDownOrRight , tickMarks , true /* liveTracking */ ,
wxMacLiveScrollbarActionUPP , m_peer->GetControlRefAddr() ) ); wxMacLiveScrollbarActionUPP , m_peer->GetControlRefAddr() ) );
if(style & wxSL_VERTICAL) { if(style & wxSL_VERTICAL) {
SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width 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 // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the
// proper dimensions, it also means other people cannot bugger the slider with // proper dimensions, it also means other people cannot bugger the slider with
// other values // other values
if(style & wxSL_LABELS) if(style & wxSL_LABELS)
{ {
m_macMinimumStatic = new wxStaticText( parent, -1, wxEmptyString ); m_macMinimumStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString );
m_macMaximumStatic = new wxStaticText( parent, -1, wxEmptyString ); m_macMaximumStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString );
m_macValueStatic = new wxStaticText( parent, -1, wxEmptyString ); m_macValueStatic = new wxStaticText( parent, wxID_ANY, wxEmptyString );
SetRange(minValue, maxValue); SetRange(minValue, maxValue);
SetValue(value); SetValue(value);
} }
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
return true; return true;
} }
@@ -129,7 +133,7 @@ int wxSlider::GetValue() const
void wxSlider::SetValue(int value) void wxSlider::SetValue(int value)
{ {
wxString valuestring ; wxString valuestring ;
valuestring.Printf( wxT("%d") , value ) ; valuestring.Printf( wxT("%d") , value ) ;
if ( m_macValueStatic ) if ( m_macValueStatic )
m_macValueStatic->SetLabel( valuestring ) ; m_macValueStatic->SetLabel( valuestring ) ;
m_peer->SetValue( value ) ; m_peer->SetValue( value ) ;
@@ -138,13 +142,13 @@ void wxSlider::SetValue(int value)
void wxSlider::SetRange(int minValue, int maxValue) void wxSlider::SetRange(int minValue, int maxValue)
{ {
wxString value; wxString value;
m_rangeMin = minValue; m_rangeMin = minValue;
m_rangeMax = maxValue; m_rangeMax = maxValue;
m_peer->SetMinimum( m_rangeMin); m_peer->SetMinimum( m_rangeMin);
m_peer->SetMaximum( m_rangeMax); m_peer->SetMaximum( m_rangeMax);
if(m_macMinimumStatic) { if(m_macMinimumStatic) {
value.Printf(wxT("%d"), m_rangeMin); value.Printf(wxT("%d"), m_rangeMin);
m_macMinimumStatic->SetLabel(value); m_macMinimumStatic->SetLabel(value);
@@ -235,47 +239,47 @@ void wxSlider::Command (wxCommandEvent & event)
ProcessCommand (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() ; SInt16 value = m_peer->GetValue() ;
SetValue( value ) ; SetValue( value ) ;
wxEventType scrollEvent = wxEVT_NULL ; wxEventType scrollEvent = wxEVT_NULL ;
scrollEvent = wxEVT_SCROLL_THUMBTRACK; scrollEvent = wxEVT_SCROLL_THUMBTRACK;
wxScrollEvent event(scrollEvent, m_windowId); wxScrollEvent event(scrollEvent, m_windowId);
event.SetPosition(value); event.SetPosition(value);
event.SetEventObject( this ); event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
cevent.SetInt( value ); cevent.SetInt( value );
cevent.SetEventObject( this ); cevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( cevent ); GetEventHandler()->ProcessEvent( cevent );
} }
wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent ) wxInt32 wxSlider::MacControlHit( WXEVENTHANDLERREF handler , WXEVENTREF mevent )
{ {
SInt16 value = m_peer->GetValue() ; SInt16 value = m_peer->GetValue() ;
SetValue( value ) ; SetValue( value ) ;
wxEventType scrollEvent = wxEVT_NULL ; wxEventType scrollEvent = wxEVT_NULL ;
scrollEvent = wxEVT_SCROLL_THUMBRELEASE; scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
wxScrollEvent event(scrollEvent, m_windowId); wxScrollEvent event(scrollEvent, m_windowId);
event.SetPosition(value); event.SetPosition(value);
event.SetEventObject( this ); event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
cevent.SetInt( value ); cevent.SetInt( value );
cevent.SetEventObject( this ); cevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( cevent ); GetEventHandler()->ProcessEvent( cevent );
return noErr ; return noErr ;
} }
@@ -288,7 +292,7 @@ void wxSlider::SetSizeHints( int minW, int minH,
int incW , int incH ) int incW , int incH )
{ {
wxSize size = GetBestSize(); wxSize size = GetBestSize();
if(GetWindowStyle() & wxSL_VERTICAL) { if(GetWindowStyle() & wxSL_VERTICAL) {
wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH);
} }
@@ -301,12 +305,12 @@ wxSize wxSlider::DoGetBestSize() const
{ {
wxSize size; wxSize size;
int textwidth, textheight; int textwidth, textheight;
if(GetWindowStyle() & wxSL_LABELS) if(GetWindowStyle() & wxSL_LABELS)
{ {
wxString text; wxString text;
int ht, wd; int ht, wd;
// Get maximum text label width and height // Get maximum text label width and height
text.Printf(wxT("%d"), m_rangeMin); text.Printf(wxT("%d"), m_rangeMin);
GetTextExtent(text, &textwidth, &textheight); GetTextExtent(text, &textwidth, &textheight);
@@ -319,7 +323,7 @@ wxSize wxSlider::DoGetBestSize() const
textwidth = wd; textwidth = wd;
} }
} }
if(GetWindowStyle() & wxSL_VERTICAL) if(GetWindowStyle() & wxSL_VERTICAL)
{ {
if(GetWindowStyle() & wxSL_AUTOTICKS) { 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 xborder, yborder;
int minValWidth, maxValWidth, textwidth, textheight; int minValWidth, maxValWidth, textwidth, textheight;
int sliderBreadth; int sliderBreadth;
xborder = yborder = 0; xborder = yborder = 0;
if (GetWindowStyle() & wxSL_LABELS) 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 //relative to its parent in order to size properly, so
//move the control first so we can use GetPosition() //move the control first so we can use GetPosition()
wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ; wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ;
wxString text; wxString text;
int ht; int ht;
// Get maximum text label width and height // Get maximum text label width and height
text.Printf(wxT("%d"), m_rangeMin); text.Printf(wxT("%d"), m_rangeMin);
GetTextExtent(text, &minValWidth, &textheight); GetTextExtent(text, &minValWidth, &textheight);
@@ -378,10 +382,10 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
textheight = ht; textheight = ht;
} }
textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth);
xborder = textwidth + wxSLIDER_BORDERTEXT; xborder = textwidth + wxSLIDER_BORDERTEXT;
yborder = textheight + wxSLIDER_BORDERTEXT; yborder = textheight + wxSLIDER_BORDERTEXT;
// Get slider breadth // Get slider breadth
if(GetWindowStyle() & wxSL_AUTOTICKS) { if(GetWindowStyle() & wxSL_AUTOTICKS) {
sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
@@ -389,11 +393,11 @@ void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
else { else {
sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW;
} }
if(GetWindowStyle() & wxSL_VERTICAL) if(GetWindowStyle() & wxSL_VERTICAL)
{ {
h = h - yborder ; h = h - yborder ;
if ( m_macMinimumStatic ) if ( m_macMinimumStatic )
m_macMinimumStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT, m_macMinimumStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT,
GetPosition().y + h - yborder); 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 //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 ) ; 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) ; wxControl::DoMoveWindow(x,y,width,height) ;
} }
#endif // wxUSE_SLIDER

View File

@@ -14,6 +14,10 @@
#pragma implementation "spinbuttbase.h" #pragma implementation "spinbuttbase.h"
#endif #endif
#include "wx/defs.h"
#if wxUSE_SPINBTN
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#include "wx/mac/uma.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, bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)
{ {
m_macIsUserPane = FALSE ; m_macIsUserPane = false ;
if ( !wxSpinButtonBase::Create(parent, id, pos, size, if ( !wxSpinButtonBase::Create(parent, id, pos, size,
style, wxDefaultValidator, name) ) style, wxDefaultValidator, name) )
return false; return false;
m_min = 0; m_min = 0;
m_max = 100; m_max = 100;
if (!parent) if (!parent)
return FALSE; return false;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
m_peer = new wxMacControl() ; m_peer = new wxMacControl() ;
verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 , verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 ,
m_peer->GetControlRefAddr() ) ); m_peer->GetControlRefAddr() ) );
m_peer->SetActionProc( wxMacLiveScrollbarActionUPP ) ; m_peer->SetActionProc( wxMacLiveScrollbarActionUPP ) ;
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
return TRUE; return true;
} }
wxSpinButton::~wxSpinButton() wxSpinButton::~wxSpinButton()
{ {
} }
@@ -101,12 +105,12 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
void wxSpinButton::MacHandleValueChanged( int inc ) void wxSpinButton::MacHandleValueChanged( int inc )
{ {
wxEventType scrollEvent = wxEVT_NULL; wxEventType scrollEvent = wxEVT_NULL;
int oldValue = m_value ; int oldValue = m_value ;
m_value = oldValue + inc; m_value = oldValue + inc;
if (m_value < m_min) if (m_value < m_min)
{ {
if ( m_windowStyle & wxSP_WRAP ) if ( m_windowStyle & wxSP_WRAP )
@@ -114,7 +118,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
else else
m_value = m_min; m_value = m_min;
} }
if (m_value > m_max) if (m_value > m_max)
{ {
if ( m_windowStyle & wxSP_WRAP ) if ( m_windowStyle & wxSP_WRAP )
@@ -122,16 +126,16 @@ void wxSpinButton::MacHandleValueChanged( int inc )
else else
m_value = m_max; m_value = m_max;
} }
if ( m_value - oldValue == -1 ) if ( m_value - oldValue == -1 )
scrollEvent = wxEVT_SCROLL_LINEDOWN ; scrollEvent = wxEVT_SCROLL_LINEDOWN ;
else if ( m_value - oldValue == 1 ) else if ( m_value - oldValue == 1 )
scrollEvent = wxEVT_SCROLL_LINEUP ; scrollEvent = wxEVT_SCROLL_LINEUP ;
else else
scrollEvent = wxEVT_SCROLL_THUMBTRACK ; scrollEvent = wxEVT_SCROLL_THUMBTRACK ;
wxSpinEvent event(scrollEvent, m_windowId); wxSpinEvent event(scrollEvent, m_windowId);
event.SetPosition(m_value); event.SetPosition(m_value);
event.SetEventObject( this ); event.SetEventObject( this );
if ((GetEventHandler()->ProcessEvent( event )) && if ((GetEventHandler()->ProcessEvent( event )) &&
@@ -140,7 +144,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
m_value = oldValue ; m_value = oldValue ;
} }
m_peer->SetValue( m_value ) ; m_peer->SetValue( m_value ) ;
/* always send a thumbtrack event */ /* always send a thumbtrack event */
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) 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; int nScrollInc = 0;
switch( controlpart ) switch( controlpart )
{ {
case kControlUpButtonPart : case kControlUpButtonPart :
@@ -168,13 +172,13 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart
MacHandleValueChanged( nScrollInc ) ; 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 // these have been handled by the live action proc already
int nScrollInc = 0; int nScrollInc = 0;
wxMacCarbonEvent cEvent( (EventRef) event ) ; wxMacCarbonEvent cEvent( (EventRef) event ) ;
switch( cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) ) switch( cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) )
{ {
case kControlUpButtonPart : case kControlUpButtonPart :
@@ -198,3 +202,4 @@ wxSize wxSpinButton::DoGetBestSize() const
return wxSize(16,24); return wxSize(16,24);
} }
#endif // wxUSE_SPINBTN

View File

@@ -14,6 +14,9 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -82,7 +85,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
{ {
Append(choices[i]); 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++ ) for( int i = 0 ; i < GetCount() ; i++ )
{ {
if ( GetString( i ).IsSameAs(s, FALSE) ) if ( GetString( i ).IsSameAs(s, false) )
return i ; return i ;
} }
return wxNOT_FOUND ; return wxNOT_FOUND ;
@@ -229,7 +232,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const
return (wxClientData *)DoGetItemClientData(n); 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 ); wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
int n = GetSelection(); int n = GetSelection();
@@ -298,3 +301,5 @@ wxSize wxChoice::DoGetBestSize() const
} }
return wxSize(lbWidth, lbHeight); return wxSize(lbWidth, lbHeight);
} }
#endif // wxUSE_CHOICE

View File

@@ -13,6 +13,10 @@
#pragma implementation "slider.h" #pragma implementation "slider.h"
#endif #endif
#include "wx/defs.h"
#if wxUSE_SLIDER
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -27,15 +31,15 @@ END_EVENT_TABLE()
#define wxSLIDER_DIMENSIONACROSS 15 #define wxSLIDER_DIMENSIONACROSS 15
#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
#define wxSLIDER_DIMENSIONACROSS_ARROW 18 #define wxSLIDER_DIMENSIONACROSS_ARROW 18
// Distance between slider and text // Distance between slider and text
#define wxSLIDER_BORDERTEXT 5 #define wxSLIDER_BORDERTEXT 5
/* NB! The default orientation for a slider is horizontal however if the user specifies /* 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 * 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 * 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 * 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 // Slider
@@ -63,51 +67,51 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
SInt16 procID; SInt16 procID;
m_macMinimumStatic = NULL ; m_macMinimumStatic = NULL ;
m_macMaximumStatic = NULL ; m_macMaximumStatic = NULL ;
m_macValueStatic = NULL ; m_macValueStatic = NULL ;
m_lineSize = 1; m_lineSize = 1;
m_tickFreq = 0; m_tickFreq = 0;
m_rangeMax = maxValue; m_rangeMax = maxValue;
m_rangeMin = minValue; m_rangeMin = minValue;
m_pageSize = (int)((maxValue-minValue)/10); m_pageSize = (int)((maxValue-minValue)/10);
MacPreControlCreate( parent, id, wxEmptyString, pos, size, style, MacPreControlCreate( parent, id, wxEmptyString, pos, size, style,
validator, name, &bounds, title ); validator, name, &bounds, title );
procID = kControlSliderProc + kControlSliderLiveFeedback; procID = kControlSliderProc + kControlSliderLiveFeedback;
if(style & wxSL_AUTOTICKS) { if(style & wxSL_AUTOTICKS) {
procID += kControlSliderHasTickMarks; procID += kControlSliderHasTickMarks;
} }
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false,
value, minValue, maxValue, procID, (long) this); value, minValue, maxValue, procID, (long) this);
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
if(style & wxSL_LABELS) if(style & wxSL_LABELS)
{ {
m_macMinimumStatic = new wxStaticText( this, -1, wxEmptyString ); m_macMinimumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
m_macMaximumStatic = new wxStaticText( this, -1, wxEmptyString ); m_macMaximumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
m_macValueStatic = new wxStaticText( this, -1, wxEmptyString ); m_macValueStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
SetRange(minValue, maxValue); SetRange(minValue, maxValue);
SetValue(value); SetValue(value);
} }
else { else {
m_macMinimumStatic = NULL ; m_macMinimumStatic = NULL ;
m_macMaximumStatic = NULL ; m_macMaximumStatic = NULL ;
m_macValueStatic = NULL ; m_macValueStatic = NULL ;
} }
if(style & wxSL_VERTICAL) { if(style & wxSL_VERTICAL) {
SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width 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 // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the
// proper dimensions, it also means other people cannot bugger the slider with // proper dimensions, it also means other people cannot bugger the slider with
// other values // other values
MacPostControlCreate() ; MacPostControlCreate() ;
return true; return true;
} }
@@ -135,7 +139,7 @@ int wxSlider::GetValue() const
void wxSlider::SetValue(int value) void wxSlider::SetValue(int value)
{ {
wxString valuestring ; wxString valuestring ;
valuestring.Printf( wxT("%d") , value ) ; valuestring.Printf( wxT("%d") , value ) ;
if ( m_macValueStatic ) if ( m_macValueStatic )
m_macValueStatic->SetLabel( valuestring ) ; m_macValueStatic->SetLabel( valuestring ) ;
SetControl32BitValue( (ControlHandle) m_macControl , value ) ; SetControl32BitValue( (ControlHandle) m_macControl , value ) ;
@@ -144,13 +148,13 @@ void wxSlider::SetValue(int value)
void wxSlider::SetRange(int minValue, int maxValue) void wxSlider::SetRange(int minValue, int maxValue)
{ {
wxString value; wxString value;
m_rangeMin = minValue; m_rangeMin = minValue;
m_rangeMax = maxValue; m_rangeMax = maxValue;
SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin);
SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax);
if(m_macMinimumStatic) { if(m_macMinimumStatic) {
value.Printf(wxT("%d"), m_rangeMin); value.Printf(wxT("%d"), m_rangeMin);
m_macMinimumStatic->SetLabel(value); m_macMinimumStatic->SetLabel(value);
@@ -241,28 +245,28 @@ void wxSlider::Command (wxCommandEvent & event)
ProcessCommand (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 ) ; SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ;
SetValue( value ) ; SetValue( value ) ;
wxEventType scrollEvent = wxEVT_NULL ; wxEventType scrollEvent = wxEVT_NULL ;
if ( mouseStillDown ) if ( mouseStillDown )
scrollEvent = wxEVT_SCROLL_THUMBTRACK; scrollEvent = wxEVT_SCROLL_THUMBTRACK;
else else
scrollEvent = wxEVT_SCROLL_THUMBRELEASE; scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
wxScrollEvent event(scrollEvent, m_windowId); wxScrollEvent event(scrollEvent, m_windowId);
event.SetPosition(value); event.SetPosition(value);
event.SetEventObject( this ); event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
cevent.SetInt( value ); cevent.SetInt( value );
cevent.SetEventObject( this ); cevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( cevent ); GetEventHandler()->ProcessEvent( cevent );
} }
@@ -273,7 +277,7 @@ void wxSlider::SetSizeHints( int minW, int minH,
int incW , int incH ) int incW , int incH )
{ {
wxSize size = GetBestSize(); wxSize size = GetBestSize();
if(GetWindowStyle() & wxSL_VERTICAL) { if(GetWindowStyle() & wxSL_VERTICAL) {
wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH);
} }
@@ -286,12 +290,12 @@ wxSize wxSlider::DoGetBestSize() const
{ {
wxSize size; wxSize size;
int textwidth, textheight; int textwidth, textheight;
if(GetWindowStyle() & wxSL_LABELS) if(GetWindowStyle() & wxSL_LABELS)
{ {
wxString text; wxString text;
int ht, wd; int ht, wd;
// Get maximum text label width and height // Get maximum text label width and height
text.Printf(wxT("%d"), m_rangeMin); text.Printf(wxT("%d"), m_rangeMin);
GetTextExtent(text, &textwidth, &textheight); GetTextExtent(text, &textwidth, &textheight);
@@ -304,7 +308,7 @@ wxSize wxSlider::DoGetBestSize() const
textwidth = wd; textwidth = wd;
} }
} }
if(GetWindowStyle() & wxSL_VERTICAL) if(GetWindowStyle() & wxSL_VERTICAL)
{ {
if(GetWindowStyle() & wxSL_AUTOTICKS) { 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 ) ; 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 // actually in the current systems this should never be possible, but later reparenting
// may become a reality // may become a reality
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return ; return ;
if ( GetParent() == NULL ) if ( GetParent() == NULL )
return ; return ;
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
if ( rootwindow == NULL ) if ( rootwindow == NULL )
return ; return ;
int xborder, yborder; int xborder, yborder;
int minValWidth, maxValWidth, textwidth, textheight; int minValWidth, maxValWidth, textwidth, textheight;
int sliderBreadth; int sliderBreadth;
xborder = yborder = 0; xborder = yborder = 0;
if (GetWindowStyle() & wxSL_LABELS) if (GetWindowStyle() & wxSL_LABELS)
{ {
wxString text; wxString text;
int ht; int ht;
// Get maximum text label width and height // Get maximum text label width and height
text.Printf(wxT("%d"), m_rangeMin); text.Printf(wxT("%d"), m_rangeMin);
GetTextExtent(text, &minValWidth, &textheight); GetTextExtent(text, &minValWidth, &textheight);
@@ -374,10 +378,10 @@ void wxSlider::MacUpdateDimensions()
textheight = ht; textheight = ht;
} }
textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth);
xborder = textwidth + wxSLIDER_BORDERTEXT; xborder = textwidth + wxSLIDER_BORDERTEXT;
yborder = textheight + wxSLIDER_BORDERTEXT; yborder = textheight + wxSLIDER_BORDERTEXT;
// Get slider breadth // Get slider breadth
if(GetWindowStyle() & wxSL_AUTOTICKS) { if(GetWindowStyle() & wxSL_AUTOTICKS) {
sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
@@ -385,7 +389,7 @@ void wxSlider::MacUpdateDimensions()
else { else {
sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW;
} }
if(GetWindowStyle() & wxSL_VERTICAL) if(GetWindowStyle() & wxSL_VERTICAL)
{ {
m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT,
@@ -401,15 +405,15 @@ void wxSlider::MacUpdateDimensions()
m_macValueStatic->Move(m_width - textwidth, 0); m_macValueStatic->Move(m_width - textwidth, 0);
} }
} }
Rect oldBounds ; Rect oldBounds ;
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ; int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ; int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ; int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ;
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ; int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ;
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; 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) ; wxControl::DoMoveWindow(x,y,width,height) ;
} }
#endif // wxUSE_SLIDER

View File

@@ -14,6 +14,10 @@
#pragma implementation "spinbuttbase.h" #pragma implementation "spinbuttbase.h"
#endif #endif
#include "wx/defs.h"
#if wxUSE_SPINBTN
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#include "wx/mac/uma.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_min = 0;
m_max = 100; m_max = 100;
if (!parent) if (!parent)
return FALSE; return false;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , 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 ) ; kControlLittleArrowsProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
wxSpinButton::~wxSpinButton() wxSpinButton::~wxSpinButton()
{ {
} }
@@ -100,12 +104,12 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
void wxSpinButton::MacHandleValueChanged( int inc ) void wxSpinButton::MacHandleValueChanged( int inc )
{ {
wxEventType scrollEvent = wxEVT_NULL; wxEventType scrollEvent = wxEVT_NULL;
int oldValue = m_value ; int oldValue = m_value ;
m_value = oldValue + inc; m_value = oldValue + inc;
if (m_value < m_min) if (m_value < m_min)
{ {
if ( m_windowStyle & wxSP_WRAP ) if ( m_windowStyle & wxSP_WRAP )
@@ -113,7 +117,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
else else
m_value = m_min; m_value = m_min;
} }
if (m_value > m_max) if (m_value > m_max)
{ {
if ( m_windowStyle & wxSP_WRAP ) if ( m_windowStyle & wxSP_WRAP )
@@ -121,16 +125,16 @@ void wxSpinButton::MacHandleValueChanged( int inc )
else else
m_value = m_max; m_value = m_max;
} }
if ( m_value - oldValue == -1 ) if ( m_value - oldValue == -1 )
scrollEvent = wxEVT_SCROLL_LINEDOWN ; scrollEvent = wxEVT_SCROLL_LINEDOWN ;
else if ( m_value - oldValue == 1 ) else if ( m_value - oldValue == 1 )
scrollEvent = wxEVT_SCROLL_LINEUP ; scrollEvent = wxEVT_SCROLL_LINEUP ;
else else
scrollEvent = wxEVT_SCROLL_THUMBTRACK ; scrollEvent = wxEVT_SCROLL_THUMBTRACK ;
wxSpinEvent event(scrollEvent, m_windowId); wxSpinEvent event(scrollEvent, m_windowId);
event.SetPosition(m_value); event.SetPosition(m_value);
event.SetEventObject( this ); event.SetEventObject( this );
if ((GetEventHandler()->ProcessEvent( event )) && if ((GetEventHandler()->ProcessEvent( event )) &&
@@ -139,7 +143,7 @@ void wxSpinButton::MacHandleValueChanged( int inc )
m_value = oldValue ; m_value = oldValue ;
} }
SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ;
/* always send a thumbtrack event */ /* always send a thumbtrack event */
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) 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 ) if ( (ControlHandle) m_macControl == NULL )
return ; return ;
int nScrollInc = 0; int nScrollInc = 0;
switch( controlpart ) switch( controlpart )
{ {
case kControlUpButtonPart : case kControlUpButtonPart :
@@ -168,7 +172,7 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart
break ; break ;
} }
MacHandleValueChanged( nScrollInc ) ; MacHandleValueChanged( nScrollInc ) ;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -180,3 +184,4 @@ wxSize wxSpinButton::DoGetBestSize() const
return wxSize(16,24); return wxSize(16,24);
} }
#endif // wxUSE_SPINBTN

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -23,6 +23,8 @@
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/arrstr.h" #include "wx/arrstr.h"
@@ -71,7 +73,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxString& name) const wxString& name)
{ {
if ( !CreateControl(parent, id, pos, size, style, validator, name) ) if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return FALSE; return false;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
@@ -138,13 +140,13 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
ChangeFont(FALSE); ChangeFont(false);
ChangeBackgroundColour(); ChangeBackgroundColour();
AttachWidget (parent, m_buttonWidget, m_formWidget, AttachWidget (parent, m_buttonWidget, m_formWidget,
pos.x, pos.y, bestSize.x, bestSize.y); pos.x, pos.y, bestSize.x, bestSize.y);
return TRUE; return true;
} }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, 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) 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")); // wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
// if (pos == GetCount()) return DoAppend(item); // if (pos == GetCount()) return DoAppend(item);
@@ -300,7 +302,7 @@ int wxChoice::GetSelection() const
void wxChoice::SetSelection(int n) void wxChoice::SetSelection(int n)
{ {
m_inSetValue = TRUE; m_inSetValue = true;
wxStringList::compatibility_iterator node = m_stringList.Item(n); wxStringList::compatibility_iterator node = m_stringList.Item(n);
if (node) if (node)
@@ -327,7 +329,7 @@ void wxChoice::SetSelection(int n)
XmNmenuHistory, (Widget) m_widgetArray[n], NULL); XmNmenuHistory, (Widget) m_widgetArray[n], NULL);
#endif #endif
} }
m_inSetValue = FALSE; m_inSetValue = false;
} }
int wxChoice::FindString(const wxString& s) const int wxChoice::FindString(const wxString& s) const
@@ -342,7 +344,7 @@ int wxChoice::FindString(const wxString& s) const
i++; i++;
} }
return -1; return wxNOT_FOUND;
} }
wxString wxChoice::GetString(int n) const wxString wxChoice::GetString(int n) const
@@ -471,11 +473,11 @@ void wxChoice::ChangeFont(bool keepOriginalSize)
XtVaSetValues( (Widget)m_widgetArray[i], XtVaSetValues( (Widget)m_widgetArray[i],
fontTag, fontType, fontTag, fontType,
NULL ); NULL );
GetSize(& width1, & height1); GetSize(& width1, & height1);
if (keepOriginalSize && (width != width1 || height != 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) 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 void* wxChoice::DoGetItemClientData(int n) const
@@ -518,7 +520,7 @@ void* wxChoice::DoGetItemClientData(int n) const
void wxChoice::DoSetItemClientObject(int n, wxClientData* clientData) void wxChoice::DoSetItemClientObject(int n, wxClientData* clientData)
{ {
// don't delete, wxItemContainer does that for us // 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 wxClientData* wxChoice::DoGetItemClientObject(int n) const
@@ -557,3 +559,5 @@ wxSize wxChoice::DoGetBestSize() const
return wxSize( ( items.x ? items.x + WIDTH_OVERHEAD : 120 ), return wxSize( ( items.x ? items.x + WIDTH_OVERHEAD : 120 ),
items.y + HEIGHT_OVERHEAD ); items.y + HEIGHT_OVERHEAD );
} }
#endif // wxUSE_CHOICE

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -16,6 +16,10 @@
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/defs.h"
#if wxUSE_SLIDER
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/utils.h" #include "wx/utils.h"
@@ -106,12 +110,12 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); 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); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return true;
} }
wxSlider::~wxSlider() wxSlider::~wxSlider()
@@ -242,3 +246,4 @@ void wxSliderCallback (Widget widget, XtPointer clientData,
slider->GetEventHandler()->ProcessEvent(event2); slider->GetEventHandler()->ProcessEvent(event2);
} }
#endif // wxUSE_SLIDER

View File

@@ -16,6 +16,10 @@
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/defs.h"
#if wxUSE_SPINBTN
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
#include "wx/timer.h" #include "wx/timer.h"
@@ -77,7 +81,7 @@ class wxArrowButton : public wxControl
{ {
friend class wxArrowButtonTimer; friend class wxArrowButtonTimer;
public: public:
wxArrowButton( int increment ) wxArrowButton( int increment )
: m_increment( increment ), : m_increment( increment ),
m_timer( 0 ) {} m_timer( 0 ) {}
@@ -230,7 +234,7 @@ bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID id,
SetForegroundColour( parent->GetBackgroundColour() ); 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 ) ) if( !wxControl::Create( parent, id, pos, newSize, style ) )
{ {
return FALSE; return false;
} }
SetName(name); SetName(name);
m_windowId = ( id == -1 ) ? NewControlId() : id; m_windowId = ( id == wxID_ANY ) ? NewControlId() : id;
bool isVert = IsVertical(); bool isVert = IsVertical();
wxPoint pt1, pt2; wxPoint pt1, pt2;
@@ -289,7 +293,7 @@ bool wxSpinButton::Create( wxWindow *parent, wxWindowID id,
isVert ? wxARROW_DOWN : wxARROW_LEFT, isVert ? wxARROW_DOWN : wxARROW_LEFT,
pt2, sz2, -1 ); pt2, sz2, -1 );
return TRUE; return true;
} }
wxSpinButton::~wxSpinButton() wxSpinButton::~wxSpinButton()
@@ -403,3 +407,5 @@ void wxSpinButton::ChangeForegroundColour()
{ {
// TODO // TODO
} }
#endif // wxUSE_SPINBTN

View File

@@ -12,6 +12,10 @@
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/defs.h"
#if wxUSE_CHOICE
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/utils.h" #include "wx/utils.h"
@@ -62,7 +66,7 @@ bool wxChoice::Create(
,rValidator ,rValidator
,rsName ,rsName
)) ))
return FALSE; return false;
lSstyle = CBS_DROPDOWNLIST | lSstyle = CBS_DROPDOWNLIST |
WS_TABSTOP | WS_TABSTOP |
WS_VISIBLE; WS_VISIBLE;
@@ -79,7 +83,7 @@ bool wxChoice::Create(
if (!OS2CreateControl( wxT("COMBOBOX") if (!OS2CreateControl( wxT("COMBOBOX")
,lSstyle ,lSstyle
)) ))
return FALSE; return false;
// //
// A choice/combobox normally has a white background (or other, depending // A choice/combobox normally has a white background (or other, depending
@@ -102,7 +106,7 @@ bool wxChoice::Create(
,rSize.y ,rSize.y
); );
delete pTextFont; delete pTextFont;
return TRUE; return true;
} // end of wxChoice::Create } // end of wxChoice::Create
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -419,7 +423,7 @@ bool wxChoice::OS2Command(
// //
// "selection changed" is the only event we're after // "selection changed" is the only event we're after
// //
return FALSE; return false;
} }
int n = GetSelection(); int n = GetSelection();
@@ -438,7 +442,7 @@ bool wxChoice::OS2Command(
vEvent.SetClientData(GetClientData(n)); vEvent.SetClientData(GetClientData(n));
ProcessCommand(vEvent); ProcessCommand(vEvent);
} }
return TRUE; return true;
} // end of wxChoice::OS2Command } // end of wxChoice::OS2Command
void wxChoice::Free() void wxChoice::Free()
@@ -452,4 +456,6 @@ void wxChoice::Free()
delete GetClientObject(n); delete GetClientObject(n);
} }
} }
} // end of wxhoice::Free } // end of wxChoice::Free
#endif // wxUSE_CHOICE

View File

@@ -23,6 +23,8 @@
#include <wx/scrolwin.h> #include <wx/scrolwin.h>
#endif #endif
#if wxUSE_SLIDER
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/os2/private.h" #include "wx/os2/private.h"
@@ -460,7 +462,7 @@ bool wxSlider::Create(
,(PVOID)&lColor ,(PVOID)&lColor
); );
SetValue(nValue); SetValue(nValue);
return TRUE; return true;
} // end of wxSlider::Create } // end of wxSlider::Create
void wxSlider::DoSetSize( void wxSlider::DoSetSize(
@@ -941,7 +943,7 @@ bool wxSlider::OS2OnScroll(
break; break;
default: default:
return FALSE; return false;
} }
int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
@@ -970,7 +972,7 @@ bool wxSlider::OS2OnScroll(
// //
// Out of range - but we did process it // Out of range - but we did process it
// //
return TRUE; return true;
} }
SetValue(nNewPos); SetValue(nNewPos);
@@ -1168,6 +1170,7 @@ bool wxSlider::Show(
::WinShowWindow((HWND)m_hStaticMin, bShow); ::WinShowWindow((HWND)m_hStaticMin, bShow);
if(m_hStaticMax) if(m_hStaticMax)
::WinShowWindow((HWND)m_hStaticMax, bShow); ::WinShowWindow((HWND)m_hStaticMax, bShow);
return TRUE; return true;
} // end of wxSlider::Show } // end of wxSlider::Show
#endif // wxUSE_SLIDER

View File

@@ -31,7 +31,7 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#if wxUSE_SPINBTN #if wxUSE_SPINCTRL
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
#include "wx/os2/private.h" #include "wx/os2/private.h"
@@ -50,7 +50,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton) BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton)
EVT_CHAR(wxSpinCtrl::OnChar) EVT_CHAR(wxSpinCtrl::OnChar)
EVT_SPIN(-1, wxSpinCtrl::OnSpinChange) EVT_SPIN(wxID_ANY, wxSpinCtrl::OnSpinChange)
EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus) EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus)
END_EVENT_TABLE() END_EVENT_TABLE()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -132,7 +132,7 @@ bool wxSpinCtrl::Create(
{ {
SWP vSwp; SWP vSwp;
if (vId == -1) if (vId == wxID_ANY)
m_windowId = NewControlId(); m_windowId = NewControlId();
else else
m_windowId = vId; m_windowId = vId;
@@ -174,7 +174,7 @@ bool wxSpinCtrl::Create(
); );
if (m_hWnd == 0) if (m_hWnd == 0)
{ {
return FALSE; return false;
} }
m_hWndBuddy = m_hWnd; // One in the same for OS/2 m_hWndBuddy = m_hWnd; // One in the same for OS/2
if(pParent) if(pParent)
@@ -207,7 +207,7 @@ bool wxSpinCtrl::Create(
fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc); fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc);
m_svAllSpins.Add(this); m_svAllSpins.Add(this);
delete pTextFont; delete pTextFont;
return TRUE; return true;
} // end of wxSpinCtrl::Create } // end of wxSpinCtrl::Create
wxSize wxSpinCtrl::DoGetBestSize() const wxSize wxSpinCtrl::DoGetBestSize() const
@@ -301,10 +301,10 @@ bool wxSpinCtrl::Enable(
{ {
if (!wxControl::Enable(bEnable)) if (!wxControl::Enable(bEnable))
{ {
return FALSE; return false;
} }
::WinEnableWindow(GetHwnd(), bEnable); ::WinEnableWindow(GetHwnd(), bEnable);
return TRUE; return true;
} // end of wxSpinCtrl::Enable } // end of wxSpinCtrl::Enable
wxSpinCtrl* wxSpinCtrl::GetSpinForTextCtrl( wxSpinCtrl* wxSpinCtrl::GetSpinForTextCtrl(
@@ -455,7 +455,7 @@ bool wxSpinCtrl::ProcessTextCommand(
// //
// Not processed // Not processed
// //
return FALSE; return false;
} // end of wxSpinCtrl::ProcessTextCommand } // end of wxSpinCtrl::ProcessTextCommand
void wxSpinCtrl::SetFocus() void wxSpinCtrl::SetFocus()
@@ -470,13 +470,13 @@ bool wxSpinCtrl::SetFont(
if (!wxWindowBase::SetFont(rFont)) if (!wxWindowBase::SetFont(rFont))
{ {
// nothing to do // nothing to do
return FALSE; return false;
} }
wxOS2SetFont( m_hWnd wxOS2SetFont( m_hWnd
,rFont ,rFont
); );
return TRUE; return true;
} // end of wxSpinCtrl::SetFont } // end of wxSpinCtrl::SetFont
void wxSpinCtrl::SetValue( void wxSpinCtrl::SetValue(
@@ -495,9 +495,9 @@ bool wxSpinCtrl::Show(
{ {
if (!wxControl::Show(bShow)) if (!wxControl::Show(bShow))
{ {
return FALSE; return false;
} }
return TRUE; return true;
} // end of wxSpinCtrl::Show } // end of wxSpinCtrl::Show
void wxSpinCtrl::SetSelection ( void wxSpinCtrl::SetSelection (
@@ -516,4 +516,4 @@ void wxSpinCtrl::SetSelection (
::WinSendMsg(m_hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), (MPARAM)0); ::WinSendMsg(m_hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), (MPARAM)0);
} // end of wxSpinCtrl::SetSelection } // end of wxSpinCtrl::SetSelection
#endif //wxUSE_SPINBTN #endif //wxUSE_SPINCTRL