X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..3a9becbd5439254a77e7dbc0278d80117a397264:/wxPython/src/_vscroll.i diff --git a/wxPython/src/_vscroll.i b/wxPython/src/_vscroll.i index 23f2542c6b..e833ef77b6 100644 --- a/wxPython/src/_vscroll.i +++ b/wxPython/src/_vscroll.i @@ -125,11 +125,14 @@ IMP_PYCALLBACK_COORD_const (wxPyVScrolledWindow, wxVScrolledWindow, Est of the window and not its entire client area. */ -%name(VScrolledWindow) class wxPyVScrolledWindow : public wxPanel +MustHaveApp(wxPyVScrolledWindow); + +%rename(VScrolledWindow) wxPyVScrolledWindow; +class wxPyVScrolledWindow : public wxPanel { public: - %addtofunc wxPyVScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, VScrolledWindow)" - %addtofunc wxPyVScrolledWindow() "" + %pythonAppend wxPyVScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, VScrolledWindow)" + %pythonAppend wxPyVScrolledWindow() "" wxPyVScrolledWindow(wxWindow *parent, @@ -139,7 +142,7 @@ public: long style = 0, const wxString& name = wxPyPanelNameStr); - %name(PreVScrolledWindow)wxPyVScrolledWindow(); + %RenameCtor(PreVScrolledWindow, wxPyVScrolledWindow()); void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -159,7 +162,7 @@ public: // scroll to the specified line: it will become the first visible line in // the window // - // return true if we scrolled the window, false if nothing was done + // return True if we scrolled the window, False if nothing was done bool ScrollToLine(size_t line); // scroll by the specified number of lines/pages @@ -174,7 +177,7 @@ public: // return the item at the specified (in physical coordinates) position or // wxNOT_FOUND if none, i.e. if it is below the last item - %name(HitTestXT) int HitTest(wxCoord x, wxCoord y) const; + %Rename(HitTestXY, int, HitTest(wxCoord x, wxCoord y) const); int HitTest(const wxPoint& pt) const; // recalculate all our parameters and redisplay all lines @@ -186,14 +189,25 @@ public: size_t GetLineCount() const; // get the first currently visible line - size_t GetFirstVisibleLine() const; + size_t GetVisibleBegin() const; // get the last currently visible line - size_t GetLastVisibleLine() const; + size_t GetVisibleEnd() const; // is this line currently visible? bool IsVisible(size_t line) const; + // this is the same as GetVisibleBegin(), exists to match + // GetLastVisibleLine() and for backwards compatibility only + size_t GetFirstVisibleLine() const; + + // get the last currently visible line + // + // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive + // number) if the control is empty, use GetVisibleEnd() instead, this one + // is kept for backwards compatibility + size_t GetLastVisibleLine() const; + }; //--------------------------------------------------------------------------- @@ -201,9 +215,10 @@ public: %{ #include -DECLARE_DEF_STRING(VListBoxNameStr); %} +MAKE_CONST_WXSTRING(VListBoxNameStr); + // First, the C++ version %{ @@ -281,11 +296,14 @@ IMP_PYCALLBACK__DCRECTSIZET_const (wxPyVListBox, wxVListBox, OnDrawBackground It emits the same events as wxListBox and the same event macros may be used with it. */ -%name(VListBox) class wxPyVListBox : public wxPyVScrolledWindow +MustHaveApp(wxPyVListBox); + +%rename(VListBox) wxPyVListBox; +class wxPyVListBox : public wxPyVScrolledWindow { public: - %addtofunc wxPyVListBox "self._setOORInfo(self);self._setCallbackInfo(self, VListBox)" - %addtofunc wxPyVListBox() "" + %pythonAppend wxPyVListBox "self._setOORInfo(self);self._setCallbackInfo(self, VListBox)" + %pythonAppend wxPyVListBox() "" wxPyVListBox(wxWindow *parent, @@ -295,7 +313,7 @@ public: long style = 0, const wxString& name = wxPyVListBoxNameStr); - %name(PreVListBox) wxPyVListBox(); + %RenameCtor(PreVListBox, wxPyVListBox()); void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -328,22 +346,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); + wxPyBlock_t 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); + wxPyBlock_t 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; @@ -368,7 +408,7 @@ public: // selects or deselects the specified item which must be valid (i.e. not // equal to wxNOT_FOUND) // - // return true if the items selection status has changed or false + // return True if the items selection status has changed or False // otherwise // // this function is only valid for the multiple selection listboxes @@ -377,7 +417,7 @@ public: // selects the items in the specified range whose end points may be given // in any order // - // return true if any items selection status has changed, false otherwise + // return True if any items selection status has changed, False otherwise // // this function is only valid for the single selection listboxes bool SelectRange(size_t from, size_t to); @@ -390,7 +430,7 @@ public: // select all items in the listbox // // the return code indicates if any items were affected by this operation - // (true) or if nothing has changed (false) + // (True) or if nothing has changed (False) bool SelectAll(); // unselect all items in the listbox @@ -404,7 +444,7 @@ public: // // by default both margins are 0 void SetMargins(const wxPoint& pt); - %name(SetMarginsXY) void SetMargins(wxCoord x, wxCoord y); + %Rename(SetMarginsXY, void, SetMargins(wxCoord x, wxCoord y)); // change the background colour of the selected cells void SetSelectionBackground(const wxColour& col); @@ -477,11 +517,13 @@ IMP_PYCALLBACK_STRING_SIZET (wxPyHtmlListBox, wxHtmlListBox, OnGetItemMarkup // wxHtmlListBox is a listbox whose items are wxHtmlCells -%name(HtmlListBox) class wxPyHtmlListBox : public wxPyVListBox +MustHaveApp(wxPyHtmlListBox); +%rename(HtmlListBox) wxPyHtmlListBox; +class wxPyHtmlListBox : public wxPyVListBox { public: - %addtofunc wxPyHtmlListBox "self._setOORInfo(self);self._setCallbackInfo(self, HtmlListBox)" - %addtofunc wxPyHtmlListBox() "" + %pythonAppend wxPyHtmlListBox "self._setOORInfo(self);self._setCallbackInfo(self, HtmlListBox)" + %pythonAppend wxPyHtmlListBox() "" // normal constructor which calls Create() internally @@ -492,7 +534,7 @@ public: long style = 0, const wxString& name = wxPyVListBoxNameStr); - %name(PreHtmlListBox) wxPyHtmlListBox(); + %RenameCtor(PreHtmlListBox, wxPyHtmlListBox()); void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -507,6 +549,9 @@ public: void RefreshAll(); void SetItemCount(size_t count); + // retrieve the file system used by the wxHtmlWinParser: if you use + // relative paths in your HTML, you should use its ChangePathTo() method + wxFileSystem& GetFileSystem(); };