]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/checkbox.cpp
Correct the direction passed to wxDataObject in wxGTK clipboard code.
[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
ffecfa5a
JS
43// ----------------------------------------------------------------------------
44// wxCheckBox
45// ----------------------------------------------------------------------------
46
ffecfa5a
JS
47bool wxCheckBox::Create(wxWindow *parent,
48 wxWindowID id,
49 const wxString& label,
50 const wxPoint& pos,
51 const wxSize& size, long style,
52 const wxValidator& validator,
53 const wxString& name)
54{
a152561c
WS
55 if(!wxControl::Create(parent, id, pos, size, style, validator, name))
56 return false;
57
6afc1b46 58 m_state = wxCHK_UNCHECKED;
a152561c 59 return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
ffecfa5a
JS
60}
61
62wxSize wxCheckBox::DoGetBestSize() const
63{
64 return wxSize(0,0);
65}
66
67void wxCheckBox::SetValue(bool val)
68{
ba889513 69 SetBoolValue(val);
ffecfa5a
JS
70}
71
72bool wxCheckBox::GetValue() const
73{
ba889513 74 return GetBoolValue();
ffecfa5a
JS
75}
76
a152561c
WS
77bool wxCheckBox::SendClickEvent()
78{
79 wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
80 event.SetInt(GetValue());
81 event.SetEventObject(this);
82 return ProcessCommand(event);
83}
84
ffecfa5a
JS
85void wxCheckBox::Command(wxCommandEvent& event)
86{
6afc1b46
VZ
87 int state = event.GetInt();
88 wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
89 || (state == wxCHK_UNDETERMINED),
90 wxT("event.GetInt() returned an invalid checkbox state") );
91
92 Set3StateValue((wxCheckBoxState) state);
93 ProcessCommand(event);
ffecfa5a
JS
94}
95
ffecfa5a
JS
96void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
97{
6afc1b46
VZ
98 Int16 newValue;
99 ControlType *control = (ControlType *)GetObjectPtr();
100 if(NULL == control) {
101 return;
102 }
103 m_state = state;
104 switch (state) {
105 case wxCHK_UNCHECKED:
106 newValue = 0;
107 break;
108 case wxCHK_CHECKED:
109 newValue = 1;
110 break;
111 case wxCHK_UNDETERMINED:
112 default:
113 return;
114 break;
115 }
116 CtlSetValue (control, newValue);
ffecfa5a
JS
117}
118
119wxCheckBoxState wxCheckBox::DoGet3StateValue() const
120{
6afc1b46 121 return m_state;
ffecfa5a
JS
122}
123
124#endif // wxUSE_CHECKBOX