X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f254e2424a5220e559e48205ace1114ea3e87f3f..f363cee882672e147340240cf0bb194a68e37833:/src/osx/checkbox_osx.cpp diff --git a/src/osx/checkbox_osx.cpp b/src/osx/checkbox_osx.cpp index 93cbf2c7bb..6e4d58a680 100644 --- a/src/osx/checkbox_osx.cpp +++ b/src/osx/checkbox_osx.cpp @@ -1,10 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/checkbox.cpp +// Name: src/osx/checkbox_osx.cpp // Purpose: wxCheckBox // Author: Stefan Csomor // Modified by: // Created: 04/01/98 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +15,6 @@ #include "wx/checkbox.h" #include "wx/osx/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) // Single check box item @@ -28,16 +26,16 @@ bool wxCheckBox::Create(wxWindow *parent, long style, const wxValidator& validator, const wxString& name) -{ - m_macIsUserPane = false ; - +{ + DontCreatePeer(); + if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) ) return false; m_labelOrig = m_label = label ; WXValidateStyle( &style ); - m_peer = wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() ) ; + SetPeer(wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() )) ; MacPostControlCreate(pos, size) ; @@ -73,12 +71,12 @@ void wxCheckBox::Command(wxCommandEvent & event) wxCheckBoxState wxCheckBox::DoGet3StateValue() const { - return (wxCheckBoxState)m_peer->GetValue() ; + return (wxCheckBoxState)GetPeer()->GetValue() ; } void wxCheckBox::DoSet3StateValue(wxCheckBoxState val) { - m_peer->SetValue( val ) ; + GetPeer()->SetValue( val ) ; } bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) ) @@ -86,11 +84,11 @@ bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) ) bool sendEvent = true; wxCheckBoxState newState = Get3StateValue(); - if ( !m_peer->ButtonClickDidStateChange() ) + if ( !GetPeer()->ButtonClickDidStateChange() ) { wxCheckBoxState origState ; - newState = origState = Get3StateValue(); + origState = Get3StateValue(); switch (origState) { @@ -111,15 +109,25 @@ bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) ) default: break; } + if (newState == origState) sendEvent = false; + else + Set3StateValue( newState ); } - + else + { + // in case we cannot avoid this user state change natively (eg cocoa) we intercept it here + if ( newState == wxCHK_UNDETERMINED && !Is3rdStateAllowedForUser() ) + { + newState = wxCHK_CHECKED; + Set3StateValue( newState ); + } + } + if (sendEvent) { - Set3StateValue( newState ); - - wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); + wxCommandEvent event( wxEVT_CHECKBOX, m_windowId ); event.SetInt( newState ); event.SetEventObject( this ); ProcessCommand( event );