]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/checkbox.cpp
wxDataViewCtrl::Expand() only works on items whose parents are already
[wxWidgets.git] / src / palmos / checkbox.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/checkbox.cpp
ffecfa5a 3// Purpose: wxCheckBox
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
bdb54365 5// Modified by: Wlodzimierz ABX Skiba - native implementation
ffecfa5a 6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
bdb54365 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_CHECKBOX
28
ab1ce969
WS
29#include "wx/checkbox.h"
30
ffecfa5a 31#ifndef WX_PRECOMP
ffecfa5a
JS
32 #include "wx/brush.h"
33 #include "wx/dcscreen.h"
34 #include "wx/settings.h"
35#endif
36
20bc5ad8
WS
37#include <Control.h>
38
ffecfa5a
JS
39// ============================================================================
40// implementation
41// ============================================================================
42
43#if wxUSE_EXTENDED_RTTI
44WX_DEFINE_FLAGS( wxCheckBoxStyle )
45
46wxBEGIN_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)
e2731512 55
ffecfa5a
JS
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)
63
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)
73
74wxEND_FLAGS( wxCheckBoxStyle )
75
76IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckBox, wxControl,"wx/checkbox.h")
77
78wxBEGIN_PROPERTIES_TABLE(wxCheckBox)
79 wxEVENT_PROPERTY( Click , wxEVT_COMMAND_CHECKBOX_CLICKED , wxCommandEvent )
80
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
85wxEND_PROPERTIES_TABLE()
86
87wxBEGIN_HANDLERS_TABLE(wxCheckBox)
88wxEND_HANDLERS_TABLE()
89
e2731512 90wxCONSTRUCTOR_6( wxCheckBox , wxWindow* , Parent , wxWindowID , Id , wxString , Label , wxPoint , Position , wxSize , Size , long , WindowStyle )
ffecfa5a
JS
91#else
92IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
93#endif
94
95
96// ----------------------------------------------------------------------------
97// wxCheckBox
98// ----------------------------------------------------------------------------
99
ffecfa5a
JS
100bool wxCheckBox::Create(wxWindow *parent,
101 wxWindowID id,
102 const wxString& label,
103 const wxPoint& pos,
104 const wxSize& size, long style,
105 const wxValidator& validator,
106 const wxString& name)
107{
a152561c
WS
108 if(!wxControl::Create(parent, id, pos, size, style, validator, name))
109 return false;
110
6afc1b46 111 m_state = wxCHK_UNCHECKED;
a152561c 112 return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
ffecfa5a
JS
113}
114
115wxSize wxCheckBox::DoGetBestSize() const
116{
117 return wxSize(0,0);
118}
119
120void wxCheckBox::SetValue(bool val)
121{
ba889513 122 SetBoolValue(val);
ffecfa5a
JS
123}
124
125bool wxCheckBox::GetValue() const
126{
ba889513 127 return GetBoolValue();
ffecfa5a
JS
128}
129
a152561c
WS
130bool wxCheckBox::SendClickEvent()
131{
132 wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
133 event.SetInt(GetValue());
134 event.SetEventObject(this);
135 return ProcessCommand(event);
136}
137
ffecfa5a
JS
138void wxCheckBox::Command(wxCommandEvent& event)
139{
6afc1b46
VZ
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") );
144
145 Set3StateValue((wxCheckBoxState) state);
146 ProcessCommand(event);
ffecfa5a
JS
147}
148
ffecfa5a
JS
149void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
150{
6afc1b46
VZ
151 Int16 newValue;
152 ControlType *control = (ControlType *)GetObjectPtr();
153 if(NULL == control) {
154 return;
155 }
156 m_state = state;
157 switch (state) {
158 case wxCHK_UNCHECKED:
159 newValue = 0;
160 break;
161 case wxCHK_CHECKED:
162 newValue = 1;
163 break;
164 case wxCHK_UNDETERMINED:
165 default:
166 return;
167 break;
168 }
169 CtlSetValue (control, newValue);
ffecfa5a
JS
170}
171
172wxCheckBoxState wxCheckBox::DoGet3StateValue() const
173{
6afc1b46 174 return m_state;
ffecfa5a
JS
175}
176
177#endif // wxUSE_CHECKBOX