%{
#include <wx/listctrl.h>
-
- const wxChar* wxListCtrlNameStr = _T("wxListCtrl");
- DECLARE_DEF_STRING(ListCtrlNameStr);
%}
+MAKE_CONST_WXSTRING(ListCtrlNameStr);
+
//---------------------------------------------------------------------------
%newgroup
wxLIST_HITTEST_TOLEFT,
wxLIST_HITTEST_TORIGHT,
wxLIST_HITTEST_ONITEM,
+
+// GetSubItemRect constants
+ wxLIST_GETSUBITEMRECT_WHOLEITEM,
};
wxListItemAttr(const wxColour& colText = wxNullColour,
const wxColour& colBack = wxNullColour,
const wxFont& font = wxNullFont);
-
+ ~wxListItemAttr();
// setters
void SetTextColour(const wxColour& colText);
wxColour GetBackgroundColour();
wxFont GetFont();
+ void AssignFrom(const wxListItemAttr& source);
+
+ %pythonPrepend Destroy "args[0].this.own(False)"
%extend { void Destroy() { delete self; } }
+
+ %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
+ %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
+ %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
};
//---------------------------------------------------------------------------
%newgroup
+
// wxListItem: the item or column info, used to exchange data with wxListCtrl
class wxListItem : public wxObject {
public:
+ // turn off this typemap
+ %typemap(out) wxListItem*;
+
wxListItem();
~wxListItem();
+ // Turn it back on again
+ %typemap(out) wxListItem* { $result = wxPyMake_wxObject($1, $owner); }
+
// resetting
void Clear();
void ClearAttributes();
int m_format; // left, right, centre
int m_width; // width of column
+ %property(Align, GetAlign, SetAlign, doc="See `GetAlign` and `SetAlign`");
+ %property(Attributes, GetAttributes, doc="See `GetAttributes`");
+ %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
+ %property(Column, GetColumn, SetColumn, doc="See `GetColumn` and `SetColumn`");
+ %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
+ %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
+ %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
+ %property(Image, GetImage, SetImage, doc="See `GetImage` and `SetImage`");
+ %property(Mask, GetMask, SetMask, doc="See `GetMask` and `SetMask`");
+ %property(State, GetState, SetState, doc="See `GetState` and `SetState`");
+ %property(Text, GetText, SetText, doc="See `GetText` and `SetText`");
+ %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
+ %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
};
long GetIndex();
int GetColumn();
wxPoint GetPoint();
- %pythoncode { GetPostiion = GetPoint }
+ %pythoncode { GetPosition = GetPoint }
const wxString& GetLabel();
const wxString& GetText();
int GetImage();
// was label editing canceled? (for wxEVT_COMMAND_LIST_END_LABEL_EDIT only)
bool IsEditCancelled() const;
void SetEditCanceled(bool editCancelled);
+
+ %property(CacheFrom, GetCacheFrom, doc="See `GetCacheFrom`");
+ %property(CacheTo, GetCacheTo, doc="See `GetCacheTo`");
+ %property(Column, GetColumn, doc="See `GetColumn`");
+ %property(Data, GetData, doc="See `GetData`");
+ %property(Image, GetImage, doc="See `GetImage`");
+ %property(Index, GetIndex, doc="See `GetIndex`");
+ %property(Item, GetItem, doc="See `GetItem`");
+ %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
+ %property(Label, GetLabel, doc="See `GetLabel`");
+ %property(Mask, GetMask, doc="See `GetMask`");
+ %property(Point, GetPoint, doc="See `GetPoint`");
+ %property(Text, GetText, doc="See `GetText`");
+
};
/* List control event types */
%constant wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT;
%constant wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM;
%constant wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
-%constant wxEventType wxEVT_COMMAND_LIST_GET_INFO;
-%constant wxEventType wxEVT_COMMAND_LIST_SET_INFO;
%constant wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED;
%constant wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED;
%constant wxEventType wxEVT_COMMAND_LIST_KEY_DOWN;
%constant wxEventType wxEVT_COMMAND_LIST_COL_END_DRAG;
%constant wxEventType wxEVT_COMMAND_LIST_ITEM_FOCUSED;
-
+// WXWIN_COMPATIBILITY_2_4
+#if 0
+%constant wxEventType wxEVT_COMMAND_LIST_GET_INFO;
+%constant wxEventType wxEVT_COMMAND_LIST_SET_INFO;
+#endif
%pythoncode {
EVT_LIST_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_LIST_END_LABEL_EDIT , 1)
EVT_LIST_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ITEM , 1)
EVT_LIST_DELETE_ALL_ITEMS = wx.PyEventBinder(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS , 1)
-EVT_LIST_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_GET_INFO , 1)
-EVT_LIST_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_SET_INFO , 1)
+#WXWIN_COMPATIBILITY_2_4
+#EVT_LIST_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_GET_INFO , 1)
+#EVT_LIST_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_LIST_SET_INFO , 1)
+#END WXWIN_COMPATIBILITY_2_4
EVT_LIST_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_SELECTED , 1)
EVT_LIST_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_DESELECTED , 1)
EVT_LIST_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_LIST_KEY_DOWN , 1)
EVT_LIST_COL_DRAGGING = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_DRAGGING , 1)
EVT_LIST_COL_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_LIST_COL_END_DRAG , 1)
EVT_LIST_ITEM_FOCUSED = wx.PyEventBinder(wxEVT_COMMAND_LIST_ITEM_FOCUSED , 1)
+
+#WXWIN_COMPATIBILITY_2_4
+#EVT_LIST_GET_INFO = wx._deprecated(EVT_LIST_GET_INFO)
+#EVT_LIST_SET_INFO = wx._deprecated(EVT_LIST_SET_INFO)
}
//---------------------------------------------------------------------------
static int wxCALLBACK wxPyListCtrl_SortItems(long item1, long item2, long funcPtr) {
int retval = 0;
PyObject* func = (PyObject*)funcPtr;
- wxPyBeginBlockThreads();
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
PyObject* args = Py_BuildValue("(ii)", item1, item2);
PyObject* result = PyEval_CallObject(func, args);
Py_DECREF(result);
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
return retval;
}
%}
%{ // C++ Version of a Python aware class
class wxPyListCtrl : public wxListCtrl {
- DECLARE_ABSTRACT_CLASS(wxPyListCtrl);
+ DECLARE_ABSTRACT_CLASS(wxPyListCtrl)
public:
wxPyListCtrl() : wxListCtrl() {}
wxPyListCtrl(wxWindow* parent, wxWindowID id,
}
DEC_PYCALLBACK_STRING_LONGLONG(OnGetItemText);
- DEC_PYCALLBACK_INT_LONG(OnGetItemImage);
DEC_PYCALLBACK_LISTATTR_LONG(OnGetItemAttr);
+ // use the virtual version to avoid a confusing assert in the base class
+ DEC_PYCALLBACK_INT_LONG_virtual(OnGetItemImage);
+ DEC_PYCALLBACK_INT_LONGLONG(OnGetItemColumnImage);
+
PYPRIVATE;
};
IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl);
IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText);
-IMP_PYCALLBACK_INT_LONG(wxPyListCtrl, wxListCtrl, OnGetItemImage);
IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr);
+IMP_PYCALLBACK_INT_LONG_virtual(wxPyListCtrl, wxListCtrl, OnGetItemImage);
+IMP_PYCALLBACK_INT_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemColumnImage);
+
%}
+// NOTE: The following option is set in _settings.i
+// # Until the new native control for wxMac is up to par, still use the generic one.
+// SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 1)
+MustHaveApp(wxPyListCtrl);
-%name(ListCtrl)class wxPyListCtrl : public wxControl {
+%rename(ListCtrl) wxPyListCtrl;
+class wxPyListCtrl : public wxControl {
public:
+ // turn off this typemap
+ %typemap(out) wxPyListCtrl*;
+
+ %pythonAppend wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
+ %pythonAppend wxPyListCtrl() ""
- %addtofunc wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
- %addtofunc wxPyListCtrl() ""
-
wxPyListCtrl(wxWindow* parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxPyListCtrlNameStr);
- %name(PreListCtrl)wxPyListCtrl();
+ %RenameCtor(PreListCtrl, wxPyListCtrl());
+
+ // Turn it back on again
+ %typemap(out) wxPyListCtrl* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
void _setCallbackInfo(PyObject* self, PyObject* _class);
-
+
// Set the control colours
bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col);
// Gets information about this column
- %addtofunc GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
+ %pythonAppend GetColumn "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
%extend {
wxListItem* GetColumn(int col) {
wxListItem item;
// return the total area occupied by all the items (icon/small icon only)
wxRect GetViewRect() const;
-
-#ifdef __WXMSW__
+
// Gets the edit control for editing labels.
wxTextCtrl* GetEditControl() const;
-#endif
// Gets information about the item
- %addtofunc GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
+ %pythonAppend GetItem "if val is not None: val.thisown = 1"; // %newobject doesn't work with OOR typemap
%extend {
wxListItem* GetItem(long itemId, int col=0) {
wxListItem* info = new wxListItem;
bool SetItem(wxListItem& info) ;
// Sets a string field at a particular column
- %name(SetStringItem)long SetItem(long index, int col, const wxString& label, int imageId = -1);
+ %Rename(SetStringItem, long, SetItem(long index, int col, const wxString& label, int imageId = -1));
// Gets the item state
int GetItemState(long item, long stateMask) const ;
bool SetItemState(long item, long state, long stateMask) ;
// Sets the item image
- bool SetItemImage(long item, int image, int selImage) ;
+ bool SetItemImage(long item, int image, int selImage=-1) ;
+ bool SetItemColumnImage( long item, long column, int image );
// Gets the item text
wxString GetItemText(long item) const ;
self->GetItemRect(item, rect, code);
return rect;
}
+
+// MSW only so far...
+// wxRect GetSubItemRect(long item, long subItem, int code = wxLIST_RECT_BOUNDS) {
+// wxRect rect;
+// self->GetSubItemRect(item, subItem, rect, code);
+// return rect;
+// }
}
// get the horizontal and vertical components of the item spacing
wxSize GetItemSpacing() const;
+ %pythoncode { GetItemSpacing = wx._deprecated(GetItemSpacing) }
#ifndef __WXMSW__
- void SetItemSpacing( int spacing, bool isSmall = FALSE );
+ void SetItemSpacing( int spacing, bool isSmall = false );
+ %pythoncode { SetItemSpacing = wx._deprecated(SetItemSpacing) }
#endif
// Gets the number of selected items in the list control
long GetTopItem() const ;
// Add or remove a single window style
- void SetSingleStyle(long style, bool add = TRUE) ;
+ void SetSingleStyle(long style, bool add = true) ;
// Set the whole window style
void SetWindowStyleFlag(long style) ;
// Sets the image list
void SetImageList(wxImageList *imageList, int which);
- // is there a way to tell SWIG to disown this???
-
- %addtofunc AssignImageList "args[1].thisown = 0";
+ %disownarg( wxImageList *imageList );
void AssignImageList(wxImageList *imageList, int which);
+ %cleardisown( wxImageList *imageList );
+
+ // are we in report mode?
+ bool InReportView() const;
- // returns true if it is a virtual list control
+ // returns True if it is a virtual list control
bool IsVirtual() const;
// refresh items selectively (only useful for virtual list controls)
// Find an item whose label matches this string, starting from the item after 'start'
// or the beginning if 'start' is -1.
- long FindItem(long start, const wxString& str, bool partial = FALSE);
+ long FindItem(long start, const wxString& str, bool partial = false);
// Find an item whose data matches this data, starting from the item after 'start'
// or the beginning if 'start' is -1.
- %name(FindItemData) long FindItem(long start, long data);
+ %Rename(FindItemData, long, FindItem(long start, long data));
// Find an item nearest this position in the specified direction, starting from
// the item after 'start' or the beginning if 'start' is -1.
- %name(FindItemAtPos) long FindItem(long start, const wxPoint& pt, int direction);
+ %Rename(FindItemAtPos, long, FindItem(long start, const wxPoint& pt, int direction));
+
+
+ DocDeclAStr(
+ long, HitTest(const wxPoint& point, int& OUTPUT),
+ "HitTest(Point point) -> (item, where)",
+ "Determines which item (if any) is at the specified point, giving
+details in the second return value (see wx.LIST_HITTEST flags.)", "");
- // Determines which item (if any) is at the specified point,
- // giving details in the second return value (see wxLIST_HITTEST_... flags above)
- long HitTest(const wxPoint& point, int& OUTPUT);
+ DocDeclAStrName(
+ long, HitTest(const wxPoint& point, int& OUTPUT, long* OUTPUT),
+ "HitTestSubItem(Point point) -> (item, where, subItem)",
+ "Determines which item (if any) is at the specified point, giving details in
+the second return value (see wx.LIST_HITTEST flags) and also the subItem, if
+any.", "",
+ HitTestSubItem);
+
// Inserts an item, returning the index of the new item if successful,
// -1 otherwise.
long InsertItem(wxListItem& info);
// Insert a string item
- %name(InsertStringItem) long InsertItem(long index, const wxString& label);
+ %Rename(InsertStringItem,
+ long, InsertItem(long index, const wxString& label, int imageIndex=-1));
// Insert an image item
- %name(InsertImageItem) long InsertItem(long index, int imageIndex);
+ %Rename(InsertImageItem,
+ long, InsertItem(long index, int imageIndex));
// Insert an image/string item
- %name(InsertImageStringItem) long InsertItem(long index, const wxString& label, int imageIndex);
+ %Rename(InsertImageStringItem,
+ long, InsertItem(long index, const wxString& label, int imageIndex));
// For list view mode (only), inserts a column.
- %name(InsertColumnInfo) long InsertColumn(long col, wxListItem& info);
+ %Rename(InsertColumnItem, long, InsertColumn(long col, wxListItem& info));
+ %pythoncode { InsertColumnInfo = InsertColumnItem }
long InsertColumn(long col,
const wxString& heading,
void SetItemBackgroundColour( long item, const wxColour &col);
wxColour GetItemBackgroundColour( long item ) const;
+ // Font of an item.
+ void SetItemFont( long item, const wxFont &f);
+ wxFont GetItemFont( long item ) const;
%pythoncode {
%#
%# Some helpers...
def Select(self, idx, on=1):
'''[de]select an item'''
- if on: state = wxLIST_STATE_SELECTED
+ if on: state = wx.LIST_STATE_SELECTED
else: state = 0
- self.SetItemState(idx, state, wxLIST_STATE_SELECTED)
+ self.SetItemState(idx, state, wx.LIST_STATE_SELECTED)
def Focus(self, idx):
'''Focus and show the given item'''
- self.SetItemState(idx, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED)
+ self.SetItemState(idx, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
self.EnsureVisible(idx)
def GetFocusedItem(self):
'''get the currently focused item or -1 if none'''
- return self.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED)
+ return self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_FOCUSED)
def GetFirstSelected(self, *args):
'''return first selected item, or -1 when none'''
def GetNextSelected(self, item):
'''return subsequent selected items, or -1 when no more'''
- return self.GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)
+ return self.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
def IsSelected(self, idx):
- '''return TRUE if the item is selected'''
- return self.GetItemState(idx, wxLIST_STATE_SELECTED) != 0
+ '''return True if the item is selected'''
+ return (self.GetItemState(idx, wx.LIST_STATE_SELECTED) & wx.LIST_STATE_SELECTED) != 0
def SetColumnImage(self, col, image):
item = self.GetColumn(col)
- # preserve all other attributes too
- item.SetMask( wxLIST_MASK_STATE |
- wxLIST_MASK_TEXT |
- wxLIST_MASK_IMAGE |
- wxLIST_MASK_DATA |
- wxLIST_SET_ITEM |
- wxLIST_MASK_WIDTH |
- wxLIST_MASK_FORMAT )
+ %# preserve all other attributes too
+ item.SetMask( wx.LIST_MASK_STATE |
+ wx.LIST_MASK_TEXT |
+ wx.LIST_MASK_IMAGE |
+ wx.LIST_MASK_DATA |
+ wx.LIST_SET_ITEM |
+ wx.LIST_MASK_WIDTH |
+ wx.LIST_MASK_FORMAT )
item.SetImage(image)
self.SetColumn(col, item)
'''Append an item to the list control. The entry parameter should be a
sequence with an item for each column'''
if len(entry):
- if wx.wxUSE_UNICODE:
+ if wx.USE_UNICODE:
cvtfunc = unicode
else:
cvtfunc = str
// or zero if the two items are equivalent.
bool SortItems(PyObject* func) {
if (!PyCallable_Check(func))
- return FALSE;
+ return false;
return self->SortItems((wxListCtrlCompare)wxPyListCtrl_SortItems, (long)func);
}
}
%extend {
wxWindow* GetMainWindow() {
- #ifdef __WXMSW__
+ #if defined(__WXMSW__) || defined(__WXMAC__)
return self;
#else
return (wxWindow*)self->m_mainWin;
#endif
}
}
+
+ static wxVisualAttributes
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
+ %property(ColumnCount, GetColumnCount, doc="See `GetColumnCount`");
+ %property(CountPerPage, GetCountPerPage, doc="See `GetCountPerPage`");
+ %property(EditControl, GetEditControl, doc="See `GetEditControl`");
+ %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
+ %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
+ %property(ItemCount, GetItemCount, SetItemCount, doc="See `GetItemCount` and `SetItemCount`");
+ %property(MainWindow, GetMainWindow, doc="See `GetMainWindow`");
+ %property(SelectedItemCount, GetSelectedItemCount, doc="See `GetSelectedItemCount`");
+ %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
+ %property(TopItem, GetTopItem, doc="See `GetTopItem`");
+ %property(ViewRect, GetViewRect, doc="See `GetViewRect`");
};
%newgroup
+MustHaveApp(wxListView);
+
// wxListView: a class which provides a little better API for list control
class wxListView : public wxPyListCtrl
{
public:
- %addtofunc wxListView "self._setOORInfo(self)"
- %addtofunc wxListView() ""
+ %pythonAppend wxListView "self._setOORInfo(self)"
+ %pythonAppend wxListView() ""
wxListView( wxWindow *parent,
wxWindowID id = -1,
long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxPyListCtrlNameStr);
- %name(PreListView)wxListView();
+ %RenameCtor(PreListView, wxListView());
bool Create( wxWindow *parent,
wxWindowID id = -1,
const wxString& name = wxPyListCtrlNameStr);
// [de]select an item
- void Select(long n, bool on = TRUE);
+ void Select(long n, bool on = true);
// focus and show the given item
void Focus(long index);
long GetNextSelected(long item) const;
long GetFirstSelected() const;
- // return TRUE if the item is selected
+ // return True if the item is selected
bool IsSelected(long index);
void SetColumnImage(int col, int image);
void ClearColumnImage(int col);
+
+ %property(FocusedItem, GetFocusedItem, doc="See `GetFocusedItem`");
};