X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e6b35578d9be94739e1f9ebadcb57d9a483db6a..3d6c9062b162bebeb423a24e3199cecc46cbdd6c:/wxPython/src/_vscroll.i diff --git a/wxPython/src/_vscroll.i b/wxPython/src/_vscroll.i index ff24d30bd3..ce66f5cd23 100644 --- a/wxPython/src/_vscroll.i +++ b/wxPython/src/_vscroll.i @@ -35,7 +35,7 @@ %{ class wxPyVScrolledWindow : public wxVScrolledWindow { - DECLARE_ABSTRACT_CLASS(wxPyVScrolledWindow); + DECLARE_ABSTRACT_CLASS(wxPyVScrolledWindow) public: wxPyVScrolledWindow() : wxVScrolledWindow() {} @@ -95,6 +95,11 @@ public: wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const { return wxVScrolledWindow::GetLinesHeight(lineMin, lineMax); } + // update the thumb size shown by the scrollbar + void UpdateScrollbar() { wxVScrolledWindow::UpdateScrollbar(); } + + // remove the scrollbar completely because we don't need it + void RemoveScrollbar() { wxVScrolledWindow::RemoveScrollbar(); } PYPRIVATE; }; @@ -189,16 +194,36 @@ 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; + + // find the index of the line we need to show at the top of the window such + // that the last (fully or partially) visible line is the given one + size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false); + + // get the total height of the lines between lineMin (inclusive) and + // lineMax (exclusive) + wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const; }; + + //--------------------------------------------------------------------------- // wxVListBox @@ -213,7 +238,7 @@ MAKE_CONST_WXSTRING(VListBoxNameStr); %{ class wxPyVListBox : public wxVListBox { - DECLARE_ABSTRACT_CLASS(wxPyVListBox); + DECLARE_ABSTRACT_CLASS(wxPyVListBox) public: wxPyVListBox() : wxVListBox() {} @@ -246,7 +271,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 @@ -267,7 +292,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); %} @@ -438,6 +463,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; }; @@ -452,7 +479,7 @@ public: %{ class wxPyHtmlListBox : public wxHtmlListBox { - DECLARE_ABSTRACT_CLASS(wxPyHtmlListBox); + DECLARE_ABSTRACT_CLASS(wxPyHtmlListBox) public: wxPyHtmlListBox() : wxHtmlListBox() {} @@ -474,6 +501,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 @@ -488,6 +519,11 @@ public: // // globally using SetSelectionBackground() // virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const; + + // This method may be overriden to handle clicking on a link in + // the listbox. By default, clicking links is ignored. + virtual void OnLinkClicked(size_t n, + const wxHtmlLinkInfo& link); PYPRIVATE; }; @@ -497,7 +533,24 @@ 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); + + +void wxPyHtmlListBox::OnLinkClicked(size_t n, + const wxHtmlLinkInfo& link) { + bool found; + wxPyBlock_t blocked = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { + PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0); + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", n, obj)); + Py_DECREF(obj); + } + wxPyEndBlockThreads(blocked); + if (! found) + wxPyHtmlListBox::OnLinkClicked(n, link); +} + %} @@ -541,6 +594,8 @@ public: // retrieve the file system used by the wxHtmlWinParser: if you use // relative paths in your HTML, you should use its ChangePathTo() method wxFileSystem& GetFileSystem(); + + void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link); };