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 %pythonPrepend Destroy "args[0].this.own(False)"
178 %extend { void Destroy() { delete self; } }
180 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
181 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
182 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
188 //---------------------------------------------------------------------------
192 // wxListItem: the item or column info, used to exchange data with wxListCtrl
193 class wxListItem : public wxObject {
195 // turn off this typemap
196 %typemap(out) wxListItem*;
201 // Turn it back on again
202 %typemap(out) wxListItem* { $result = wxPyMake_wxObject($1, $owner); }
206 void ClearAttributes();
209 void SetMask(long mask);
211 void SetColumn(int col);
212 void SetState(long state);
213 void SetStateMask(long stateMask);
214 void SetText(const wxString& text);
215 void SetImage(int image);
216 void SetData(long data);
218 void SetWidth(int width);
219 void SetAlign(wxListColumnFormat align);
221 void SetTextColour(const wxColour& colText);
222 void SetBackgroundColour(const wxColour& colBack);
223 void SetFont(const wxFont& font);
230 const wxString& GetText();
235 wxListColumnFormat GetAlign();
237 wxListItemAttr *GetAttributes();
238 bool HasAttributes();
240 wxColour GetTextColour() const;
241 wxColour GetBackgroundColour() const;
242 wxFont GetFont() const;
244 // these members are public for compatibility
245 long m_mask; // Indicates what fields are valid
246 long m_itemId; // The zero-based item position
247 int m_col; // Zero-based column, if in report mode
248 long m_state; // The state of the item
249 long m_stateMask;// Which flags of m_state are valid (uses same flags)
250 wxString m_text; // The label/header text
251 int m_image; // The zero-based index into an image list
252 long m_data; // App-defined data
255 int m_format; // left, right, centre
256 int m_width; // width of column
258 %property(Align, GetAlign, SetAlign, doc="See `GetAlign` and `SetAlign`");
259 %property(Attributes, GetAttributes, doc="See `GetAttributes`");
260 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
261 %property(Column, GetColumn, SetColumn, doc="See `GetColumn` and `SetColumn`");
262 %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
263 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
264 %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
265 %property(Image, GetImage, SetImage, doc="See `GetImage` and `SetImage`");
266 %property(Mask, GetMask, SetMask, doc="See `GetMask` and `SetMask`");
267 %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
268 %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
269 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
270 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
274 //---------------------------------------------------------------------------
278 // wxListEvent - the event class for the wxListCtrl notifications
279 class wxListEvent: public wxNotifyEvent {
281 wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
293 %pythoncode { GetCode = GetKeyCode }
297 %pythoncode { GetPosition = GetPoint }
298 const wxString& GetLabel();
299 const wxString& GetText();
303 const wxListItem& GetItem();
308 // was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only)
309 bool IsEditCancelled() const;
310 void SetEditCanceled(bool editCancelled);
312 %property(CacheFrom, GetCacheFrom, doc="See `GetCacheFrom`");
313 %property(CacheTo, GetCacheTo, doc="See `GetCacheTo`");
314 %property(Column, GetColumn, doc="See `GetColumn`");
315 %property(Data, GetData, doc="See `GetData`");
316 %property(Image, GetImage, doc="See `GetImage`");
317 %property(Index, GetIndex, doc="See `GetIndex`");
318 %property(Item, GetItem, doc="See `GetItem`");
319 %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
320 %property(Label, GetLabel, doc="See `GetLabel`");
321 %property(Mask, GetMask, doc="See `GetMask`");
322 %property(Point, GetPoint, doc="See `GetPoint`");
323 %property(Text, GetText, doc="See `GetText`");
327 /* List control event types */
328 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG;
329 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG;
330 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
331 %constant wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT;
332 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM;
333 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
334 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED;
335 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED;
336 %constant wxEventType wxEVT_COMMAND_LIST_KEY_DOWN;
337 %constant wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM;
338 %constant wxEventType wxEVT_COMMAND_LIST_COL_CLICK;
339 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
340 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK;
341 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
342 %constant wxEventType wxEVT_COMMAND_LIST_CACHE_HINT;
343 %constant wxEventType wxEVT_COMMAND_LIST_COL_RIGHT_CLICK;
344 %constant wxEventType wxEVT_COMMAND_LIST_COL_BEGIN_DRAG;
345 %constant wxEventType wxEVT_COMMAND_LIST_COL_DRAGGING;
346 %constant wxEventType wxEVT_COMMAND_LIST_COL_END_DRAG;
347 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_FOCUSED;
349 // WXWIN_COMPATIBILITY_2_4
351 %constant wxEventType wxEVT_COMMAND_LIST_GET_INFO;
352 %constant wxEventType wxEVT_COMMAND_LIST_SET_INFO;
357 EVT_LIST_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_DRAG , 1)
358 EVT_LIST_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_RDRAG , 1)
359 EVT_LIST_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT , 1)
360 EVT_LIST_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_END_LABEL_EDIT , 1)
361 EVT_LIST_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ITEM , 1)
362 EVT_LIST_DELETE_ALL_ITEMS = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS , 1)
363 #WXWIN_COMPATIBILITY_2_4
364 #EVT_LIST_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_GET_INFO , 1)
365 #EVT_LIST_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_SET_INFO , 1)
366 #END WXWIN_COMPATIBILITY_2_4
367 EVT_LIST_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_SELECTED , 1)
368 EVT_LIST_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_DESELECTED , 1)
369 EVT_LIST_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_LIST_KEY_DOWN , 1)
370 EVT_LIST_INSERT_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_INSERT_ITEM , 1)
371 EVT_LIST_COL_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_CLICK , 1)
372 EVT_LIST_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK , 1)
373 EVT_LIST_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 1)
374 EVT_LIST_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_ACTIVATED , 1)
375 EVT_LIST_CACHE_HINT = wx.PyEventBinder(wxEVT_COMMAND_LIST_CACHE_HINT , 1)
376 EVT_LIST_COL_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK , 1)
377 EVT_LIST_COL_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG , 1)
378 EVT_LIST_COL_DRAGGING = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_DRAGGING , 1)
379 EVT_LIST_COL_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_END_DRAG , 1)
380 EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED , 1)
382 #WXWIN_COMPATIBILITY_2_4
383 #EVT_LIST_GET_INFO = wx._deprecated(EVT_LIST_GET_INFO)
384 #EVT_LIST_SET_INFO = wx._deprecated(EVT_LIST_SET_INFO)
387 //---------------------------------------------------------------------------
391 %{ // Python aware sorting function for wxPyListCtrl
392 static int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
394 PyObject* func = (PyObject*)funcPtr;
395 wxPyBlock_t blocked = wxPyBeginBlockThreads();
397 PyObject* args = Py_BuildValue("(ii)", item1, item2);
398 PyObject* result = PyEval_CallObject(func, args);
401 retval = PyInt_AsLong(result);
405 wxPyEndBlockThreads(blocked);
412 %{ // C++ Version of a Python aware class
413 class wxPyListCtrl : public wxListCtrl {
414 DECLARE_ABSTRACT_CLASS(wxPyListCtrl)
416 wxPyListCtrl() : wxListCtrl() {}
417 wxPyListCtrl(wxWindow* parent, wxWindowID id,
421 const wxValidator& validator,
422 const wxString& name) :
423 wxListCtrl(parent, id, pos, size, style, validator, name) {}
425 bool Create(wxWindow* parent, wxWindowID id,
429 const wxValidator& validator,
430 const wxString& name) {
431 return wxListCtrl::Create(parent, id, pos, size, style, validator, name);
434 DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText);
435 DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr);
437 // use the virtual version to avoid a confusing assert in the base class
438 DEC_PYCALLBACK_INT_LONG_virtual(OnGetItemImage);
439 DEC_PYCALLBACK_INT_LONGLONG(OnGetItemColumnImage);
444 IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl);
446 IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText);
447 IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
448 IMP_PYCALLBACK_INT_LONG_virtual(wxPyListCtrl, wxListCtrl, OnGetItemImage);
449 IMP_PYCALLBACK_INT_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemColumnImage);
455 // NOTE: The following option is set in _settings.i
456 // # Until the new native control for wxMac is up to par, still use the generic one.
457 // SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 1)
459 MustHaveApp(wxPyListCtrl);
461 %rename(ListCtrl) wxPyListCtrl;
462 class wxPyListCtrl : public wxControl {
464 // turn off this typemap
465 %typemap(out) wxPyListCtrl*;
467 %pythonAppend wxPyListCtrl "self._setOORInfo(self);" setCallbackInfo(ListCtrl)
468 %pythonAppend wxPyListCtrl() ""
470 wxPyListCtrl(wxWindow* parent, wxWindowID id = -1,
471 const wxPoint& pos = wxDefaultPosition,
472 const wxSize& size = wxDefaultSize,
473 long style = wxLC_ICON,
474 const wxValidator& validator = wxDefaultValidator,
475 const wxString& name = wxPyListCtrlNameStr);
476 %RenameCtor(PreListCtrl, wxPyListCtrl());
478 // Turn it back on again
479 %typemap(out) wxPyListCtrl* { $result = wxPyMake_wxObject($1, $owner); }
481 bool Create(wxWindow* parent, wxWindowID id = -1,
482 const wxPoint& pos = wxDefaultPosition,
483 const wxSize& size = wxDefaultSize,
484 long style = wxLC_ICON,
485 const wxValidator& validator = wxDefaultValidator,
486 const wxString& name = wxPyListCtrlNameStr);
488 void _setCallbackInfo(PyObject* self, PyObject* _class);
491 // Set the control colours
492 bool SetForegroundColour(const wxColour& col);
493 bool SetBackgroundColour(const wxColour& col);
495 // Gets information about this column
496 %pythonAppend GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
498 wxListItem* GetColumn(int col) {
500 item.SetMask( wxLIST_MASK_STATE |
508 if (self->GetColumn(col, item))
509 return new wxListItem(item);
515 // Sets information about this column
516 bool SetColumn(int col, wxListItem& item) ;
518 // Gets the column width
519 int GetColumnWidth(int col) const;
521 // Sets the column width
522 bool SetColumnWidth(int col, int width) ;
524 // Gets the number of items that can fit vertically in the
525 // visible area of the list control (list or report view)
526 // or the total number of items in the list control (icon
527 // or small icon view)
528 int GetCountPerPage() const;
530 // return the total area occupied by all the items (icon/small icon only)
531 wxRect GetViewRect() const;
533 // Gets the edit control for editing labels.
534 wxTextCtrl* GetEditControl() const;
536 // Gets information about the item
537 %pythonAppend GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
539 wxListItem* GetItem(long itemId, int col=0) {
540 wxListItem* info = new wxListItem;
541 info->m_itemId = itemId;
543 info->m_mask = 0xFFFF;
544 self->GetItem(*info);
549 // Sets information about the item
550 bool SetItem(wxListItem& info) ;
552 // Sets a string field at a particular column
553 %Rename(SetStringItem, long, SetItem(long index, int col, const wxString& label, int imageId = -1));
555 // Gets the item state
556 int GetItemState(long item, long stateMask) const ;
558 // Sets the item state
559 bool SetItemState(long item, long state, long stateMask) ;
561 // Sets the item image
562 bool SetItemImage(long item, int image, int selImage=-1) ;
563 bool SetItemColumnImage( long item, long column, int image );
565 // Gets the item text
566 wxString GetItemText(long item) const ;
568 // Sets the item text
569 void SetItemText(long item, const wxString& str) ;
571 // Gets the item data
572 long GetItemData(long item) const ;
574 // Sets the item data
575 bool SetItemData(long item, long data) ;
578 //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ;
579 //bool GetItemPosition(long item, wxPoint& pos) const ;
581 // Gets the item position
583 wxPoint GetItemPosition(long item) {
585 self->GetItemPosition(item, pos);
588 // Gets the item rectangle
589 wxRect GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
591 self->GetItemRect(item, rect, code);
595 // MSW only so far...
596 // wxRect GetSubItemRect(long item, long subItem, int code = wxLIST_RECT_BOUNDS) {
598 // self->GetSubItemRect(item, subItem, rect, code);
604 // Sets the item position
605 bool SetItemPosition(long item, const wxPoint& pos) ;
607 // Gets the number of items in the list control
608 int GetItemCount() const;
610 // Gets the number of columns in the list control
611 int GetColumnCount() const;
613 // get the horizontal and vertical components of the item spacing
614 wxSize GetItemSpacing() const;
615 %pythoncode { GetItemSpacing = wx._deprecated(GetItemSpacing) }
618 void SetItemSpacing( int spacing, bool isSmall = false );
619 %pythoncode { SetItemSpacing = wx._deprecated(SetItemSpacing) }
622 // Gets the number of selected items in the list control
623 int GetSelectedItemCount() const;
625 // Gets the text colour of the listview
626 wxColour GetTextColour() const;
628 // Sets the text colour of the listview
629 void SetTextColour(const wxColour& col);
631 // Gets the index of the topmost visible item when in
632 // list or report view
633 long GetTopItem() const ;
635 // Add or remove a single window style
636 void SetSingleStyle(long style, bool add = true) ;
638 // Set the whole window style
639 void SetWindowStyleFlag(long style) ;
641 // Searches for an item, starting from 'item'.
642 // item can be -1 to find the first item that matches the
644 // Returns the item or -1 if unsuccessful.
645 long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
647 // Gets one of the three image lists
648 wxImageList *GetImageList(int which) const ;
650 // Sets the image list
651 void SetImageList(wxImageList *imageList, int which);
653 %disownarg( wxImageList *imageList );
654 void AssignImageList(wxImageList *imageList, int which);
655 %cleardisown( wxImageList *imageList );
657 // are we in report mode?
658 bool InReportView() const;
660 // returns True if it is a virtual list control
661 bool IsVirtual() const;
663 // refresh items selectively (only useful for virtual list controls)
664 void RefreshItem(long item);
665 void RefreshItems(long itemFrom, long itemTo);
667 // Arranges the items
668 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
671 bool DeleteItem(long item);
674 bool DeleteAllItems() ;
677 bool DeleteColumn(int col);
679 // Deletes all columns
680 bool DeleteAllColumns();
682 // Clears items, and columns if there are any.
687 wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/);
689 // End label editing, optionally cancelling the edit
690 bool EndEditLabel(bool cancel);
692 void EditLabel(long item);
695 // Ensures this item is visible
696 bool EnsureVisible(long item) ;
698 // Find an item whose label matches this string, starting from the item after 'start'
699 // or the beginning if 'start' is -1.
700 long FindItem(long start, const wxString& str, bool partial = false);
702 // Find an item whose data matches this data, starting from the item after 'start'
703 // or the beginning if 'start' is -1.
704 %Rename(FindItemData, long, FindItem(long start, long data));
706 // Find an item nearest this position in the specified direction, starting from
707 // the item after 'start' or the beginning if 'start' is -1.
708 %Rename(FindItemAtPos, long, FindItem(long start, const wxPoint& pt, int direction));
712 long, HitTest(const wxPoint& point, int& OUTPUT),
713 "HitTest(Point point) -> (item, where)",
714 "Determines which item (if any) is at the specified point, giving
715 details in the second return value (see wx.LIST_HITTEST flags.)", "");
718 long, HitTest(const wxPoint& point, int& OUTPUT, long* OUTPUT),
719 "HitTestSubItem(Point point) -> (item, where, subItem)",
720 "Determines which item (if any) is at the specified point, giving details in
721 the second return value (see wx.LIST_HITTEST flags) and also the subItem, if
726 // Inserts an item, returning the index of the new item if successful,
728 long InsertItem(wxListItem& info);
730 // Insert a string item
731 %Rename(InsertStringItem,
732 long, InsertItem(long index, const wxString& label, int imageIndex=-1));
734 // Insert an image item
735 %Rename(InsertImageItem,
736 long, InsertItem(long index, int imageIndex));
738 // Insert an image/string item
739 %Rename(InsertImageStringItem,
740 long, InsertItem(long index, const wxString& label, int imageIndex));
742 // For list view mode (only), inserts a column.
743 %Rename(InsertColumnItem, long, InsertColumn(long col, wxListItem& info));
744 %pythoncode { InsertColumnInfo = InsertColumnItem }
746 long InsertColumn(long col,
747 const wxString& heading,
748 int format = wxLIST_FORMAT_LEFT,
751 // set the number of items in a virtual list control
752 void SetItemCount(long count);
754 // Scrolls the list control. If in icon, small icon or report view mode,
755 // x specifies the number of pixels to scroll. If in list view mode, x
756 // specifies the number of columns to scroll.
757 // If in icon, small icon or list view mode, y specifies the number of pixels
758 // to scroll. If in report view mode, y specifies the number of lines to scroll.
759 bool ScrollList(int dx, int dy);
761 void SetItemTextColour( long item, const wxColour& col);
762 wxColour GetItemTextColour( long item ) const;
763 void SetItemBackgroundColour( long item, const wxColour &col);
764 wxColour GetItemBackgroundColour( long item ) const;
767 void SetItemFont( long item, const wxFont &f);
768 wxFont GetItemFont( long item ) const;
773 def Select(self, idx, on=1):
774 '''[de]select an item'''
775 if on: state = wx.LIST_STATE_SELECTED
777 self.SetItemState(idx, state, wx.LIST_STATE_SELECTED)
779 def Focus(self, idx):
780 '''Focus and show the given item'''
781 self.SetItemState(idx, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
782 self.EnsureVisible(idx)
784 def GetFocusedItem(self):
785 '''get the currently focused item or -1 if none'''
786 return self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_FOCUSED)
788 def GetFirstSelected(self, *args):
789 '''return first selected item, or -1 when none'''
790 return self.GetNextSelected(-1)
792 def GetNextSelected(self, item):
793 '''return subsequent selected items, or -1 when no more'''
794 return self.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
796 def IsSelected(self, idx):
797 '''return True if the item is selected'''
798 return (self.GetItemState(idx, wx.LIST_STATE_SELECTED) & wx.LIST_STATE_SELECTED) != 0
800 def SetColumnImage(self, col, image):
801 item = self.GetColumn(col)
802 %# preserve all other attributes too
803 item.SetMask( wx.LIST_MASK_STATE |
809 wx.LIST_MASK_FORMAT )
811 self.SetColumn(col, item)
813 def ClearColumnImage(self, col):
814 self.SetColumnImage(col, -1)
816 def Append(self, entry):
817 '''Append an item to the list control. The entry parameter should be a
818 sequence with an item for each column'''
824 pos = self.GetItemCount()
825 self.InsertStringItem(pos, cvtfunc(entry[0]))
826 for i in range(1, len(entry)):
827 self.SetStringItem(pos, i, cvtfunc(entry[i]))
832 // bool SortItems(wxListCtrlCompare fn, long data);
835 // func is a function which takes 2 long arguments: item1, item2.
836 // item1 is the long data associated with a first item (NOT the index).
837 // item2 is the long data associated with a second item (NOT the index).
838 // The return value is a negative number if the first item should precede the second
839 // item, a positive number of the second item should precede the first,
840 // or zero if the two items are equivalent.
841 bool SortItems(PyObject* func) {
842 if (!PyCallable_Check(func))
844 return self->SortItems((wxListCtrlCompare)wxPyListCtrl_SortItems, (long)func);
850 wxWindow* GetMainWindow() {
851 #if defined(__WXMSW__) || defined(__WXMAC__)
854 return (wxWindow*)self->m_mainWin;
859 static wxVisualAttributes
860 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
862 %property(ColumnCount, GetColumnCount, doc="See `GetColumnCount`");
863 %property(CountPerPage, GetCountPerPage, doc="See `GetCountPerPage`");
864 %property(EditControl, GetEditControl, doc="See `GetEditControl`");
865 %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
866 %property(ItemCount, GetItemCount, SetItemCount, doc="See `GetItemCount` and `SetItemCount`");
867 %property(MainWindow, GetMainWindow, doc="See `GetMainWindow`");
868 %property(SelectedItemCount, GetSelectedItemCount, doc="See `GetSelectedItemCount`");
869 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
870 %property(TopItem, GetTopItem, doc="See `GetTopItem`");
871 %property(ViewRect, GetViewRect, doc="See `GetViewRect`");
876 //---------------------------------------------------------------------------
880 MustHaveApp(wxListView);
882 // wxListView: a class which provides a little better API for list control
883 class wxListView : public wxPyListCtrl
886 %pythonAppend wxListView "self._setOORInfo(self)"
887 %pythonAppend wxListView() ""
889 wxListView( wxWindow *parent,
891 const wxPoint& pos = wxDefaultPosition,
892 const wxSize& size = wxDefaultSize,
893 long style = wxLC_REPORT,
894 const wxValidator& validator = wxDefaultValidator,
895 const wxString& name = wxPyListCtrlNameStr);
896 %RenameCtor(PreListView, wxListView());
898 bool Create( wxWindow *parent,
900 const wxPoint& pos = wxDefaultPosition,
901 const wxSize& size = wxDefaultSize,
902 long style = wxLC_REPORT,
903 const wxValidator& validator = wxDefaultValidator,
904 const wxString& name = wxPyListCtrlNameStr);
906 // [de]select an item
907 void Select(long n, bool on = true);
909 // focus and show the given item
910 void Focus(long index);
912 // get the currently focused item or -1 if none
913 long GetFocusedItem() const;
915 // get first and subsequent selected items, return -1 when no more
916 long GetNextSelected(long item) const;
917 long GetFirstSelected() const;
919 // return True if the item is selected
920 bool IsSelected(long index);
922 void SetColumnImage(int col, int image);
923 void ClearColumnImage(int col);
925 %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
930 //---------------------------------------------------------------------------
933 // Map renamed classes back to their common name for OOR
934 wxPyPtrTypeMap_Add("wxListCtrl", "wxPyListCtrl");
937 //---------------------------------------------------------------------------