FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions
Fl_Scroll Class Reference

This container widget lets you maneuver around a set of widgets much larger than your window. More...

`#include <Fl_Scroll.H>`

Inheritance diagram for Fl_Scroll:

List of all members.

## Classes
struct | ScrollInfo
## Public Types
enum | { HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS_ON = 4, HORIZONTAL_ALWAYS = 5, VERTICAL_ALWAYS = 6, BOTH_ALWAYS = 7 }
## Public Member Functions
void | clear ()
| Clear all but the scrollbars...
| Fl_Scroll (int X, int Y, int W, int H, const char *l=0)
| Creates a new Fl_Scroll widget using the given position, size, and label string.
int | handle (int)
| Handles the specified event.
void | resize (int, int, int, int)
| Resizes the Fl_Group widget and all of its children.
void | scroll_to (int, int)
| Moves the contents of the scroll group to a new position.
int | scrollbar_size () const
| Gets the current size of the scrollbars' troughs, in pixels.
void | scrollbar_size (int newSize)
| Sets the pixel size of the scrollbars' troughs to `newSize`, in pixels.
int | xposition () const
| Gets the current horizontal scrolling position.
int | yposition () const
| Gets the current vertical scrolling position.
## Public Attributes
Fl_Scrollbar | hscrollbar
Fl_Scrollbar | scrollbar
## Protected Member Functions
void | bbox (int &, int &, int &, int &)
| Returns the bounding box for the interior of the scrolling area, inside the scrollbars.
void | draw ()
| Draws the widget.

## 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:

If all of the child widgets are packed together into a solid rectangle then you want to set box() to FL_NO_BOX or one of the _FRAME types. This will result in the best output. However, if the child widgets are a sparse arrangement you must set box() to a real _BOX type. This can result in some blinking during redrawing, but that can be solved by using a Fl_Double_Window.

By default you can scroll in both directions, and the scrollbars disappear if the data will fit in the area of the scroll.

Use Fl_Scroll::type() to change this as follows :

- 0 - No scrollbars
- Fl_Scroll::HORIZONTAL - Only a horizontal scrollbar.
- Fl_Scroll::VERTICAL - Only a vertical scrollbar.
- Fl_Scroll::BOTH - The default is both scrollbars.
- Fl_Scroll::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, vertical always off.
- Fl_Scroll::VERTICAL_ALWAYS - Vertical scrollbar always on, horizontal always off.
- Fl_Scroll::BOTH_ALWAYS - Both always on.

Use scrollbar.align(int) ( see void Fl_Widget::align(Fl_Align) ) : to change what side the scrollbars are drawn on.

If the FL_ALIGN_LEFT bit is on, the vertical scrollbar is on the left. If the FL_ALIGN_TOP bit is on, the horizontal scrollbar is on the top. Note that only the alignment flags in scrollbar are considered. The flags in hscrollbar however are ignored.

This widget can also be used to pan around a single child widget "canvas". This child widget should be of your own class, with a draw() method that draws the contents. The scrolling is done by changing the x() and y() of the widget, so this child must use the x() and y() to position its drawing. To speed up drawing it should test fl_push_clip().

Another very useful child is a single Fl_Pack, which is itself a group that packs its children together and changes size to surround them. Filling the Fl_Pack with Fl_Tabs groups (and then putting normal widgets inside those) gives you a very powerful scrolling list of individually-openable panels.

Fluid lets you create these, but you can only lay out objects that fit inside the Fl_Scroll without scrolling. Be sure to leave space for the scrollbars, as Fluid won't show these either.

You cannot use Fl_Window as a child of this since the clipping is not conveyed to it when drawn, and it will draw over the scrollbars and neighboring objects.

## Constructor & Destructor Documentation

Fl_Scroll::Fl_Scroll | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H,
|  | const char * | L = `0`
| ) |  |

Creates a new Fl_Scroll widget using the given position, size, and label string.

The default boxtype is FL_NO_BOX.

The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in the user code. A kludge has been done so the Fl_Scroll and all of its children can be automatic (local) variables, but you must declare the Fl_Scroll first, so that it is destroyed last.

## Member Function Documentation

void Fl_Scroll::bbox | ( | int & | X,
|  | int & | Y,
|  | int & | W,
|  | int & | H
| ) |  | `[protected]`

Returns the bounding box for the interior of the scrolling area, inside the scrollbars.

Currently this is only reliable after draw(), and before any resizing of the Fl_Scroll or any child widgets occur.

Todo:
  The visibility of the scrollbars ought to be checked/calculated outside of the draw() method (STR #1895).

void Fl_Scroll::clear | ( |  | ) |

Clear all but the scrollbars...

Reimplemented from Fl_Group.

void Fl_Scroll::draw | ( |  | ) | `[protected, virtual]`

Draws the widget.

Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.

Override this function to draw your own widgets.

If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:

            Fl_Widget *s = &scroll;         // scroll is an embedded Fl_Scrollbar
            s->draw();                      // calls Fl_Scrollbar::draw()

Reimplemented from Fl_Group.

int Fl_Scroll::handle | ( | int | event | ) | `[virtual]`

Handles the specified event.

You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.

When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.

Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.

Parameters:

  [in] | event | the kind of event received

Return values:

  0 | if the event was not used or understood
  1 | if the event was used and can be deleted

See also:
  Fl_Event

Reimplemented from Fl_Group.

void Fl_Scroll::resize | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H
| ) |  | `[virtual]`

Resizes the Fl_Group widget and all of its children.

The Fl_Group widget first resizes itself, and then it moves and resizes all its children according to the rules documented for Fl_Group::resizable(Fl_Widget*)

See also:
  Fl_Group::resizable(Fl_Widget*)
  Fl_Group::resizable()
  Fl_Widget::resize(int,int,int,int)

Reimplemented from Fl_Group.

void Fl_Scroll::scroll_to | ( | int | X,
|  | int | Y
| ) |  |

Moves the contents of the scroll group to a new position.

int Fl_Scroll::scrollbar_size | ( |  | ) | const`[inline]`

Gets the current size of the scrollbars' troughs, in pixels.

If this value is zero (default), this widget will use the Fl::scrollbar_size() value as the scrollbar's width.

Returns:
  Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.

See also:
  Fl::scrollbar_size(int)

void Fl_Scroll::scrollbar_size | ( | int | newSize | ) | `[inline]`

Sets the pixel size of the scrollbars' troughs to `newSize`, in pixels.

Normally you should not need this method, and should use Fl::scrollbar_size(int) instead to manage the size of ALL your widgets' scrollbars. This ensures your application has a consistent UI, is the default behavior, and is normally what you want.

Only use THIS method if you really need to override the global scrollbar size. The need for this should be rare.

Setting `newSize` to the special value of 0 causes the widget to track the global Fl::scrollbar_size(), which is the default.

Parameters:

  [in] | newSize | Sets the scrollbar size in pixels. If 0 (default), scrollbar size tracks the global Fl::scrollbar_size()

See also:
  Fl::scrollbar_size()

int Fl_Scroll::xposition | ( |  | ) | const`[inline]`

Gets the current horizontal scrolling position.

int Fl_Scroll::yposition | ( |  | ) | const`[inline]`

Gets the current vertical scrolling position.

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

- Fl_Scroll.H
- Fl_Scroll.cxx