Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::ScrolledWindow Class Reference

A GtkScrolledWindow C++ wrapper class. More...

`#include <xfc/gtk/scrolledwindow.hh>`

Inheritance diagram for Xfc::Gtk::ScrolledWindow:

List of all members.

## Public Member Functions

Constructors

- ScrolledWindow ()
    Construct a new scrolled window.
- ScrolledWindow (Adjustment *hadjustment, Adjustment *vadjustment)
    Construct a new scrolled window with the specified adjustments.
- virtual ~ScrolledWindow ()
    Destructor.

Accessors

- GtkScrolledWindow * gtk_scrolled_window () const
    Get a pointer to the GtkScrolledWindow structure.
- operator GtkScrolledWindow * () const
    Conversion operator; safely converts a ScrolledWindow to a GtkScrolledWindow pointer.
- HScrollbar * hscrollbar () const
    Get a pointer to the horizontal scrollbar.
- VScrollbar * vscrollbar () const
    Get a pointer to the vertical scrollbar.
- Adjustment * get_hadjustment () const
    Returns the horizontal scrollbar's adjustment, used to connect the horizontal scrollbar to the child widget's horizontal scroll functionality.
- Adjustment * get_vadjustment () const
    Returns the vertical scrollbar's adjustment, used to connect the vertical scrollbar to the child widget's vertical scroll functionality.
- void get_policy (PolicyType *hscrollbar_policy, PolicyType *vscrollbar_policy) const
    Retrieves the current policy values for the horizontal and vertical scrollbars (see set_policy()).
- CornerType get_placement () const
    Gets the placement of the scrollbars for the scrolled window (see set_placement()).
- ShadowType get_shadow_type () const
    Gets the shadow type of the scrolled window (see set_shadow_type()).

Methods

- void set_hadjustment (Adjustment *hadjustment)
    Sets the Adjustment for the horizontal scrollbar.
- void set_vadjustment (Adjustment *vadjustment)
    Sets the Adjustment for the vertical scrollbar.
- void set_policy (PolicyType hscrollbar_policy, PolicyType vscrollbar_policy)
    Sets the scrollbar policy for the horizontal and vertical scrollbars.
- void set_policy_automatic ()
    Sets the scrollbar policy for the horizontal and vertical scrollbars to POLICY_AUTOMATIC, which means the scrollbars are present only if needed.
- void set_placement (CornerType window_placement)
    Determines the location of the child widget with respect to the scrollbars.
- void set_shadow_type (ShadowType type)
    Changes the type of shadow drawn around the contents of scrolled_window.
- void add_with_viewport (Widget &child)
    Used to add children without native scrolling capabilities.

## Protected Member Functions

Constructors

- ScrolledWindow (GtkScrolledWindow *scrolled_window, bool owns_reference=false)
    Construct a new ScrolledWindow from an existing GtkScrolledWindow.

## Detailed Description

A GtkScrolledWindow C++ wrapper class.

ScrolledWindow is a Bin subclass: it's a container that holds a single child widget. 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 Adjustment objects. The scrolled window installs Adjustment objects in the child window's slots using the set_scroll_adjustments_signal. Widgets with native scroll support include TreeView, TextView, and Layout.

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

If a widget has native scrolling abilities, it can be added to the ScrolledWindow with Gtk::Container::add(). If a widget does not, you must first add the widget to a Viewport, then add the Viewport to the scrolled window. The convenience function 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 Adjustment for the fields in an adjustment - for Scrollbar, used by 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 Page Down key).

If a 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 Scrollbar and for example a Table.

See also: the ScrolledWindow and Viewport HOWTOs.

## Constructor & Destructor Documentation

Xfc::Gtk::ScrolledWindow::ScrolledWindow | ( | GtkScrolledWindow * | scrolled_window,
|  | bool | owns_reference = `false`
| ) | `[explicit, protected]`

Construct a new ScrolledWindow from an existing GtkScrolledWindow.

Parameters:

  | scrolled_window | A pointer to a GtkScrolledWindow.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.

The scrolled_window can be a newly created GtkScrolledWindow or an existing GtkScrolledWindow (see G::Object::Object).

Xfc::Gtk::ScrolledWindow::ScrolledWindow | ( |  | ) |

| Construct a new scrolled window. The scrolled window will create both adjustments for you. The adjustments can be retrieved by calling get_hadjustment() and get_vadjustment().

Xfc::Gtk::ScrolledWindow::ScrolledWindow | ( | Adjustment * | hadjustment,
|  | Adjustment * | vadjustment
| ) |

Construct a new scrolled window with the specified adjustments.

Parameters:

  | hadjustment | The Horizontal adjustment.
  | vadjustment | The Vertical adjustment.

The two adjustments will be shared with the scrollbars and the child widget to keep the bars in sync with the child. If you pass null for an adjustment the scrolled window will create that adjustment for you.

## Member Function Documentation

void Xfc::Gtk::ScrolledWindow::add_with_viewport | ( | Widget & | child | ) |

Used to add children without native scrolling capabilities.

Parameters:

  | child | The wdget you want to scroll.

This is simply a convenience function; 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 function. 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 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 Viewport proxy.

A widget supports scrolling natively if the set_scroll_adjustments_signal is declared in its class declaration.

Adjustment* Xfc::Gtk::ScrolledWindow::get_hadjustment | ( |  | ) | const

Returns the horizontal scrollbar's adjustment, used to connect the horizontal scrollbar to the child widget's horizontal scroll functionality.

Returns:
  The horizontal Adjustment.

CornerType Xfc::Gtk::ScrolledWindow::get_placement | ( |  | ) | const

Gets the placement of the scrollbars for the scrolled window (see set_placement()).

Returns:
  The current placement value.

void Xfc::Gtk::ScrolledWindow::get_policy | ( | PolicyType * | hscrollbar_policy,
|  | PolicyType * | vscrollbar_policy
| ) | const

Retrieves the current policy values for the horizontal and vertical scrollbars (see set_policy()).

Parameters:

  | hscrollbar_policy | The location to store the policy for the horizontal scrollbar, or null.
  | vscrollbar_policy | The location to store the policy for the horizontal scrollbar, or null.

ShadowType Xfc::Gtk::ScrolledWindow::get_shadow_type | ( |  | ) | const

Gets the shadow type of the scrolled window (see set_shadow_type()).

Returns:
  The current shadow type.

Adjustment* Xfc::Gtk::ScrolledWindow::get_vadjustment | ( |  | ) | const

Returns the vertical scrollbar's adjustment, used to connect the vertical scrollbar to the child widget's vertical scroll functionality.

Returns:
  The vertical Adjustment.

void Xfc::Gtk::ScrolledWindow::set_hadjustment | ( | Adjustment * | hadjustment | ) |

Sets the Adjustment for the horizontal scrollbar.

Parameters:

  | hadjustment | The horizontal scroll adjustment.

void Xfc::Gtk::ScrolledWindow::set_placement | ( | CornerType | window_placement | ) |

Determines the location of the child widget with respect to the scrollbars.

Parameters:

  | window_placement | The position of the child window.

The default is CORNER_TOP_LEFT, meaning the child is in the top left, with the scrollbars underneath and to the right. Other values in CornerType are CORNER_TOP_RIGHT, CORNER_BOTTOM_LEFT, and CORNER_BOTTOM_RIGHT.

void Xfc::Gtk::ScrolledWindow::set_policy | ( | PolicyType | hscrollbar_policy,
|  | PolicyType | vscrollbar_policy
| ) |

Sets the scrollbar policy for the horizontal and vertical scrollbars.

Parameters:

  | hscrollbar_policy | The policy for horizontal bar.
  | vscrollbar_policy | The policy for vertical bar.

The policy determines when the scrollbar should appear; it is a value from the Gtk::PolicyType enumeration. If POLICY_ALWAYS, the scrollbar is always present; if POLICY_NEVER, the scrollbar is never present; if 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).

void Xfc::Gtk::ScrolledWindow::set_shadow_type | ( | ShadowType | type | ) |

Changes the type of shadow drawn around the contents of scrolled_window.

Parameters:

  | type | The kind of shadow to draw around scrolled window contents.

void Xfc::Gtk::ScrolledWindow::set_vadjustment | ( | Adjustment * | vadjustment | ) |

Sets the Adjustment for the vertical scrollbar.

Parameters:

  | vadjustment | The vertical scroll adjustment.

The documentation for this class was generated from the following file:

- scrolledwindow.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3