]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/checklst.cpp
Fix typo in last commit
[wxWidgets.git] / src / palmos / checklst.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/checklst.cpp
3 // Purpose: implementation of wxCheckListBox class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10.13.04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
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_CHECKLISTBOX && wxUSE_OWNER_DRAWN
28
29 #include "wx/checklst.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/object.h"
33 #include "wx/colour.h"
34 #include "wx/font.h"
35 #include "wx/bitmap.h"
36 #include "wx/window.h"
37 #include "wx/listbox.h"
38 #include "wx/dcmemory.h"
39
40 #include "wx/settings.h"
41
42 #include "wx/log.h"
43 #endif
44
45 #include "wx/ownerdrw.h"
46
47 #include "wx/palmos/wrapwin.h"
48
49 #include "wx/palmos/private.h"
50
51 // ----------------------------------------------------------------------------
52 // private functions
53 // ----------------------------------------------------------------------------
54
55 // get item (converted to right type)
56 #define GetItem(n) ((wxCheckListBoxItem *)(GetItem(n)))
57
58 // ============================================================================
59 // implementation
60 // ============================================================================
61
62 // ----------------------------------------------------------------------------
63 // declaration and implementation of wxCheckListBoxItem class
64 // ----------------------------------------------------------------------------
65
66 class wxCheckListBoxItem : public wxOwnerDrawn
67 {
68 friend class WXDLLEXPORT wxCheckListBox;
69 public:
70 // ctor
71 wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex);
72
73 // drawing functions
74 virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
75
76 // simple accessors and operations
77 bool IsChecked() const { return m_bChecked; }
78
79 void Check(bool bCheck);
80 void Toggle() { Check(!IsChecked()); }
81
82 void SendEvent();
83
84 private:
85
86 wxDECLARE_NO_COPY_CLASS(wxCheckListBoxItem);
87 bool m_bChecked;
88 wxCheckListBox *m_pParent;
89 size_t m_nIndex;
90 };
91
92 wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex)
93 : wxOwnerDrawn(wxEmptyString, true) // checkable
94 {
95 }
96
97 bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
98 wxODAction act, wxODStatus stat)
99 {
100 return false;
101 }
102
103 // change the state of the item and redraw it
104 void wxCheckListBoxItem::Check(bool check)
105 {
106 }
107
108 // send an "item checked" event
109 void wxCheckListBoxItem::SendEvent()
110 {
111 }
112
113 // ----------------------------------------------------------------------------
114 // implementation of wxCheckListBox class
115 // ----------------------------------------------------------------------------
116
117 // define event table
118 // ------------------
119 BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
120 EVT_KEY_DOWN(wxCheckListBox::OnKeyDown)
121 EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
122 END_EVENT_TABLE()
123
124 // control creation
125 // ----------------
126
127 // def ctor: use Create() to really create the control
128 wxCheckListBox::wxCheckListBox()
129 {
130 }
131
132 // ctor which creates the associated control
133 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
134 const wxPoint& pos, const wxSize& size,
135 int nStrings, const wxString choices[],
136 long style, const wxValidator& val,
137 const wxString& name)
138 {
139 Create(parent, id, pos, size, nStrings, choices, style, val, name);
140 }
141
142 wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
143 const wxPoint& pos, const wxSize& size,
144 const wxArrayString& choices,
145 long style, const wxValidator& val,
146 const wxString& name)
147 {
148 Create(parent, id, pos, size, choices, style, val, name);
149 }
150
151 bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
152 const wxPoint& pos, const wxSize& size,
153 int n, const wxString choices[],
154 long style,
155 const wxValidator& validator, const wxString& name)
156 {
157 return wxListBox::Create(parent, id, pos, size, n, choices,
158 style | wxLB_OWNERDRAW, validator, name);
159 }
160
161 bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
162 const wxPoint& pos, const wxSize& size,
163 const wxArrayString& choices,
164 long style,
165 const wxValidator& validator, const wxString& name)
166 {
167 return wxListBox::Create(parent, id, pos, size, choices,
168 style | wxLB_OWNERDRAW, validator, name);
169 }
170
171 // misc overloaded methods
172 // -----------------------
173
174 void wxCheckListBox::Delete(unsigned int n)
175 {
176 }
177
178 bool wxCheckListBox::SetFont( const wxFont &font )
179 {
180 return false;
181 }
182
183 // create/retrieve item
184 // --------------------
185
186 // create a check list box item
187 wxOwnerDrawn *wxCheckListBox::CreateLboxItem(size_t nIndex)
188 {
189 wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex);
190 return pItem;
191 }
192
193 // return item size
194 // ----------------
195 bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
196 {
197 return false;
198 }
199
200 // check items
201 // -----------
202
203 bool wxCheckListBox::IsChecked(unsigned int uiIndex) const
204 {
205 return false;
206 }
207
208 void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck)
209 {
210 }
211
212 // process events
213 // --------------
214
215 void wxCheckListBox::OnKeyDown(wxKeyEvent& event)
216 {
217 }
218
219 void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
220 {
221 }
222
223 int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const
224 {
225 return wxNOT_FOUND;
226 }
227
228 #endif // wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN