]> git.saurik.com Git - wxWidgets.git/commitdiff
Change macro used for OnGetItemImage so it ignores the base class
authorRobin Dunn <robin@alldunn.com>
Sat, 9 Oct 2004 01:25:33 +0000 (01:25 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 9 Oct 2004 01:25:33 +0000 (01:25 +0000)
version

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/include/wx/wxPython/wxPython_int.h
wxPython/src/_listctrl.i

index 0b964cf4697d800c32ee805fb271e8d1126006ee..187f5e2e18517a23cc98ad1ec25b32384895f28a 100644 (file)
@@ -2125,6 +2125,30 @@ extern wxPyApp *wxPythonApp;
     }
 
 
+
+
+#define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME)                                 \
+    int CBNAME(long a) const;
+
+
+#define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME)                  \
+    int CLASS::CBNAME(long a) const {                                           \
+        int rval=-1;    /* this rval is important for OnGetItemImage */         \
+        bool found;                                                             \
+        bool blocked = wxPyBeginBlockThreads();                                 \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
+            PyObject* ro;                                                       \
+            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a));     \
+            if (ro) {                                                           \
+                rval = PyInt_AsLong(ro);                                        \
+                Py_DECREF(ro);                                                  \
+            }                                                                   \
+        }                                                                       \
+        wxPyEndBlockThreads(blocked);                                           \
+        return rval;                                                            \
+    }  
+
+
 //---------------------------------------------------------------------------
 
 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME)                                    \
index bbb7b1918121b0088b406fad9749301b7f7d5678..c342e9517f6e21fbee62efb1aeb321db6d672105 100644 (file)
@@ -384,17 +384,20 @@ public:
     }
 
     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);
 %}
 
 
@@ -408,7 +411,7 @@ public:
 
     %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,
@@ -426,7 +429,7 @@ public:
 
     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
-    
+
     // Set the control colours
     bool SetForegroundColour(const wxColour& col);
     bool SetBackgroundColour(const wxColour& col);
@@ -468,7 +471,7 @@ public:
 
     // 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;
@@ -586,10 +589,10 @@ public:
     %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;