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; } }
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 {
200 void ClearAttributes();
203 void SetMask(long mask);
205 void SetColumn(int col);
206 void SetState(long state);
207 void SetStateMask(long stateMask);
208 void SetText(const wxString& text);
209 void SetImage(int image);
210 void SetData(long data);
212 void SetWidth(int width);
213 void SetAlign(wxListColumnFormat align);
215 void SetTextColour(const wxColour& colText);
216 void SetBackgroundColour(const wxColour& colBack);
217 void SetFont(const wxFont& font);
224 const wxString& GetText();
229 wxListColumnFormat GetAlign();
231 wxListItemAttr *GetAttributes();
232 bool HasAttributes();
234 wxColour GetTextColour() const;
235 wxColour GetBackgroundColour() const;
236 wxFont GetFont() const;
238 // these members are public for compatibility
239 long m_mask; // Indicates what fields are valid
240 long m_itemId; // The zero-based item position
241 int m_col; // Zero-based column, if in report mode
242 long m_state; // The state of the item
243 long m_stateMask;// Which flags of m_state are valid (uses same flags)
244 wxString m_text; // The label/header text
245 int m_image; // The zero-based index into an image list
246 long m_data; // App-defined data
249 int m_format; // left, right, centre
250 int m_width; // width of column
252 %property(Align, GetAlign, SetAlign, doc="See `GetAlign` and `SetAlign`");
253 %property(Attributes, GetAttributes, doc="See `GetAttributes`");
254 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
255 %property(Column, GetColumn, SetColumn, doc="See `GetColumn` and `SetColumn`");
256 %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
257 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
258 %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
259 %property(Image, GetImage, SetImage, doc="See `GetImage` and `SetImage`");
260 %property(Mask, GetMask, SetMask, doc="See `GetMask` and `SetMask`");
261 %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
262 %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
263 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
264 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
268 //---------------------------------------------------------------------------
272 // wxListEvent - the event class for the wxListCtrl notifications
273 class wxListEvent: public wxNotifyEvent {
275 wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
287 %pythoncode { GetCode = GetKeyCode }
291 %pythoncode { GetPosition = GetPoint }
292 const wxString& GetLabel();
293 const wxString& GetText();
297 const wxListItem& GetItem();
302 // was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only)
303 bool IsEditCancelled() const;
304 void SetEditCanceled(bool editCancelled);
306 %property(CacheFrom, GetCacheFrom, doc="See `GetCacheFrom`");
307 %property(CacheTo, GetCacheTo, doc="See `GetCacheTo`");
308 %property(Column, GetColumn, doc="See `GetColumn`");
309 %property(Data, GetData, doc="See `GetData`");
310 %property(Image, GetImage, doc="See `GetImage`");
311 %property(Index, GetIndex, doc="See `GetIndex`");
312 %property(Item, GetItem, doc="See `GetItem`");
313 %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
314 %property(Label, GetLabel, doc="See `GetLabel`");
315 %property(Mask, GetMask, doc="See `GetMask`");
316 %property(Point, GetPoint, doc="See `GetPoint`");
317 %property(Text, GetText, doc="See `GetText`");
321 /* List control event types */
322 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG;
323 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG;
324 %constant wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
325 %constant wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT;
326 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM;
327 %constant wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
328 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED;
329 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED;
330 %constant wxEventType wxEVT_COMMAND_LIST_KEY_DOWN;
331 %constant wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM;
332 %constant wxEventType wxEVT_COMMAND_LIST_COL_CLICK;
333 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
334 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK;
335 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
336 %constant wxEventType wxEVT_COMMAND_LIST_CACHE_HINT;
337 %constant wxEventType wxEVT_COMMAND_LIST_COL_RIGHT_CLICK;
338 %constant wxEventType wxEVT_COMMAND_LIST_COL_BEGIN_DRAG;
339 %constant wxEventType wxEVT_COMMAND_LIST_COL_DRAGGING;
340 %constant wxEventType wxEVT_COMMAND_LIST_COL_END_DRAG;
341 %constant wxEventType wxEVT_COMMAND_LIST_ITEM_FOCUSED;
343 // WXWIN_COMPATIBILITY_2_4
345 %constant wxEventType wxEVT_COMMAND_LIST_GET_INFO;
346 %constant wxEventType wxEVT_COMMAND_LIST_SET_INFO;
351 EVT_LIST_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_DRAG , 1)
352 EVT_LIST_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_RDRAG , 1)
353 EVT_LIST_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT , 1)
354 EVT_LIST_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_END_LABEL_EDIT , 1)
355 EVT_LIST_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ITEM , 1)
356 EVT_LIST_DELETE_ALL_ITEMS = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS , 1)
357 #WXWIN_COMPATIBILITY_2_4
358 #EVT_LIST_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_GET_INFO , 1)
359 #EVT_LIST_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_SET_INFO , 1)
360 #END WXWIN_COMPATIBILITY_2_4
361 EVT_LIST_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_SELECTED , 1)
362 EVT_LIST_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_DESELECTED , 1)
363 EVT_LIST_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_LIST_KEY_DOWN , 1)
364 EVT_LIST_INSERT_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_INSERT_ITEM , 1)
365 EVT_LIST_COL_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_CLICK , 1)
366 EVT_LIST_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK , 1)
367 EVT_LIST_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, 1)
368 EVT_LIST_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_ACTIVATED , 1)
369 EVT_LIST_CACHE_HINT = wx.PyEventBinder(wxEVT_COMMAND_LIST_CACHE_HINT , 1)
370 EVT_LIST_COL_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK , 1)
371 EVT_LIST_COL_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG , 1)
372 EVT_LIST_COL_DRAGGING = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_DRAGGING , 1)
373 EVT_LIST_COL_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_END_DRAG , 1)
374 EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED , 1)
376 #WXWIN_COMPATIBILITY_2_4
377 #EVT_LIST_GET_INFO = wx._deprecated(EVT_LIST_GET_INFO)
378 #EVT_LIST_SET_INFO = wx._deprecated(EVT_LIST_SET_INFO)
381 //---------------------------------------------------------------------------
385 %{ // Python aware sorting function for wxPyListCtrl
386 static int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
388 PyObject* func = (PyObject*)funcPtr;
389 wxPyBlock_t blocked = wxPyBeginBlockThreads();
391 PyObject* args = Py_BuildValue("(ii)", item1, item2);
392 PyObject* result = PyEval_CallObject(func, args);
395 retval = PyInt_AsLong(result);
399 wxPyEndBlockThreads(blocked);
406 %{ // C++ Version of a Python aware class
407 class wxPyListCtrl : public wxListCtrl {
408 DECLARE_ABSTRACT_CLASS(wxPyListCtrl)
410 wxPyListCtrl() : wxListCtrl() {}
411 wxPyListCtrl(wxWindow* parent, wxWindowID id,
415 const wxValidator& validator,
416 const wxString& name) :
417 wxListCtrl(parent, id, pos, size, style, validator, name) {}
419 bool Create(wxWindow* parent, wxWindowID id,
423 const wxValidator& validator,
424 const wxString& name) {
425 return wxListCtrl::Create(parent, id, pos, size, style, validator, name);
428 DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText);
429 DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr);
431 // use the virtual version to avoid a confusing assert in the base class
432 DEC_PYCALLBACK_INT_LONG_virtual(OnGetItemImage);
433 DEC_PYCALLBACK_INT_LONGLONG(OnGetItemColumnImage);
438 IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl);
440 IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText);
441 IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
442 IMP_PYCALLBACK_INT_LONG_virtual(wxPyListCtrl, wxListCtrl, OnGetItemImage);
443 IMP_PYCALLBACK_INT_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemColumnImage);
451 MustHaveApp(wxPyListCtrl);
453 %rename(ListCtrl) wxPyListCtrl;
454 class wxPyListCtrl : public wxControl {
457 %pythonAppend wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
458 %pythonAppend wxPyListCtrl() ""
460 wxPyListCtrl(wxWindow* parent, wxWindowID id = -1,
461 const wxPoint& pos = wxDefaultPosition,
462 const wxSize& size = wxDefaultSize,
463 long style = wxLC_ICON,
464 const wxValidator& validator = wxDefaultValidator,
465 const wxString& name = wxPyListCtrlNameStr);
466 %RenameCtor(PreListCtrl, wxPyListCtrl());
468 bool Create(wxWindow* parent, wxWindowID id = -1,
469 const wxPoint& pos = wxDefaultPosition,
470 const wxSize& size = wxDefaultSize,
471 long style = wxLC_ICON,
472 const wxValidator& validator = wxDefaultValidator,
473 const wxString& name = wxPyListCtrlNameStr);
475 void _setCallbackInfo(PyObject* self, PyObject* _class);
478 // Set the control colours
479 bool SetForegroundColour(const wxColour& col);
480 bool SetBackgroundColour(const wxColour& col);
482 // Gets information about this column
483 %pythonAppend GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
485 wxListItem* GetColumn(int col) {
487 item.SetMask( wxLIST_MASK_STATE |
495 if (self->GetColumn(col, item))
496 return new wxListItem(item);
502 // Sets information about this column
503 bool SetColumn(int col, wxListItem& item) ;
505 // Gets the column width
506 int GetColumnWidth(int col) const;
508 // Sets the column width
509 bool SetColumnWidth(int col, int width) ;
511 // Gets the number of items that can fit vertically in the
512 // visible area of the list control (list or report view)
513 // or the total number of items in the list control (icon
514 // or small icon view)
515 int GetCountPerPage() const;
517 // return the total area occupied by all the items (icon/small icon only)
518 wxRect GetViewRect() const;
520 // Gets the edit control for editing labels.
521 wxTextCtrl* GetEditControl() const;
523 // Gets information about the item
524 %pythonAppend GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
526 wxListItem* GetItem(long itemId, int col=0) {
527 wxListItem* info = new wxListItem;
528 info->m_itemId = itemId;
530 info->m_mask = 0xFFFF;
531 self->GetItem(*info);
536 // Sets information about the item
537 bool SetItem(wxListItem& info) ;
539 // Sets a string field at a particular column
540 %Rename(SetStringItem, long, SetItem(long index, int col, const wxString& label, int imageId = -1));
542 // Gets the item state
543 int GetItemState(long item, long stateMask) const ;
545 // Sets the item state
546 bool SetItemState(long item, long state, long stateMask) ;
548 // Sets the item image
549 bool SetItemImage(long item, int image, int selImage=-1) ;
550 bool SetItemColumnImage( long item, long column, int image );
552 // Gets the item text
553 wxString GetItemText(long item) const ;
555 // Sets the item text
556 void SetItemText(long item, const wxString& str) ;
558 // Gets the item data
559 long GetItemData(long item) const ;
561 // Sets the item data
562 bool SetItemData(long item, long data) ;
565 //bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ;
566 //bool GetItemPosition(long item, wxPoint& pos) const ;
568 // Gets the item position
570 wxPoint GetItemPosition(long item) {
572 self->GetItemPosition(item, pos);
575 // Gets the item rectangle
576 wxRect GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
578 self->GetItemRect(item, rect, code);
582 // MSW only so far...
583 // wxRect GetSubItemRect(long item, long subItem, int code = wxLIST_RECT_BOUNDS) {
585 // self->GetSubItemRect(item, subItem, rect, code);
591 // Sets the item position
592 bool SetItemPosition(long item, const wxPoint& pos) ;
594 // Gets the number of items in the list control
595 int GetItemCount() const;
597 // Gets the number of columns in the list control
598 int GetColumnCount() const;
600 // get the horizontal and vertical components of the item spacing
601 wxSize GetItemSpacing() const;
602 %pythoncode { GetItemSpacing = wx._deprecated(GetItemSpacing) }
605 void SetItemSpacing( int spacing, bool isSmall = false );
606 %pythoncode { SetItemSpacing = wx._deprecated(SetItemSpacing) }
609 // Gets the number of selected items in the list control
610 int GetSelectedItemCount() const;
612 // Gets the text colour of the listview
613 wxColour GetTextColour() const;
615 // Sets the text colour of the listview
616 void SetTextColour(const wxColour& col);
618 // Gets the index of the topmost visible item when in
619 // list or report view
620 long GetTopItem() const ;
622 // Add or remove a single window style
623 void SetSingleStyle(long style, bool add = true) ;
625 // Set the whole window style
626 void SetWindowStyleFlag(long style) ;
628 // Searches for an item, starting from 'item'.
629 // item can be -1 to find the first item that matches the
631 // Returns the item or -1 if unsuccessful.
632 long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
634 // Gets one of the three image lists
635 wxImageList *GetImageList(int which) const ;
637 // Sets the image list
638 void SetImageList(wxImageList *imageList, int which);
640 %disownarg( wxImageList *imageList );
641 void AssignImageList(wxImageList *imageList, int which);
642 %cleardisown( wxImageList *imageList );
644 // are we in report mode?
645 bool InReportView() const;
647 // returns True if it is a virtual list control
648 bool IsVirtual() const;
650 // refresh items selectively (only useful for virtual list controls)
651 void RefreshItem(long item);
652 void RefreshItems(long itemFrom, long itemTo);
654 // Arranges the items
655 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
658 bool DeleteItem(long item);
661 bool DeleteAllItems() ;
664 bool DeleteColumn(int col);
666 // Deletes all columns
667 bool DeleteAllColumns();
669 // Clears items, and columns if there are any.
674 wxTextCtrl* EditLabel(long item /*, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl)*/);
676 // End label editing, optionally cancelling the edit
677 bool EndEditLabel(bool cancel);
679 void EditLabel(long item);
682 // Ensures this item is visible
683 bool EnsureVisible(long item) ;
685 // Find an item whose label matches this string, starting from the item after 'start'
686 // or the beginning if 'start' is -1.
687 long FindItem(long start, const wxString& str, bool partial = false);
689 // Find an item whose data matches this data, starting from the item after 'start'
690 // or the beginning if 'start' is -1.
691 %Rename(FindItemData, long, FindItem(long start, long data));
693 // Find an item nearest this position in the specified direction, starting from
694 // the item after 'start' or the beginning if 'start' is -1.
695 %Rename(FindItemAtPos, long, FindItem(long start, const wxPoint& pt, int direction));
699 long, HitTest(const wxPoint& point, int& OUTPUT),
700 "HitTest(Point point) -> (item, where)",
701 "Determines which item (if any) is at the specified point, giving
702 details in the second return value (see wx.LIST_HITTEST flags.)", "");
705 long, HitTest(const wxPoint& point, int& OUTPUT, long* OUTPUT),
706 "HitTestSubItem(Point point) -> (item, where, subItem)",
707 "Determines which item (if any) is at the specified point, giving details in
708 the second return value (see wx.LIST_HITTEST flags) and also the subItem, if
713 // Inserts an item, returning the index of the new item if successful,
715 long InsertItem(wxListItem& info);
717 // Insert a string item
718 %Rename(InsertStringItem,
719 long, InsertItem(long index, const wxString& label, int imageIndex=-1));
721 // Insert an image item
722 %Rename(InsertImageItem,
723 long, InsertItem(long index, int imageIndex));
725 // Insert an image/string item
726 %Rename(InsertImageStringItem,
727 long, InsertItem(long index, const wxString& label, int imageIndex));
729 // For list view mode (only), inserts a column.
730 %Rename(InsertColumnItem, long, InsertColumn(long col, wxListItem& info));
731 %pythoncode { InsertColumnInfo = InsertColumnItem }
733 long InsertColumn(long col,
734 const wxString& heading,
735 int format = wxLIST_FORMAT_LEFT,
738 // set the number of items in a virtual list control
739 void SetItemCount(long count);
741 // Scrolls the list control. If in icon, small icon or report view mode,
742 // x specifies the number of pixels to scroll. If in list view mode, x
743 // specifies the number of columns to scroll.
744 // If in icon, small icon or list view mode, y specifies the number of pixels
745 // to scroll. If in report view mode, y specifies the number of lines to scroll.
746 bool ScrollList(int dx, int dy);
748 void SetItemTextColour( long item, const wxColour& col);
749 wxColour GetItemTextColour( long item ) const;
750 void SetItemBackgroundColour( long item, const wxColour &col);
751 wxColour GetItemBackgroundColour( long item ) const;
754 void SetItemFont( long item, const wxFont &f);
755 wxFont GetItemFont( long item ) const;
760 def Select(self, idx, on=1):
761 '''[de]select an item'''
762 if on: state = wx.LIST_STATE_SELECTED
764 self.SetItemState(idx, state, wx.LIST_STATE_SELECTED)
766 def Focus(self, idx):
767 '''Focus and show the given item'''
768 self.SetItemState(idx, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
769 self.EnsureVisible(idx)
771 def GetFocusedItem(self):
772 '''get the currently focused item or -1 if none'''
773 return self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_FOCUSED)
775 def GetFirstSelected(self, *args):
776 '''return first selected item, or -1 when none'''
777 return self.GetNextSelected(-1)
779 def GetNextSelected(self, item):
780 '''return subsequent selected items, or -1 when no more'''
781 return self.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
783 def IsSelected(self, idx):
784 '''return True if the item is selected'''
785 return (self.GetItemState(idx, wx.LIST_STATE_SELECTED) & wx.LIST_STATE_SELECTED) != 0
787 def SetColumnImage(self, col, image):
788 item = self.GetColumn(col)
789 %# preserve all other attributes too
790 item.SetMask( wx.LIST_MASK_STATE |
796 wx.LIST_MASK_FORMAT )
798 self.SetColumn(col, item)
800 def ClearColumnImage(self, col):
801 self.SetColumnImage(col, -1)
803 def Append(self, entry):
804 '''Append an item to the list control. The entry parameter should be a
805 sequence with an item for each column'''
811 pos = self.GetItemCount()
812 self.InsertStringItem(pos, cvtfunc(entry[0]))
813 for i in range(1, len(entry)):
814 self.SetStringItem(pos, i, cvtfunc(entry[i]))
819 // bool SortItems(wxListCtrlCompare fn, long data);
822 // func is a function which takes 2 long arguments: item1, item2.
823 // item1 is the long data associated with a first item (NOT the index).
824 // item2 is the long data associated with a second item (NOT the index).
825 // The return value is a negative number if the first item should precede the second
826 // item, a positive number of the second item should precede the first,
827 // or zero if the two items are equivalent.
828 bool SortItems(PyObject* func) {
829 if (!PyCallable_Check(func))
831 return self->SortItems((wxListCtrlCompare)wxPyListCtrl_SortItems, (long)func);
837 wxWindow* GetMainWindow() {
841 return (wxWindow*)self->m_mainWin;
846 static wxVisualAttributes
847 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
849 %property(ColumnCount, GetColumnCount, doc="See `GetColumnCount`");
850 %property(CountPerPage, GetCountPerPage, doc="See `GetCountPerPage`");
851 %property(EditControl, GetEditControl, doc="See `GetEditControl`");
852 %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
853 %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
854 %property(ItemCount, GetItemCount, SetItemCount, doc="See `GetItemCount` and `SetItemCount`");
855 %property(MainWindow, GetMainWindow, doc="See `GetMainWindow`");
856 %property(SelectedItemCount, GetSelectedItemCount, doc="See `GetSelectedItemCount`");
857 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
858 %property(TopItem, GetTopItem, doc="See `GetTopItem`");
859 %property(ViewRect, GetViewRect, doc="See `GetViewRect`");
864 //---------------------------------------------------------------------------
868 MustHaveApp(wxListView);
870 // wxListView: a class which provides a little better API for list control
871 class wxListView : public wxPyListCtrl
874 %pythonAppend wxListView "self._setOORInfo(self)"
875 %pythonAppend wxListView() ""
877 wxListView( wxWindow *parent,
879 const wxPoint& pos = wxDefaultPosition,
880 const wxSize& size = wxDefaultSize,
881 long style = wxLC_REPORT,
882 const wxValidator& validator = wxDefaultValidator,
883 const wxString& name = wxPyListCtrlNameStr);
884 %RenameCtor(PreListView, wxListView());
886 bool Create( wxWindow *parent,
888 const wxPoint& pos = wxDefaultPosition,
889 const wxSize& size = wxDefaultSize,
890 long style = wxLC_REPORT,
891 const wxValidator& validator = wxDefaultValidator,
892 const wxString& name = wxPyListCtrlNameStr);
894 // [de]select an item
895 void Select(long n, bool on = true);
897 // focus and show the given item
898 void Focus(long index);
900 // get the currently focused item or -1 if none
901 long GetFocusedItem() const;
903 // get first and subsequent selected items, return -1 when no more
904 long GetNextSelected(long item) const;
905 long GetFirstSelected() const;
907 // return True if the item is selected
908 bool IsSelected(long index);
910 void SetColumnImage(int col, int image);
911 void ClearColumnImage(int col);
913 %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
918 //---------------------------------------------------------------------------
921 // Map renamed classes back to their common name for OOR
922 wxPyPtrTypeMap_Add("wxListCtrl", "wxPyListCtrl");
925 //---------------------------------------------------------------------------