]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/radiobut.cpp
now we don't only show label mnemonics but they also work
[wxWidgets.git] / src / palmos / radiobut.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/radiobut.cpp
ffecfa5a 3// Purpose: wxRadioButton
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
808e3bce 5// Modified by: Wlodzimierz ABX Skiba - native wxRadioButton implementation
ffecfa5a 6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
808e3bce 8// Copyright: (c) William Osborne, Wlodzimierz Skiba
ffecfa5a
JS
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
ffecfa5a
JS
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
20bc5ad8
WS
35#include <Control.h>
36
ffecfa5a
JS
37// ============================================================================
38// wxRadioButton implementation
39// ============================================================================
40
41// ----------------------------------------------------------------------------
42// wxRadioButton creation
43// ----------------------------------------------------------------------------
44
45
46#if wxUSE_EXTENDED_RTTI
47WX_DEFINE_FLAGS( wxRadioButtonStyle )
48
49wxBEGIN_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)
e2731512 58
ffecfa5a
JS
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
79wxEND_FLAGS( wxRadioButtonStyle )
80
81IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioButton, wxControl,"wx/radiobut.h")
82
83wxBEGIN_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
89wxEND_PROPERTIES_TABLE()
90
91wxBEGIN_HANDLERS_TABLE(wxRadioButton)
92wxEND_HANDLERS_TABLE()
93
e2731512 94wxCONSTRUCTOR_6( wxRadioButton , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
ffecfa5a
JS
95
96#else
97IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
98#endif
99
100
101void wxRadioButton::Init()
102{
a152561c 103 m_radioStyle = pushButtonCtl;
8be10866 104 m_groupID = 0;
ffecfa5a
JS
105}
106
107bool 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{
9a727a3b 116 // replace native push button with native checkbox
d79decb5 117 if ( style & wxRB_USE_CHECKBOX )
9a727a3b
WS
118 m_radioStyle = checkboxCtl;
119
a152561c
WS
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,
8be10866
WS
128 size,
129 m_groupID
a152561c 130 );
ffecfa5a
JS
131}
132
8be10866
WS
133void wxRadioButton::SetGroup(uint8_t group)
134{
135 m_groupID = group;
136}
137
ffecfa5a
JS
138// ----------------------------------------------------------------------------
139// wxRadioButton functions
140// ----------------------------------------------------------------------------
141
142void wxRadioButton::SetValue(bool value)
143{
808e3bce 144 SetBoolValue(value);
ffecfa5a
JS
145}
146
147bool wxRadioButton::GetValue() const
148{
808e3bce 149 return GetBoolValue();
ffecfa5a
JS
150}
151
152// ----------------------------------------------------------------------------
153// wxRadioButton event processing
154// ----------------------------------------------------------------------------
155
a152561c
WS
156bool 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
ffecfa5a
JS
164void wxRadioButton::Command (wxCommandEvent& event)
165{
166}
167
ffecfa5a
JS
168// ----------------------------------------------------------------------------
169// wxRadioButton geometry
170// ----------------------------------------------------------------------------
171
172wxSize wxRadioButton::DoGetBestSize() const
173{
174 return wxSize(0,0);
175}
176
177#endif // wxUSE_RADIOBTN
178