%{
#include <wx/listctrl.h>
-
- const wxChar* wxListCtrlNameStr = _T("wxListCtrl");
- DECLARE_DEF_STRING(ListCtrlNameStr);
%}
+MAKE_CONST_WXSTRING2(ListCtrlNameStr, _T("wxListCtrl"));
+
//---------------------------------------------------------------------------
%newgroup
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)
+
+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();
+ bool blocked = wxPyBeginBlockThreads();
PyObject* args = Py_BuildValue("(ii)", item1, item2);
PyObject* result = PyEval_CallObject(func, args);
Py_DECREF(result);
}
- wxPyEndBlockThreads();
+ wxPyEndBlockThreads(blocked);
return retval;
}
%}
}
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);
+
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);
+
%}
+MustHaveApp(wxPyListCtrl);
+
%name(ListCtrl)class wxPyListCtrl : public wxControl {
public:
- %addtofunc wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
- %addtofunc wxPyListCtrl() ""
-
+ %pythonAppend wxPyListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, ListCtrl)"
+ %pythonAppend wxPyListCtrl() ""
+
wxPyListCtrl(wxWindow* parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
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 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) ;
// Gets the item text
wxString GetItemText(long item) const ;
wxSize GetItemSpacing() const;
#ifndef __WXMSW__
- void SetItemSpacing( int spacing, bool isSmall = False );
+ void SetItemSpacing( int spacing, bool isSmall = false );
#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) ;
// is there a way to tell SWIG to disown this???
- %addtofunc AssignImageList "args[1].thisown = 0";
+ %apply SWIGTYPE *DISOWN { wxImageList *imageList };
void AssignImageList(wxImageList *imageList, int which);
+ %clear wxImageList *imageList;
+
+ // are we in report mode?
+ bool InReportView() const;
// returns True if it is a virtual list control
bool IsVirtual() const;
// 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.
DocDeclAStr(
long, HitTest(const wxPoint& point, int& OUTPUT),
"HitTest(Point point) -> (item, where)",
- "Determines which item (if any) is at the specified point,\n"
- "giving details in the second return value (see wxLIST_HITTEST_... flags.)");
+ "Determines which item (if any) is at the specified point, giving
+details in the second return value (see wxLIST_HITTEST_... flags.)", "");
// Inserts an item, returning the index of the new item if successful,
// -1 otherwise.
// 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);
}
}
#endif
}
}
+
+ static wxVisualAttributes
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
};
%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,
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);