]> git.saurik.com Git - wxWidgets.git/commitdiff
Enable OnDrawSeparator and OnDrawBackground to be overridable in wx.HtmlListBox
authorRobin Dunn <robin@alldunn.com>
Thu, 16 Mar 2006 02:30:42 +0000 (02:30 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 16 Mar 2006 02:30:42 +0000 (02:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index f53949f05967dd14d25e77069e5a619cb567a488..f41cf77b5c7ce67db761f2bd2ac41896920f7f35 100644 (file)
@@ -2241,11 +2241,10 @@ extern wxPyApp *wxPythonApp;
 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME)                           \
     void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
 
-
 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME)            \
     void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const {              \
         bool found;                                                             \
-        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                 \
+        wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
             PyObject* obj = wxPyMake_wxObject(&a,false);                        \
             PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0);    \
@@ -2255,12 +2254,11 @@ extern wxPyApp *wxPythonApp;
         wxPyEndBlockThreads(blocked);                                           \
     }                                                                           \
 
-//---------------------------------------------------------------------------
+
 
 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME)                               \
     void CBNAME(wxDC& a, const wxRect& b, size_t c) const
 
-
 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME)                \
     void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const {              \
         bool found;                                                             \
@@ -2276,9 +2274,52 @@ extern wxPyApp *wxPythonApp;
             PCLASS::CBNAME(a,b,c);                                              \
     }            
 
+
+//---------------------------------------------------------------------------
+// Same as the above set, but the wxRect is not const
+
+#define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME)                          \
+    void CBNAME(wxDC& a, wxRect& b, size_t c) const;
+
+#define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME)           \
+    void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const {                    \
+        bool found;                                                             \
+        wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
+            PyObject* obj = wxPyMake_wxObject(&a,false);                        \
+            PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0);    \
+            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
+            Py_DECREF(obj);                                                     \
+        }                                                                       \
+        wxPyEndBlockThreads(blocked);                                           \
+    }                                                                           \
+
+
+
+#define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME)                              \
+    void CBNAME(wxDC& a, wxRect& b, size_t c) const
+
+#define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME)               \
+    void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const {                    \
+        bool found;                                                             \
+        wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
+        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
+            PyObject* obj = wxPyMake_wxObject(&a,false);                        \
+            PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0);    \
+            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
+            Py_DECREF(obj);                                                     \
+        }                                                                       \
+        wxPyEndBlockThreads(blocked);                                           \
+        if (! found)                                                            \
+            PCLASS::CBNAME(a,b,c);                                              \
+    }            
+
+
+
 //---------------------------------------------------------------------------
 
 
+
 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME)                                     \
     wxString CBNAME(size_t a) const
 
index 5d387f124478c63d23429f0db2f82ef354d2f066..94bc99e13e49603b0764e28eb56e8f194f3fa554 100644 (file)
@@ -517,7 +517,7 @@ public:
     //
     // the base class version doesn't do anything
     //    virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const;
-    DEC_PYCALLBACK__DCRECTSIZET_constpure(OnDrawSeparator);
+    DEC_PYCALLBACK__DCRECTSIZET2_const(OnDrawSeparator);
 
 
     // this method is used to draw the items background and, maybe, a border
@@ -538,7 +538,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyVListBox, wxVListBox);
 
 IMP_PYCALLBACK__DCRECTSIZET_constpure(wxPyVListBox, wxVListBox, OnDrawItem);
 IMP_PYCALLBACK_COORD_SIZET_constpure (wxPyVListBox, wxVListBox, OnMeasureItem);
-IMP_PYCALLBACK__DCRECTSIZET_constpure(wxPyVListBox, wxVListBox, OnDrawSeparator);
+IMP_PYCALLBACK__DCRECTSIZET2_const   (wxPyVListBox, wxVListBox, OnDrawSeparator);
 IMP_PYCALLBACK__DCRECTSIZET_const    (wxPyVListBox, wxVListBox, OnDrawBackground);
 
 %}
@@ -709,6 +709,8 @@ public:
     // change the background colour of the selected cells
     void SetSelectionBackground(const wxColour& col);
 
+    virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const;
+    virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const;
 };
 
 
@@ -745,6 +747,10 @@ public:
     // this function may be overridden to decorate HTML returned by OnGetItem()
     DEC_PYCALLBACK_STRING_SIZET(OnGetItemMarkup);
 
+    // These are from wxVListBox
+    DEC_PYCALLBACK__DCRECTSIZET2_const(OnDrawSeparator);
+    DEC_PYCALLBACK__DCRECTSIZET_const(OnDrawBackground);
+
 // TODO:
 //     // this method allows to customize the selection appearance: it may be used
 //     // to specify the colour of the text which normally has the given colour
@@ -768,6 +774,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlListBox, wxHtmlListBox)
 
 IMP_PYCALLBACK_STRING_SIZET_pure(wxPyHtmlListBox, wxHtmlListBox, OnGetItem);
 IMP_PYCALLBACK_STRING_SIZET     (wxPyHtmlListBox, wxHtmlListBox, OnGetItemMarkup);
+IMP_PYCALLBACK__DCRECTSIZET2_const   (wxPyHtmlListBox, wxHtmlListBox, OnDrawSeparator);
+IMP_PYCALLBACK__DCRECTSIZET_const    (wxPyHtmlListBox, wxHtmlListBox, OnDrawBackground);
 
 %}