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"
30 #include "wx/radiobut.h"
31 #include "wx/settings.h"
32 #include "wx/dcscreen.h"
37 // ============================================================================
38 // wxRadioButton implementation
39 // ============================================================================
41 // ----------------------------------------------------------------------------
42 // wxRadioButton creation
43 // ----------------------------------------------------------------------------
46 #if wxUSE_EXTENDED_RTTI
47 WX_DEFINE_FLAGS( wxRadioButtonStyle
)
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
)
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
)
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
)
77 wxFLAGS_MEMBER(wxRB_GROUP
)
79 wxEND_FLAGS( wxRadioButtonStyle
)
81 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton
, wxControl
,"wx/radiobut.h")
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()
91 wxBEGIN_HANDLERS_TABLE(wxRadioButton
)
92 wxEND_HANDLERS_TABLE()
94 wxCONSTRUCTOR_6( wxRadioButton
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
97 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
101 void wxRadioButton::Init()
103 m_radioStyle
= pushButtonCtl
;
107 bool wxRadioButton::Create(wxWindow
*parent
,
109 const wxString
& label
,
113 const wxValidator
& validator
,
114 const wxString
& name
)
116 // replace native push button with native checkbox
117 if ( style
& wxRB_USE_CHECKBOX
)
118 m_radioStyle
= checkboxCtl
;
120 if(!wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
))
123 return wxControl::PalmCreateControl(
124 // be sure only one of two possibilities was taken
125 m_radioStyle
== checkboxCtl
? checkboxCtl
: pushButtonCtl
,
133 void wxRadioButton::SetGroup(uint8_t group
)
138 // ----------------------------------------------------------------------------
139 // wxRadioButton functions
140 // ----------------------------------------------------------------------------
142 void wxRadioButton::SetValue(bool value
)
147 bool wxRadioButton::GetValue() const
149 return GetBoolValue();
152 // ----------------------------------------------------------------------------
153 // wxRadioButton event processing
154 // ----------------------------------------------------------------------------
156 bool wxRadioButton::SendClickEvent()
158 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, GetId());
159 event
.SetInt(GetValue());
160 event
.SetEventObject(this);
161 return ProcessCommand(event
);
164 void wxRadioButton::Command (wxCommandEvent
& event
)
168 // ----------------------------------------------------------------------------
169 // wxRadioButton geometry
170 // ----------------------------------------------------------------------------
172 wxSize
wxRadioButton::DoGetBestSize() const
177 #endif // wxUSE_RADIOBTN