]>
Commit | Line | Data |
---|---|---|
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 | |
45 | WX_DEFINE_FLAGS( wxListBoxStyle ) | |
46 | ||
47 | wxBEGIN_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 | ||
83 | wxEND_FLAGS( wxListBoxStyle ) | |
84 | ||
85 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox, wxControl,"wx/listbox.h") | |
86 | ||
87 | wxBEGIN_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 | |
95 | wxEND_PROPERTIES_TABLE() | |
96 | ||
97 | wxBEGIN_HANDLERS_TABLE(wxListBox) | |
98 | wxEND_HANDLERS_TABLE() | |
99 | ||
100 | wxCONSTRUCTOR_4( wxListBox , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) | |
101 | #else | |
102 | IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) | |
103 | #endif | |
104 | ||
105 | // ============================================================================ | |
106 | // list box item declaration and implementation | |
107 | // ============================================================================ | |
108 | ||
109 | #if wxUSE_OWNER_DRAWN | |
110 | ||
111 | class wxListBoxItem : public wxOwnerDrawn | |
112 | { | |
113 | public: | |
114 | wxListBoxItem(const wxString& str = wxEmptyString); | |
115 | }; | |
116 | ||
117 | wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE) | |
118 | { | |
119 | // no bitmaps/checkmarks | |
120 | SetMarginWidth(0); | |
121 | } | |
122 | ||
123 | wxOwnerDrawn *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 | |
139 | wxListBox::wxListBox() | |
140 | { | |
141 | } | |
142 | ||
143 | bool 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 | ||
155 | bool 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 | ||
167 | wxListBox::~wxListBox() | |
168 | { | |
169 | } | |
170 | ||
171 | WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const | |
172 | { | |
173 | return 0; | |
174 | } | |
175 | ||
176 | // ---------------------------------------------------------------------------- | |
177 | // implementation of wxListBoxBase methods | |
178 | // ---------------------------------------------------------------------------- | |
179 | ||
180 | void wxListBox::DoSetFirstItem(int N) | |
181 | { | |
182 | } | |
183 | ||
184 | void wxListBox::Delete(int N) | |
185 | { | |
186 | } | |
187 | ||
188 | int wxListBox::DoAppend(const wxString& item) | |
189 | { | |
190 | return 0; | |
191 | } | |
192 | ||
193 | void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) | |
194 | { | |
195 | } | |
196 | ||
197 | int wxListBox::FindString(const wxString& s) const | |
198 | { | |
199 | return wxNOT_FOUND; | |
200 | } | |
201 | ||
202 | void wxListBox::Clear() | |
203 | { | |
204 | } | |
205 | ||
206 | void wxListBox::Free() | |
207 | { | |
208 | } | |
209 | ||
210 | void wxListBox::DoSetSelection(int N, bool select) | |
211 | { | |
212 | } | |
213 | ||
214 | bool wxListBox::IsSelected(int N) const | |
215 | { | |
216 | return false; | |
217 | } | |
218 | ||
219 | wxClientData* wxListBox::DoGetItemClientObject(int n) const | |
220 | { | |
221 | return (wxClientData *)DoGetItemClientData(n); | |
222 | } | |
223 | ||
224 | void *wxListBox::DoGetItemClientData(int n) const | |
225 | { | |
226 | return (void *)NULL; | |
227 | } | |
228 | ||
229 | void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData) | |
230 | { | |
231 | } | |
232 | ||
233 | void wxListBox::DoSetItemClientData(int n, void *clientData) | |
234 | { | |
235 | } | |
236 | ||
237 | // Return number of selections and an array of selected integers | |
238 | int wxListBox::GetSelections(wxArrayInt& aSelections) const | |
239 | { | |
240 | return 0; | |
241 | } | |
242 | ||
243 | // Get single selection, for single choice list items | |
244 | int wxListBox::GetSelection() const | |
245 | { | |
246 | return 0; | |
247 | } | |
248 | ||
249 | // Find string for position | |
250 | wxString wxListBox::GetString(int N) const | |
251 | { | |
252 | wxString result; | |
253 | ||
254 | return result; | |
255 | } | |
256 | ||
257 | void | |
258 | wxListBox::DoInsertItems(const wxArrayString& items, int pos) | |
259 | { | |
260 | } | |
261 | ||
262 | void wxListBox::SetString(int N, const wxString& s) | |
263 | { | |
264 | } | |
265 | ||
266 | int wxListBox::GetCount() const | |
267 | { | |
268 | return m_noItems; | |
269 | } | |
270 | ||
271 | // ---------------------------------------------------------------------------- | |
272 | // helpers | |
273 | // ---------------------------------------------------------------------------- | |
274 | ||
275 | void wxListBox::SetHorizontalExtent(const wxString& s) | |
276 | { | |
277 | } | |
278 | ||
279 | wxSize wxListBox::DoGetBestSize() const | |
280 | { | |
281 | return wxSize(0,0); | |
282 | } | |
283 | ||
284 | // ---------------------------------------------------------------------------- | |
285 | // callbacks | |
286 | // ---------------------------------------------------------------------------- | |
287 | ||
288 | bool 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! | |
311 | bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) | |
312 | { | |
313 | return true; | |
314 | } | |
315 | ||
316 | // forward the message to the appropriate item | |
317 | bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) | |
318 | { | |
319 | return true; | |
320 | } | |
321 | ||
322 | #endif // wxUSE_OWNER_DRAWN | |
323 | ||
324 | #endif // wxUSE_LISTBOX |