From: Robin Dunn Date: Thu, 26 Jan 2006 00:31:31 +0000 (+0000) Subject: Add supoprt for wxListCtrl::OnGetItemColumnImage X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e280c9ca954797b8405c3e945008d09a4d26c37b Add supoprt for wxListCtrl::OnGetItemColumnImage git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37148 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index c66fb1319a..6dd2c9a49f 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -25,7 +25,7 @@ wx.EventLoop is now implemented for wxMac. -2.6.2.2 +2.6.3.0 ------- Change the wx.ListCtrl InsertStringItem wrapper to use the form that @@ -35,7 +35,11 @@ the native control doesn't use one anyway. wxMSW: wx.ListCtrl in report mode is now able to support images in other columns besides the first one. Simply pass an image index to -SetStringItem. +SetStringItem. For virtual list controls you can specify the image to +use on the extra columns by overriding OnGetItemColumnImage in your +derived class. It is passed the item number and the column number as +parameters, and the default version simply calls OnGetItemImage for +column zero, or returns -1 for other columns. diff --git a/wxPython/include/wx/wxPython/wxPython_int.h b/wxPython/include/wx/wxPython/wxPython_int.h index cca6beddb2..fb611c3d7a 100644 --- a/wxPython/include/wx/wxPython/wxPython_int.h +++ b/wxPython/include/wx/wxPython/wxPython_int.h @@ -2181,6 +2181,60 @@ extern wxPyApp *wxPythonApp; } +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \ + int CBNAME(long a, long b) const; \ + int base_##CBNAME(long a, long b) const + + +#define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \ + int CLASS::CBNAME(long a, long b) const { \ + int rval=-1; \ + bool found; \ + wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ + if (ro) { \ + rval = PyInt_AsLong(ro); \ + Py_DECREF(ro); \ + } \ + } \ + wxPyEndBlockThreads(blocked); \ + if (! found) \ + rval = PCLASS::CBNAME(a, b); \ + return rval; \ + } \ + int CLASS::base_##CBNAME(long a, long b) const { \ + return PCLASS::CBNAME(a, b); \ + } + + + + +#define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \ + int CBNAME(long a, long b) const; + + +#define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \ + int CLASS::CBNAME(long a, long b) const { \ + int rval=-1; /* this rval is important for OnGetItemImage */ \ + bool found; \ + wxPyBlock_t blocked = wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ + if (ro) { \ + rval = PyInt_AsLong(ro); \ + Py_DECREF(ro); \ + } \ + } \ + wxPyEndBlockThreads(blocked); \ + return rval; \ + } + + //--------------------------------------------------------------------------- #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \ diff --git a/wxPython/src/_listctrl.i b/wxPython/src/_listctrl.i index 01d62edc5e..836730ddac 100644 --- a/wxPython/src/_listctrl.i +++ b/wxPython/src/_listctrl.i @@ -393,6 +393,7 @@ public: // 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; }; @@ -402,7 +403,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyListCtrl, wxListCtrl); IMP_PYCALLBACK_STRING_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemText); IMP_PYCALLBACK_LISTATTR_LONG(wxPyListCtrl, wxListCtrl, OnGetItemAttr); IMP_PYCALLBACK_INT_LONG_virtual(wxPyListCtrl, wxListCtrl, OnGetItemImage); - +IMP_PYCALLBACK_INT_LONGLONG(wxPyListCtrl, wxListCtrl, OnGetItemColumnImage); + %}