1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/mac/classic/radiobut.cpp 
   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 ///////////////////////////////////////////////////////////////////////////// 
  12 #include "wx/wxprec.h" 
  18 #include "wx/radiobut.h" 
  20 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
) 
  22 #include "wx/mac/uma.h" 
  24 bool wxRadioButton::Create(wxWindow 
*parent
, wxWindowID id
, 
  25            const wxString
& label
, 
  27            const wxSize
& size
, long style
, 
  28            const wxValidator
& validator
, 
  31     if ( !wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
) ) 
  37     MacPreControlCreate( parent 
, id 
,  label 
, pos 
, size 
,style
, validator 
, name 
, &bounds 
, title 
) ; 
  39     m_macControl 
= (WXWidget
) ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds 
, title 
, false , 0 , 0 , 1, 
  40           kControlRadioButtonProc 
, (long) this ) ; 
  42     MacPostControlCreate() ; 
  46     if (HasFlag(wxRB_GROUP
)) 
  52         /* search backward for last group start */ 
  53         wxRadioButton 
*chief 
= (wxRadioButton
*) NULL
; 
  54         wxWindowList::Node 
*node 
= parent
->GetChildren().GetLast(); 
  57             wxWindow 
*child 
= node
->GetData(); 
  58             if (child
->IsKindOf( CLASSINFO( wxRadioButton 
) ) ) 
  60                 chief 
= (wxRadioButton
*) child
; 
  61                 if (child
->HasFlag(wxRB_GROUP
)) break; 
  63             node 
= node
->GetPrevious(); 
  70 void wxRadioButton::SetValue(bool val
) 
  73       if ( GetControl32BitValue( (ControlHandle
) m_macControl 
) == val 
) 
  76    ::SetControl32BitValue( (ControlHandle
) m_macControl 
, val 
) ; 
  79            cycle
=this->NextInCycle(); 
  82                    cycle
->SetValue(false); 
  83                    cycle
=cycle
->NextInCycle(); 
  90 bool wxRadioButton::GetValue() const 
  92     return ::GetControl32BitValue( (ControlHandle
) m_macControl 
) ; 
  95 void wxRadioButton::Command (wxCommandEvent 
& event
) 
  97   SetValue ( (event
.GetInt() != 0) ); 
  98   ProcessCommand (event
); 
 101 void wxRadioButton::MacHandleControlClick( WXWidget control 
, wxInt16 controlpart 
, bool WXUNUSED(mouseStillDown
)) 
 106     wxRadioButton 
*cycle
, *old 
= NULL 
; 
 107     cycle
=this->NextInCycle(); 
 109           while (cycle
!=this) { 
 110             if ( cycle
->GetValue() ) { 
 112                 cycle
->SetValue(false); 
 114               cycle
=cycle
->NextInCycle(); 
 121       wxCommandEvent 
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, old
->m_windowId 
); 
 122       event
.SetEventObject(old
); 
 123       event
.SetInt( false ); 
 124       old
->ProcessCommand(event
); 
 126     wxCommandEvent 
event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId 
); 
 127     event2
.SetEventObject(this); 
 128     event2
.SetInt( true ); 
 129     ProcessCommand(event2
); 
 132 wxRadioButton 
*wxRadioButton::AddInCycle(wxRadioButton 
*cycle
) 
 134     wxRadioButton 
*next
,*current
; 
 142           while ((next
=current
->m_cycle
)!=cycle
) 
 143             current
=current
->m_cycle
; 
 145           current
->m_cycle
=this;