Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gtk::ScrolledWindow

class Gtk::ScrolledWindow

Gtk::ScrolledWindow is a Gtk::Bin subclass: it is a container that accepts a single child widget. Gtk::ScrolledWindow adds scrollbars to the child widget and optionally draws a beveled frame around the child widget.

The scrolled window can work in two ways. Some widgets have native scrolling support; these widgets have "slots" for Gtk::Adjustment objects. Widgets with native scroll support include Gtk::TreeView, Gtk::TextView, and Gtk::Layout.

For widgets that lack native scrolling support, the Gtk::Viewport widget acts as an adaptor class, implementing scrollability for child widgets that lack their own scrolling capabilities. Use Gtk::Viewport to scroll child widgets such as Gtk::Table, Gtk::Box, and so on.

If a widget has native scrolling abilities, it can be added to the Gtk::ScrolledWindow with Gtk::Container#add. If a widget is lacking native scrolling, you must first add the widget to a Gtk::Viewport, then add the Gtk::Viewport to the scrolled window. The convenience method Gtk::ScrolledWindow#add_with_viewport does exactly this, so you can ignore the presence of the viewport.

The position of the scrollbars is controlled by the scroll adjustments. See Gtk::Adjustment for the fields in an adjustment - for Gtk::Scrollbar, used by Gtk::ScrolledWindow, the "value" field represents the position of the scrollbar, which must be between the "lower" field and "upper - page_size." The "page_size" field represents the size of the visible scrollable area. The "step_increment" and "page_increment" fields are used when the user asks to step down (using the small stepper arrows) or page down (using for example the PageDown key).

If a Gtk::ScrolledWindow doesn't behave quite as you would like, or doesn't have exactly the right layout, it's very possible to set up your own scrolling with Gtk::Scrollbar and for example a Gtk::Table.

Class Methods

Gtk::ScrolledWindow.new(hadjustment = nil, vadjustment = nil)
Creates a new scrolled window. The two arguments are the scrolled window's adjustments; these will be shared with the scrollbars and the child widget to keep the bars in sync with the child. Usually you want to pass nil for the adjustments, which will cause the scrolled window to create them for you.

Instance Methods

add_with_viewport(child)
Used to add children without native scrolling capabilities. This is simply a convenience method; it is equivalent to adding the unscrollable child to a viewport, then adding the viewport to the scrolled window. If a child has native scrolling, use Gtk::Container#add instead of this method. The viewport scrolls the child by moving its Gdk::Window, and takes the size of the child to be the size of its toplevel Gdk::Window. This will be very wrong for most widgets that support native scrolling; for example, if you add a widget such as Gtk::TreeView with a viewport, the whole widget will scroll, including the column headings. Thus, widgets with native scrolling support should not be used with the Gtk::Viewport proxy.
hadjustment
Returns the horizontal scrollbar's adjustment, used to connect the horizontal scrollbar to the child widget's horizontal scroll functionality.
hadjustment=(hadjustment)
Sets the Gtk::Adjustment for the horizontal scrollbar.
  • hadjustment : Horizontal scroll adjustment.
  • Returns: hadjustment
set_hadjustment(hadjustment)
Same as Gtk::ScrolledWindow#hadjustment=.
  • hadjustment : Horizontal scroll adjustment.
  • Returns: self
vadjustment
Returns the vertical scrollbar's adjustment, used to connect the vertical scrollbar to the child widget's vertical scroll functionality.
vadjustment=(vadjustment)
Sets the GtkAdjustment for the vertical scrollbar.
  • vadjustment: Vertical scroll adjustment.
  • Returns: vadjustment
set_vadjustment(vadjustment)
Same as Gtk::ScrolledWindow#vadjustment=.
  • vadjustment: Vertical scroll adjustment.
  • Returns: self
hscrollbar
Returns the horizontal scrollbar of the scrolled window. Since 2.8
vscrollbar
Returns the vertical scrollbar of the scrolled window. Since 2.8
policy
Retrieves the current policy values for the horizontal and vertical scrollbars. See Gtk::ScrolledWindow#set_policy.
  • Returns: [hscrollbar_policy, vscrollbar_policy]
set_policy(hscrollbar_policy, vscrollbar_policy)
Sets the scrollbar policy for the horizontal and vertical scrollbars. The policy determines when the scrollbar should appear; it is a value from the GtkPolicyType constants. If Gtk::POLICY_ALWAYS, the scrollbar is always present; if Gtk::POLICY_NEVER, the scrollbar is never present; if Gtk::POLICY_AUTOMATIC, the scrollbar is present only if needed (that is, if the slider part of the bar would be smaller than the trough - the display is larger than the page size).
  • hscrollbar_policy: Policy for horizontal bar. (GtkPolicyType)
  • vscrollbar_policy: Policy for vertical bar. (GtkPolicyType)
  • Returns: self
hscrollbar_policy
Retrieves the current policy values for the horizontal scrollbar. See Gtk::ScrolledWindow#set_policy.
hscrollbar_policy=(hscrollbar_policy)
Sets the scrollbar policy for the horizontal scrollbar.
  • hscrollbar_policy: Policy for horizontal bar. (GtkPolicyType)
  • Returns: hscrollbar_policy
set_hscrollbar_policy(vscrollbar_policy)
Same as Gtk::ScrolledWindow#hscrollbar_policy=.
  • hscrollbar_policy: Policy for horizontal bar. (GtkPolicyType)
  • Returns: self
vscrollbar_policy
Retrieves the current policy values for the vertical scrollbar. See Gtk::ScrolledWindow#set_policy.
vscrollbar_policy=(vscrollbar_policy)
Sets the scrollbar policy for the vertical scrollbar.
  • vscrollbar_policy: Policy for vertical bar. (GtkPolicyType)
  • Returns: vscrollbar_policy
set_vscrollbar_policy(vscrollbar_policy)
Same as Gtk::ScrolledWindow#vscrollbar_policy=.
  • vscrollbar_policy: Policy for vertical bar. (GtkPolicyType)
  • Returns: self
shadow_type
Gets the shadow type of the scrolled window. See Gtk::ScrolledWindow#shadow_type=.
  • Returns: the current shadow type
shadow_type=(type)
Changes the type of shadow drawn around the contents of scrolled_window.
  • type: kind of shadow to draw around scrolled window contents(GtkShadowType)
  • Returns: type
set_shadow_type(type)
Same as Gtk::ScrolledWindow#shadow_type=.
  • type: kind of shadow to draw around scrolled window contents(GtkShadowType)
  • Returns: self
window_placement
window_placement=(window_placement)
Determines the location of the child widget with respect to the scrollbars. The default is Gtk::CORNER_TOP_LEFT, meaning the child is in the top left, with the scrollbars underneath and to the right. Other values in GtkCornerType are Gtk::CORNER_TOP_RIGHT, Gtk::CORNER_BOTTOM_LEFT, and Gtk::CORNER_BOTTOM_RIGHT.
  • window_placement: Position of the child window. (GtkCornerType)
  • Returns: window_placement
set_window_placement(window_placement)
Same as Gtk::ScrolledWindow#window_placement=.
  • window_placement: Position of the child window. (GtkCornerType)
  • Returns: self
move_focus_out
  • Returns: self: FIXME
placement
  • Returns: self: FIXME
placement=
  • Returns: self: FIXME
ref_accessible
See Atk::Implementor#ref_accessible.
scroll_child
  • Returns: self: FIXME
set_placement
  • Returns: self: FIXME
set_window_placement_set(window_placement_set)
Same as window_placement_set=.
  • window_placement_set: true if "window-placement" should be used to determine the location of the contents with respect to the scrollbars.
  • Returns: self
unset_placement
  • Returns: self: FIXME
window_placement_set=(window_placement_set)
Sets the value whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars. or not.
  • window_placement_set: true if "window-placement" should be used to determine the location of the contents with respect to the scrollbars.
  • Returns: window_placement_set
window_placement_set?
Gets the value whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars. or not.
  • Returns: true if "window-placement" should be used to determine the location of the contents with respect to the scrollbars.
add_child
See Gtk::Buildable#add_child.
construct_child
See Gtk::Buildable#construct_child.
get_internal_child
See Gtk::Buildable#get_internal_child.
name
See Gtk::Buildable#name.
name=
See Gtk::Buildable#name=.
set_buildable_property
See Gtk::Buildable#set_buildable_property.
set_name
See Gtk::Buildable#set_name.
builder_name
See Gtk::Buildable#builder_name.
builder_name=
See Gtk::Buildable#builder_name=.
set_builder_name
See Gtk::Buildable#set_builder_name.

Properties

hadjustment: Gtk::Adjustment (Read/Write)
The Gtk::Adjustment for the horizontal position
hscrollbar-policy: Integer (Read/Write)
When the horizontal scrollbar is displayed
shadow-type: Integer (Read/Write)
Style of bevel around the contents
vadjustment: Gtk::Adjustment (Read/Write)
The Gtk::Adjustment for the vertical position
vscrollbar-policy: Integer (Read/Write)
When the vertical scrollbar is displayed
window-placement: Integer (Read/Write)
Where the contents are located with respect to the scrollbars
window-placement-set: true or false (Read/Write)
Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.

Style Properties

scrollbar-spacing: Integer (Read)
Number of pixels between the scrollbars and the scrolled window
scrollbars-within-bevel: true or false (Read)
Place scrollbars within the scrolled window's bevel