]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/radiobut.cpp
set more event object fields for lbox dbl click events
[wxWidgets.git] / src / mac / carbon / radiobut.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: radiobut.cpp
3// Purpose: wxRadioButton
4// Author: AUTHOR
1dd52151 5// Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
e9576ca5
SC
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "radiobut.h"
14#endif
15
16#include "wx/radiobut.h"
17
2f1ae414 18#if !USE_SHARED_LIBRARY
e9576ca5 19IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
2f1ae414 20#endif
e9576ca5 21
1dd52151
UJ
22#include <wx/mac/uma.h>
23
e9576ca5
SC
24bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
25 const wxString& label,
26 const wxPoint& pos,
27 const wxSize& size, long style,
28 const wxValidator& validator,
29 const wxString& name)
30{
1dd52151
UJ
31 Rect bounds ;
32 Str255 title ;
33
34 m_cycle=NULL;
35
36 MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
e9576ca5 37
1dd52151
UJ
38 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
39 kControlRadioButtonProc , (long) this ) ;
40
41 MacPostControlCreate() ;
e9576ca5 42
1dd52151 43 return TRUE;
e9576ca5
SC
44}
45
1dd52151 46void wxRadioButton::SetValue(bool val)
e9576ca5 47{
1dd52151
UJ
48 int i;
49 wxRadioButton *cycle;
50
51 ::SetControlValue( m_macControl , val ) ;
52
2f1ae414
SC
53 if (val)
54 {
1dd52151
UJ
55 cycle=this->NextInCycle();
56 if (cycle!=NULL) {
57 while (cycle!=this) {
58 cycle->SetValue(false);
59 cycle=cycle->NextInCycle();
60 }
61 }
62 }
e9576ca5
SC
63}
64
e9576ca5
SC
65bool wxRadioButton::GetValue() const
66{
1dd52151 67 return ::GetControlValue( m_macControl ) ;
e9576ca5
SC
68}
69
70void wxRadioButton::Command (wxCommandEvent & event)
71{
1dd52151 72 SetValue ( (event.GetInt() != 0) );
e9576ca5
SC
73 ProcessCommand (event);
74}
75
1dd52151
UJ
76void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
77{
78 SetValue(true) ;
8208e181
SC
79 wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
80 event.SetEventObject(this);
81 ProcessCommand(event);
1dd52151
UJ
82}
83
84wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
85{
86 wxRadioButton *next,*current;
87
88 if (cycle==NULL) {
89 m_cycle=this;
90 return(this);
91 }
92 else {
93 current=cycle;
94 while ((next=current->m_cycle)!=cycle) current=current->m_cycle;
95 m_cycle=cycle;
96 current->m_cycle=this;
97 return(cycle);
98 }
99}