h1(#wxscrolledwindow). Wx::ScrolledWindow 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":scrolledwindow.html#ScrolledWindow_setscrollbars. 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":window.html#Window_setvirtualsize, or "Window#fit_inside":window.html#Window_fitinside, and setting the scrolling increments for it by calling "ScrolledWindow#set_scroll_rate":scrolledwindow.html#ScrolledWindow_setscrollrate. 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":window.html#Window_setsizer. 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":scrolledwindow.html#ScrolledWindow_setscrollrate. 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":window.html#Window_setvirtualsizehints. (calling "ScrolledWindow#set_scrollbars":scrolledwindow.html#ScrolledWindow_setscrollbars 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":dcoverview.html. You have the option of handling the OnPaint handler or overriding the "on_draw":#ScrolledWindow_ondraw function, which is passed a pre-scrolled device context (prepared by "do_prepare_dc":#ScrolledWindow_dopreparedc). 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":#ScrolledWindow_settargetwindow 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). h2. Derived from "Panel":panel.html "Window":window.html "EvtHandler":evthandler.html "Object":object.html h2. Window styles |@RETAINED@|Uses a backing pixmap to speed refreshes. Motif only.| See also "window styles overview":windowstyles.html. h2. Remarks 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. h2. See also "ScrollBar":scrollbar.html, "ClientDC":clientdc.html, "PaintDC":paintdc.html, "VScrolledWindow":vscrolledwindow.html
h2. Methods * "ScrolledWindow.new":#ScrolledWindow_new * "ScrolledWindow#calc_scrolled_position":#ScrolledWindow_calcscrolledposition * "ScrolledWindow#calc_unscrolled_position":#ScrolledWindow_calcunscrolledposition * "ScrolledWindow#create":#ScrolledWindow_create * "ScrolledWindow#enable_scrolling":#ScrolledWindow_enablescrolling * "ScrolledWindow#get_scroll_pixels_per_unit":#ScrolledWindow_getscrollpixelsperunit * "ScrolledWindow#get_view_start":#ScrolledWindow_getviewstart * "ScrolledWindow#get_virtual_size":#ScrolledWindow_getvirtualsize * "ScrolledWindow#is_retained":#ScrolledWindow_isretained * "ScrolledWindow#do_prepare_dc":#ScrolledWindow_dopreparedc * "ScrolledWindow#on_draw":#ScrolledWindow_ondraw * "ScrolledWindow#prepare_dc":#ScrolledWindow_preparedc * "ScrolledWindow#scroll":#ScrolledWindow_scroll * "ScrolledWindow#set_scrollbars":#ScrolledWindow_setscrollbars * "ScrolledWindow#set_scroll_rate":#ScrolledWindow_setscrollrate * "ScrolledWindow#set_target_window":#ScrolledWindow_settargetwindow
h3(#ScrolledWindow_new). ScrolledWindow.new *ScrolledWindow.new*(%(arg-type)"Window":window.html% parent, %(arg-type)Integer% id = -1, %(arg-type)"Point":point.html% pos = DEFAULT_POSITION, %(arg-type)"Size":size.html% size = DEFAULT_SIZE, %(arg-type)Integer% style = HSCROLL VSCROLL, %(arg-type)String% name = "scrolledWindow") Constructor. h4. Parameters * _parent_ Parent window. * _id_ Window identifier. A value of -1 indicates a default value. * _pos_ Window position. If a position of (-1, -1) is specified then a default position is chosen. * _size_ Window size. If a size of (-1, -1) is specified then the window is sized appropriately. * _style_ Window style. See "ScrolledWindow":scrolledwindow.html. * _name_ Window name. h4. Remarks The window is initially created without visible scrollbars. Call "ScrolledWindow#set_scrollbars":scrolledwindow.html#ScrolledWindow_setscrollbars to specify how big the virtual window size should be. *destructor*() Destructor. h3(#ScrolledWindow_calcscrolledposition). ScrolledWindow#calc_scrolled_position *calc_scrolled_position*( %(arg-type)Integer% x, %(arg-type)Integer% y, %(arg-type)Integer% xx %(arg-type)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. h4. See also "calc_unscrolled_position":#ScrolledWindow_calcunscrolledposition h3(#ScrolledWindow_calcunscrolledposition). ScrolledWindow#calc_unscrolled_position *calc_unscrolled_position*( %(arg-type)Integer% x, %(arg-type)Integer% y, %(arg-type)Integer% xx %(arg-type)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. h4. See also "calc_scrolled_position":#ScrolledWindow_calcscrolledposition h3(#ScrolledWindow_create). ScrolledWindow#create Boolean *create*(%(arg-type)"Window":window.html% parent, %(arg-type)Integer% id = -1, %(arg-type)"Point":point.html% pos = DEFAULT_POSITION, %(arg-type)"Size":size.html% size = DEFAULT_SIZE, %(arg-type)Integer% style = HSCROLL VSCROLL, %(arg-type)String% name = "scrolledWindow") Creates the window for two-step construction. Derived classes should call or replace this function. See "ScrolledWindow.new":scrolledwindow.html#ScrolledWindow_new for details. h3(#ScrolledWindow_enablescrolling). ScrolledWindow#enable_scrolling *enable_scrolling*(%(arg-type)Boolean% xScrolling, %(arg-type)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. h4. Parameters * _xScrolling_ If true, enables physical scrolling in the x direction. * _yScrolling_ If true, enables physical scrolling in the y direction. h4. Remarks Physical scrolling may not be available on all platforms. Where it is available, it is enabled by default. h3(#ScrolledWindow_getscrollpixelsperunit). ScrolledWindow#get_scroll_pixels_per_unit *get_scroll_pixels_per_unit*(%(arg-type)Integer% xUnit, %(arg-type)Integer% yUnit) Get the number of pixels per scroll unit (line), in each direction, as set by "ScrolledWindow#set_scrollbars":scrolledwindow.html#ScrolledWindow_setscrollbars. A value of zero indicates no scrolling in that direction. h4. Parameters * _xUnit_ Receives the number of pixels per horizontal unit. * _yUnit_ Receives the number of pixels per vertical unit. h4. See also "ScrolledWindow#set_scrollbars":scrolledwindow.html#ScrolledWindow_setscrollbars, "ScrolledWindow#get_virtual_size":scrolledwindow.html#ScrolledWindow_getvirtualsize h3(#ScrolledWindow_getviewstart). ScrolledWindow#get_view_start *get_view_start*(%(arg-type)Integer% x, %(arg-type)Integer% y) Get the position at which the visible portion of the window starts. h4. Parameters * _x_ Receives the first visible x position in scroll units. * _y_ Receives the first visible y position in scroll units. h4. Remarks If either of the scrollbars is not at the home position, _x_ and/or