]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/listctrl.cpp
Implemented user dashes for gnome print.
[wxWidgets.git] / src / palmos / listctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/listctrl.cpp
3 // Purpose: wxListCtrl
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_LISTCTRL
28
29 #ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #include "wx/intl.h"
32 #include "wx/log.h"
33 #include "wx/settings.h"
34 #endif
35
36 #include "wx/textctrl.h"
37 #include "wx/imaglist.h"
38 #include "wx/listctrl.h"
39 #include "wx/dcclient.h"
40
41 // ----------------------------------------------------------------------------
42 // events
43 // ----------------------------------------------------------------------------
44
45 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
46 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
47 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
48 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
49 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
50 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
51 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
52 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
53 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
54 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
55 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
56 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
57 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
58 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
59 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
60 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
61 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
62 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
63 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
64 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
65 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
66 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
67
68 #if wxUSE_EXTENDED_RTTI
69 WX_DEFINE_FLAGS( wxListCtrlStyle )
70
71 wxBEGIN_FLAGS( wxListCtrlStyle )
72 // new style border flags, we put them first to
73 // use them for streaming out
74 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
75 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
76 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
77 wxFLAGS_MEMBER(wxBORDER_RAISED)
78 wxFLAGS_MEMBER(wxBORDER_STATIC)
79 wxFLAGS_MEMBER(wxBORDER_NONE)
80
81 // old style border flags
82 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
83 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
84 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
85 wxFLAGS_MEMBER(wxRAISED_BORDER)
86 wxFLAGS_MEMBER(wxSTATIC_BORDER)
87 wxFLAGS_MEMBER(wxBORDER)
88
89 // standard window styles
90 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
91 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
92 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
93 wxFLAGS_MEMBER(wxWANTS_CHARS)
94 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
95 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
96 wxFLAGS_MEMBER(wxVSCROLL)
97 wxFLAGS_MEMBER(wxHSCROLL)
98
99 wxFLAGS_MEMBER(wxLC_LIST)
100 wxFLAGS_MEMBER(wxLC_REPORT)
101 wxFLAGS_MEMBER(wxLC_ICON)
102 wxFLAGS_MEMBER(wxLC_SMALL_ICON)
103 wxFLAGS_MEMBER(wxLC_ALIGN_TOP)
104 wxFLAGS_MEMBER(wxLC_ALIGN_LEFT)
105 wxFLAGS_MEMBER(wxLC_AUTOARRANGE)
106 wxFLAGS_MEMBER(wxLC_USER_TEXT)
107 wxFLAGS_MEMBER(wxLC_EDIT_LABELS)
108 wxFLAGS_MEMBER(wxLC_NO_HEADER)
109 wxFLAGS_MEMBER(wxLC_SINGLE_SEL)
110 wxFLAGS_MEMBER(wxLC_SORT_ASCENDING)
111 wxFLAGS_MEMBER(wxLC_SORT_DESCENDING)
112 wxFLAGS_MEMBER(wxLC_VIRTUAL)
113
114 wxEND_FLAGS( wxListCtrlStyle )
115
116 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
117
118 wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
119 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
120
121 wxPROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
122 wxEND_PROPERTIES_TABLE()
123
124 wxBEGIN_HANDLERS_TABLE(wxListCtrl)
125 wxEND_HANDLERS_TABLE()
126
127 wxCONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle )
128
129 /*
130 TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
131 */
132 #else
133 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
134 #endif
135
136 IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
137 IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
138
139 IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
140
141 BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
142 EVT_PAINT(wxListCtrl::OnPaint)
143 END_EVENT_TABLE()
144
145 // ============================================================================
146 // implementation
147 // ============================================================================
148
149 // ----------------------------------------------------------------------------
150 // wxListCtrl construction
151 // ----------------------------------------------------------------------------
152
153 void wxListCtrl::Init()
154 {
155 }
156
157 bool wxListCtrl::Create(wxWindow *parent,
158 wxWindowID id,
159 const wxPoint& pos,
160 const wxSize& size,
161 long style,
162 const wxValidator& validator,
163 const wxString& name)
164 {
165 return false;
166 }
167
168 void wxListCtrl::UpdateStyle()
169 {
170 }
171
172 void wxListCtrl::FreeAllInternalData()
173 {
174 }
175
176 wxListCtrl::~wxListCtrl()
177 {
178 }
179
180 // ----------------------------------------------------------------------------
181 // set/get/change style
182 // ----------------------------------------------------------------------------
183
184 // Add or remove a single window style
185 void wxListCtrl::SetSingleStyle(long style, bool add)
186 {
187 }
188
189 // ----------------------------------------------------------------------------
190 // accessors
191 // ----------------------------------------------------------------------------
192
193 /* static */ wxVisualAttributes wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
194 {
195 wxVisualAttributes attrs;
196
197 return attrs;
198 }
199
200 // Sets the foreground, i.e. text, colour
201 bool wxListCtrl::SetForegroundColour(const wxColour& col)
202 {
203 return false;
204 }
205
206 // Sets the background colour
207 bool wxListCtrl::SetBackgroundColour(const wxColour& col)
208 {
209 return false;
210 }
211
212 // Gets information about this column
213 bool wxListCtrl::GetColumn(int col, wxListItem& item) const
214 {
215 return false;
216 }
217
218 // Sets information about this column
219 bool wxListCtrl::SetColumn(int col, wxListItem& item)
220 {
221 return false;
222 }
223
224 // Gets the column width
225 int wxListCtrl::GetColumnWidth(int col) const
226 {
227 return 0;
228 }
229
230 // Sets the column width
231 bool wxListCtrl::SetColumnWidth(int col, int width)
232 {
233 return false;
234 }
235
236 // Gets the number of items that can fit vertically in the
237 // visible area of the list control (list or report view)
238 // or the total number of items in the list control (icon
239 // or small icon view)
240 int wxListCtrl::GetCountPerPage() const
241 {
242 return 0;
243 }
244
245 // Gets the edit control for editing labels.
246 wxTextCtrl* wxListCtrl::GetEditControl() const
247 {
248 return NULL;
249 }
250
251 // Gets information about the item
252 bool wxListCtrl::GetItem(wxListItem& info) const
253 {
254 return false;
255 }
256
257 // Sets information about the item
258 bool wxListCtrl::SetItem(wxListItem& info)
259 {
260 return false;
261 }
262
263 long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
264 {
265 return 0;
266 }
267
268
269 // Gets the item state
270 int wxListCtrl::GetItemState(long item, long stateMask) const
271 {
272 return 0;
273 }
274
275 // Sets the item state
276 bool wxListCtrl::SetItemState(long item, long state, long stateMask)
277 {
278 return false;
279 }
280
281 // Sets the item image
282 bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
283 {
284 return false;
285 }
286
287 // Gets the item text
288 wxString wxListCtrl::GetItemText(long item) const
289 {
290 wxListItem info;
291
292 return info.m_text;
293 }
294
295 // Sets the item text
296 void wxListCtrl::SetItemText(long item, const wxString& str)
297 {
298 }
299
300 // Gets the item data
301 long wxListCtrl::GetItemData(long item) const
302 {
303 return 0;
304 }
305
306 // Sets the item data
307 bool wxListCtrl::SetItemData(long item, long data)
308 {
309 return false;
310 }
311
312 wxRect wxListCtrl::GetViewRect() const
313 {
314 wxRect rect;
315
316 return rect;
317 }
318
319 // Gets the item rectangle
320 bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
321 {
322 return false;
323 }
324
325 // Gets the item position
326 bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
327 {
328 return false;
329 }
330
331 // Sets the item position.
332 bool wxListCtrl::SetItemPosition(long item, const wxPoint& pos)
333 {
334 return false;
335 }
336
337 // Gets the number of items in the list control
338 int wxListCtrl::GetItemCount() const
339 {
340 return 0;
341 }
342
343 wxSize wxListCtrl::GetItemSpacing() const
344 {
345 return wxSize(0,0);
346 }
347
348 int wxListCtrl::GetItemSpacing(bool isSmall) const
349 {
350 return 0;
351 }
352
353 void wxListCtrl::SetItemTextColour( long item, const wxColour &col )
354 {
355 }
356
357 wxColour wxListCtrl::GetItemTextColour( long item ) const
358 {
359 wxColour col;
360
361 return col;
362 }
363
364 void wxListCtrl::SetItemBackgroundColour( long item, const wxColour &col )
365 {
366 }
367
368 wxColour wxListCtrl::GetItemBackgroundColour( long item ) const
369 {
370 wxColour col;
371
372 return col;
373 }
374
375 // Gets the number of selected items in the list control
376 int wxListCtrl::GetSelectedItemCount() const
377 {
378 return 0;
379 }
380
381 // Gets the text colour of the listview
382 wxColour wxListCtrl::GetTextColour() const
383 {
384 wxColour col;
385 return col;
386 }
387
388 // Sets the text colour of the listview
389 void wxListCtrl::SetTextColour(const wxColour& col)
390 {
391 }
392
393 // Gets the index of the topmost visible item when in
394 // list or report view
395 long wxListCtrl::GetTopItem() const
396 {
397 return 0;
398 }
399
400 // Searches for an item, starting from 'item'.
401 // 'geometry' is one of
402 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
403 // 'state' is a state bit flag, one or more of
404 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
405 // item can be -1 to find the first item that matches the
406 // specified flags.
407 // Returns the item or -1 if unsuccessful.
408 long wxListCtrl::GetNextItem(long item, int geom, int state) const
409 {
410 return 0;
411 }
412
413
414 wxImageList *wxListCtrl::GetImageList(int which) const
415 {
416 return NULL;
417 }
418
419 void wxListCtrl::SetImageList(wxImageList *imageList, int which)
420 {
421 }
422
423 void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
424 {
425 }
426
427 // ----------------------------------------------------------------------------
428 // Operations
429 // ----------------------------------------------------------------------------
430
431 // Arranges the items
432 bool wxListCtrl::Arrange(int flag)
433 {
434 return false;
435 }
436
437 // Deletes an item
438 bool wxListCtrl::DeleteItem(long item)
439 {
440 return false;
441 }
442
443 // Deletes all items
444 bool wxListCtrl::DeleteAllItems()
445 {
446 return false;
447 }
448
449 // Deletes all items
450 bool wxListCtrl::DeleteAllColumns()
451 {
452 return false;
453 }
454
455 // Deletes a column
456 bool wxListCtrl::DeleteColumn(int col)
457 {
458 return false;
459 }
460
461 // Clears items, and columns if there are any.
462 void wxListCtrl::ClearAll()
463 {
464 }
465
466 wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass)
467 {
468 return NULL;
469 }
470
471 // End label editing, optionally cancelling the edit
472 bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel))
473 {
474 return false;
475 }
476
477 // Ensures this item is visible
478 bool wxListCtrl::EnsureVisible(long item)
479 {
480 return false;
481 }
482
483 // Find an item whose label matches this string, starting from the item after 'start'
484 // or the beginning if 'start' is -1.
485 long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
486 {
487 return 0;
488 }
489
490 // Find an item whose data matches this data, starting from the item after 'start'
491 // or the beginning if 'start' is -1.
492 // NOTE : Lindsay Mathieson - 14-July-2002
493 // No longer use ListView_FindItem as the data attribute is now stored
494 // in a wxListItemInternalData structure refernced by the actual lParam
495 long wxListCtrl::FindItem(long start, long data)
496 {
497 return wxNOT_FOUND;
498 }
499
500 // Find an item nearest this position in the specified direction, starting from
501 // the item after 'start' or the beginning if 'start' is -1.
502 long wxListCtrl::FindItem(long start, const wxPoint& pt, int direction)
503 {
504 return wxNOT_FOUND;
505 }
506
507 // Determines which item (if any) is at the specified point,
508 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
509 long wxListCtrl::HitTest(const wxPoint& point, int& flags)
510 {
511 return 0;
512 }
513
514 // Inserts an item, returning the index of the new item if successful,
515 // -1 otherwise.
516 long wxListCtrl::InsertItem(wxListItem& info)
517 {
518 return 0;
519 }
520
521 long wxListCtrl::InsertItem(long index, const wxString& label)
522 {
523 return 0;
524 }
525
526 // Inserts an image item
527 long wxListCtrl::InsertItem(long index, int imageIndex)
528 {
529 return 0;
530 }
531
532 // Inserts an image/string item
533 long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
534 {
535 return 0;
536 }
537
538 // For list view mode (only), inserts a column.
539 long wxListCtrl::InsertColumn(long col, wxListItem& item)
540 {
541 return 0;
542 }
543
544 long wxListCtrl::InsertColumn(long col,
545 const wxString& heading,
546 int format,
547 int width)
548 {
549 return 0;
550 }
551
552 // scroll the control by the given number of pixels (exception: in list view,
553 // dx is interpreted as number of columns)
554 bool wxListCtrl::ScrollList(int dx, int dy)
555 {
556 return false;
557 }
558
559 // Sort items.
560
561 // fn is a function which takes 3 long arguments: item1, item2, data.
562 // item1 is the long data associated with a first item (NOT the index).
563 // item2 is the long data associated with a second item (NOT the index).
564 // data is the same value as passed to SortItems.
565 // The return value is a negative number if the first item should precede the second
566 // item, a positive number of the second item should precede the first,
567 // or zero if the two items are equivalent.
568
569 // data is arbitrary data to be passed to the sort function.
570
571 // Internal structures for proxying the user compare function
572 // so that we can pass it the *real* user data
573
574 // translate lParam data and call user func
575 struct wxInternalDataSort
576 {
577 wxListCtrlCompare user_fn;
578 long data;
579 };
580
581 int CALLBACK wxInternalDataCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
582 {
583 struct wxInternalDataSort *internalData = (struct wxInternalDataSort *) lParamSort;
584
585 wxListItemInternalData *data1 = (wxListItemInternalData *) lParam1;
586 wxListItemInternalData *data2 = (wxListItemInternalData *) lParam2;
587
588 long d1 = (data1 == NULL ? 0 : data1->lParam);
589 long d2 = (data2 == NULL ? 0 : data2->lParam);
590
591 return internalData->user_fn(d1, d2, internalData->data);
592
593 };
594
595 bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
596 {
597 return false;
598 }
599
600
601
602 // ----------------------------------------------------------------------------
603 // message processing
604 // ----------------------------------------------------------------------------
605
606 // Necessary for drawing hrules and vrules, if specified
607 void wxListCtrl::OnPaint(wxPaintEvent& event)
608 {
609 }
610
611 // ----------------------------------------------------------------------------
612 // virtual list controls
613 // ----------------------------------------------------------------------------
614
615 wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
616 {
617 return wxEmptyString;
618 }
619
620 int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
621 {
622 return -1;
623 }
624
625 int wxListCtrl::OnGetItemColumnImage(long item, long column) const
626 {
627 if (!column)
628 return OnGetItemImage(item);
629
630 return -1;
631 }
632
633 wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const
634 {
635 // no attributes by default
636 return NULL;
637 }
638
639 void wxListCtrl::SetItemCount(long count)
640 {
641 }
642
643 void wxListCtrl::RefreshItem(long item)
644 {
645 }
646
647 void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
648 {
649 }
650
651 // ----------------------------------------------------------------------------
652 // internal data stuff
653 // ----------------------------------------------------------------------------
654
655 static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId)
656 {
657 return NULL;
658 };
659
660 static wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId)
661 {
662 return wxGetInternalData(GetHwndOf(ctl), itemId);
663 };
664
665 static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId)
666 {
667 return NULL;
668 };
669
670 static void wxDeleteInternalData(wxListCtrl* ctl, long itemId)
671 {
672 }
673
674 #endif // wxUSE_LISTCTRL
675