NTK 1.3.0
Fl_Group.H
1//
2// "$Id: Fl_Group.H 8157 2011-01-01 14:01:53Z AlbrechtS $"
3//
4// Group header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2010 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems on the following page:
24//
25// http://www.fltk.org/str.php
26//
27
28/* \file
29 Fl_Group, Fl_End classes . */
30
31#ifndef Fl_Group_H
32#define Fl_Group_H
33
34#ifndef Fl_Widget_H
35#include "Fl_Widget.H"
36#endif
37
45class FL_EXPORT Fl_Group : public Fl_Widget {
46
47 Fl_Widget** array_;
48 Fl_Widget* savedfocus_;
49 Fl_Widget* resizable_;
50 int children_;
51 int *sizes_; // remembered initial sizes of children
52
53 int navigation(int);
54 static Fl_Group *current_;
55
56 // unimplemented copy ctor and assignment operator
57 Fl_Group(const Fl_Group&);
58 Fl_Group& operator=(const Fl_Group&);
59
60protected:
61 void draw();
62 void draw_child(Fl_Widget& widget) const;
63 void draw_children();
64 void draw_outside_label(const Fl_Widget& widget) const ;
65 void update_child(Fl_Widget& widget) const;
66 int *sizes();
67
68public:
69
70 int handle(int);
71 void begin();
72 void end();
73 static Fl_Group *current();
74 static void current(Fl_Group *g);
75
79 int children() const {return children_;}
83 Fl_Widget* child(int n) const {return array()[n];}
84 int find(const Fl_Widget*) const;
88 int find(const Fl_Widget& o) const {return find(&o);}
89 Fl_Widget* const* array() const;
90
91 void resize(int,int,int,int);
96 Fl_Group(int,int,int,int, const char * = 0);
97 virtual ~Fl_Group();
98 void add(Fl_Widget&);
102 void add(Fl_Widget* o) {add(*o);}
103 void insert(Fl_Widget&, int i);
108 void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
109 void remove(int index);
110 void remove(Fl_Widget&);
115 void remove(Fl_Widget* o) {remove(*o);}
116 void clear();
117
121 void resizable(Fl_Widget& o) {resizable_ = &o;}
150 void resizable(Fl_Widget* o) {resizable_ = o;}
154 Fl_Widget* resizable() const {return resizable_;}
158 void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
159 void init_sizes();
160
170 void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
178 unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
179
180 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
181 virtual Fl_Group* as_group() { return this; }
182
183 // back compatibility functions:
184
190 void focus(Fl_Widget* W) {W->take_focus();}
191
193 Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
194
196 void forms_end();
197};
198
199// dummy class used to end child groups in constructors for complex
200// subclasses of Fl_Group:
220class FL_EXPORT Fl_End {
221public:
224};
225
226#endif
227
228//
229// End of "$Id: Fl_Group.H 8157 2011-01-01 14:01:53Z AlbrechtS $".
230//
Fl_Widget, Fl_Label classes .
This is a dummy class that allows you to end a Fl_Group in a constructor list of a class:
Definition: Fl_Group.H:220
Fl_End()
All it does is calling Fl_Group::current()->end()
Definition: Fl_Group.H:223
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:45
void end()
Exactly the same as current(this->parent()).
Definition: Fl_Group.cxx:80
void add_resizable(Fl_Widget &o)
Adds a widget to the group and makes it the resizable widget.
Definition: Fl_Group.H:158
void add(Fl_Widget *o)
See void Fl_Group::add(Fl_Widget &w)
Definition: Fl_Group.H:102
void focus(Fl_Widget *W)
Definition: Fl_Group.H:190
Fl_Widget * child(int n) const
Returns array()[n].
Definition: Fl_Group.H:83
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:79
Fl_Widget *& _ddfdesign_kludge()
This is for forms compatibility only.
Definition: Fl_Group.H:193
void forms_end()
This is for forms compatibility only.
void remove(Fl_Widget *o)
Removes the widget o from the group.
Definition: Fl_Group.H:115
void resizable(Fl_Widget &o)
See void Fl_Group::resizable(Fl_Widget *box)
Definition: Fl_Group.H:121
void clip_children(int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box.
Definition: Fl_Group.H:170
unsigned int clip_children()
Returns the current clipping mode.
Definition: Fl_Group.H:178
void insert(Fl_Widget &o, Fl_Widget *before)
This does insert(w, find(before)).
Definition: Fl_Group.H:108
Fl_Widget * resizable() const
See void Fl_Group::resizable(Fl_Widget *box)
Definition: Fl_Group.H:154
virtual Fl_Group * as_group()
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Group.H:181
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:89
void resizable(Fl_Widget *o)
The resizable widget defines the resizing box for the group.
Definition: Fl_Group.H:150
int find(const Fl_Widget &o) const
See int Fl_Group::find(const Fl_Widget *w) const.
Definition: Fl_Group.H:88
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:111
virtual void draw()=0
Draws the widget.
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:157
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:159
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:106
int take_focus()
Gives the widget the keyboard focus.
Definition: Fl_Widget.cxx:152
virtual void resize(int x, int y, int w, int h)
Changes the size or position of the widget.
Definition: Fl_Widget.cxx:140
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:161