From 467e3168b33200bf6d62317294799363ed7dd50e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 13 Aug 2002 08:50:41 +0000 Subject: [PATCH] all controls use 32 bit values now git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16479 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/aga.cpp | 14 ++++----- src/mac/carbon/aga.cpp | 14 ++++----- src/mac/carbon/checkbox.cpp | 4 +-- src/mac/carbon/choice.cpp | 16 +++++------ src/mac/carbon/gauge.cpp | 4 +-- src/mac/carbon/notebmac.cpp | 10 +++---- src/mac/carbon/radiobut.cpp | 6 ++-- src/mac/carbon/scrolbar.cpp | 16 +++++------ src/mac/carbon/slider.cpp | 10 +++---- src/mac/carbon/spinbutt.cpp | 6 ++-- src/mac/carbon/toolbar.cpp | 8 +++--- src/mac/carbon/window.cpp | 57 +++++++++++++++++++++++++++++++++---- src/mac/checkbox.cpp | 4 +-- src/mac/choice.cpp | 16 +++++------ src/mac/gauge.cpp | 4 +-- src/mac/notebmac.cpp | 10 +++---- src/mac/radiobut.cpp | 6 ++-- src/mac/scrolbar.cpp | 16 +++++------ src/mac/slider.cpp | 10 +++---- src/mac/spinbutt.cpp | 6 ++-- src/mac/toolbar.cpp | 8 +++--- src/mac/window.cpp | 57 +++++++++++++++++++++++++++++++++---- 22 files changed, 198 insertions(+), 104 deletions(-) diff --git a/src/mac/aga.cpp b/src/mac/aga.cpp index 4f4f139e87..3052728ea7 100644 --- a/src/mac/aga.cpp +++ b/src/mac/aga.cpp @@ -955,9 +955,9 @@ pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, Co GetForeColor( &oldForeColor ) ; { - int theValue = GetControlValue(theControl) ; - int theMinimum = GetControlMinimum(theControl) ; - int theMaximum = GetControlMaximum(theControl) ; + int theValue = GetControl32BitValue(theControl) ; + int theMinimum = GetControl32BitMinimum(theControl) ; + int theMaximum = GetControl32BitMaximum(theControl) ; AGADrawRectProgress( &(**theControl).contrlRect , kAGAStateEnabled , (( double )( theValue - theMinimum )) / ( theMaximum-theMinimum ) ) ; } @@ -1052,7 +1052,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co AGASetFontStyle( &info->fontStyle ) ; Boolean mRadioBehavior = false ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; long theValue = (mRadioBehavior ? mValue : 0); Boolean inPushed = (**theControl).contrlHilite ; Boolean down = inPushed || (theValue != 0); @@ -1193,7 +1193,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control Boolean mRadioBehavior = false ; Rect frame, tempRect; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; long theValue = (mRadioBehavior ? mValue : 0); Boolean inPushed = (**theControl).contrlHilite ; Boolean down = inPushed || (theValue != 0); @@ -1429,7 +1429,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr Rect frame = (**theControl).contrlRect ; Boolean hasColor = true; Boolean disabled = (*theControl)->contrlHilite == 255 ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; Boolean inPushed = (**theControl).contrlHilite ; int mEnabled = 1 ; int triState_Off = 3 ; @@ -1625,7 +1625,7 @@ pascal SInt32 AGARadioButtonDefProc (SInt16 procID, ControlHandle theControl, Co Rect frame = (**theControl).contrlRect ; Boolean hasColor = true; Boolean disabled = (*theControl)->contrlHilite == 255 ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; Boolean inPushed = (**theControl).contrlHilite ; int mEnabled = 1 ; int triState_Off = 3 ; diff --git a/src/mac/carbon/aga.cpp b/src/mac/carbon/aga.cpp index 4f4f139e87..3052728ea7 100644 --- a/src/mac/carbon/aga.cpp +++ b/src/mac/carbon/aga.cpp @@ -955,9 +955,9 @@ pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, Co GetForeColor( &oldForeColor ) ; { - int theValue = GetControlValue(theControl) ; - int theMinimum = GetControlMinimum(theControl) ; - int theMaximum = GetControlMaximum(theControl) ; + int theValue = GetControl32BitValue(theControl) ; + int theMinimum = GetControl32BitMinimum(theControl) ; + int theMaximum = GetControl32BitMaximum(theControl) ; AGADrawRectProgress( &(**theControl).contrlRect , kAGAStateEnabled , (( double )( theValue - theMinimum )) / ( theMaximum-theMinimum ) ) ; } @@ -1052,7 +1052,7 @@ pascal SInt32 AGABevelButtonDefProc (SInt16 procID, ControlHandle theControl, Co AGASetFontStyle( &info->fontStyle ) ; Boolean mRadioBehavior = false ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; long theValue = (mRadioBehavior ? mValue : 0); Boolean inPushed = (**theControl).contrlHilite ; Boolean down = inPushed || (theValue != 0); @@ -1193,7 +1193,7 @@ pascal SInt32 AGAButtonDefProc (SInt16 procID, ControlHandle theControl, Control Boolean mRadioBehavior = false ; Rect frame, tempRect; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; long theValue = (mRadioBehavior ? mValue : 0); Boolean inPushed = (**theControl).contrlHilite ; Boolean down = inPushed || (theValue != 0); @@ -1429,7 +1429,7 @@ pascal SInt32 AGACheckBoxDefProc (SInt16 procID, ControlHandle theControl, Contr Rect frame = (**theControl).contrlRect ; Boolean hasColor = true; Boolean disabled = (*theControl)->contrlHilite == 255 ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; Boolean inPushed = (**theControl).contrlHilite ; int mEnabled = 1 ; int triState_Off = 3 ; @@ -1625,7 +1625,7 @@ pascal SInt32 AGARadioButtonDefProc (SInt16 procID, ControlHandle theControl, Co Rect frame = (**theControl).contrlRect ; Boolean hasColor = true; Boolean disabled = (*theControl)->contrlHilite == 255 ; - int mValue = GetControlValue( theControl ) ; + int mValue = GetControl32BitValue( theControl ) ; Boolean inPushed = (**theControl).contrlHilite ; int mEnabled = 1 ; int triState_Off = 3 ; diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index 94c9c92b2f..b595c99c7a 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -46,13 +46,13 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxCheckBox::SetValue(bool val) { - ::SetControlValue( (ControlHandle) m_macControl , val ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; MacRedrawControl() ; } bool wxCheckBox::GetValue() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxCheckBox::Command (wxCommandEvent & event) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 072badfdd2..a88ecc17a1 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -50,10 +50,10 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, m_macPopUpMenuHandle = NewUniqueMenu() ; SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; - SetControlMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControlMaximum( (ControlHandle) m_macControl , 0) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; if ( n > 0 ) - SetControlValue( (ControlHandle) m_macControl , 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; MacPostControlCreate() ; @@ -77,7 +77,7 @@ int wxChoice::DoAppend(const wxString& item) m_datas.Add( NULL ) ; int index = m_strings.GetCount() - 1 ; DoSetItemClientData( index , NULL ) ; - SetControlMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; return index ; } @@ -93,7 +93,7 @@ void wxChoice::Delete(int n) ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; m_strings.Remove( n ) ; m_datas.RemoveAt( n ) ; - SetControlMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; } void wxChoice::Clear() @@ -106,7 +106,7 @@ void wxChoice::Clear() } m_strings.Empty() ; m_datas.Empty() ; - SetControlMaximum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ; } void wxChoice::FreeData() @@ -127,12 +127,12 @@ void wxChoice::FreeData() int wxChoice::GetSelection() const { - return GetControlValue( (ControlHandle) m_macControl ) -1 ; + return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ; } void wxChoice::SetSelection(int n) { - SetControlValue( (ControlHandle) m_macControl , n + 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index adc5110236..b367d44393 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -61,13 +61,13 @@ void wxGauge::SetBezelFace(int w) void wxGauge::SetRange(int r) { m_rangeMax = r; - ::SetControlMaximum( (ControlHandle) m_macControl , m_rangeMax ) ; + ::SetControl32BitMaximum( (ControlHandle) m_macControl , m_rangeMax ) ; } void wxGauge::SetValue(int pos) { m_gaugePos = pos; - ::SetControlValue( (ControlHandle) m_macControl , m_gaugePos ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index 81ca5ebce6..7c72298654 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -205,7 +205,7 @@ int wxNotebook::SetSelection(int nPage) return m_nSelection ; ChangePage(m_nSelection, nPage); - SetControlValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; return m_nSelection; } @@ -328,7 +328,7 @@ bool wxNotebook::InsertPage(int nPage, */ void wxNotebook::MacSetupTabs() { - SetControlMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; wxNotebookPage *page; ControlTabInfoRec info; @@ -518,7 +518,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) { { wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, - ::GetControlValue(control) - 1, m_nSelection); + ::GetControl32BitValue(control) - 1, m_nSelection); changing.SetEventObject(this); ProcessEvent(changing); @@ -529,7 +529,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) wxTheApp->s_lastMouseDown = 0 ; wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, - ::GetControlValue(control) - 1, m_nSelection); + ::GetControl32BitValue(control) - 1, m_nSelection); event.SetEventObject(this); ProcessEvent(event); @@ -543,7 +543,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { #if 0 - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue((ControlHandle)m_macControl) - 1, m_nSelection); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); event.SetEventObject(this); ProcessEvent(event); diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 7fcaaf579d..e94c762f1d 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -69,10 +69,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, void wxRadioButton::SetValue(bool val) { wxRadioButton *cycle; - if ( GetControlValue( (ControlHandle) m_macControl ) == val ) + if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) return ; - ::SetControlValue( (ControlHandle) m_macControl , val ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; if (val) { cycle=this->NextInCycle(); @@ -88,7 +88,7 @@ void wxRadioButton::SetValue(bool val) bool wxRadioButton::GetValue() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxRadioButton::Command (wxCommandEvent & event) diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index 49dc3aeca2..075c1efc8a 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -61,12 +61,12 @@ wxScrollBar::~wxScrollBar() void wxScrollBar::SetThumbPosition(int viewStart) { - ::SetControlValue( (ControlHandle) m_macControl , viewStart ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , viewStart ) ; } int wxScrollBar::GetThumbPosition() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, @@ -78,9 +78,9 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS int range1 = wxMax((m_objectSize - m_viewSize), 0) ; - SetControlMaximum( (ControlHandle) m_macControl , range1 ) ; - SetControlMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControlValue( (ControlHandle) m_macControl , position ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , position ) ; if ( UMAGetAppearanceVersion() >= 0x0110 ) { @@ -105,9 +105,9 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart if ( (ControlHandle) m_macControl == NULL ) return ; - int position = GetControlValue( (ControlHandle) m_macControl) ; - int minPos = GetControlMinimum( (ControlHandle) m_macControl) ; - int maxPos = GetControlMaximum( (ControlHandle) m_macControl) ; + int position = GetControl32BitValue( (ControlHandle) m_macControl) ; + int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; + int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; wxEventType scrollEvent = wxEVT_NULL; int nScrollInc; diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index 8dcae35279..aa4e68609a 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -127,7 +127,7 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - return GetControlValue( (ControlHandle) m_macControl) ; + return GetControl32BitValue( (ControlHandle) m_macControl) ; } void wxSlider::SetValue(int value) @@ -136,7 +136,7 @@ void wxSlider::SetValue(int value) valuestring.Printf( "%d" , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; - SetControlValue( (ControlHandle) m_macControl , value ) ; + SetControl32BitValue( (ControlHandle) m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) @@ -146,8 +146,8 @@ void wxSlider::SetRange(int minValue, int maxValue) m_rangeMin = minValue; m_rangeMax = maxValue; - SetControlMinimum( (ControlHandle) m_macControl, m_rangeMin); - SetControlMaximum( (ControlHandle) m_macControl, m_rangeMax); + SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); + SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); if(m_macMinimumStatic) { value.Printf("%d", m_rangeMin); @@ -241,7 +241,7 @@ void wxSlider::Command (wxCommandEvent & event) void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - SInt16 value = ::GetControlValue( (ControlHandle) m_macControl ) ; + SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; SetValue( value ) ; diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index fd9d5d4e47..08151678ac 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -90,8 +90,8 @@ void wxSpinButton::SetRange(int minVal, int maxVal) { m_min = minVal; m_max = maxVal; - SetControlMaximum( (ControlHandle) m_macControl , maxVal ) ; - SetControlMinimum((ControlHandle) m_macControl , minVal ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ; + SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ; } void wxSpinButton::MacHandleValueChanged( int inc ) @@ -134,7 +134,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) { m_value = oldValue ; } - SetControlValue( (ControlHandle) m_macControl , m_value ) ; + SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 7c6fa528d5..07c86add46 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -240,11 +240,11 @@ bool wxToolBar::Realize() } if ( tool->CanBeToggled() && tool->IsToggled() ) { - ::SetControlValue( m_macToolHandle , 1 ) ; + ::SetControl32BitValue( m_macToolHandle , 1 ) ; } else { - ::SetControlValue( m_macToolHandle , 0 ) ; + ::SetControl32BitValue( m_macToolHandle , 0 ) ; } /* ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ; @@ -336,7 +336,7 @@ void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data(); if ( tool->CanBeToggled() ) { - tool->Toggle( GetControlValue( (ControlHandle) control ) ) ; + tool->Toggle( GetControl32BitValue( (ControlHandle) control ) ) ; } OnLeftClick( tool->GetId() , tool -> IsToggled() ) ; break ; @@ -533,7 +533,7 @@ void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) return ; ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ; - ::SetControlValue( control , toggle ) ; + ::SetControl32BitValue( control , toggle ) ; } bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 471c87c462..8e269242e8 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -37,6 +37,7 @@ #include "wx/menuitem.h" #include "wx/spinctrl.h" #include "wx/log.h" +#include "wx/geometry.h" #if wxUSE_CARET #include "wx/caret.h" @@ -1434,6 +1435,48 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa extern int wxBusyCursorCount ; static wxWindow *gs_lastWhich = NULL; +bool wxWindowMac::MacSetupCursor( const wxPoint& pt) +{ + // first trigger a set cursor event + + wxPoint clientorigin = GetClientAreaOrigin() ; + wxSize clientsize = GetClientSize() ; + wxCursor cursor ; + if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) + { + wxSetCursorEvent event( pt.x , pt.y ); + + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); + if ( processedEvtSetCursor && event.HasCursor() ) + { + cursor = event.GetCursor() ; + } + else + { + + // the test for processedEvtSetCursor is here to prevent using m_cursor + // if the user code caught EVT_SET_CURSOR() and returned nothing from + // it - this is a way to say that our cursor shouldn't be used for this + // point + if ( !processedEvtSetCursor && m_cursor.Ok() ) + { + cursor = m_cursor ; + } + if ( wxIsBusy() ) + { + } + else + { + if ( !GetParent() ) + cursor = *wxSTANDARD_CURSOR ; + } + } + if ( cursor.Ok() ) + cursor.MacInstall() ; + } + return cursor.Ok() ; +} + bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) { if ((event.m_x < m_x) || (event.m_y < m_y) || @@ -1462,14 +1505,18 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) } } - event.m_x = x ; - event.m_y = y ; - event.SetEventObject( this ) ; + wxWindow* cursorTarget = this ; + wxPoint cursorPoint( x , y ) ; - if ( wxBusyCursorCount == 0 ) + while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) { - m_cursor.MacInstall() ; + cursorTarget = cursorTarget->GetParent() ; + if ( cursorTarget ) + cursorPoint += cursorTarget->GetPosition() ; } + event.m_x = x ; + event.m_y = y ; + event.SetEventObject( this ) ; if ( event.GetEventType() == wxEVT_LEFT_DOWN ) { diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index 94c9c92b2f..b595c99c7a 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -46,13 +46,13 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxCheckBox::SetValue(bool val) { - ::SetControlValue( (ControlHandle) m_macControl , val ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; MacRedrawControl() ; } bool wxCheckBox::GetValue() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxCheckBox::Command (wxCommandEvent & event) diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 072badfdd2..a88ecc17a1 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -50,10 +50,10 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, m_macPopUpMenuHandle = NewUniqueMenu() ; SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; - SetControlMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControlMaximum( (ControlHandle) m_macControl , 0) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; if ( n > 0 ) - SetControlValue( (ControlHandle) m_macControl , 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; MacPostControlCreate() ; @@ -77,7 +77,7 @@ int wxChoice::DoAppend(const wxString& item) m_datas.Add( NULL ) ; int index = m_strings.GetCount() - 1 ; DoSetItemClientData( index , NULL ) ; - SetControlMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; return index ; } @@ -93,7 +93,7 @@ void wxChoice::Delete(int n) ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; m_strings.Remove( n ) ; m_datas.RemoveAt( n ) ; - SetControlMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; } void wxChoice::Clear() @@ -106,7 +106,7 @@ void wxChoice::Clear() } m_strings.Empty() ; m_datas.Empty() ; - SetControlMaximum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ; } void wxChoice::FreeData() @@ -127,12 +127,12 @@ void wxChoice::FreeData() int wxChoice::GetSelection() const { - return GetControlValue( (ControlHandle) m_macControl ) -1 ; + return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ; } void wxChoice::SetSelection(int n) { - SetControlValue( (ControlHandle) m_macControl , n + 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/gauge.cpp b/src/mac/gauge.cpp index adc5110236..b367d44393 100644 --- a/src/mac/gauge.cpp +++ b/src/mac/gauge.cpp @@ -61,13 +61,13 @@ void wxGauge::SetBezelFace(int w) void wxGauge::SetRange(int r) { m_rangeMax = r; - ::SetControlMaximum( (ControlHandle) m_macControl , m_rangeMax ) ; + ::SetControl32BitMaximum( (ControlHandle) m_macControl , m_rangeMax ) ; } void wxGauge::SetValue(int pos) { m_gaugePos = pos; - ::SetControlValue( (ControlHandle) m_macControl , m_gaugePos ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const diff --git a/src/mac/notebmac.cpp b/src/mac/notebmac.cpp index 81ca5ebce6..7c72298654 100644 --- a/src/mac/notebmac.cpp +++ b/src/mac/notebmac.cpp @@ -205,7 +205,7 @@ int wxNotebook::SetSelection(int nPage) return m_nSelection ; ChangePage(m_nSelection, nPage); - SetControlValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; return m_nSelection; } @@ -328,7 +328,7 @@ bool wxNotebook::InsertPage(int nPage, */ void wxNotebook::MacSetupTabs() { - SetControlMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; wxNotebookPage *page; ControlTabInfoRec info; @@ -518,7 +518,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) { { wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, - ::GetControlValue(control) - 1, m_nSelection); + ::GetControl32BitValue(control) - 1, m_nSelection); changing.SetEventObject(this); ProcessEvent(changing); @@ -529,7 +529,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) wxTheApp->s_lastMouseDown = 0 ; wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, - ::GetControlValue(control) - 1, m_nSelection); + ::GetControl32BitValue(control) - 1, m_nSelection); event.SetEventObject(this); ProcessEvent(event); @@ -543,7 +543,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { #if 0 - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue((ControlHandle)m_macControl) - 1, m_nSelection); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); event.SetEventObject(this); ProcessEvent(event); diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index 7fcaaf579d..e94c762f1d 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -69,10 +69,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, void wxRadioButton::SetValue(bool val) { wxRadioButton *cycle; - if ( GetControlValue( (ControlHandle) m_macControl ) == val ) + if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) return ; - ::SetControlValue( (ControlHandle) m_macControl , val ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; if (val) { cycle=this->NextInCycle(); @@ -88,7 +88,7 @@ void wxRadioButton::SetValue(bool val) bool wxRadioButton::GetValue() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxRadioButton::Command (wxCommandEvent & event) diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index 49dc3aeca2..075c1efc8a 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -61,12 +61,12 @@ wxScrollBar::~wxScrollBar() void wxScrollBar::SetThumbPosition(int viewStart) { - ::SetControlValue( (ControlHandle) m_macControl , viewStart ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , viewStart ) ; } int wxScrollBar::GetThumbPosition() const { - return ::GetControlValue( (ControlHandle) m_macControl ) ; + return ::GetControl32BitValue( (ControlHandle) m_macControl ) ; } void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, @@ -78,9 +78,9 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS int range1 = wxMax((m_objectSize - m_viewSize), 0) ; - SetControlMaximum( (ControlHandle) m_macControl , range1 ) ; - SetControlMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControlValue( (ControlHandle) m_macControl , position ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitValue( (ControlHandle) m_macControl , position ) ; if ( UMAGetAppearanceVersion() >= 0x0110 ) { @@ -105,9 +105,9 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart if ( (ControlHandle) m_macControl == NULL ) return ; - int position = GetControlValue( (ControlHandle) m_macControl) ; - int minPos = GetControlMinimum( (ControlHandle) m_macControl) ; - int maxPos = GetControlMaximum( (ControlHandle) m_macControl) ; + int position = GetControl32BitValue( (ControlHandle) m_macControl) ; + int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; + int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; wxEventType scrollEvent = wxEVT_NULL; int nScrollInc; diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index 8dcae35279..aa4e68609a 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -127,7 +127,7 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - return GetControlValue( (ControlHandle) m_macControl) ; + return GetControl32BitValue( (ControlHandle) m_macControl) ; } void wxSlider::SetValue(int value) @@ -136,7 +136,7 @@ void wxSlider::SetValue(int value) valuestring.Printf( "%d" , value ) ; if ( m_macValueStatic ) m_macValueStatic->SetLabel( valuestring ) ; - SetControlValue( (ControlHandle) m_macControl , value ) ; + SetControl32BitValue( (ControlHandle) m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) @@ -146,8 +146,8 @@ void wxSlider::SetRange(int minValue, int maxValue) m_rangeMin = minValue; m_rangeMax = maxValue; - SetControlMinimum( (ControlHandle) m_macControl, m_rangeMin); - SetControlMaximum( (ControlHandle) m_macControl, m_rangeMax); + SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); + SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); if(m_macMinimumStatic) { value.Printf("%d", m_rangeMin); @@ -241,7 +241,7 @@ void wxSlider::Command (wxCommandEvent & event) void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - SInt16 value = ::GetControlValue( (ControlHandle) m_macControl ) ; + SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; SetValue( value ) ; diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index fd9d5d4e47..08151678ac 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -90,8 +90,8 @@ void wxSpinButton::SetRange(int minVal, int maxVal) { m_min = minVal; m_max = maxVal; - SetControlMaximum( (ControlHandle) m_macControl , maxVal ) ; - SetControlMinimum((ControlHandle) m_macControl , minVal ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ; + SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ; } void wxSpinButton::MacHandleValueChanged( int inc ) @@ -134,7 +134,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) { m_value = oldValue ; } - SetControlValue( (ControlHandle) m_macControl , m_value ) ; + SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 7c6fa528d5..07c86add46 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -240,11 +240,11 @@ bool wxToolBar::Realize() } if ( tool->CanBeToggled() && tool->IsToggled() ) { - ::SetControlValue( m_macToolHandle , 1 ) ; + ::SetControl32BitValue( m_macToolHandle , 1 ) ; } else { - ::SetControlValue( m_macToolHandle , 0 ) ; + ::SetControl32BitValue( m_macToolHandle , 0 ) ; } /* ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ; @@ -336,7 +336,7 @@ void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data(); if ( tool->CanBeToggled() ) { - tool->Toggle( GetControlValue( (ControlHandle) control ) ) ; + tool->Toggle( GetControl32BitValue( (ControlHandle) control ) ) ; } OnLeftClick( tool->GetId() , tool -> IsToggled() ) ; break ; @@ -533,7 +533,7 @@ void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) return ; ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ; - ::SetControlValue( control , toggle ) ; + ::SetControl32BitValue( control , toggle ) ; } bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 471c87c462..8e269242e8 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -37,6 +37,7 @@ #include "wx/menuitem.h" #include "wx/spinctrl.h" #include "wx/log.h" +#include "wx/geometry.h" #if wxUSE_CARET #include "wx/caret.h" @@ -1434,6 +1435,48 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa extern int wxBusyCursorCount ; static wxWindow *gs_lastWhich = NULL; +bool wxWindowMac::MacSetupCursor( const wxPoint& pt) +{ + // first trigger a set cursor event + + wxPoint clientorigin = GetClientAreaOrigin() ; + wxSize clientsize = GetClientSize() ; + wxCursor cursor ; + if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) + { + wxSetCursorEvent event( pt.x , pt.y ); + + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); + if ( processedEvtSetCursor && event.HasCursor() ) + { + cursor = event.GetCursor() ; + } + else + { + + // the test for processedEvtSetCursor is here to prevent using m_cursor + // if the user code caught EVT_SET_CURSOR() and returned nothing from + // it - this is a way to say that our cursor shouldn't be used for this + // point + if ( !processedEvtSetCursor && m_cursor.Ok() ) + { + cursor = m_cursor ; + } + if ( wxIsBusy() ) + { + } + else + { + if ( !GetParent() ) + cursor = *wxSTANDARD_CURSOR ; + } + } + if ( cursor.Ok() ) + cursor.MacInstall() ; + } + return cursor.Ok() ; +} + bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) { if ((event.m_x < m_x) || (event.m_y < m_y) || @@ -1462,14 +1505,18 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) } } - event.m_x = x ; - event.m_y = y ; - event.SetEventObject( this ) ; + wxWindow* cursorTarget = this ; + wxPoint cursorPoint( x , y ) ; - if ( wxBusyCursorCount == 0 ) + while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) { - m_cursor.MacInstall() ; + cursorTarget = cursorTarget->GetParent() ; + if ( cursorTarget ) + cursorPoint += cursorTarget->GetPosition() ; } + event.m_x = x ; + event.m_y = y ; + event.SetEventObject( this ) ; if ( event.GetEventType() == wxEVT_LEFT_DOWN ) { -- 2.45.2