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