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
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/radiobut.h"
32 #include "wx/settings.h"
33 #include "wx/dcscreen.h"
38 // ============================================================================
39 // wxRadioButton implementation
40 // ============================================================================
42 // ----------------------------------------------------------------------------
43 // wxRadioButton creation
44 // ----------------------------------------------------------------------------
47 #if wxUSE_EXTENDED_RTTI
48 WX_DEFINE_FLAGS( wxRadioButtonStyle
)
50 wxBEGIN_FLAGS( wxRadioButtonStyle
)
51 // new style border flags, we put them first to
52 // use them for streaming out
53 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
54 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
55 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
56 wxFLAGS_MEMBER(wxBORDER_RAISED
)
57 wxFLAGS_MEMBER(wxBORDER_STATIC
)
58 wxFLAGS_MEMBER(wxBORDER_NONE
)
60 // old style border flags
61 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
62 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
63 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
64 wxFLAGS_MEMBER(wxRAISED_BORDER
)
65 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
66 wxFLAGS_MEMBER(wxBORDER
)
68 // standard window styles
69 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
70 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
71 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
72 wxFLAGS_MEMBER(wxWANTS_CHARS
)
73 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
74 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
75 wxFLAGS_MEMBER(wxVSCROLL
)
76 wxFLAGS_MEMBER(wxHSCROLL
)
78 wxFLAGS_MEMBER(wxRB_GROUP
)
80 wxEND_FLAGS( wxRadioButtonStyle
)
82 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton
, wxControl
,"wx/radiobut.h")
84 wxBEGIN_PROPERTIES_TABLE(wxRadioButton
)
85 wxEVENT_PROPERTY( Click
, wxEVT_COMMAND_RADIOBUTTON_SELECTED
, wxCommandEvent
)
86 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
87 wxPROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
88 wxPROPERTY( Value
,bool, SetValue
, GetValue
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
89 wxPROPERTY_FLAGS( WindowStyle
, wxRadioButtonStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
90 wxEND_PROPERTIES_TABLE()
92 wxBEGIN_HANDLERS_TABLE(wxRadioButton
)
93 wxEND_HANDLERS_TABLE()
95 wxCONSTRUCTOR_6( wxRadioButton
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
98 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
102 void wxRadioButton::Init()
104 m_radioStyle
= pushButtonCtl
;
108 bool wxRadioButton::Create(wxWindow
*parent
,
110 const wxString
& label
,
114 const wxValidator
& validator
,
115 const wxString
& name
)
117 // replace native push button with native checkbox
118 if ( style
& wxRB_USE_CHECKBOX
)
119 m_radioStyle
= checkboxCtl
;
121 if(!wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
))
124 return wxControl::PalmCreateControl(
125 // be sure only one of two possibilities was taken
126 m_radioStyle
== checkboxCtl
? checkboxCtl
: pushButtonCtl
,
134 void wxRadioButton::SetGroup(uint8_t group
)
139 // ----------------------------------------------------------------------------
140 // wxRadioButton functions
141 // ----------------------------------------------------------------------------
143 void wxRadioButton::SetValue(bool value
)
148 bool wxRadioButton::GetValue() const
150 return GetBoolValue();
153 // ----------------------------------------------------------------------------
154 // wxRadioButton event processing
155 // ----------------------------------------------------------------------------
157 bool wxRadioButton::SendClickEvent()
159 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, GetId());
160 event
.SetInt(GetValue());
161 event
.SetEventObject(this);
162 return ProcessCommand(event
);
165 void wxRadioButton::Command (wxCommandEvent
& event
)
169 // ----------------------------------------------------------------------------
170 // wxRadioButton geometry
171 // ----------------------------------------------------------------------------
173 wxSize
wxRadioButton::DoGetBestSize() const
178 #endif // wxUSE_RADIOBTN