1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Group header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Group, Fl_End classes . */
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Group_H
|
|
|
|
#define Fl_Group_H
|
|
|
|
|
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#include "Fl_Widget.H"
|
|
|
|
#endif
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
The Fl_Group class is the FLTK container widget. It maintains
|
|
|
|
an array of child widgets. These children can themselves be any widget
|
|
|
|
including Fl_Group. The most important subclass of Fl_Group
|
2009-02-08 20:26:02 +03:00
|
|
|
is Fl_Window, however groups can also be used to control radio buttons
|
|
|
|
or to enforce resize behavior.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
class FL_EXPORT Fl_Group : public Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
Fl_Widget** array_;
|
|
|
|
Fl_Widget* savedfocus_;
|
|
|
|
Fl_Widget* resizable_;
|
|
|
|
int children_;
|
2008-04-23 19:07:13 +04:00
|
|
|
int *sizes_; // remembered initial sizes of children
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2001-08-07 03:51:39 +04:00
|
|
|
int navigation(int);
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Group *current_;
|
2005-07-15 13:34:53 +04:00
|
|
|
|
|
|
|
// unimplemented copy ctor and assignment operator
|
|
|
|
Fl_Group(const Fl_Group&);
|
|
|
|
Fl_Group& operator=(const Fl_Group&);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
protected:
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw();
|
2009-03-21 20:08:23 +03:00
|
|
|
void draw_child(Fl_Widget& widget) const;
|
2002-11-08 18:22:15 +03:00
|
|
|
void draw_children();
|
2009-03-21 20:08:23 +03:00
|
|
|
void draw_outside_label(const Fl_Widget& widget) const ;
|
|
|
|
void update_child(Fl_Widget& widget) const;
|
2008-04-23 19:07:13 +04:00
|
|
|
int *sizes();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2002-07-14 23:08:25 +04:00
|
|
|
int handle(int);
|
|
|
|
void begin();
|
|
|
|
void end();
|
|
|
|
static Fl_Group *current();
|
|
|
|
static void current(Fl_Group *g);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns how many child widgets the group has.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int children() const {return children_;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns array()[n]. <i>No range checking is done!</i>
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Widget* child(int n) const {return array()[n];}
|
2002-07-14 23:08:25 +04:00
|
|
|
int find(const Fl_Widget*) const;
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
See int Fl_Group::find(const Fl_Widget *w) const
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int find(const Fl_Widget& o) const {return find(&o);}
|
2002-07-14 23:08:25 +04:00
|
|
|
Fl_Widget* const* array() const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-07-14 23:08:25 +04:00
|
|
|
void resize(int,int,int,int);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Creates a new Fl_Group widget using the given position, size,
|
|
|
|
and label string. The default boxtype is FL_NO_BOX.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
Fl_Group(int,int,int,int, const char * = 0);
|
|
|
|
virtual ~Fl_Group();
|
|
|
|
void add(Fl_Widget&);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
See void Fl_Group::add(Fl_Widget &w)
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void add(Fl_Widget* o) {add(*o);}
|
2002-07-14 23:08:25 +04:00
|
|
|
void insert(Fl_Widget&, int i);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-02-08 20:26:02 +03:00
|
|
|
This does insert(w, find(before)). This will append the
|
2009-03-24 04:40:44 +03:00
|
|
|
widget if \p before is not in the group.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
|
2010-08-31 14:01:59 +04:00
|
|
|
void remove(int index);
|
2002-07-14 23:08:25 +04:00
|
|
|
void remove(Fl_Widget&);
|
2008-09-21 04:35:54 +04:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Removes the widget \p o from the group.
|
2008-09-21 04:35:54 +04:00
|
|
|
\sa void remove(Fl_Widget&)
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void remove(Fl_Widget* o) {remove(*o);}
|
2002-07-14 23:08:25 +04:00
|
|
|
void clear();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
See void Fl_Group::resizable(Fl_Widget *box)
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void resizable(Fl_Widget& o) {resizable_ = &o;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
The resizable widget defines the resizing box for the group. When the
|
|
|
|
group is resized it calculates a new size and position for all of its
|
|
|
|
children. Widgets that are horizontally or vertically inside the
|
|
|
|
dimensions of the box are scaled to the new size. Widgets outside the
|
|
|
|
box are moved.
|
2009-02-08 20:26:02 +03:00
|
|
|
|
|
|
|
In these examples the gray area is the resizable:
|
|
|
|
|
|
|
|
\image html resizebox1.gif
|
2009-02-09 14:41:56 +03:00
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
\image html resizebox2.gif
|
2009-02-09 14:41:56 +03:00
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
\image latex resizebox1.eps "before resize" width=4cm
|
2009-02-09 14:41:56 +03:00
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
\image latex resizebox2.eps "after resize" width=4cm
|
|
|
|
|
|
|
|
The resizable may be set to the group itself, in which case all the
|
|
|
|
contents are resized. This is the default value for Fl_Group,
|
|
|
|
although NULL is the default for Fl_Window and Fl_Pack.
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
If the resizable is NULL then all widgets remain a fixed size
|
2009-02-08 20:26:02 +03:00
|
|
|
and distance from the top-left corner.
|
|
|
|
|
|
|
|
It is possible to achieve any type of resize behavior by using an
|
2008-09-14 02:33:03 +04:00
|
|
|
invisible Fl_Box as the resizable and/or by using a hierarchy
|
|
|
|
of child Fl_Group's.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void resizable(Fl_Widget* o) {resizable_ = o;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
See void Fl_Group::resizable(Fl_Widget *box)
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Widget* resizable() const {return resizable_;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Adds a widget to the group and makes it the resizable widget.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
|
2002-07-14 23:08:25 +04:00
|
|
|
void init_sizes();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-19 14:23:37 +04:00
|
|
|
/**
|
|
|
|
Controls whether the group widget clips the drawing of
|
|
|
|
child widgets to its bounding box.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
Set \p c to 1 if you want to clip the child widgets to the
|
2008-10-19 14:23:37 +04:00
|
|
|
bounding box.
|
|
|
|
|
|
|
|
The default is to not clip (0) the drawing of child widgets.
|
|
|
|
*/
|
|
|
|
void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
|
|
|
|
/**
|
|
|
|
Returns the current clipping mode.
|
|
|
|
|
|
|
|
\return true, if clipping is enabled, false otherwise.
|
|
|
|
|
|
|
|
\see void Fl_Group::clip_children(int c)
|
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
|
2008-10-19 14:23:37 +04:00
|
|
|
|
2010-02-13 15:25:58 +03:00
|
|
|
/** Returns an Fl_Group pointer if this widget is an Fl_Group.
|
|
|
|
|
|
|
|
\retval NULL if this widget is not derived from Fl_Group.
|
|
|
|
\note This method is provided to avoid dynamic_cast.
|
|
|
|
\todo More documentation ...
|
|
|
|
*/
|
2010-03-17 01:51:31 +03:00
|
|
|
virtual Fl_Group* as_group() { return this; }
|
2010-02-13 15:25:58 +03:00
|
|
|
|
2008-09-29 02:25:23 +04:00
|
|
|
// back compatibility functions:
|
|
|
|
|
|
|
|
/**
|
|
|
|
\deprecated This is for backwards compatibility only. You should use
|
|
|
|
\e W->%take_focus() instead.
|
|
|
|
\sa Fl_Widget::take_focus();
|
|
|
|
*/
|
|
|
|
void focus(Fl_Widget* W) {W->take_focus();}
|
2009-02-08 20:26:02 +03:00
|
|
|
|
2008-09-29 02:25:23 +04:00
|
|
|
/** This is for forms compatibility only */
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
|
2009-02-08 20:26:02 +03:00
|
|
|
|
2008-09-29 02:25:23 +04:00
|
|
|
/** This is for forms compatibility only */
|
2002-07-14 23:08:25 +04:00
|
|
|
void forms_end();
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// dummy class used to end child groups in constructors for complex
|
|
|
|
// subclasses of Fl_Group:
|
2008-09-14 19:45:27 +04:00
|
|
|
/**
|
|
|
|
This is a dummy class that allows you to end a Fl_Group in a constructor list of a
|
|
|
|
class:
|
2008-09-15 23:21:20 +04:00
|
|
|
\code
|
|
|
|
class MyClass {
|
2008-09-14 19:45:27 +04:00
|
|
|
Fl_Group group;
|
|
|
|
Fl_Button button_in_group;
|
|
|
|
Fl_End end;
|
|
|
|
Fl_Button button_outside_group;
|
|
|
|
MyClass();
|
|
|
|
};
|
|
|
|
MyClass::MyClass() :
|
|
|
|
group(10,10,100,100),
|
|
|
|
button_in_group(20,20,60,30),
|
|
|
|
end(),
|
|
|
|
button_outside_group(10,120,60,30)
|
2008-09-15 23:21:20 +04:00
|
|
|
{}
|
|
|
|
\endcode
|
2008-09-14 19:45:27 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
class FL_EXPORT Fl_End {
|
1998-10-06 22:21:25 +04:00
|
|
|
public:
|
2008-09-14 19:45:27 +04:00
|
|
|
/** All it does is calling Fl_Group::current()->end() */
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_End() {Fl_Group::current()->end();}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|