fltk::ScrollGroup Class Reference

Inherits fltk::Group.

List of all members.

Public Member Functions

void bbox (Rectangle &)
virtual int handle (int)
virtual void layout ()
void scrollTo (int, int)
int xposition () const
int yposition () const

Protected Member Functions

void draw ()

Detailed Description

This container widget lets you maneuver around a set of widgets much larger than your window. If the child widgets are larger than the size of this object then scrollbars will appear so that you can scroll over to them:


The default type() will just scroll a whole arrangement of widgets and never resize them. This is useful if you just want to get a big control panel into a smaller window. The bounding box of the widgets are the area it can scroll, this will remove any borders, if you want the borders preserved put some invisible widgets there as placeholders.

This can be used to pan around a large drawing by making a single child widget "canvas". This child widget should be of your own class, with a draw() method that draws everything. The scrolling is done by changing the x() and y() of the widget and drawing it with the fltk clip region set to the newly exposed rectangles. You can speed things up by using fltk::not_clipped() or fltk::intersect_with_clip() to detect and skip the clipped portions of the drawing.

By default you can scroll in both directions, and the scrollbars disappear if the data will fit in the area of the scroll. type() can change this:

  • HORIZONTAL resize vertically but scroll horizontally
  • VERTICAL resize horizontally but scroll vertically
  • BOTH this is the default
  • HORIZONTAL_ALWAYS resize vertically but always show horizontal scrollbar
  • VERTICAL_ALWAYS resize horizontally but always show vertical scrollbar
  • BOTH_ALWAYS always show both scrollbars

If you use HORIZONTAL or VERTICAL you must initally position and size your child widgets as though the scrollbar is off (ie fill the box() width entirely if type() is VERTICAL). The first time layout() is called it will resize the widgets to fit inside the scrollbars.

It is very useful to put a single PackedGroup child into a VERTICAL ScrollGroup.

Also note that scrollbar_align() (a Style parameter) can put the scrollbars on different sides of the widget.

Currently you cannot use Window or any subclass (including GlWindow) as a child of this. The clipping is not conveyed to the operating system's window and it will draw over the scrollbars and neighboring objects.

Member Function Documentation

void ScrollGroup::bbox ( Rectangle r)

Set the rectangle to the scrolling area (in the ScrollGroup's coordinate system). This removes the border of the box() and the space needed for any visible scrollbars.

void ScrollGroup::draw ( void  ) [protected, virtual]

Fltk calls this virtual function to draw the widget, after setting up the graphics (current window, xy translation, etc) so that any drawing functions will go into this widget.

User code should not call this! You probably want to call redraw().

The default version calls draw_box() and draw_label(), thus drawing the box() to fill the widget and putting the label() and image() inside it to fill it, unless the align() flags are set to put it outside.

Information on how to write your own version is here.

Reimplemented from fltk::Group.

int ScrollGroup::handle ( int  event) [virtual]

Calls send() on some or all of the children widgets.

Reimplemented from fltk::Group.

void ScrollGroup::layout ( ) [virtual]

Virtual function to respond to layout_damage(), it should calculate the correct size of this widget and all it's children. This function is called by fltk or by the layout() method in other widgets. User programs should not call it.

A widget is allowed to alter it's own size in a layout() method, to indicate a size that the data will fit in. A parent widget is then expected to rearrange itself to accomodate the new size. This may mean it will move the widget and thus layout() will be called again.

You can look at layout_damage() to find out why this is being called.

The base class redraws the widget.

Reimplemented from fltk::Group.

void ScrollGroup::scrollTo ( int  X,
int  Y 

Set xposition() and yposition() to these new values, thus scrolling the display.

int ScrollGroup::xposition ( ) const [inline]

Return the horizontal scrolling position. This is the distance from the left-most widget to the left of the bbox().

int ScrollGroup::yposition ( ) const [inline]

Return the vertical scrolling position. This is the distance from the top-most widget edge to the top of the bbox().

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