1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxRadioButton 
   5 // Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox 
   8 // Copyright:   (c) AUTHOR 
   9 // Licence:       wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "radiobut.h" 
  18 #include "wx/radiobut.h" 
  20 #if !USE_SHARED_LIBRARY 
  21 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
) 
  24 #include "wx/mac/uma.h" 
  26 bool wxRadioButton::Create(wxWindow 
*parent
, wxWindowID id
, 
  27            const wxString
& label
, 
  29            const wxSize
& size
, long style
, 
  30            const wxValidator
& validator
, 
  33     if ( !wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
) ) 
  39     MacPreControlCreate( parent 
, id 
,  label 
, pos 
, size 
,style
, validator 
, name 
, &bounds 
, title 
) ; 
  41     m_macControl 
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds 
, title 
, false , 0 , 0 , 1,  
  42           kControlRadioButtonProc 
, (long) this ) ; 
  44     MacPostControlCreate() ; 
  48   if (HasFlag(wxRB_GROUP
)) 
  54     /* search backward for last group start */ 
  55     wxRadioButton 
*chief 
= (wxRadioButton
*) NULL
; 
  56     wxWindowList::Node 
*node 
= parent
->GetChildren().GetLast(); 
  59       wxWindow 
*child 
= node
->GetData(); 
  60       if (child
->IsKindOf( CLASSINFO( wxRadioButton 
) ) ) 
  62           chief 
= (wxRadioButton
*) child
; 
  63          if (child
->HasFlag(wxRB_GROUP
)) break; 
  65       node 
= node
->GetPrevious(); 
  72 void wxRadioButton::SetValue(bool val
) 
  75       if ( GetControl32BitValue( (ControlHandle
) m_macControl 
) == val 
) 
  78    ::SetControl32BitValue( (ControlHandle
) m_macControl 
, val 
) ; 
  81            cycle
=this->NextInCycle(); 
  84                    cycle
->SetValue(false); 
  85                    cycle
=cycle
->NextInCycle(); 
  92 bool wxRadioButton::GetValue() const 
  94     return ::GetControl32BitValue( (ControlHandle
) m_macControl 
) ; 
  97 void wxRadioButton::Command (wxCommandEvent 
& event
) 
  99   SetValue ( (event
.GetInt() != 0) ); 
 100   ProcessCommand (event
); 
 103 void wxRadioButton::MacHandleControlClick( WXWidget control 
, wxInt16 controlpart 
, bool WXUNUSED(mouseStillDown
))  
 108       wxRadioButton 
*cycle
, *old 
= NULL 
; 
 109     cycle
=this->NextInCycle(); 
 111           while (cycle
!=this) { 
 112             if ( cycle
->GetValue() ) { 
 114                 cycle
->SetValue(false); 
 116               cycle
=cycle
->NextInCycle(); 
 123       wxCommandEvent 
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, old
->m_windowId 
); 
 124       event
.SetEventObject(old
); 
 125       event
.SetInt( false ); 
 126       old
->ProcessCommand(event
); 
 128     wxCommandEvent 
event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId 
); 
 129     event2
.SetEventObject(this); 
 130     event2
.SetInt( true ); 
 131     ProcessCommand(event2
); 
 134 wxRadioButton 
*wxRadioButton::AddInCycle(wxRadioButton 
*cycle
) 
 136     wxRadioButton 
*next
,*current
; 
 144           while ((next
=current
->m_cycle
)!=cycle
)  
 145             current
=current
->m_cycle
; 
 147           current
->m_cycle
=this;