wx.VScrolledWindow

Inheritance diagram for 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 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 and 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.

Class API

Methods

__init__(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name=wx.PanelNameStr)

This is the default constructor.

Parameters:


Returns:

wx.VScrolledWindow

Note

Note that wx.VSCROLL is always automatically added to our style, there is no need to specify it explicitly.


FindFirstFromBottom(lineLast, fullyVisible=False)

Parameters:

  • lineLast (int)
  • fullyVisible (bool)

Returns:

int


GetFirstVisibleLine()

Returns the index of the first currently visible line.

This is same as GetVisibleBegin and exists only for symmetry with GetLastVisibleLine.


Returns:

long


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 instead.


GetLineCount()

Get the number of lines this window contains (previously set by SetLineCount)


Returns:

long


GetLinesHeight(lineMin, lineMax)

Parameters:

  • lineMin (int)
  • lineMax (int)

Returns:

int


GetVisibleBegin()

Returns the index of the first currently visible line.


Returns:

long

See also

GetVisibleEnd


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.

See also

GetVisibleBegin


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:


Returns:

int


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


IsVisible(line)

Returns True if the given line is (at least partially) visible or False otherwise.

Parameters:

  • line (long)

Returns:

bool


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.

RefreshLine(line)

Refreshes the specified line – it will be redrawn during the next main loop iteration.

Parameters:

  • line (long)

See also

RefreshLines


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)

See also

RefreshLine


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


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


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


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

FirstVisibleLine
See GetFirstVisibleLine
LastVisibleLine
See GetLastVisibleLine
LineCount
See GetLineCount and SetLineCount
VisibleBegin
See GetVisibleBegin
VisibleEnd
See GetVisibleEnd