Fl_Tile Class Reference

The Fl_Tile class lets you resize its children by dragging the border between them. More...

Inheritance diagram for Fl_Tile:
Fl_Group Fl_Widget

List of all members.

Public Member Functions

 Fl_Tile (int X, int Y, int W, int H, const char *L=0)
 Creates a new Fl_Tile widget using the given position, size, and label string.
int handle (int event)
 Handles the specified event.
void position (int oldx, int oldy, int newx, int newy)
 Drags the intersection at (oldx,oldy) to (newx,newy).
void resize (int X, int Y, int W, int H)
 Resizes the Fl_Tile widget and its children.

Detailed Description

The Fl_Tile class lets you resize its children by dragging the border between them.

Fl_Tile.png

For the tiling to work correctly, the children of an Fl_Tile must cover the entire area of the widget, but not overlap. This means that all children must touch each other at their edges, and no gaps can be left inside the Fl_Tile.

Fl_Tile does not normally draw any graphics of its own. The "borders" which can be seen in the snapshot above are actually part of the children. Their boxtypes have been set to FL_DOWN_BOX creating the impression of "ridges" where the boxes touch. What you see are actually two adjacent FL_DOWN_BOX's drawn next to each other. All neighboring widgets share the same edge - the widget's thick borders make it appear as though the widgets aren't actually touching, but they are. If the edges of adjacent widgets do not touch, then it will be impossible to drag the corresponding edges.

Fl_Tile allows objects to be resized to zero dimensions. To prevent this you can use the resizable() to limit where corners can be dragged to. For more information see note below.

Even though objects can be resized to zero sizes, they must initially have non-zero sizes so the Fl_Tile can figure out their layout. If desired, call position() after creating the children but before displaying the window to set the borders where you want.

Note on resizable(Fl_Widget &w): The "resizable" child widget (which should be invisible) limits where the borders can be dragged to. All dragging will be limited inside the resizable widget's borders. If you don't set it, it will be possible to drag the borders right to the edges of the Fl_Tile widget, and thus resize objects on the edges to zero width or height. When the entire Fl_Tile widget is resized, the resizable() widget will keep its border distance to all borders the same (this is normal resize behavior), so that you can effectively set a border width that will never change. To ensure correct event delivery to all child widgets the resizable() widget must be the first child of the Fl_Tile widget group. Otherwise some events (e.g. FL_MOVE and FL_ENTER) might be consumed by the resizable() widget so that they are lost for widgets covered (overlapped) by the resizable() widget.

Note:
You can still resize widgets inside the resizable() to zero width and/or height, i.e. box 2b above to zero width and box 3a to zero height.
See also:
void Fl_Group::resizable(Fl_Widget &w)

Example for resizable with 20 pixel border distance:

    int dx = 20, dy = dx;
    Fl_Tile tile(50,50,300,300);
    // create resizable() box first
    Fl_Box r(tile.x()+dx,tile.y()+dy,tile.w()-2*dx,tile.h()-2*dy);
    tile.resizable(r);
    // ... create widgets inside tile (see test/tile.cxx) ...
    tile.end();

See also the complete example program in test/tile.cxx.


Constructor & Destructor Documentation

Fl_Tile::Fl_Tile ( int  X,
int  Y,
int  W,
int  H,
const char *  L = 0 
)

Creates a new Fl_Tile 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_Tile and all of its children can be automatic (local) variables, but you must declare the Fl_Tile first, so that it is destroyed last.

See also:
class Fl_Group

Member Function Documentation

int Fl_Tile::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_Tile::position ( int  oldx,
int  oldy,
int  newx,
int  newy 
)

Drags the intersection at (oldx,oldy) to (newx,newy).

This redraws all the necessary children.

Pass zero as oldx or oldy to disable drag in that direction.

void Fl_Tile::resize ( int  X,
int  Y,
int  W,
int  H 
) [virtual]

Resizes the Fl_Tile widget and its children.

Fl_Tile implements its own resize() method. It does not use Fl_Group::resize() to resize itself and its children.

Enlarging works by just moving the lower-right corner and resizing the bottom and right border widgets accordingly.

Shrinking the Fl_Tile works in the opposite way by shrinking the bottom and right border widgets, unless they are reduced to zero width or height, resp. or to their minimal sizes defined by the resizable() widget. In this case other widgets will be shrunk as well.

See the Fl_Tile class documentation about how the resizable() works.

Reimplemented from Fl_Group.


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