]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/palmos/listbox.cpp
about menu item changes : can appear anywhere in a menu, separator lines above or...
[wxWidgets.git] / src / palmos / listbox.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/listbox.cpp
3// Purpose: wxListBox
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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "listbox.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
23#if wxUSE_LISTBOX
24
25#ifndef WX_PRECOMP
26#include "wx/listbox.h"
27#include "wx/settings.h"
28#include "wx/brush.h"
29#include "wx/font.h"
30#include "wx/dc.h"
31#include "wx/utils.h"
32#endif
33
34#include "wx/window.h"
35#include "wx/palmos/private.h"
36
37#include "wx/dynarray.h"
38#include "wx/log.h"
39
40#if wxUSE_OWNER_DRAWN
41 #include "wx/ownerdrw.h"
42#endif
43
44#if wxUSE_EXTENDED_RTTI
45WX_DEFINE_FLAGS( wxListBoxStyle )
46
47wxBEGIN_FLAGS( wxListBoxStyle )
48 // new style border flags, we put them first to
49 // use them for streaming out
50 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
51 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
52 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
53 wxFLAGS_MEMBER(wxBORDER_RAISED)
54 wxFLAGS_MEMBER(wxBORDER_STATIC)
55 wxFLAGS_MEMBER(wxBORDER_NONE)
56
57 // old style border flags
58 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
59 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
60 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
61 wxFLAGS_MEMBER(wxRAISED_BORDER)
62 wxFLAGS_MEMBER(wxSTATIC_BORDER)
63 wxFLAGS_MEMBER(wxBORDER)
64
65 // standard window styles
66 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
67 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
68 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
69 wxFLAGS_MEMBER(wxWANTS_CHARS)
70 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
71 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
72 wxFLAGS_MEMBER(wxVSCROLL)
73 wxFLAGS_MEMBER(wxHSCROLL)
74
75 wxFLAGS_MEMBER(wxLB_SINGLE)
76 wxFLAGS_MEMBER(wxLB_MULTIPLE)
77 wxFLAGS_MEMBER(wxLB_EXTENDED)
78 wxFLAGS_MEMBER(wxLB_HSCROLL)
79 wxFLAGS_MEMBER(wxLB_ALWAYS_SB)
80 wxFLAGS_MEMBER(wxLB_NEEDED_SB)
81 wxFLAGS_MEMBER(wxLB_SORT)
82
83wxEND_FLAGS( wxListBoxStyle )
84
85IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox, wxControl,"wx/listbox.h")
86
87wxBEGIN_PROPERTIES_TABLE(wxListBox)
88 wxEVENT_PROPERTY( Select , wxEVT_COMMAND_LISTBOX_SELECTED , wxCommandEvent )
89 wxEVENT_PROPERTY( DoubleClick , wxEVT_COMMAND_LISTBOX_DOUBLECLICKED , wxCommandEvent )
90
91 wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
92 wxPROPERTY_COLLECTION( Choices , wxArrayString , wxString , AppendString , GetStrings, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
93 wxPROPERTY( Selection ,int, SetSelection, GetSelection, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
94 wxPROPERTY_FLAGS( WindowStyle , wxListBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
95wxEND_PROPERTIES_TABLE()
96
97wxBEGIN_HANDLERS_TABLE(wxListBox)
98wxEND_HANDLERS_TABLE()
99
100wxCONSTRUCTOR_4( wxListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size )
101#else
102IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
103#endif
104
105// ============================================================================
106// list box item declaration and implementation
107// ============================================================================
108
109#if wxUSE_OWNER_DRAWN
110
111class wxListBoxItem : public wxOwnerDrawn
112{
113public:
114 wxListBoxItem(const wxString& str = wxEmptyString);
115};
116
117wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
118{
119 // no bitmaps/checkmarks
120 SetMarginWidth(0);
121}
122
123wxOwnerDrawn *wxListBox::CreateLboxItem(size_t WXUNUSED(n))
124{
125 return new wxListBoxItem();
126}
127
128#endif //USE_OWNER_DRAWN
129
130// ============================================================================
131// list box control implementation
132// ============================================================================
133
134// ----------------------------------------------------------------------------
135// creation
136// ----------------------------------------------------------------------------
137
138// Listbox item
139wxListBox::wxListBox()
140{
141}
142
143bool wxListBox::Create(wxWindow *parent,
144 wxWindowID id,
145 const wxPoint& pos,
146 const wxSize& size,
147 int n, const wxString choices[],
148 long style,
149 const wxValidator& validator,
150 const wxString& name)
151{
152 return false;
153}
154
155bool wxListBox::Create(wxWindow *parent,
156 wxWindowID id,
157 const wxPoint& pos,
158 const wxSize& size,
159 const wxArrayString& choices,
160 long style,
161 const wxValidator& validator,
162 const wxString& name)
163{
164 return false;
165}
166
167wxListBox::~wxListBox()
168{
169}
170
171WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const
172{
173 return 0;
174}
175
176// ----------------------------------------------------------------------------
177// implementation of wxListBoxBase methods
178// ----------------------------------------------------------------------------
179
180void wxListBox::DoSetFirstItem(int N)
181{
182}
183
184void wxListBox::Delete(int N)
185{
186}
187
188int wxListBox::DoAppend(const wxString& item)
189{
190 return 0;
191}
192
193void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
194{
195}
196
197int wxListBox::FindString(const wxString& s) const
198{
199 return wxNOT_FOUND;
200}
201
202void wxListBox::Clear()
203{
204}
205
206void wxListBox::Free()
207{
208}
209
210void wxListBox::DoSetSelection(int N, bool select)
211{
212}
213
214bool wxListBox::IsSelected(int N) const
215{
216 return false;
217}
218
219wxClientData* wxListBox::DoGetItemClientObject(int n) const
220{
221 return (wxClientData *)DoGetItemClientData(n);
222}
223
224void *wxListBox::DoGetItemClientData(int n) const
225{
226 return (void *)NULL;
227}
228
229void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
230{
231}
232
233void wxListBox::DoSetItemClientData(int n, void *clientData)
234{
235}
236
237// Return number of selections and an array of selected integers
238int wxListBox::GetSelections(wxArrayInt& aSelections) const
239{
240 return 0;
241}
242
243// Get single selection, for single choice list items
244int wxListBox::GetSelection() const
245{
246 return 0;
247}
248
249// Find string for position
250wxString wxListBox::GetString(int N) const
251{
252 wxString result;
253
254 return result;
255}
256
257void
258wxListBox::DoInsertItems(const wxArrayString& items, int pos)
259{
260}
261
262void wxListBox::SetString(int N, const wxString& s)
263{
264}
265
266int wxListBox::GetCount() const
267{
268 return m_noItems;
269}
270
271// ----------------------------------------------------------------------------
272// helpers
273// ----------------------------------------------------------------------------
274
275void wxListBox::SetHorizontalExtent(const wxString& s)
276{
277}
278
279wxSize wxListBox::DoGetBestSize() const
280{
281 return wxSize(0,0);
282}
283
284// ----------------------------------------------------------------------------
285// callbacks
286// ----------------------------------------------------------------------------
287
288bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
289{
290 return false;
291}
292
293// ----------------------------------------------------------------------------
294// wxCheckListBox support
295// ----------------------------------------------------------------------------
296
297#if wxUSE_OWNER_DRAWN
298
299// drawing
300// -------
301
302// space beneath/above each row in pixels
303// "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
304#define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
305
306// the height is the same for all items
307// TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes
308
309// NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
310// message is not yet sent when we get here!
311bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
312{
313 return true;
314}
315
316// forward the message to the appropriate item
317bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
318{
319 return true;
320}
321
322#endif // wxUSE_OWNER_DRAWN
323
324#endif // wxUSE_LISTBOX