1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/checkbox.cpp
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - native 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/checkbox.h"
33 #include "wx/dcscreen.h"
34 #include "wx/settings.h"
39 // ============================================================================
41 // ============================================================================
43 #if wxUSE_EXTENDED_RTTI
44 WX_DEFINE_FLAGS( wxCheckBoxStyle
)
46 wxBEGIN_FLAGS( wxCheckBoxStyle
)
47 // new style border flags, we put them first to
48 // use them for streaming out
49 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
50 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
51 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
52 wxFLAGS_MEMBER(wxBORDER_RAISED
)
53 wxFLAGS_MEMBER(wxBORDER_STATIC
)
54 wxFLAGS_MEMBER(wxBORDER_NONE
)
56 // old style border flags
57 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
58 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
59 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
60 wxFLAGS_MEMBER(wxRAISED_BORDER
)
61 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
62 wxFLAGS_MEMBER(wxNO_BORDER
)
64 // standard window styles
65 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
66 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
67 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
68 wxFLAGS_MEMBER(wxWANTS_CHARS
)
69 wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE
)
70 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
71 wxFLAGS_MEMBER(wxVSCROLL
)
72 wxFLAGS_MEMBER(wxHSCROLL
)
74 wxEND_FLAGS( wxCheckBoxStyle
)
76 IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckBox
, wxControl
,"wx/checkbox.h")
78 wxBEGIN_PROPERTIES_TABLE(wxCheckBox
)
79 wxEVENT_PROPERTY( Click
, wxEVT_COMMAND_CHECKBOX_CLICKED
, wxCommandEvent
)
81 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
82 wxPROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
83 wxPROPERTY( Value
,bool, SetValue
, GetValue
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
84 wxPROPERTY_FLAGS( WindowStyle
, wxCheckBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
85 wxEND_PROPERTIES_TABLE()
87 wxBEGIN_HANDLERS_TABLE(wxCheckBox
)
88 wxEND_HANDLERS_TABLE()
90 wxCONSTRUCTOR_6( wxCheckBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Label
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
92 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 bool wxCheckBox::Create(wxWindow
*parent
,
102 const wxString
& label
,
104 const wxSize
& size
, long style
,
105 const wxValidator
& validator
,
106 const wxString
& name
)
108 if(!wxControl::Create(parent
, id
, pos
, size
, style
, validator
, name
))
111 m_state
= wxCHK_UNCHECKED
;
112 return wxControl::PalmCreateControl(checkboxCtl
, label
, pos
, size
);
115 wxSize
wxCheckBox::DoGetBestSize() const
120 void wxCheckBox::SetValue(bool val
)
125 bool wxCheckBox::GetValue() const
127 return GetBoolValue();
130 bool wxCheckBox::SendClickEvent()
132 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, GetId());
133 event
.SetInt(GetValue());
134 event
.SetEventObject(this);
135 return ProcessCommand(event
);
138 void wxCheckBox::Command(wxCommandEvent
& event
)
140 int state
= event
.GetInt();
141 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
142 || (state
== wxCHK_UNDETERMINED
),
143 wxT("event.GetInt() returned an invalid checkbox state") );
145 Set3StateValue((wxCheckBoxState
) state
);
146 ProcessCommand(event
);
149 void wxCheckBox::DoSet3StateValue(wxCheckBoxState state
)
152 ControlType
*control
= (ControlType
*)GetObjectPtr();
153 if(NULL
== control
) {
158 case wxCHK_UNCHECKED
:
164 case wxCHK_UNDETERMINED
:
169 CtlSetValue (control
, newValue
);
172 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
177 #endif // wxUSE_CHECKBOX