****************** wx.VScrolledWindow ****************** Inheritance diagram for `wx.VScrolledWindow`: | .. inheritance-diagram:: wx.VScrolledWindow | Description =========== In the name of this class, "V" may stand for "variable" because it can be used for scrolling lines of variable heights; "virtual" because it is not necessary to know the heights of all lines in advance -- only those which are shown on the screen need to be measured; or, even, "vertical" because this class only supports scrolling in one direction currently (this could and probably will change in the future however). In any case, this is a generalization of the `wx.ScrolledWindow `_ class which can be only used when all lines have the same height. It lacks some other `wx.ScrolledWindow` features however, notably there is currently no support for horizontal scrolling; it can't scroll another window nor only a rectangle of the window and not its entire client area. To use this class, you need to derive from it and implement `OnGetLineHeight` pure virtual method. You also must call `SetLineCount <#SetLineCount>`_ to let the base class know how many lines it should display but from that moment on the scrolling is handled entirely by `wx.VScrolledWindow`, you only need to draw the visible part of contents in your `OnPaint()` method as usual. You should use `GetFirstVisibleLine <#GetFirstVisibleLine>`_ and `GetLastVisibleLine <#GetLastVisibleLine>`_ to select the lines to display. .. note:: Note that the device context origin is not shifted so the first visible line always appears at the point (0, 0) in physical as well as logical coordinates. Derived From ^^^^^^^^^^^^^ * `wx.Panel `_ * `wx.Window `_ * `wx.EvtHandler `_ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.HtmlListBox `_, `wx.SimpleHtmlListBox `_, `wx.VListBox `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `FindFirstFromBottom <#FindFirstFromBottom>`_ * `GetFirstVisibleLine <#GetFirstVisibleLine>`_ * `GetLastVisibleLine <#GetLastVisibleLine>`_ * `GetLineCount <#GetLineCount>`_ * `GetLinesHeight <#GetLinesHeight>`_ * `GetVisibleBegin <#GetVisibleBegin>`_ * `GetVisibleEnd <#GetVisibleEnd>`_ * `HitTest <#HitTest>`_ * `HitTestXY <#HitTestXY>`_ * `IsVisible <#IsVisible>`_ * `RefreshAll <#RefreshAll>`_ * `RefreshLine <#RefreshLine>`_ * `RefreshLines <#RefreshLines>`_ * `ScrollLines <#ScrollLines>`_ * `ScrollPages <#ScrollPages>`_ * `ScrollToLine <#ScrollToLine>`_ * `SetLineCount <#SetLineCount>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `FirstVisibleLine <#FirstVisibleLine>`_ * `LastVisibleLine <#LastVisibleLine>`_ * `LineCount <#LineCount>`_ * `VisibleBegin <#VisibleBegin>`_ * `VisibleEnd <#VisibleEnd>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name=wx.PanelNameStr) This is the default constructor. **Parameters:** * `parent` (`wx.Window `_) * `id` (int) * `pos` (`wx.Point `_) * `size` (`wx.Size `_) * `style` (long) * `name` (string) | **Returns:** `wx.VScrolledWindow `_ .. note:: Note that ``wx.VSCROLL`` is always automatically added to our style, there is no need to specify it explicitly. -------- .. method:: FindFirstFromBottom(lineLast, fullyVisible=False) | **Parameters:** * `lineLast` (int) * `fullyVisible` (bool) | **Returns:** `int` -------- .. method:: GetFirstVisibleLine() Returns the index of the first currently visible line. This is same as `GetVisibleBegin <#GetVisibleBegin>`_ and exists only for symmetry with `GetLastVisibleLine <#GetLastVisibleLine>`_. | **Returns:** `long` -------- .. method:: GetLastVisibleLine() Returns the index of the last currently visible line. | **Returns:** `long` .. note:: Note that this method returns ``(size_t)-1`` (i.e. a huge positive number) if the control is empty so if this is possible you should use `GetVisibleEnd <#GetVisibleEnd>`_ instead. .. seealso:: `GetFirstVisibleLine <#GetFirstVisibleLine>`_ -------- .. method:: GetLineCount() Get the number of lines this window contains (previously set by `SetLineCount <#SetLineCount>`_) | **Returns:** `long` -------- .. method:: GetLinesHeight(lineMin, lineMax) | **Parameters:** * `lineMin` (int) * `lineMax` (int) | **Returns:** `int` -------- .. method:: GetVisibleBegin() Returns the index of the first currently visible line. | **Returns:** `long` .. seealso:: `GetVisibleEnd <#GetVisibleEnd>`_ -------- .. method:: GetVisibleEnd() Returns the index of the first line after the currently visible one. If the return value is 0 it means that no lines are currently shown (which only happens if the control is empty). | **Returns:** `long` .. note:: Note that the index returned by this method is not always a valid index as it may be equal to `GetLineCount <#GetLineCount>`_. .. seealso:: `GetVisibleBegin <#GetVisibleBegin>`_ -------- .. method:: HitTest(pt) Return the item at the specified (in physical coordinates) position or ``wx.NOT_FOUND`` if none, i.e. if it is below the last item. **Parameters:** * `pt` (`wx.Point `_) | **Returns:** `int` -------- .. method:: HitTestXY(x, y) Return the item at the specified (in physical coordinates) position or ``wx.NOT_FOUND`` if none, i.e. if it is below the last item. **Parameters:** * `x` (int) * `y` (int) | **Returns:** `int` -------- .. method:: IsVisible(line) Returns ``True`` if the given line is (at least partially) visible or ``False`` otherwise. **Parameters:** * `line` (long) | **Returns:** `bool` -------- .. method:: RefreshAll() This function completely refreshes the control, recalculating the number of items shown on screen and repainting them. It should be called when the values returned by `OnGetLineHeight` change for some reason and the window must be updated to reflect this. -------- .. method:: RefreshLine(line) Refreshes the specified line -- it will be redrawn during the next main loop iteration. **Parameters:** * `line` (long) .. seealso:: `RefreshLines <#RefreshLines>`_ -------- .. method:: RefreshLines(from, to) Refreshes all lines between `from` and `to`, inclusive. `from` should be less than or equal to `to`. **Parameters:** * `from` (long) * `to` (long) .. seealso:: `RefreshLine <#RefreshLine>`_ -------- .. method:: ScrollLines(lines) If the platform and window class supports it, scrolls the window by the given number of lines down, if `lines` is positive, or up if `lines` is negative. Returns ``True`` if the window was scrolled, ``False`` if it was already on top/bottom and nothing was done. **Parameters:** * `lines` (long) | **Returns:** `bool` -------- .. method:: ScrollPages(pages) If the platform and window class supports it, scrolls the window by the given number of pages down, if `pages` is positive, or up if `pages` is negative. Returns ``True`` if the window was scrolled, ``False`` if it was already on top/bottom and nothing was done. **Parameters:** * `pages` (long) | **Returns:** `bool` -------- .. method:: ScrollToLine(line) 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. **Parameters:** * `line` (long) | **Returns:** `bool` -------- .. method:: SetLineCount(count) Set the number of lines the window contains: the derived class must provide the heights for all lines with indices up to the one given here in its `OnGetLineHeight`. **Parameters:** * `count` (long) -------- Properties ^^^^^^^^^^ .. attribute:: FirstVisibleLine See `GetFirstVisibleLine <#GetFirstVisibleLine>`_ .. attribute:: LastVisibleLine See `GetLastVisibleLine <#GetLastVisibleLine>`_ .. attribute:: LineCount See `GetLineCount <#GetLineCount>`_ and `SetLineCount <#SetLineCount>`_ .. attribute:: VisibleBegin See `GetVisibleBegin <#GetVisibleBegin>`_ .. attribute:: VisibleEnd See `GetVisibleEnd <#GetVisibleEnd>`_