]>
git.saurik.com Git - wxWidgets.git/blob - src/stubs/listctrl.cpp
a659399c6364614d90a2ccd00d659bf3b339a24c
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl. See also Robert's generic wxListCtrl
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "listctrl.h"
16 #include "wx/listctrl.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
20 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
24 wxListCtrl::wxListCtrl()
26 m_imageListNormal
= NULL
;
27 m_imageListSmall
= NULL
;
28 m_imageListState
= NULL
;
33 bool wxListCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
34 long style
, const wxValidator
& validator
, const wxString
& name
)
36 m_imageListNormal
= NULL
;
37 m_imageListSmall
= NULL
;
38 m_imageListState
= NULL
;
41 SetValidator(validator
);
44 m_windowStyle
= style
;
48 m_windowId
= (id
== -1) ? NewControlId() : id
;
50 if (parent
) parent
->AddChild(this);
52 // TODO create list control
56 wxListCtrl::~wxListCtrl()
60 // Add or remove a single window style
61 void wxListCtrl::SetSingleStyle(long style
, bool add
)
63 long flag
= GetWindowStyleFlag();
65 // Get rid of conflicting styles
68 if ( style
& wxLC_MASK_TYPE
)
69 flag
= flag
& ~wxLC_MASK_TYPE
;
70 if ( style
& wxLC_MASK_ALIGN
)
71 flag
= flag
& ~wxLC_MASK_ALIGN
;
72 if ( style
& wxLC_MASK_SORT
)
73 flag
= flag
& ~wxLC_MASK_SORT
;
91 /* TODO RecreateWindow(); */
94 // Set the whole window style
95 void wxListCtrl::SetWindowStyleFlag(long flag
)
99 /* TODO RecreateWindow(); */
103 // Gets information about this column
104 bool wxListCtrl::GetColumn(int col
, wxListItem
& item
) const
110 // Sets information about this column
111 bool wxListCtrl::SetColumn(int col
, wxListItem
& item
)
117 // Gets the column width
118 int wxListCtrl::GetColumnWidth(int col
) const
124 // Sets the column width
125 bool wxListCtrl::SetColumnWidth(int col
, int width
)
131 // Gets the number of items that can fit vertically in the
132 // visible area of the list control (list or report view)
133 // or the total number of items in the list control (icon
134 // or small icon view)
135 int wxListCtrl::GetCountPerPage() const
141 // Gets the edit control for editing labels.
142 wxTextCtrl
* wxListCtrl::GetEditControl() const
147 // Gets information about the item
148 bool wxListCtrl::GetItem(wxListItem
& info
) const
154 // Sets information about the item
155 bool wxListCtrl::SetItem(wxListItem
& info
)
161 long wxListCtrl::SetItem(long index
, int col
, const wxString
& label
, int imageId
)
165 info
.m_mask
= wxLIST_MASK_TEXT
;
166 info
.m_itemId
= index
;
170 info
.m_image
= imageId
;
171 info
.m_mask
|= wxLIST_MASK_IMAGE
;
173 return SetItem(info
);
177 // Gets the item state
178 int wxListCtrl::GetItemState(long item
, long stateMask
) const
182 info
.m_mask
= wxLIST_MASK_STATE
;
183 info
.m_stateMask
= stateMask
;
184 info
.m_itemId
= item
;
192 // Sets the item state
193 bool wxListCtrl::SetItemState(long item
, long state
, long stateMask
)
197 info
.m_mask
= wxLIST_MASK_STATE
;
198 info
.m_state
= state
;
199 info
.m_stateMask
= stateMask
;
200 info
.m_itemId
= item
;
202 return SetItem(info
);
205 // Sets the item image
206 bool wxListCtrl::SetItemImage(long item
, int image
, int selImage
)
210 info
.m_mask
= wxLIST_MASK_IMAGE
;
211 info
.m_image
= image
;
212 info
.m_itemId
= item
;
214 return SetItem(info
);
217 // Gets the item text
218 wxString
wxListCtrl::GetItemText(long item
) const
222 info
.m_mask
= wxLIST_MASK_TEXT
;
223 info
.m_itemId
= item
;
230 // Sets the item text
231 void wxListCtrl::SetItemText(long item
, const wxString
& str
)
235 info
.m_mask
= wxLIST_MASK_TEXT
;
236 info
.m_itemId
= item
;
242 // Gets the item data
243 long wxListCtrl::GetItemData(long item
) const
247 info
.m_mask
= wxLIST_MASK_DATA
;
248 info
.m_itemId
= item
;
255 // Sets the item data
256 bool wxListCtrl::SetItemData(long item
, long data
)
260 info
.m_mask
= wxLIST_MASK_DATA
;
261 info
.m_itemId
= item
;
264 return SetItem(info
);
267 // Gets the item rectangle
268 bool wxListCtrl::GetItemRect(long item
, wxRectangle
& rect
, int code
) const
274 // Gets the item position
275 bool wxListCtrl::GetItemPosition(long item
, wxPoint
& pos
) const
281 // Sets the item position.
282 bool wxListCtrl::SetItemPosition(long item
, const wxPoint
& pos
)
288 // Gets the number of items in the list control
289 int wxListCtrl::GetItemCount() const
295 // Retrieves the spacing between icons in pixels.
296 // If small is TRUE, gets the spacing for the small icon
297 // view, otherwise the large icon view.
298 int wxListCtrl::GetItemSpacing(bool isSmall
) const
304 // Gets the number of selected items in the list control
305 int wxListCtrl::GetSelectedItemCount() const
311 // Gets the text colour of the listview
312 wxColour
wxListCtrl::GetTextColour() const
318 // Sets the text colour of the listview
319 void wxListCtrl::SetTextColour(const wxColour
& col
)
324 // Gets the index of the topmost visible item when in
325 // list or report view
326 long wxListCtrl::GetTopItem() const
332 // Searches for an item, starting from 'item'.
333 // 'geometry' is one of
334 // wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
335 // 'state' is a state bit flag, one or more of
336 // wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
337 // item can be -1 to find the first item that matches the
339 // Returns the item or -1 if unsuccessful.
340 long wxListCtrl::GetNextItem(long item
, int geom
, int state
) const
346 wxImageList
*wxListCtrl::GetImageList(int which
) const
348 if ( which
== wxIMAGE_LIST_NORMAL
)
350 return m_imageListNormal
;
352 else if ( which
== wxIMAGE_LIST_SMALL
)
354 return m_imageListSmall
;
356 else if ( which
== wxIMAGE_LIST_STATE
)
358 return m_imageListState
;
363 void wxListCtrl::SetImageList(wxImageList
*imageList
, int which
)
366 if ( which
== wxIMAGE_LIST_NORMAL
)
368 flags
= LVSIL_NORMAL
;
369 m_imageListNormal
= imageList
;
371 else if ( which
== wxIMAGE_LIST_SMALL
)
374 m_imageListSmall
= imageList
;
376 else if ( which
== wxIMAGE_LIST_STATE
)
379 m_imageListState
= imageList
;
381 // TODO set image list
385 ////////////////////////////////////////////////////////////////////////////
387 // Arranges the items
388 bool wxListCtrl::Arrange(int flag
)
395 bool wxListCtrl::DeleteItem(long item
)
402 bool wxListCtrl::DeleteAllItems()
409 bool wxListCtrl::DeleteAllColumns()
416 bool wxListCtrl::DeleteColumn(int col
)
422 // Clears items, and columns if there are any.
423 void wxListCtrl::ClearAll()
426 if ( m_colCount
> 0 )
431 wxTextCtrl
* wxListCtrl::EditLabel(long item
, wxClassInfo
* textControlClass
)
437 // End label editing, optionally cancelling the edit
438 bool wxListCtrl::EndEditLabel(bool cancel
)
444 // Ensures this item is visible
445 bool wxListCtrl::EnsureVisible(long item
)
451 // Find an item whose label matches this string, starting from the item after 'start'
452 // or the beginning if 'start' is -1.
453 long wxListCtrl::FindItem(long start
, const wxString
& str
, bool partial
)
459 // Find an item whose data matches this data, starting from the item after 'start'
460 // or the beginning if 'start' is -1.
461 long wxListCtrl::FindItem(long start
, long data
)
467 // Find an item nearest this position in the specified direction, starting from
468 // the item after 'start' or the beginning if 'start' is -1.
469 long wxListCtrl::FindItem(long start
, const wxPoint
& pt
, int direction
)
475 // Determines which item (if any) is at the specified point,
476 // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
477 long wxListCtrl::HitTest(const wxPoint
& point
, int& flags
)
483 // Inserts an item, returning the index of the new item if successful,
485 long wxListCtrl::InsertItem(wxListItem
& info
)
491 long wxListCtrl::InsertItem(long index
, const wxString
& label
)
495 info
.m_mask
= wxLIST_MASK_TEXT
;
496 info
.m_itemId
= index
;
497 return InsertItem(info
);
500 // Inserts an image item
501 long wxListCtrl::InsertItem(long index
, int imageIndex
)
504 info
.m_image
= imageIndex
;
505 info
.m_mask
= wxLIST_MASK_IMAGE
;
506 info
.m_itemId
= index
;
507 return InsertItem(info
);
510 // Inserts an image/string item
511 long wxListCtrl::InsertItem(long index
, const wxString
& label
, int imageIndex
)
514 info
.m_image
= imageIndex
;
516 info
.m_mask
= wxLIST_MASK_IMAGE
| wxLIST_MASK_TEXT
;
517 info
.m_itemId
= index
;
518 return InsertItem(info
);
521 // For list view mode (only), inserts a column.
522 long wxListCtrl::InsertColumn(long col
, wxListItem
& item
)
528 long wxListCtrl::InsertColumn(long col
, const wxString
& heading
, int format
,
532 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
533 item
.m_text
= heading
;
536 item
.m_mask
|= wxLIST_MASK_WIDTH
;
537 item
.m_width
= width
;
539 item
.m_format
= format
;
541 return InsertColumn(col
, item
);
544 // Scrolls the list control. If in icon, small icon or report view mode,
545 // x specifies the number of pixels to scroll. If in list view mode, x
546 // specifies the number of columns to scroll.
547 // If in icon, small icon or list view mode, y specifies the number of pixels
548 // to scroll. If in report view mode, y specifies the number of lines to scroll.
549 bool wxListCtrl::ScrollList(int dx
, int dy
)
557 // fn is a function which takes 3 long arguments: item1, item2, data.
558 // item1 is the long data associated with a first item (NOT the index).
559 // item2 is the long data associated with a second item (NOT the index).
560 // data is the same value as passed to SortItems.
561 // The return value is a negative number if the first item should precede the second
562 // item, a positive number of the second item should precede the first,
563 // or zero if the two items are equivalent.
565 // data is arbitrary data to be passed to the sort function.
566 bool wxListCtrl::SortItems(wxListCtrlCompare fn
, long data
)
572 // List item structure
573 wxListItem::wxListItem()
583 m_format
= wxLIST_FORMAT_CENTRE
;
588 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxCommandEvent
)
590 wxListEvent::wxListEvent(wxEventType commandType
, int id
):
591 wxCommandEvent(commandType
, id
)