]>
Commit | Line | Data |
---|---|---|
ffecfa5a | 1 | /////////////////////////////////////////////////////////////////////////////// |
e2731512 | 2 | // Name: src/palmos/checklst.cpp |
ffecfa5a | 3 | // Purpose: implementation of wxCheckListBox class |
e2731512 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
ffecfa5a JS |
5 | // Modified by: |
6 | // Created: 10.13.04 | |
e2731512 | 7 | // RCS-ID: $Id$ |
ffecfa5a JS |
8 | // Copyright: (c) William Osborne |
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_OWNER_DRAWN | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #include "wx/object.h" | |
31 | #include "wx/colour.h" | |
32 | #include "wx/font.h" | |
33 | #include "wx/bitmap.h" | |
34 | #include "wx/window.h" | |
35 | #include "wx/listbox.h" | |
36 | #include "wx/dcmemory.h" | |
37 | ||
38 | #include "wx/settings.h" | |
39 | ||
40 | #include "wx/log.h" | |
41 | #endif | |
42 | ||
43 | #include "wx/ownerdrw.h" | |
44 | #include "wx/checklst.h" | |
45 | ||
46 | #include "wx/palmos/wrapwin.h" | |
47 | ||
48 | #include "wx/palmos/private.h" | |
49 | ||
50 | // ---------------------------------------------------------------------------- | |
51 | // private functions | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
54 | // get item (converted to right type) | |
55 | #define GetItem(n) ((wxCheckListBoxItem *)(GetItem(n))) | |
56 | ||
57 | // ============================================================================ | |
58 | // implementation | |
59 | // ============================================================================ | |
60 | ||
61 | ||
62 | #if wxUSE_EXTENDED_RTTI | |
63 | WX_DEFINE_FLAGS( wxCheckListBoxStyle ) | |
64 | ||
65 | wxBEGIN_FLAGS( wxCheckListBoxStyle ) | |
66 | // new style border flags, we put them first to | |
67 | // use them for streaming out | |
68 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) | |
69 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
70 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
71 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
72 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
73 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
e2731512 | 74 | |
ffecfa5a JS |
75 | // old style border flags |
76 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) | |
77 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
78 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
79 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
80 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
81 | wxFLAGS_MEMBER(wxBORDER) | |
82 | ||
83 | // standard window styles | |
84 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) | |
85 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
86 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
87 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
88 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) | |
89 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
90 | wxFLAGS_MEMBER(wxVSCROLL) | |
91 | wxFLAGS_MEMBER(wxHSCROLL) | |
92 | ||
93 | wxFLAGS_MEMBER(wxLB_SINGLE) | |
94 | wxFLAGS_MEMBER(wxLB_MULTIPLE) | |
95 | wxFLAGS_MEMBER(wxLB_EXTENDED) | |
96 | wxFLAGS_MEMBER(wxLB_HSCROLL) | |
97 | wxFLAGS_MEMBER(wxLB_ALWAYS_SB) | |
98 | wxFLAGS_MEMBER(wxLB_NEEDED_SB) | |
99 | wxFLAGS_MEMBER(wxLB_SORT) | |
100 | wxFLAGS_MEMBER(wxLB_OWNERDRAW) | |
101 | ||
102 | wxEND_FLAGS( wxCheckListBoxStyle ) | |
103 | ||
104 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckListBox, wxListBox,"wx/checklst.h") | |
105 | ||
106 | wxBEGIN_PROPERTIES_TABLE(wxCheckListBox) | |
107 | wxEVENT_PROPERTY( Toggle , wxEVT_COMMAND_CHECKLISTBOX_TOGGLED , wxCommandEvent ) | |
108 | wxPROPERTY_FLAGS( WindowStyle , wxCheckListBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , wxLB_OWNERDRAW /*flags*/ , wxT("Helpstring") , wxT("group")) // style | |
109 | wxEND_PROPERTIES_TABLE() | |
110 | ||
111 | wxBEGIN_HANDLERS_TABLE(wxCheckListBox) | |
112 | wxEND_HANDLERS_TABLE() | |
113 | ||
e2731512 | 114 | wxCONSTRUCTOR_4( wxCheckListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) |
ffecfa5a JS |
115 | |
116 | #else | |
117 | IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) | |
118 | #endif | |
119 | ||
120 | // ---------------------------------------------------------------------------- | |
121 | // declaration and implementation of wxCheckListBoxItem class | |
122 | // ---------------------------------------------------------------------------- | |
123 | ||
124 | class wxCheckListBoxItem : public wxOwnerDrawn | |
125 | { | |
126 | friend class WXDLLEXPORT wxCheckListBox; | |
127 | public: | |
128 | // ctor | |
129 | wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex); | |
130 | ||
131 | // drawing functions | |
132 | virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); | |
133 | ||
134 | // simple accessors and operations | |
135 | bool IsChecked() const { return m_bChecked; } | |
136 | ||
137 | void Check(bool bCheck); | |
138 | void Toggle() { Check(!IsChecked()); } | |
139 | ||
140 | void SendEvent(); | |
141 | ||
142 | private: | |
143 | ||
144 | DECLARE_NO_COPY_CLASS(wxCheckListBoxItem) | |
145 | bool m_bChecked; | |
146 | wxCheckListBox *m_pParent; | |
147 | size_t m_nIndex; | |
148 | }; | |
149 | ||
150 | wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) | |
151 | : wxOwnerDrawn(wxEmptyString, TRUE) // checkable | |
152 | { | |
153 | } | |
154 | ||
155 | bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, | |
156 | wxODAction act, wxODStatus stat) | |
157 | { | |
158 | return FALSE; | |
159 | } | |
160 | ||
161 | // change the state of the item and redraw it | |
162 | void wxCheckListBoxItem::Check(bool check) | |
163 | { | |
164 | } | |
165 | ||
166 | // send an "item checked" event | |
167 | void wxCheckListBoxItem::SendEvent() | |
168 | { | |
169 | } | |
170 | ||
171 | // ---------------------------------------------------------------------------- | |
172 | // implementation of wxCheckListBox class | |
173 | // ---------------------------------------------------------------------------- | |
174 | ||
175 | // define event table | |
176 | // ------------------ | |
177 | BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox) | |
178 | EVT_KEY_DOWN(wxCheckListBox::OnKeyDown) | |
179 | EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick) | |
180 | END_EVENT_TABLE() | |
181 | ||
182 | // control creation | |
183 | // ---------------- | |
184 | ||
185 | // def ctor: use Create() to really create the control | |
186 | wxCheckListBox::wxCheckListBox() | |
187 | { | |
188 | } | |
189 | ||
190 | // ctor which creates the associated control | |
191 | wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id, | |
192 | const wxPoint& pos, const wxSize& size, | |
193 | int nStrings, const wxString choices[], | |
194 | long style, const wxValidator& val, | |
195 | const wxString& name) | |
196 | { | |
197 | Create(parent, id, pos, size, nStrings, choices, style, val, name); | |
198 | } | |
199 | ||
200 | wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id, | |
201 | const wxPoint& pos, const wxSize& size, | |
202 | const wxArrayString& choices, | |
203 | long style, const wxValidator& val, | |
204 | const wxString& name) | |
205 | { | |
206 | Create(parent, id, pos, size, choices, style, val, name); | |
207 | } | |
208 | ||
209 | bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, | |
210 | const wxPoint& pos, const wxSize& size, | |
211 | int n, const wxString choices[], | |
212 | long style, | |
213 | const wxValidator& validator, const wxString& name) | |
214 | { | |
215 | return wxListBox::Create(parent, id, pos, size, n, choices, | |
216 | style | wxLB_OWNERDRAW, validator, name); | |
217 | } | |
218 | ||
219 | bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, | |
220 | const wxPoint& pos, const wxSize& size, | |
221 | const wxArrayString& choices, | |
222 | long style, | |
223 | const wxValidator& validator, const wxString& name) | |
224 | { | |
225 | return wxListBox::Create(parent, id, pos, size, choices, | |
226 | style | wxLB_OWNERDRAW, validator, name); | |
227 | } | |
228 | ||
229 | // misc overloaded methods | |
230 | // ----------------------- | |
231 | ||
232 | void wxCheckListBox::Delete(int N) | |
233 | { | |
234 | } | |
235 | ||
236 | bool wxCheckListBox::SetFont( const wxFont &font ) | |
237 | { | |
238 | return false; | |
239 | } | |
240 | ||
241 | // create/retrieve item | |
242 | // -------------------- | |
243 | ||
244 | // create a check list box item | |
245 | wxOwnerDrawn *wxCheckListBox::CreateLboxItem(size_t nIndex) | |
246 | { | |
247 | wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex); | |
248 | return pItem; | |
249 | } | |
250 | ||
251 | // return item size | |
252 | // ---------------- | |
253 | bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) | |
254 | { | |
255 | return false; | |
256 | } | |
257 | ||
258 | // check items | |
259 | // ----------- | |
260 | ||
261 | bool wxCheckListBox::IsChecked(size_t uiIndex) const | |
262 | { | |
263 | return false; | |
264 | } | |
265 | ||
266 | void wxCheckListBox::Check(size_t uiIndex, bool bCheck) | |
267 | { | |
268 | } | |
269 | ||
270 | // process events | |
271 | // -------------- | |
272 | ||
273 | void wxCheckListBox::OnKeyDown(wxKeyEvent& event) | |
274 | { | |
275 | } | |
276 | ||
277 | void wxCheckListBox::OnLeftClick(wxMouseEvent& event) | |
278 | { | |
279 | } | |
280 | ||
281 | int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const | |
282 | { | |
283 | return wxNOT_FOUND; | |
284 | } | |
285 | ||
286 | #endif | |
287 |