# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # The {Wx::Scrolled} 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. # There are two commonly used (but not the only possible!) specializations of this class: # # - {Wx::ScrolledWindow}, aka {Wx::Scrolled}<{Wx::Panel}>, is equivalent to {Wx::ScrolledWindow} from earlier versions. Derived from {Wx::Panel}, it shares {Wx::Panel}'s behaviour with regard to TAB traversal and focus handling. Use this if the scrolled window will have child controls.- {Wx::ScrolledCanvas}, aka {Wx::Scrolled}<{Wx::Window}>, derives from {Wx::Window} and so doesn't handle children specially. This is suitable e.g. for implementing scrollable controls such as tree or list controls. # # See Wx::Scrolled#create if you want to use {Wx::Scrolled} with a custom class. # # Starting from version 2.4 of wxWidgets, there are several ways to use a {Wx::ScrolledWindow} (and now {Wx::Scrolled}). In particular, there are three ways to set the size of the scrolling area: # One way is to set the scrollbars directly using a call to Wx::Scrolled#set_scrollbars. This is the way it used to be in any previous version of wxWidgets 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 {Wx::Window#set_virtual_size}, or {Wx::Window#fit_inside}, and setting the scrolling increments for it by calling Wx::Scrolled#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 {Wx::Scrolled} with {Wx::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 Wx::Scrolled#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 {Wx::Window#set_virtual_size_hints}. (Calling Wx::Scrolled#set_scrollbars has analogous effects in wxWidgets 2.4 in later versions it may not continue to override the sizer.) # Note that if maximum size hints are still supported by {Wx::Window#set_virtual_size_hints} or similar and remove it entirely in future. # Todoreview docs for this class replacing SetVirtualSizeHints() with SetMinClientSize(). # # As with all windows, an application can draw onto a {Wx::Scrolled} using a device context. # You have the option of handling the OnPaint handler or overriding the Wx::Scrolled#on_draw function, which is passed a pre-scrolled device context (prepared by Wx::Scrolled#do_prepare_dc). # If you don't wish to calculate your own scrolling, you must call Wx::Scrolled#do_prepare_dc when not drawing from within Wx::Scrolled#on_draw, to set the device origin for the device context according to the current scroll position. # A {Wx::Scrolled} 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 Wx::Scrolled#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). # === Styles # # This class supports the following styles: # # - {Wx::HSCROLL}: If this style is specified and {Wx::VSCROLL} isn't, the window will be scrollable only in horizontal direction (by default, i.e. if neither this style nor {Wx::VSCROLL} is specified, it scrolls in both directions). # - {Wx::VSCROLL}: If this style is specified and {Wx::HSCROLL} isn't, the window will be scrollable only in vertical direction (by default, i.e. if neither this style nor {Wx::HSCROLL} is specified, it scrolls in both directions). # - {Wx::ALWAYS_SHOW_SB}: Since wxWidgets 2.9.5, specifying this style makes the window always show its scrollbars, even if they are not used. See Wx::Scrolled#show_scrollbars. # - {Wx::RETAINED}: Uses a backing pixmap to speed refreshes. Motif only. # # === Events emitted by this class # # The following event-handler methods redirect the events to member method or handler blocks for {Wx::ScrollWinEvent} events. # Event handler methods for events emitted by this class: # - {Wx::EvtHandler#evt_scrollwin}(meth = nil, &block): Process all scroll events. # - {Wx::EvtHandler#evt_scrollwin_top}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_TOP} scroll-to-top events. # - {Wx::EvtHandler#evt_scrollwin_bottom}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_BOTTOM} scroll-to-bottom events. # - {Wx::EvtHandler#evt_scrollwin_lineup}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_LINEUP} line up events. # - {Wx::EvtHandler#evt_scrollwin_linedown}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_LINEDOWN} line down events. # - {Wx::EvtHandler#evt_scrollwin_pageup}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_PAGEUP} page up events. # - {Wx::EvtHandler#evt_scrollwin_pagedown}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_PAGEDOWN} page down events. # - {Wx::EvtHandler#evt_scrollwin_thumbtrack}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_THUMBTRACK} thumbtrack events (frequent events sent as the user drags the thumbtrack). # - {Wx::EvtHandler#evt_scrollwin_thumbrelease}(meth = nil, &block): Process {Wx::EVT_SCROLLWIN_THUMBRELEASE} thumb release events. # # Don't confuse {Wx::ScrollWinEvents} generated by this class with {Wx::ScrollEvent} objects generated by {Wx::ScrollBar} and {Wx::Slider}. # # Use {Wx::Scrolled} 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 {Wx::Scrolled} implementation as a guide to build your own scroll behaviour or use {Wx::VScrolledWindow} or its variants. # # === # # Category: Miscellaneous Windows # @see Wx::ScrollBar # @see Wx::ClientDC # @see Wx::PaintDC # @see Wx::VScrolledWindow # @see Wx::HScrolledWindow # @see Wx::HVScrolledWindow # @see # # class ScrolledCanvas < Window # @overload initialize() # Default constructor. # @return [Scrolled] # @overload initialize(parent, id=-1, pos=Wx::DEFAULT_POSITION, size=Wx::DEFAULT_SIZE, style=(Wx::HSCROLL|Wx::VSCROLL), name=("Wx::SCROLLED_WINDOW")) # Constructor. # The window is initially created without visible scrollbars. Call Wx::Scrolled#set_scrollbars to specify how big the virtual window size should be. # @param parent [Wx::Window] Parent window. # @param id [Integer] Window identifier. The value {Wx::StandardID::ID_ANY} indicates a default value. # @param pos [Array(Integer, Integer), Wx::Point] Window position. If a position of {Wx::DEFAULT_POSITION} is specified then a default position is chosen. # @param size [Array(Integer, Integer), Wx::Size] Window size. If a size of {Wx::DEFAULT_SIZE} is specified then the window is sized appropriately. # @param style [Integer] Window style. See {Wx::Scrolled}. # @param name [String] Window name. # @return [Scrolled] def initialize(*args) end # @overload calc_scrolled_position(x, y) # 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. # {Wx::Perl} Note: In {Wx::Perl} this method takes two parameters and returns a 2-element list (xx, yy). # @see Wx::Scrolled#calc_unscrolled_position # @param x [Integer] # @param y [Integer] # @return [Array(Integer,Integer)] # @overload calc_scrolled_position(pt) # @param pt [Array(Integer, Integer), Wx::Point] # @return [Wx::Point] def calc_scrolled_position(*args) end # @overload calc_unscrolled_position(x, y) # 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. # {Wx::Perl} Note: In {Wx::Perl} this method takes two parameters and returns a 2-element list (xx, yy). # @see Wx::Scrolled#calc_scrolled_position # @param x [Integer] # @param y [Integer] # @return [Array(Integer,Integer)] # @overload calc_unscrolled_position(pt) # @param pt [Array(Integer, Integer), Wx::Point] # @return [Wx::Point] def calc_unscrolled_position(*args) end # Creates the window for two-step construction. # Derived classes should call or replace this function. If it is not replaced, bear in mind that it calls T::Create() through the global function {create_scrolled} so if T::Create() has a different signature than Wx::Scrolled#create you should implement overloaded {create_scrolled} which would call T::Create() in the correct manner. # @see Wx::Scrolled#initialize and create_scrolled for details. # @param parent [Wx::Window] # @param id [Integer] # @param pos [Array(Integer, Integer), Wx::Point] # @param size [Array(Integer, Integer), Wx::Size] # @param style [Integer] # @param name [String] # @return [true,false] def create(parent, id=-1, pos=Wx::DEFAULT_POSITION, size=Wx::DEFAULT_SIZE, style=(Wx::HSCROLL|Wx::VSCROLL), name=("Wx::SCROLLED_WINDOW")) end # Disable use of keyboard keys for scrolling. # By default cursor movement keys (including Home, End, Page Up and Down) are used to scroll the window appropriately. If the derived class uses these keys for something else, e.g. changing the currently selected item, this function can be used to disable this behaviour as it's not only not necessary then but can actually be actively harmful if another object forwards a keyboard event corresponding to one of the above keys to us using ProcessWindowEvent() because the event will always be processed which can be undesirable. # @return [void] def disable_keyboard_scrolling; end # Call this function to prepare the device context for drawing a scrolled image. # It sets the device origin according to the current scroll position. Wx::Scrolled#do_prepare_dc is called automatically within the default {Wx::EVT_PAINT} event handler, so your Wx::Scrolled#on_draw override will be passed an already 'pre-scrolled' device context. However, if you wish to draw from outside of Wx::Scrolled#on_draw (e.g. from your own {Wx::EVT_PAINT} handler), you must call this function yourself. # For example: # # void MyWindow::OnEvent(wxMouseEvent& event) # { # wxClientDC dc(this); # DoPrepareDC(dc); # # dc.SetPen(*wxBLACK_PEN); # float x, y; # event.Position(&x, &y); # if (xpos > -1 && ypos > -1 && event.Dragging()) # { # dc.DrawLine(xpos, ypos, x, y); # } # xpos = x; # ypos = y; # } # # Notice that the function sets the origin by moving it relatively to the current origin position, so you shouldn't change the origin before calling Wx::Scrolled#do_prepare_dc or, if you do, reset it to (0, 0) later. If you call Wx::Scrolled#do_prepare_dc immediately after device context creation, as in the example above, this problem doesn't arise, of course, so it is customary to do it like this. # @param dc [Wx::DC] # @return [void] def do_prepare_dc(dc) end # Enable or disable use of {Wx::Window#scroll_window} for scrolling. # By default, when a scrolled window is logically scrolled, {Wx::Window#scroll_window} is called on the underlying window which scrolls the window contents and only invalidates the part of the window newly brought into view. If false is passed as an argument, then this "physical scrolling" is disabled and the window is entirely invalidated whenever it is scrolled by calling {Wx::Window#refresh}. # It should be rarely necessary to disable physical scrolling, so this method shouldn't be called in normal circumstances. # @param xScrolling [true,false] If true, enables physical scrolling in the x direction. # @param yScrolling [true,false] If true, enables physical scrolling in the y direction. # @return [void] def enable_scrolling(xScrolling, yScrolling) end # Set the scrollbar visibility. # By default the scrollbar in the corresponding direction is only shown if it is needed, i.e. if the virtual size of the scrolled window in this direction is greater than the current physical window size. Using this function the scrollbar visibility can be changed to be: # - {Wx::ScrollbarVisibility::SHOW_SB_ALWAYS}: To always show the scrollbar, even if it is not needed currently ({Wx::ALWAYS_SHOW_SB} style can be used during the window creation to achieve the same effect but it applies in both directions).- {Wx::ScrollbarVisibility::SHOW_SB_NEVER}: To never show the scrollbar at all. In this case the program should presumably provide some other way for the user to scroll the window.- {Wx::ScrollbarVisibility::SHOW_SB_DEFAULT}: To restore the default behaviour described above. # # Note that the window must be created before calling this method. # @param horz [ScrollbarVisibility] The desired visibility for the horizontal scrollbar. # @param vert [ScrollbarVisibility] The desired visibility for the vertical scrollbar. # @return [void] def show_scrollbars(horz, vert) end # Get the number of pixels per scroll unit (line), in each direction, as set by Wx::Scrolled#set_scrollbars. # A value of zero indicates no scrolling in that direction. # # {Wx::Perl} Note: In {Wx::Perl} this method takes no parameters and returns a 2-element list (xUnit, yUnit). # @see Wx::Scrolled#set_scrollbars # @see Wx::Scrolled#get_virtual_size # @return [Array(Integer,Integer)] def get_scroll_pixels_per_unit; end alias_method :scroll_pixels_per_unit, :get_scroll_pixels_per_unit # This is a simple overload of GetViewStart(int*,int*); see that function for more info. # @return [Wx::Point] def get_view_start; end alias_method :view_start, :get_view_start # Gets the size in device units of the scrollable window area (as opposed to the client size, which is the area of the window currently visible). # Use {Wx::DC#device_to_logical_x} and {Wx::DC#device_to_logical_y} to translate these units to logical units. # # {Wx::Perl} Note: In {Wx::Perl} this method takes no parameters and returns a 2-element list (xUnit, yUnit). # @see Wx::Scrolled#set_scrollbars # @see Wx::Scrolled#get_scroll_pixels_per_unit # @return [Array(Integer,Integer)] def get_virtual_size; end alias_method :virtual_size, :get_virtual_size # Motif only: true if the window has a backing bitmap. # @return [true,false] def is_retained; end alias_method :retained?, :is_retained # This function is for backwards compatibility only and simply calls Wx::Scrolled#do_prepare_dc now. # Notice that it is not called by the default paint event handle (Wx::Scrolled#do_prepare_dc is), so overriding this method in your derived class is useless. # @param dc [Wx::DC] # @return [void] def prepare_dc(dc) end # @overload scroll(x, y) # Scrolls a window so the view start is at the given point. # The positions are in scroll units, not pixels, so to convert to pixels you will have to multiply by the number of pixels per scroll increment. If either parameter is {Wx::DEFAULT_COORD} (-1), that position will be ignored (no change in that direction). # @see Wx::Scrolled#set_scrollbars # @see Wx::Scrolled#get_scroll_pixels_per_unit # @param x [Integer] The x position to scroll to, in scroll units. # @param y [Integer] The y position to scroll to, in scroll units. # @return [void] # @overload scroll(pt) # This is an overload of Wx::Scrolled#scroll(int,int); see that function for more info. # @param pt [Array(Integer, Integer), Wx::Point] # @return [void] def scroll(*args) end # Set the horizontal and vertical scrolling increment only. # See the pixelsPerUnit parameter in Wx::Scrolled#set_scrollbars. # @param xstep [Integer] # @param ystep [Integer] # @return [void] def set_scroll_rate(xstep, ystep) end # Sets up vertical and/or horizontal scrollbars. # The first pair of parameters give the number of pixels per 'scroll step', i.e. amount moved when the up or down scroll arrows are pressed. The second pair gives the length of scrollbar in scroll steps, which sets the size of the virtual window. # xPos and yPos optionally specify a position to scroll to immediately. # For example, the following gives a window horizontal and vertical scrollbars with 20 pixels per scroll step, and a size of 50 steps (1000 pixels) in each direction: # # window->SetScrollbars(20, 20, 50, 50); # # {Wx::Scrolled} manages the page size itself, using the current client window size as the page size. # Note that for more sophisticated scrolling applications, for example where scroll steps may be variable according to the position in the document, it will be necessary to derive a new class from {Wx::Window}, overriding OnSize() and adjusting the scrollbars appropriately. # @see Wx::Window#set_virtual_size # @param pixelsPerUnitX [Integer] Pixels per scroll unit in the horizontal direction. # @param pixelsPerUnitY [Integer] Pixels per scroll unit in the vertical direction. # @param noUnitsX [Integer] Number of units in the horizontal direction. # @param noUnitsY [Integer] Number of units in the vertical direction. # @param xPos [Integer] Position to initialize the scrollbars in the horizontal direction, in scroll units. # @param yPos [Integer] Position to initialize the scrollbars in the vertical direction, in scroll units. # @param noRefresh [true,false] Will not refresh window if true. # @return [void] def set_scrollbars(pixelsPerUnitX, pixelsPerUnitY, noUnitsX, noUnitsY, xPos=0, yPos=0, noRefresh=false) end # Call this function to tell {Wx::Scrolled} to perform the actual scrolling on a different window (and not on itself). # This method is useful when only a part of the window should be scrolled. A typical example is a control consisting of a fixed header and the scrollable contents window: the scrollbars are attached to the main window itself, hence it, and not the contents window must be derived from {Wx::Scrolled}, but only the contents window scrolls when the scrollbars are used. To implement such setup, you need to call this method with the contents window as argument. # Notice that if this method is used, Wx::Scrolled#get_size_available_for_scroll_target method must be overridden. # @param window [Wx::Window] # @return [void] def set_target_window(window) end alias_method :target_window=, :set_target_window # @return [Wx::Window] def get_target_window; end alias_method :target_window, :get_target_window # @param rect [Wx::Rect] # @return [void] def set_target_rect(rect) end alias_method :target_rect=, :set_target_rect # @return [Wx::Rect] def get_target_rect; end alias_method :target_rect, :get_target_rect # @param orient [Integer] # @return [Integer] def get_scroll_page_size(orient) end alias_method :scroll_page_size, :get_scroll_page_size # @param orient [Integer] # @param pageSize [Integer] # @return [void] def set_scroll_page_size(orient, pageSize) end # @param orient [Integer] # @return [Integer] def get_scroll_lines(orient) end alias_method :scroll_lines, :get_scroll_lines # @param xs [Float] # @param ys [Float] # @return [void] def set_scale(xs, ys) end # @return [Float] def get_scale_x; end alias_method :scale_x, :get_scale_x # @return [Float] def get_scale_y; end alias_method :scale_y, :get_scale_y # @return [void] def adjust_scrollbars; end # Are we generating the autoscroll events? # @return [true,false] def is_auto_scrolling; end alias_method :auto_scrolling?, :is_auto_scrolling # Stop generating the scroll events when mouse is held outside the window. # @return [void] def stop_auto_scrolling; end # This method can be overridden in a derived class to forbid sending the auto scroll events - note that unlike Wx::Scrolled#stop_auto_scrolling it doesn't stop the timer, so it will be called repeatedly and will typically return different values depending on the current mouse position. # The base class version just returns true. # @param event [Wx::ScrollWinEvent] # @return [true,false] def send_auto_scroll_events(event) end end # ScrolledCanvas end