From 4b26b60fac70f89cf33935f78469e27536d8b614 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 7 Jun 2003 20:58:38 +0000 Subject: [PATCH] MacHandleControlClick extended by mouseStillDown state for supporting things like THUMBRELEASE git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/button.cpp | 2 +- src/mac/carbon/button.cpp | 2 +- src/mac/carbon/checkbox.cpp | 2 +- src/mac/carbon/choice.cpp | 2 +- src/mac/carbon/control.cpp | 16 +++++++++------- src/mac/carbon/listbox.cpp | 2 +- src/mac/carbon/notebmac.cpp | 2 +- src/mac/carbon/radiobut.cpp | 2 +- src/mac/carbon/scrolbar.cpp | 11 +++++++++-- src/mac/carbon/slider.cpp | 2 +- src/mac/carbon/spinbutt.cpp | 2 +- src/mac/carbon/toolbar.cpp | 12 ++++-------- src/mac/checkbox.cpp | 2 +- src/mac/choice.cpp | 2 +- src/mac/control.cpp | 16 +++++++++------- src/mac/listbox.cpp | 2 +- src/mac/notebmac.cpp | 2 +- src/mac/radiobut.cpp | 2 +- src/mac/scrolbar.cpp | 11 +++++++++-- src/mac/slider.cpp | 2 +- src/mac/spinbutt.cpp | 2 +- src/mac/toolbar.cpp | 12 ++++-------- 22 files changed, 60 insertions(+), 50 deletions(-) diff --git a/src/mac/button.cpp b/src/mac/button.cpp index 49c0586734..aaf91f644e 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -117,7 +117,7 @@ void wxButton::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart ) +void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) ) { if ( controlpart != kControlNoPart ) { diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index 49c0586734..aaf91f644e 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -117,7 +117,7 @@ void wxButton::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart ) +void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) ) { if ( controlpart != kControlNoPart ) { diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index f1bc26ccc6..cb43f117af 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -61,7 +61,7 @@ void wxCheckBox::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) ) +void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) ) { SetValue( !GetValue() ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 83e91dbfab..86d75eb0da 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -207,7 +207,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const return (wxClientData *)DoGetItemClientData(n); } -void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); int n = GetSelection(); diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index f0dc6ee7a4..35cefcfa72 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -78,7 +78,7 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod wxControl* wx = (wxControl*) GetControlReference( control ) ; if ( wx ) { - wx->MacHandleControlClick( control , partCode ) ; + wx->MacHandleControlClick( control , partCode , true /* stillDown */ ) ; } } } @@ -365,7 +365,11 @@ void wxControl::MacPostControlCreate() { ControlFontStyleRec controlstyle ; controlstyle.flags = kControlUseFontMask ; - controlstyle.font = kControlFontSmallSystemFont ; + + if (IsKindOf( CLASSINFO( wxButton ) ) ) + controlstyle.font = kControlFontSmallSystemFont ; // eventually kControlFontBigSystemFont ; + else + controlstyle.font = kControlFontSmallSystemFont ; ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; } @@ -871,11 +875,9 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) { controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; wxTheApp->s_lastMouseDown = 0 ; - if ( control && controlpart != kControlNoPart && - ! IsKindOf( CLASSINFO( wxScrollBar ) ) - ) // otherwise we will get the event twice for scrollbar + if ( control && controlpart != kControlNoPart ) { - MacHandleControlClick( control , controlpart ) ; + MacHandleControlClick( control , controlpart , false /* mouse not down anymore */ ) ; } } } @@ -895,7 +897,7 @@ bool wxControl::MacCanFocus() const return false ; } -void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 0cc15e774f..9daaf275e8 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -823,7 +823,7 @@ void wxListBox::OnSize( const wxSizeEvent &event) LCellSize( pt , (ListHandle)m_macList ) ; } -void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { Boolean wasDoubleClick = false ; long result ; diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index e620bc017b..4e8a87a9b4 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -634,7 +634,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) } -void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { #if 0 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 46014e4576..45c734c58b 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -97,7 +97,7 @@ void wxRadioButton::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { if ( GetValue() ) return ; diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index ad843c3fd9..eef2a84c54 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -105,7 +105,7 @@ void wxScrollBar::Command(wxCommandEvent& event) ProcessCommand(event); } -void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) { if ( (ControlHandle) m_macControl == NULL ) return ; @@ -117,6 +117,10 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxEventType scrollEvent = wxEVT_NULL; int nScrollInc; + // all events have already been reported during mouse down, except for THUMBRELEASE + if ( !mouseStillDown && controlpart !=kControlIndicatorPart ) + return ; + switch( controlpart ) { case kControlUpButtonPart : @@ -137,7 +141,10 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart break ; case kControlIndicatorPart : nScrollInc = 0 ; - scrollEvent = wxEVT_SCROLL_THUMBTRACK; + if ( mouseStillDown ) + scrollEvent = wxEVT_SCROLL_THUMBTRACK; + else + scrollEvent = wxEVT_SCROLL_THUMBRELEASE; break ; default : wxFAIL_MSG(wxT("illegal scrollbar selector")); diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index 87d4e58609..94c90786e5 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -238,7 +238,7 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool WXUNUSED(mouseStillDown) ) { SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 0f4faca578..57a2a4a0d7 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -147,7 +147,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) } } -void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { if ( (ControlHandle) m_macControl == NULL ) return ; diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 55a05b287b..5820490844 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -390,7 +390,7 @@ wxSize wxToolBar::GetToolSize() const return wxSize(m_defaultWidth + 4, m_defaultHeight + 4); } -void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { wxToolBarToolsList::Node *node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) @@ -602,15 +602,11 @@ void wxToolBar::OnMouse( wxMouseEvent &event ) if ( control && ::IsControlActive( control ) ) { { - if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() ) - controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ; - else - controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; + controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; wxTheApp->s_lastMouseDown = 0 ; - if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) ) - && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice + if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice { - MacHandleControlClick( control , controlpart ) ; + MacHandleControlClick( control , controlpart , false /* not down anymore */ ) ; } } } diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index f1bc26ccc6..cb43f117af 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -61,7 +61,7 @@ void wxCheckBox::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) ) +void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) ) { SetValue( !GetValue() ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 83e91dbfab..86d75eb0da 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -207,7 +207,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const return (wxClientData *)DoGetItemClientData(n); } -void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); int n = GetSelection(); diff --git a/src/mac/control.cpp b/src/mac/control.cpp index f0dc6ee7a4..35cefcfa72 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -78,7 +78,7 @@ pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCod wxControl* wx = (wxControl*) GetControlReference( control ) ; if ( wx ) { - wx->MacHandleControlClick( control , partCode ) ; + wx->MacHandleControlClick( control , partCode , true /* stillDown */ ) ; } } } @@ -365,7 +365,11 @@ void wxControl::MacPostControlCreate() { ControlFontStyleRec controlstyle ; controlstyle.flags = kControlUseFontMask ; - controlstyle.font = kControlFontSmallSystemFont ; + + if (IsKindOf( CLASSINFO( wxButton ) ) ) + controlstyle.font = kControlFontSmallSystemFont ; // eventually kControlFontBigSystemFont ; + else + controlstyle.font = kControlFontSmallSystemFont ; ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; } @@ -871,11 +875,9 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) { controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; wxTheApp->s_lastMouseDown = 0 ; - if ( control && controlpart != kControlNoPart && - ! IsKindOf( CLASSINFO( wxScrollBar ) ) - ) // otherwise we will get the event twice for scrollbar + if ( control && controlpart != kControlNoPart ) { - MacHandleControlClick( control , controlpart ) ; + MacHandleControlClick( control , controlpart , false /* mouse not down anymore */ ) ; } } } @@ -895,7 +897,7 @@ bool wxControl::MacCanFocus() const return false ; } -void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; } diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 0cc15e774f..9daaf275e8 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -823,7 +823,7 @@ void wxListBox::OnSize( const wxSizeEvent &event) LCellSize( pt , (ListHandle)m_macList ) ; } -void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { Boolean wasDoubleClick = false ; long result ; diff --git a/src/mac/notebmac.cpp b/src/mac/notebmac.cpp index e620bc017b..4e8a87a9b4 100644 --- a/src/mac/notebmac.cpp +++ b/src/mac/notebmac.cpp @@ -634,7 +634,7 @@ void wxNotebook::OnMouse( wxMouseEvent &event ) } -void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { #if 0 wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index 46014e4576..45c734c58b 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -97,7 +97,7 @@ void wxRadioButton::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { if ( GetValue() ) return ; diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index ad843c3fd9..eef2a84c54 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -105,7 +105,7 @@ void wxScrollBar::Command(wxCommandEvent& event) ProcessCommand(event); } -void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) { if ( (ControlHandle) m_macControl == NULL ) return ; @@ -117,6 +117,10 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxEventType scrollEvent = wxEVT_NULL; int nScrollInc; + // all events have already been reported during mouse down, except for THUMBRELEASE + if ( !mouseStillDown && controlpart !=kControlIndicatorPart ) + return ; + switch( controlpart ) { case kControlUpButtonPart : @@ -137,7 +141,10 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart break ; case kControlIndicatorPart : nScrollInc = 0 ; - scrollEvent = wxEVT_SCROLL_THUMBTRACK; + if ( mouseStillDown ) + scrollEvent = wxEVT_SCROLL_THUMBTRACK; + else + scrollEvent = wxEVT_SCROLL_THUMBRELEASE; break ; default : wxFAIL_MSG(wxT("illegal scrollbar selector")); diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index 87d4e58609..94c90786e5 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -238,7 +238,7 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool WXUNUSED(mouseStillDown) ) { SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index 0f4faca578..57a2a4a0d7 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -147,7 +147,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) } } -void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { if ( (ControlHandle) m_macControl == NULL ) return ; diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 55a05b287b..5820490844 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -390,7 +390,7 @@ wxSize wxToolBar::GetToolSize() const return wxSize(m_defaultWidth + 4, m_defaultHeight + 4); } -void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) { wxToolBarToolsList::Node *node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) @@ -602,15 +602,11 @@ void wxToolBar::OnMouse( wxMouseEvent &event ) if ( control && ::IsControlActive( control ) ) { { - if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() ) - controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ; - else - controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; + controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; wxTheApp->s_lastMouseDown = 0 ; - if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) ) - && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice + if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice { - MacHandleControlClick( control , controlpart ) ; + MacHandleControlClick( control , controlpart , false /* not down anymore */ ) ; } } } -- 2.45.2