]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/checkbox.cpp
Add markup support to wxMSW wxButton and show it in the sample.
[wxWidgets.git] / src / palmos / checkbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/checkbox.cpp
3 // Purpose: wxCheckBox
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - native implementation
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
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
29 #include "wx/checkbox.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/brush.h"
33 #include "wx/dcscreen.h"
34 #include "wx/settings.h"
35 #endif
36
37 #include <Control.h>
38
39 // ============================================================================
40 // implementation
41 // ============================================================================
42
43 // ----------------------------------------------------------------------------
44 // wxCheckBox
45 // ----------------------------------------------------------------------------
46
47 bool 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 {
55 if(!wxControl::Create(parent, id, pos, size, style, validator, name))
56 return false;
57
58 m_state = wxCHK_UNCHECKED;
59 return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
60 }
61
62 wxSize wxCheckBox::DoGetBestSize() const
63 {
64 return wxSize(0,0);
65 }
66
67 void wxCheckBox::SetValue(bool val)
68 {
69 SetBoolValue(val);
70 }
71
72 bool wxCheckBox::GetValue() const
73 {
74 return GetBoolValue();
75 }
76
77 bool 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
85 void wxCheckBox::Command(wxCommandEvent& event)
86 {
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);
94 }
95
96 void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
97 {
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);
117 }
118
119 wxCheckBoxState wxCheckBox::DoGet3StateValue() const
120 {
121 return m_state;
122 }
123
124 #endif // wxUSE_CHECKBOX