The ScrolledWindow class manages scrolling for its client area, transforming the coordinates according to the scrollbar positions, and setting the scroll positions, thumb sizes and ranges according to the area in view.
Starting from version 2.4 of Widgets, there are several ways to use a ScrolledWindow. In particular, there are now three ways to set the size of the scrolling area:
One way is to set the scrollbars directly using a call to ScrolledWindow#set_scrollbars. This is the way it used to be in any previous version of Widgets and it will be kept for backwards compatibility.
An additional method of manual control, which requires a little less computation of your own, is to set the total size of the scrolling area by calling either Window#set_virtual_size, or Window#fit_inside, and setting the scrolling increments for it by calling ScrolledWindow#set_scroll_rate. Scrolling in some orientation is enabled by setting a non zero increment for it.
The most automatic and newest way is to simply let sizers determine the scrolling area. This is now the default when you set an interior sizer into a ScrolledWindow with Window#set_sizer. The scrolling area will be set to the size requested by the sizer and the scrollbars will be assigned for each orientation according to the need for them and the scrolling increment set by ScrolledWindow#set_scroll_rate. As above, scrolling is only enabled in orientations with a non-zero increment. You can influence the minimum size of the scrolled area controlled by a sizer by calling Window#set_virtual_size_hints. (calling ScrolledWindow#set_scrollbars has analogous effects in Widgets 2.4—in later versions it may not continue to override the sizer)
Note: if Maximum size hints are still supported by SetVirtualSizeHints, use them at your own dire risk. They may or may not have been removed for 2.4, but it really only makes sense to set minimum size hints here. We should probably replace SetVirtualSizeHints with SetMinVirtualSize or similar and remove it entirely in future.
As with all windows, an application can draw onto a ScrolledWindow using a device context.
You have the option of handling the OnPaint handler or overriding the on_draw function, which is passed a pre-scrolled device context (prepared by do_prepare_dc).
If you don’t wish to calculate your own scrolling, you must call DoPrepareDC when not drawing from within OnDraw, to set the device origin for the device context according to the current scroll position.
A ScrolledWindow will normally scroll itself and therefore its child windows as well. It might however be desired to scroll a different window than itself: e.g. when designing a spreadsheet, you will normally only have to scroll the (usually white) cell area, whereas the (usually grey) label area will scroll very differently. For this special purpose, you can call set_target_window which means that pressing the scrollbars will scroll a different window.
Note that the underlying system knows nothing about scrolling coordinates, so that all system functions (mouse events, expose events, refresh calls etc) as well as the position of subwindows are relative to the “physical” origin of the scrolled window. If the user insert a child window at position (10,10) and scrolls the window down 100 pixels (moving the child window out of the visible area), the child window will report a position of (10,-90).
RETAINED |
Uses a backing pixmap to speed refreshes. Motif only. |
See also window styles overview.
Use ScrolledWindow for applications where the user scrolls by a fixed amount, and where a `page’ can be interpreted to be the current visible portion of the window. For more sophisticated applications, use the ScrolledWindow implementation as a guide to build your own scroll behaviour.
ScrolledWindow.new(Window parent, Integer id = -1,
Point pos = DEFAULT_POSITION,
Size size = DEFAULT_SIZE,
Integer style = HSCROLL VSCROLL,
String name = "scrolledWindow")
Constructor.
The window is initially created without visible scrollbars. Call ScrolledWindow#set_scrollbars to specify how big the virtual window size should be.
destructor()
Destructor.
calc_scrolled_position( Integer x, Integer y,
Integer xx Integer yy)
Translates the logical coordinates to the device ones. For example, if a window is scrolled 10 pixels to the bottom, the device coordinates of the origin are (0, 0) (as always), but the logical coordinates are (0, 10) and so the call to CalcScrolledPosition(0, 10, &xx, &yy) will return 0 in yy.
calc_unscrolled_position( Integer x, Integer y,
Integer xx Integer yy)
Translates the device coordinates to the logical ones. For example, if a window is scrolled 10 pixels to the bottom, the device coordinates of the origin are (0, 0) (as always), but the logical coordinates are (0, 10) and so the call to CalcUnscrolledPosition(0, 0, &xx, &yy) will return 10 in yy.
Boolean create(Window parent, Integer id = -1,
Point pos = DEFAULT_POSITION,
Size size = DEFAULT_SIZE,
Integer style = HSCROLL VSCROLL,
String name = "scrolledWindow")
Creates the window for two-step construction. Derived classes should call or replace this function. See ScrolledWindow.new for details.
enable_scrolling(Boolean xScrolling, Boolean yScrolling)
Enable or disable physical scrolling in the given direction. Physical scrolling is the physical transfer of bits up or down the screen when a scroll event occurs. If the application scrolls by a variable amount (e.g. if there are different font sizes) then physical scrolling will not work, and you should switch it off. Note that you will have to reposition child windows yourself, if physical scrolling is disabled.
Physical scrolling may not be available on all platforms. Where it is available, it is enabled by default.
get_scroll_pixels_per_unit(Integer xUnit, Integer yUnit)
Get the number of pixels per scroll unit (line), in each direction, as set by ScrolledWindow#set_scrollbars. A value of zero indicates no scrolling in that direction.
ScrolledWindow#set_scrollbars, ScrolledWindow#get_virtual_size
get_view_start(Integer x, Integer y)
Get the position at which the visible portion of the window starts.
If either of the scrollbars is not at the home position, x and/or
[This page automatically generated from the Textile source at Thu May 01 00:50:43 +0100 2008]