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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "radiobut.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/radiobut.h"
35 #include "wx/settings.h"
36 #include "wx/dcscreen.h"
39 // ============================================================================
40 // wxRadioButton implementation
41 // ============================================================================
43 // ----------------------------------------------------------------------------
44 // wxRadioButton creation
45 // ----------------------------------------------------------------------------
48 #if wxUSE_EXTENDED_RTTI
49 WX_DEFINE_FLAGS( wxRadioButtonStyle
)
51 wxBEGIN_FLAGS( wxRadioButtonStyle
)
52 // new style border flags, we put them first to
53 // use them for streaming out
54 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
55 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
56 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
57 wxFLAGS_MEMBER(wxBORDER_RAISED
)
58 wxFLAGS_MEMBER(wxBORDER_STATIC
)
59 wxFLAGS_MEMBER(wxBORDER_NONE
)
61 // old style border flags
62 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
63 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
64 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
65 wxFLAGS_MEMBER(wxRAISED_BORDER
)
66 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
67 wxFLAGS_MEMBER(wxBORDER
)
69 // standard window styles
70 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
71 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
72 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
73 wxFLAGS_MEMBER(wxWANTS_CHARS
)
74 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
75 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
76 wxFLAGS_MEMBER(wxVSCROLL
)
77 wxFLAGS_MEMBER(wxHSCROLL
)
79 wxFLAGS_MEMBER(wxRB_GROUP
)
81 wxEND_FLAGS( wxRadioButtonStyle
)
83 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton
, wxControl
,"wx/radiobut.h")
85 wxBEGIN_PROPERTIES_TABLE(wxRadioButton
)
86 wxEVENT_PROPERTY( Click
, wxEVT_COMMAND_RADIOBUTTON_SELECTED
, wxCommandEvent
)
87 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
88 wxPROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
89 wxPROPERTY( Value
,bool, SetValue
, GetValue
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
90 wxPROPERTY_FLAGS( WindowStyle
, wxRadioButtonStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
91 wxEND_PROPERTIES_TABLE()
93 wxBEGIN_HANDLERS_TABLE(wxRadioButton
)
94 wxEND_HANDLERS_TABLE()
96 wxCONSTRUCTOR_6( wxRadioButton
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
99 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
103 void wxRadioButton::Init()
105 m_radioStyle
= pushButtonCtl
;
109 bool wxRadioButton::Create(wxWindow
*parent
,
111 const wxString
& label
,
115 const wxValidator
& validator
,
116 const wxString
& name
)
118 // replace native push button with native checkbox
119 if ( style
& wxRB_USE_CHECKBOX
)
120 m_radioStyle
= checkboxCtl
;
122 if(!wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
))
125 return wxControl::PalmCreateControl(
126 // be sure only one of two possibilities was taken
127 m_radioStyle
== checkboxCtl
? checkboxCtl
: pushButtonCtl
,
135 void wxRadioButton::SetGroup(uint8_t group
)
140 // ----------------------------------------------------------------------------
141 // wxRadioButton functions
142 // ----------------------------------------------------------------------------
144 void wxRadioButton::SetValue(bool value
)
149 bool wxRadioButton::GetValue() const
151 return GetBoolValue();
154 // ----------------------------------------------------------------------------
155 // wxRadioButton event processing
156 // ----------------------------------------------------------------------------
158 bool wxRadioButton::SendClickEvent()
160 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, GetId());
161 event
.SetInt(GetValue());
162 event
.SetEventObject(this);
163 return ProcessCommand(event
);
166 void wxRadioButton::Command (wxCommandEvent
& event
)
170 // ----------------------------------------------------------------------------
171 // wxRadioButton geometry
172 // ----------------------------------------------------------------------------
174 wxSize
wxRadioButton::DoGetBestSize() const
179 #endif // wxUSE_RADIOBTN