1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxListCtrl and related classes
7 // Created: 10-June-1998
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include <wx/listctrl.h>
22 MAKE_CONST_WXSTRING(ListCtrlNameStr);
24 //---------------------------------------------------------------------------
55 // Mask flags to tell app/GUI what fields of wxListItem are valid
64 // State flags for indicating the state of an item
65 wxLIST_STATE_DONTCARE,
66 wxLIST_STATE_DROPHILITED,
68 wxLIST_STATE_SELECTED,
70 wxLIST_STATE_DISABLED,
71 wxLIST_STATE_FILTERED,
76 // Hit test flags, used in HitTest
79 wxLIST_HITTEST_NOWHERE,
80 wxLIST_HITTEST_ONITEMICON,
81 wxLIST_HITTEST_ONITEMLABEL,
82 wxLIST_HITTEST_ONITEMRIGHT,
83 wxLIST_HITTEST_ONITEMSTATEICON,
84 wxLIST_HITTEST_TOLEFT,
85 wxLIST_HITTEST_TORIGHT,
86 wxLIST_HITTEST_ONITEM,
88 // GetSubItemRect constants
89 wxLIST_GETSUBITEMRECT_WHOLEITEM,
93 // Flags for GetNextItem (MSW only except wxLIST_NEXT_ALL)
96 wxLIST_NEXT_ABOVE, // Searches for an item above the specified item
97 wxLIST_NEXT_ALL, // Searches for subsequent item by index
98 wxLIST_NEXT_BELOW, // Searches for an item below the specified item
99 wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
100 wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
103 // Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT)
106 wxLIST_ALIGN_DEFAULT,
109 wxLIST_ALIGN_SNAP_TO_GRID
112 // Column format (MSW only except wxLIST_FORMAT_LEFT)
113 enum wxListColumnFormat
117 wxLIST_FORMAT_CENTRE,
118 wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
121 // Autosize values for SetColumnWidth
124 wxLIST_AUTOSIZE = -1,
125 wxLIST_AUTOSIZE_USEHEADER = -2 // partly supported by generic version
128 // Flag values for GetItemRect
136 // Flag values for FindItem (MSW only)
147 //---------------------------------------------------------------------------
150 // wxListItemAttr: a structure containing the visual attributes of an item
156 wxListItemAttr(const wxColour& colText = wxNullColour,
157 const wxColour& colBack = wxNullColour,
158 const wxFont& font = wxNullFont);
162 void SetTextColour(const wxColour& colText);
163 void SetBackgroundColour(const wxColour& colBack);
164 void SetFont(const wxFont& font);
167 bool HasTextColour();
168 bool HasBackgroundColour();
171 wxColour GetTextColour();
172 wxColour GetBackgroundColour();
175 void AssignFrom(const wxListItemAttr& source);
177 %pythonAppend Destroy "args[0].thisown = 0"
178 %extend { void Destroy() { delete self; } }
184 //---------------------------------------------------------------------------
188 // wxListItem: the item or column info, used to exchange data with wxListCtrl
189 class wxListItem : public wxObject {
196 void ClearAttributes();
199 void SetMask(long mask);
201 void SetColumn(int col);
202 void SetState(long state);
203 void SetStateMask(long stateMask);
204 void SetText(const wxString& text);
205 void SetImage(int image);
206 void SetData(long data);
208 void SetWidth(int width);
209 void SetAlign(wxListColumnFormat align);
211 void SetTextColour(const wxColour& colText);
212 void SetBackgroundColour(const wxColour& colBack);
213 void SetFont(const wxFont& font);
220 const wxString& GetText();
225 wxListColumnFormat GetAlign();
227 wxListItemAttr *GetAttributes();
228 bool HasAttributes();
230 wxColour GetTextColour() const;
231 wxColour GetBackgroundColour() const;
232 wxFont GetFont() const;
234 // these members are public for compatibility
235 long m_mask; // Indicates what fields are valid
236 long m_itemId; // The zero-based item position
237 int m_col; // Zero-based column, if in report mode
238 long m_state; // The state of the item
239 long m_stateMask;// Which flags of m_state are valid (uses same flags)
240 wxString m_text; // The label/header text
241 int m_image; // The zero-based index into an image list
242 long m_data; // App-defined data
245 int m_format; // left, right, centre
246 int m_width; // width of column
251 //---------------------------------------------------------------------------
255 // wxListEvent - the event class for the wxListCtrl notifications
256 class wxListEvent: public wxNotifyEvent {
258 wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
270 %pythoncode { GetCode = GetKeyCode }
274 %pythoncode { GetPosition = GetPoint }
275 const wxString& GetLabel();
276 const wxString& GetText();
280 const wxListItem& GetItem();
285 // was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only)
286 bool IsEditCancelled() const;
287 void SetEditCanceled(bool editCancelled);
290 /* List control event types */
291 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG;
292 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG;
293 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
294 %constant wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT;
295 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM;
296 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
297 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED;
298 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED;
299 %constant wxEventType wxEVT_COMMAND_LIST_KEY_DOWN;
300 %constant wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM;
301 %constant wxEventType wxEVT_COMMAND_LIST_COL_CLICK;
302 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
303 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK;
304 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
305 %constant wxEventType wxEVT_COMMAND_LIST_CACHE_HINT;
306 %constant wxEventType wxEVT_COMMAND_LIST_COL_RIGHT_CLICK;
307 %constant wxEventType wxEVT_COMMAND_LIST_COL_BEGIN_DRAG;
308 %constant wxEventType wxEVT_COMMAND_LIST_COL_DRAGGING;
309 %constant wxEventType wxEVT_COMMAND_LIST_COL_END_DRAG;
310 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_FOCUSED;
312 // WXWIN_COMPATIBILITY_2_4
314 %constant wxEventType wxEVT_COMMAND_LIST_GET_INFO;
315 %constant wxEventType wxEVT_COMMAND_LIST_SET_INFO;
320 EVT_LIST_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_DRAG , 1)
321 EVT_LIST_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_RDRAG , 1)
322 EVT_LIST_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT , 1)
323 EVT_LIST_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_END_LABEL_EDIT , 1)
324 EVT_LIST_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ITEM , 1)
325 EVT_LIST_DELETE_ALL_ITEMS = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS , 1)
326 #WXWIN_COMPATIBILITY_2_4
327 #EVT_LIST_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_GET_INFO , 1)
328 #EVT_LIST_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_SET_INFO , 1)
329 #END WXWIN_COMPATIBILITY_2_4
330 EVT_LIST_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_SELECTED , 1)
331 EVT_LIST_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_DESELECTED , 1)
332 EVT_LIST_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_LIST_KEY_DOWN , 1)
333 EVT_LIST_INSERT_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_INSERT_ITEM , 1)
334 EVT_LIST_COL_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_CLICK , 1)
335 EVT_LIST_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK , 1)
336 EVT_LIST_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 1)
337 EVT_LIST_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_ACTIVATED , 1)
338 EVT_LIST_CACHE_HINT = wx.PyEventBinder(wxEVT_COMMAND_LIST_CACHE_HINT , 1)
339 EVT_LIST_COL_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK , 1)
340 EVT_LIST_COL_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG , 1)
341 EVT_LIST_COL_DRAGGING = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_DRAGGING , 1)
342 EVT_LIST_COL_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_END_DRAG , 1)
343 EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED , 1)
345 #WXWIN_COMPATIBILITY_2_4
346 #EVT_LIST_GET_INFO = wx._deprecated(EVT_LIST_GET_INFO)
347 #EVT_LIST_SET_INFO = wx._deprecated(EVT_LIST_SET_INFO)
350 //---------------------------------------------------------------------------
354 %{ // Python aware sorting function for wxPyListCtrl
355 static int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
357 PyObject* func = (PyObject*)funcPtr;
358 wxPyBlock_t blocked = wxPyBeginBlockThreads();
360 PyObject* args = Py_BuildValue("(ii)", item1, item2);
361 PyObject* result = PyEval_CallObject(func, args);
364 retval = PyInt_AsLong(result);
368 wxPyEndBlockThreads(blocked);
375 %{ // C++ Version of a Python aware class
376 class wxPyListCtrl : public wxListCtrl {
377 DECLARE_ABSTRACT_CLASS(wxPyListCtrl)
379 wxPyListCtrl() : wxListCtrl() {}
380 wxPyListCtrl(wxWindow* parent, wxWindowID id,
384 const wxValidator& validator,
385 const wxString& name) :
386 wxListCtrl(parent, id, pos, size, style, validator, name) {}
388 bool Create(wxWindow* parent, wxWindowID id,
392 const wxValidator& validator,
393 const wxString& name) {
394 return wxListCtrl::Create(parent, id, pos, size, style, validator, name);
397 DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText);
398 DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr);
400 // use the virtual version to avoid a confusing assert in the base class
401 DEC_PYCALLBACK_INT_LONG_virtual(OnGetItemImage);
402 DEC_PYCALLBACK_INT_LONGLONG(OnGetItemColumnImage);
407 IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl);
409 IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText);
410 IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
411 IMP_PYCALLBACK_INT_LONG_virtual(wxPyListCtrl, wxListCtrl, OnGetItemImage);
412 IMP_PYCALLBACK_INT_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemColumnImage);
420 MustHaveApp(wxPyListCtrl);
422 %rename(ListCtrl) wxPyListCtrl;
423 class wxPyListCtrl : public wxControl {
426 %pythonAppend wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
427 %pythonAppend wxPyListCtrl() ""
429 wxPyListCtrl(wxWindow* parent, wxWindowID id = -1,
430 const wxPoint& pos = wxDefaultPosition,
431 const wxSize& size = wxDefaultSize,
432 long style = wxLC_ICON,
433 const wxValidator& validator = wxDefaultValidator,
434 const wxString& name = wxPyListCtrlNameStr);
435 %RenameCtor(PreListCtrl, wxPyListCtrl());
437 bool Create(wxWindow* parent, wxWindowID id = -1,
438 const wxPoint& pos = wxDefaultPosition,
439 const wxSize& size = wxDefaultSize,
440 long style = wxLC_ICON,
441 const wxValidator& validator = wxDefaultValidator,
442 const wxString& name = wxPyListCtrlNameStr);
444 void _setCallbackInfo(PyObject* self, PyObject* _class);
447 // Set the control colours
448 bool SetForegroundColour(const wxColour& col);
449 bool SetBackgroundColour(const wxColour& col);
451 // Gets information about this column
452 %pythonAppend GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
454 wxListItem* GetColumn(int col) {
456 item.SetMask( wxLIST_MASK_STATE |
464 if (self->GetColumn(col, item))
465 return new wxListItem(item);
471 // Sets information about this column
472 bool SetColumn(int col, wxListItem& item) ;
474 // Gets the column width
475 int GetColumnWidth(int col) const;
477 // Sets the column width
478 bool SetColumnWidth(int col, int width) ;
480 // Gets the number of items that can fit vertically in the
481 // visible area of the list control (list or report view)
482 // or the total number of items in the list control (icon
483 // or small icon view)
484 int GetCountPerPage() const;
486 // return the total area occupied by all the items (icon/small icon only)
487 wxRect GetViewRect() const;
489 // Gets the edit control for editing labels.
490 wxTextCtrl* GetEditControl() const;
492 // Gets information about the item
493 %pythonAppend GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
495 wxListItem* GetItem(long itemId, int col=0) {
496 wxListItem* info = new wxListItem;
497 info->m_itemId = itemId;
499 info->m_mask = 0xFFFF;
500 self->GetItem(*info);
505 // Sets information about the item
506 bool SetItem(wxListItem& info) ;
508 // Sets a string field at a particular column
509 %Rename(SetStringItem, long, SetItem(long index, int col, const wxString& label, int imageId = -1));
511 // Gets the item state
512 int GetItemState(long item, long stateMask) const ;
514 // Sets the item state
515 bool SetItemState(long item, long state, long stateMask) ;
517 // Sets the item image
518 bool SetItemImage(long item, int image, int selImage=-1) ;
519 bool SetItemColumnImage( long item, long column, int image );
521 // Gets the item text
522 wxString GetItemText(long item) const ;
524 // Sets the item text
525 void SetItemText(long item, const wxString& str) ;
527 // Gets the item data
528 long GetItemData(long item) const ;
530 // Sets the item data
531 bool SetItemData(long item, long data) ;
534 //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ;
535 //bool GetItemPosition(long item, wxPoint& pos) const ;
537 // Gets the item position
539 wxPoint GetItemPosition(long item) {
541 self->GetItemPosition(item, pos);
544 // Gets the item rectangle
545 wxRect GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
547 self->GetItemRect(item, rect, code);
551 // MSW only so far...
552 // wxRect GetSubItemRect(long item, long subItem, int code = wxLIST_RECT_BOUNDS) {
554 // self->GetSubItemRect(item, subItem, rect, code);
560 // Sets the item position
561 bool SetItemPosition(long item, const wxPoint& pos) ;
563 // Gets the number of items in the list control
564 int GetItemCount() const;
566 // Gets the number of columns in the list control
567 int GetColumnCount() const;
569 // get the horizontal and vertical components of the item spacing
570 wxSize GetItemSpacing() const;
571 %pythoncode { GetItemSpacing = wx._deprecated(GetItemSpacing) }
574 void SetItemSpacing( int spacing, bool isSmall = false );
575 %pythoncode { SetItemSpacing = wx._deprecated(SetItemSpacing) }
578 // Gets the number of selected items in the list control
579 int GetSelectedItemCount() const;
581 // Gets the text colour of the listview
582 wxColour GetTextColour() const;
584 // Sets the text colour of the listview
585 void SetTextColour(const wxColour& col);
587 // Gets the index of the topmost visible item when in
588 // list or report view
589 long GetTopItem() const ;
591 // Add or remove a single window style
592 void SetSingleStyle(long style, bool add = true) ;
594 // Set the whole window style
595 void SetWindowStyleFlag(long style) ;
597 // Searches for an item, starting from 'item'.
598 // item can be -1 to find the first item that matches the
600 // Returns the item or -1 if unsuccessful.
601 long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
603 // Gets one of the three image lists
604 wxImageList *GetImageList(int which) const ;
606 // Sets the image list
607 void SetImageList(wxImageList *imageList, int which);
609 %disownarg( wxImageList *imageList );
610 void AssignImageList(wxImageList *imageList, int which);
611 %cleardisown( wxImageList *imageList );
613 // are we in report mode?
614 bool InReportView() const;
616 // returns True if it is a virtual list control
617 bool IsVirtual() const;
619 // refresh items selectively (only useful for virtual list controls)
620 void RefreshItem(long item);
621 void RefreshItems(long itemFrom, long itemTo);
623 // Arranges the items
624 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
627 bool DeleteItem(long item);
630 bool DeleteAllItems() ;
633 bool DeleteColumn(int col);
635 // Deletes all columns
636 bool DeleteAllColumns();
638 // Clears items, and columns if there are any.
643 wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/);
645 // End label editing, optionally cancelling the edit
646 bool EndEditLabel(bool cancel);
648 void EditLabel(long item);
651 // Ensures this item is visible
652 bool EnsureVisible(long item) ;
654 // Find an item whose label matches this string, starting from the item after 'start'
655 // or the beginning if 'start' is -1.
656 long FindItem(long start, const wxString& str, bool partial = false);
658 // Find an item whose data matches this data, starting from the item after 'start'
659 // or the beginning if 'start' is -1.
660 %Rename(FindItemData, long, FindItem(long start, long data));
662 // Find an item nearest this position in the specified direction, starting from
663 // the item after 'start' or the beginning if 'start' is -1.
664 %Rename(FindItemAtPos, long, FindItem(long start, const wxPoint& pt, int direction));
668 long, HitTest(const wxPoint& point, int& OUTPUT),
669 "HitTest(Point point) -> (item, where)",
670 "Determines which item (if any) is at the specified point, giving
671 details in the second return value (see wx.LIST_HITTEST flags.)", "");
674 long, HitTest(const wxPoint& point, int& OUTPUT, long* OUTPUT),
675 "HitTestSubItem(Point point) -> (item, where, subItem)",
676 "Determines which item (if any) is at the specified point, giving details in
677 the second return value (see wx.LIST_HITTEST flags) and also the subItem, if
682 // Inserts an item, returning the index of the new item if successful,
684 long InsertItem(wxListItem& info);
686 // Insert a string item
687 %Rename(InsertStringItem,
688 long, InsertItem(long index, const wxString& label, int imageIndex=-1));
690 // Insert an image item
691 %Rename(InsertImageItem,
692 long, InsertItem(long index, int imageIndex));
694 // Insert an image/string item
695 %Rename(InsertImageStringItem,
696 long, InsertItem(long index, const wxString& label, int imageIndex));
698 // For list view mode (only), inserts a column.
699 %Rename(InsertColumnItem, long, InsertColumn(long col, wxListItem& info));
700 %pythoncode { InsertColumnInfo = InsertColumnItem }
702 long InsertColumn(long col,
703 const wxString& heading,
704 int format = wxLIST_FORMAT_LEFT,
707 // set the number of items in a virtual list control
708 void SetItemCount(long count);
710 // Scrolls the list control. If in icon, small icon or report view mode,
711 // x specifies the number of pixels to scroll. If in list view mode, x
712 // specifies the number of columns to scroll.
713 // If in icon, small icon or list view mode, y specifies the number of pixels
714 // to scroll. If in report view mode, y specifies the number of lines to scroll.
715 bool ScrollList(int dx, int dy);
717 void SetItemTextColour( long item, const wxColour& col);
718 wxColour GetItemTextColour( long item ) const;
719 void SetItemBackgroundColour( long item, const wxColour &col);
720 wxColour GetItemBackgroundColour( long item ) const;
723 void SetItemFont( long item, const wxFont &f);
724 wxFont GetItemFont( long item ) const;
729 def Select(self, idx, on=1):
730 '''[de]select an item'''
731 if on: state = wx.LIST_STATE_SELECTED
733 self.SetItemState(idx, state, wx.LIST_STATE_SELECTED)
735 def Focus(self, idx):
736 '''Focus and show the given item'''
737 self.SetItemState(idx, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
738 self.EnsureVisible(idx)
740 def GetFocusedItem(self):
741 '''get the currently focused item or -1 if none'''
742 return self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_FOCUSED)
744 def GetFirstSelected(self, *args):
745 '''return first selected item, or -1 when none'''
746 return self.GetNextSelected(-1)
748 def GetNextSelected(self, item):
749 '''return subsequent selected items, or -1 when no more'''
750 return self.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
752 def IsSelected(self, idx):
753 '''return True if the item is selected'''
754 return (self.GetItemState(idx, wx.LIST_STATE_SELECTED) & wx.LIST_STATE_SELECTED) != 0
756 def SetColumnImage(self, col, image):
757 item = self.GetColumn(col)
758 %# preserve all other attributes too
759 item.SetMask( wx.LIST_MASK_STATE |
765 wx.LIST_MASK_FORMAT )
767 self.SetColumn(col, item)
769 def ClearColumnImage(self, col):
770 self.SetColumnImage(col, -1)
772 def Append(self, entry):
773 '''Append an item to the list control. The entry parameter should be a
774 sequence with an item for each column'''
780 pos = self.GetItemCount()
781 self.InsertStringItem(pos, cvtfunc(entry[0]))
782 for i in range(1, len(entry)):
783 self.SetStringItem(pos, i, cvtfunc(entry[i]))
788 // bool SortItems(wxListCtrlCompare fn, long data);
791 // func is a function which takes 2 long arguments: item1, item2.
792 // item1 is the long data associated with a first item (NOT the index).
793 // item2 is the long data associated with a second item (NOT the index).
794 // The return value is a negative number if the first item should precede the second
795 // item, a positive number of the second item should precede the first,
796 // or zero if the two items are equivalent.
797 bool SortItems(PyObject* func) {
798 if (!PyCallable_Check(func))
800 return self->SortItems((wxListCtrlCompare)wxPyListCtrl_SortItems, (long)func);
806 wxWindow* GetMainWindow() {
810 return (wxWindow*)self->m_mainWin;
815 static wxVisualAttributes
816 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
821 //---------------------------------------------------------------------------
825 MustHaveApp(wxListView);
827 // wxListView: a class which provides a little better API for list control
828 class wxListView : public wxPyListCtrl
831 %pythonAppend wxListView "self._setOORInfo(self)"
832 %pythonAppend wxListView() ""
834 wxListView( wxWindow *parent,
836 const wxPoint& pos = wxDefaultPosition,
837 const wxSize& size = wxDefaultSize,
838 long style = wxLC_REPORT,
839 const wxValidator& validator = wxDefaultValidator,
840 const wxString& name = wxPyListCtrlNameStr);
841 %RenameCtor(PreListView, wxListView());
843 bool Create( wxWindow *parent,
845 const wxPoint& pos = wxDefaultPosition,
846 const wxSize& size = wxDefaultSize,
847 long style = wxLC_REPORT,
848 const wxValidator& validator = wxDefaultValidator,
849 const wxString& name = wxPyListCtrlNameStr);
851 // [de]select an item
852 void Select(long n, bool on = true);
854 // focus and show the given item
855 void Focus(long index);
857 // get the currently focused item or -1 if none
858 long GetFocusedItem() const;
860 // get first and subsequent selected items, return -1 when no more
861 long GetNextSelected(long item) const;
862 long GetFirstSelected() const;
864 // return True if the item is selected
865 bool IsSelected(long index);
867 void SetColumnImage(int col, int image);
868 void ClearColumnImage(int col);
873 //---------------------------------------------------------------------------
876 // Map renamed classes back to their common name for OOR
877 wxPyPtrTypeMap_Add("wxListCtrl", "wxPyListCtrl");
880 //---------------------------------------------------------------------------