From 3d8a2fd724f6a36d6597aad39a2e99317b11d157 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 7 Jun 2004 23:58:13 +0000 Subject: [PATCH 1/1] handle returning the cookie for Get[First|Next]Selected like in the treectrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_vscroll.i | 52 +++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/wxPython/src/_vscroll.i b/wxPython/src/_vscroll.i index 9cc2071a9b..467a4a2494 100644 --- a/wxPython/src/_vscroll.i +++ b/wxPython/src/_vscroll.i @@ -333,22 +333,44 @@ public: // this method is valid for both single and multi selection listboxes size_t GetSelectedCount() const; - // get the first selected item, returns wxNOT_FOUND if none - // - // cookie is an opaque parameter which should be passed to - // GetNextSelected() later - // - // this method is only valid for the multi selection listboxes - int GetFirstSelected(unsigned long& cookie) const; - - // get next selection item, return wxNOT_FOUND if no more - // - // cookie must be the same parameter that was passed to GetFirstSelected() - // before - // - // this method is only valid for the multi selection listboxes - int GetNextSelected(unsigned long& cookie) const; + %extend { + // get the first selected item, returns wxNOT_FOUND if none + // + // cookie is an opaque parameter which should be passed to + // GetNextSelected() later + // + // this method is only valid for the multi selection listboxes + //int GetFirstSelected(unsigned long& cookie) const; + PyObject* GetFirstSelected() { + unsigned long cookie = 0; + int selected = self->GetFirstSelected(cookie); + bool blocked = wxPyBeginBlockThreads(); + PyObject* tup = PyTuple_New(2); + PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(selected)); + PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie)); + wxPyEndBlockThreads(blocked); + return tup; + } + + // get next selection item, return wxNOT_FOUND if no more + // + // cookie must be the same parameter that was passed to GetFirstSelected() + // before + // + // this method is only valid for the multi selection listboxes + // int GetNextSelected(unsigned long& cookie) const; + PyObject* GetNextSelected(unsigned long cookie) { + int selected = self->GetNextSelected(cookie); + bool blocked = wxPyBeginBlockThreads(); + PyObject* tup = PyTuple_New(2); + PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(selected)); + PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie)); + wxPyEndBlockThreads(blocked); + return tup; + } + } + // get the margins around each item wxPoint GetMargins() const; -- 2.45.2