]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/checklst.cpp
When wxPGProperty is un-attached from wxPropertyGrid, keep its 'default' cell referen...
[wxWidgets.git] / src / palmos / checklst.cpp
CommitLineData
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__
e6e83933 24 #pragma hdrstop
ffecfa5a
JS
25#endif
26
e6e83933
WS
27#if wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN
28
29#include "wx/checklst.h"
ffecfa5a
JS
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"
ffecfa5a
JS
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
64WX_DEFINE_FLAGS( wxCheckListBoxStyle )
65
66wxBEGIN_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)
e2731512 75
ffecfa5a
JS
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
103wxEND_FLAGS( wxCheckListBoxStyle )
104
105IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckListBox, wxListBox,"wx/checklst.h")
106
107wxBEGIN_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
110wxEND_PROPERTIES_TABLE()
111
112wxBEGIN_HANDLERS_TABLE(wxCheckListBox)
113wxEND_HANDLERS_TABLE()
114
e2731512 115wxCONSTRUCTOR_4( wxCheckListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size )
ffecfa5a
JS
116
117#else
118IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
119#endif
120
121// ----------------------------------------------------------------------------
122// declaration and implementation of wxCheckListBoxItem class
123// ----------------------------------------------------------------------------
124
125class wxCheckListBoxItem : public wxOwnerDrawn
126{
127friend class WXDLLEXPORT wxCheckListBox;
128public:
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
143private:
144
c0c133e1 145 wxDECLARE_NO_COPY_CLASS(wxCheckListBoxItem);
ffecfa5a
JS
146 bool m_bChecked;
147 wxCheckListBox *m_pParent;
148 size_t m_nIndex;
149};
150
151wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex)
aa61d352 152 : wxOwnerDrawn(wxEmptyString, true) // checkable
ffecfa5a
JS
153{
154}
155
156bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
157 wxODAction act, wxODStatus stat)
158{
aa61d352 159 return false;
ffecfa5a
JS
160}
161
162// change the state of the item and redraw it
163void wxCheckListBoxItem::Check(bool check)
164{
165}
166
167// send an "item checked" event
168void wxCheckListBoxItem::SendEvent()
169{
170}
171
172// ----------------------------------------------------------------------------
173// implementation of wxCheckListBox class
174// ----------------------------------------------------------------------------
175
176// define event table
177// ------------------
178BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
179 EVT_KEY_DOWN(wxCheckListBox::OnKeyDown)
180 EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
181END_EVENT_TABLE()
182
183// control creation
184// ----------------
185
186// def ctor: use Create() to really create the control
187wxCheckListBox::wxCheckListBox()
188{
189}
190
191// ctor which creates the associated control
192wxCheckListBox::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
201wxCheckListBox::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
210bool 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
220bool 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
aa61d352 233void wxCheckListBox::Delete(unsigned int n)
ffecfa5a
JS
234{
235}
236
237bool wxCheckListBox::SetFont( const wxFont &font )
238{
239 return false;
240}
241
242// create/retrieve item
243// --------------------
244
245// create a check list box item
246wxOwnerDrawn *wxCheckListBox::CreateLboxItem(size_t nIndex)
247{
248 wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex);
249 return pItem;
250}
251
252// return item size
253// ----------------
254bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
255{
256 return false;
257}
258
259// check items
260// -----------
261
aa61d352 262bool wxCheckListBox::IsChecked(unsigned int uiIndex) const
ffecfa5a
JS
263{
264 return false;
265}
266
aa61d352 267void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck)
ffecfa5a
JS
268{
269}
270
271// process events
272// --------------
273
274void wxCheckListBox::OnKeyDown(wxKeyEvent& event)
275{
276}
277
278void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
279{
280}
281
282int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const
283{
284 return wxNOT_FOUND;
285}
286
e6e83933 287#endif // wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN