]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/radiobut.cpp
cleanup - reformat
[wxWidgets.git] / src / palmos / radiobut.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/radiobut.cpp
3 // Purpose: wxRadioButton
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - native wxRadioButton implementation
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_RADIOBTN
28
29 #ifndef WX_PRECOMP
30 #include "wx/radiobut.h"
31 #include "wx/settings.h"
32 #include "wx/dcscreen.h"
33 #endif
34
35 #include <Control.h>
36
37 // ============================================================================
38 // wxRadioButton implementation
39 // ============================================================================
40
41 // ----------------------------------------------------------------------------
42 // wxRadioButton creation
43 // ----------------------------------------------------------------------------
44
45
46 #if wxUSE_EXTENDED_RTTI
47 WX_DEFINE_FLAGS( wxRadioButtonStyle )
48
49 wxBEGIN_FLAGS( wxRadioButtonStyle )
50 // new style border flags, we put them first to
51 // use them for streaming out
52 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
53 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
54 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
55 wxFLAGS_MEMBER(wxBORDER_RAISED)
56 wxFLAGS_MEMBER(wxBORDER_STATIC)
57 wxFLAGS_MEMBER(wxBORDER_NONE)
58
59 // old style border flags
60 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
61 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
62 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
63 wxFLAGS_MEMBER(wxRAISED_BORDER)
64 wxFLAGS_MEMBER(wxSTATIC_BORDER)
65 wxFLAGS_MEMBER(wxBORDER)
66
67 // standard window styles
68 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
69 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
70 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
71 wxFLAGS_MEMBER(wxWANTS_CHARS)
72 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
73 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
74 wxFLAGS_MEMBER(wxVSCROLL)
75 wxFLAGS_MEMBER(wxHSCROLL)
76
77 wxFLAGS_MEMBER(wxRB_GROUP)
78
79 wxEND_FLAGS( wxRadioButtonStyle )
80
81 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton, wxControl,"wx/radiobut.h")
82
83 wxBEGIN_PROPERTIES_TABLE(wxRadioButton)
84 wxEVENT_PROPERTY( Click , wxEVT_COMMAND_RADIOBUTTON_SELECTED , wxCommandEvent )
85 wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
86 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
87 wxPROPERTY( Value ,bool, SetValue, GetValue, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
88 wxPROPERTY_FLAGS( WindowStyle , wxRadioButtonStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
89 wxEND_PROPERTIES_TABLE()
90
91 wxBEGIN_HANDLERS_TABLE(wxRadioButton)
92 wxEND_HANDLERS_TABLE()
93
94 wxCONSTRUCTOR_6( wxRadioButton , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
95
96 #else
97 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
98 #endif
99
100
101 void wxRadioButton::Init()
102 {
103 m_radioStyle = pushButtonCtl;
104 m_groupID = 0;
105 }
106
107 bool wxRadioButton::Create(wxWindow *parent,
108 wxWindowID id,
109 const wxString& label,
110 const wxPoint& pos,
111 const wxSize& size,
112 long style,
113 const wxValidator& validator,
114 const wxString& name)
115 {
116 // replace native push button with native checkbox
117 if ( style & wxRB_USE_CHECKBOX )
118 m_radioStyle = checkboxCtl;
119
120 if(!wxControl::Create(parent, id, pos, size, style, validator, name))
121 return false;
122
123 return wxControl::PalmCreateControl(
124 // be sure only one of two possibilities was taken
125 m_radioStyle == checkboxCtl ? checkboxCtl : pushButtonCtl,
126 label,
127 pos,
128 size,
129 m_groupID
130 );
131 }
132
133 void wxRadioButton::SetGroup(uint8_t group)
134 {
135 m_groupID = group;
136 }
137
138 // ----------------------------------------------------------------------------
139 // wxRadioButton functions
140 // ----------------------------------------------------------------------------
141
142 void wxRadioButton::SetValue(bool value)
143 {
144 SetBoolValue(value);
145 }
146
147 bool wxRadioButton::GetValue() const
148 {
149 return GetBoolValue();
150 }
151
152 // ----------------------------------------------------------------------------
153 // wxRadioButton event processing
154 // ----------------------------------------------------------------------------
155
156 bool wxRadioButton::SendClickEvent()
157 {
158 wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, GetId());
159 event.SetInt(GetValue());
160 event.SetEventObject(this);
161 return ProcessCommand(event);
162 }
163
164 void wxRadioButton::Command (wxCommandEvent& event)
165 {
166 }
167
168 // ----------------------------------------------------------------------------
169 // wxRadioButton geometry
170 // ----------------------------------------------------------------------------
171
172 wxSize wxRadioButton::DoGetBestSize() const
173 {
174 return wxSize(0,0);
175 }
176
177 #endif // wxUSE_RADIOBTN
178