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