bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) ) { bool sendEvent = true; wxCheckBoxState newState = Get3StateValue(); if ( !GetPeer()->ButtonClickDidStateChange() ) { wxCheckBoxState origState ; origState = Get3StateValue(); switch (origState) { case wxCHK_UNCHECKED: newState = wxCHK_CHECKED; break; case wxCHK_CHECKED: // If the style flag to allow the user setting the undetermined state is set, // then set the state to undetermined; otherwise set state to unchecked. newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED; break; case wxCHK_UNDETERMINED: newState = wxCHK_UNCHECKED; break; 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) { wxCommandEvent event( wxEVT_CHECKBOX, m_windowId ); event.SetInt( newState ); event.SetEventObject( this ); ProcessCommand( event ); } return true; }
void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) ) { wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); wxCheckBoxState state = Get3StateValue(); if (state == wxCHK_UNCHECKED) { state = wxCHK_CHECKED; } else if (state == wxCHK_CHECKED) { // If the style flag to allow the user setting the undetermined state // is set, then set the state to undetermined. Otherwise set state to // unchecked. if ( Is3rdStateAllowedForUser() ) { state = wxCHK_UNDETERMINED; } else { state = wxCHK_UNCHECKED; } } else if (state == wxCHK_UNDETERMINED) { state = wxCHK_UNCHECKED; } Set3StateValue(state); event.SetInt(state); event.SetEventObject(this); ProcessCommand(event); }
bool wxCheckBox::MSWCommand(WXUINT cmd, WXWORD WXUNUSED(id)) { if ( cmd != BN_CLICKED && cmd != BN_DBLCLK ) return false; // first update the value so that user event handler gets the new checkbox // value // ownerdrawn buttons don't manage their state themselves unlike usual // auto checkboxes so do it ourselves in any case wxCheckBoxState state; if ( Is3rdStateAllowedForUser() ) { state = (wxCheckBoxState)((m_state + 1) % 3); } else // 2 state checkbox (at least from users point of view) { // note that wxCHK_UNDETERMINED also becomes unchecked when clicked state = m_state == wxCHK_UNCHECKED ? wxCHK_CHECKED : wxCHK_UNCHECKED; } DoSet3StateValue(state); // generate the event wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId); event.SetInt(state); event.SetEventObject(this); ProcessCommand(event); return true; }
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { Init(); if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; long msStyle = WS_TABSTOP; if ( style & wxCHK_3STATE ) { msStyle |= BS_3STATE; } else { wxASSERT_MSG( !Is3rdStateAllowedForUser(), wxT("Using wxCH_ALLOW_3RD_STATE_FOR_USER") wxT(" style flag for a 2-state checkbox is useless") ); msStyle |= BS_CHECKBOX; } if ( style & wxALIGN_RIGHT ) { msStyle |= BS_LEFTTEXT | BS_RIGHT; } return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0); }
wxInt32 wxCheckBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); wxCheckBoxState state = Get3StateValue(); if (state == wxCHK_UNCHECKED) { state = wxCHK_CHECKED; } else if (state == wxCHK_CHECKED) { // If the style flag to allow the user setting the undetermined state // is set, then set the state to undetermined. Otherwise set state to // unchecked. if ( Is3rdStateAllowedForUser() ) { state = wxCHK_UNDETERMINED; } else { state = wxCHK_UNCHECKED; } } else if (state == wxCHK_UNDETERMINED) { state = wxCHK_UNCHECKED; } Set3StateValue(state); event.SetInt(state); event.SetEventObject(this); ProcessCommand(event); return noErr ; }
bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) ) { bool sendEvent = true; wxCheckBoxState newState = Get3StateValue(); if ( !m_peer->ButtonClickDidStateChange() ) { wxCheckBoxState origState ; newState = origState = Get3StateValue(); switch (origState) { case wxCHK_UNCHECKED: newState = wxCHK_CHECKED; break; case wxCHK_CHECKED: // If the style flag to allow the user setting the undetermined state is set, // then set the state to undetermined; otherwise set state to unchecked. newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED; break; case wxCHK_UNDETERMINED: newState = wxCHK_UNCHECKED; break; default: break; } if (newState == origState) sendEvent = false; } if (sendEvent) { Set3StateValue( newState ); wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); event.SetInt( newState ); event.SetEventObject( this ); ProcessCommand( event ); } return true; }
wxInt32 wxCheckBox::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { wxCheckBoxState origState, newState; newState = origState = Get3StateValue(); switch (origState) { case wxCHK_UNCHECKED: newState = wxCHK_CHECKED; break; case wxCHK_CHECKED: // If the style flag to allow the user setting the undetermined state is set, // then set the state to undetermined; otherwise set state to unchecked. newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED; break; case wxCHK_UNDETERMINED: newState = wxCHK_UNCHECKED; break; default: break; } if (newState != origState) { Set3StateValue( newState ); wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); event.SetInt( newState ); event.SetEventObject( this ); ProcessCommand( event ); } return noErr; }