FLTK 1.4.0
Fl_Group.H
Go to the documentation of this file.
1//
2// Group header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2022 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
21#ifndef Fl_Group_H
22#define Fl_Group_H
23
24#include "Fl_Widget.H"
25
26// Don't #include Fl_Rect.H because this would introduce lots
27// of unnecessary dependencies on Fl_Rect.H
28class Fl_Rect;
29
30
56class FL_EXPORT Fl_Group : public Fl_Widget {
57
58 union {
59 Fl_Widget** array_; // used if group has two or more children or NULL
60 Fl_Widget* child1_; // used if group has one child or NULL
61 };
62 Fl_Widget* savedfocus_;
63 Fl_Widget* resizable_;
64 int children_;
65 Fl_Rect *bounds_; // remembered initial sizes of children
66 int *sizes_; // remembered initial sizes of children (FLTK 1.3 compat.)
67
68 int navigation(int);
69 static Fl_Group *current_;
70
71 // unimplemented copy ctor and assignment operator
72 Fl_Group(const Fl_Group&);
73 Fl_Group& operator=(const Fl_Group&);
74
75protected:
76 void draw() FL_OVERRIDE;
77 void draw_child(Fl_Widget& widget) const;
78 void draw_children();
79 void draw_outside_label(const Fl_Widget& widget) const ;
80 void update_child(Fl_Widget& widget) const;
81 Fl_Rect *bounds();
82 int *sizes(); // FLTK 1.3 compatibility
83 virtual int on_insert(Fl_Widget*, int);
84 virtual int on_move(int, int);
85 virtual void on_remove(int);
86
87public:
88
89 int handle(int) FL_OVERRIDE;
90 void begin();
91 void end();
92 static Fl_Group *current();
93 static void current(Fl_Group *g);
94
98 int children() const {return children_;}
102 Fl_Widget* child(int n) const {return array()[n];}
103 int find(const Fl_Widget*) const;
107 int find(const Fl_Widget& o) const {return find(&o);}
108 Fl_Widget* const* array() const;
109
110 void resize(int,int,int,int) FL_OVERRIDE;
115 Fl_Group(int,int,int,int, const char * = 0);
116 virtual ~Fl_Group();
117 void add(Fl_Widget&);
121 void add(Fl_Widget* o) {add(*o);}
122 void insert(Fl_Widget&, int i);
127 void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
128 void remove(int index);
129 void remove(Fl_Widget&);
134 void remove(Fl_Widget* o) {remove(*o);}
135 void clear();
136
137 /* delete child n (by index) */
138 virtual int delete_child(int n);
139
144 void resizable(Fl_Widget& o) {resizable_ = &o;}
198 void resizable(Fl_Widget* o) {resizable_ = o;}
203 Fl_Widget* resizable() const {return resizable_;}
207 void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
208 void init_sizes();
209
219 void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
227 unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
228
229 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
230 Fl_Group* as_group() FL_OVERRIDE { return this; }
231 Fl_Group const* as_group() const FL_OVERRIDE { return this; }
232
233 // back compatibility functions:
234
240 void focus(Fl_Widget* W) {W->take_focus();}
241
243 Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
244
246 void forms_end();
247};
248
249// dummy class used to end child groups in constructors for complex
250// subclasses of Fl_Group:
271class FL_EXPORT Fl_End {
272public:
275};
276
277#endif
Fl_Widget and 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:271
Fl_End()
All it does is calling Fl_Group::current()->end()
Definition: Fl_Group.H:274
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:56
void end()
Exactly the same as current(this->parent()).
Definition: Fl_Group.cxx:73
void add_resizable(Fl_Widget &o)
Adds a widget to the group and makes it the resizable widget.
Definition: Fl_Group.H:207
void add(Fl_Widget *o)
See void Fl_Group::add(Fl_Widget &w)
Definition: Fl_Group.H:121
void focus(Fl_Widget *W)
Definition: Fl_Group.H:240
Fl_Widget * child(int n) const
Returns array()[n].
Definition: Fl_Group.H:102
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:98
Fl_Widget *& _ddfdesign_kludge()
This is for forms compatibility only.
Definition: Fl_Group.H:243
void remove(Fl_Widget *o)
Removes the widget o from the group.
Definition: Fl_Group.H:134
void resizable(Fl_Widget &o)
Sets the group's resizable widget.
Definition: Fl_Group.H:144
void clip_children(int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box.
Definition: Fl_Group.H:219
unsigned int clip_children()
Returns the current clipping mode.
Definition: Fl_Group.H:227
void insert(Fl_Widget &o, Fl_Widget *before)
This does insert(w, find(before)).
Definition: Fl_Group.H:127
Fl_Widget * resizable() const
Returns the group's resizable widget.
Definition: Fl_Group.H:203
Fl_Group * as_group() FL_OVERRIDE
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Group.H:230
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:82
void resizable(Fl_Widget *o)
The resizable widget defines both the resizing box and the resizing behavior of the group and its chi...
Definition: Fl_Group.H:198
int find(const Fl_Widget &o) const
See int Fl_Group::find(const Fl_Widget *w) const.
Definition: Fl_Group.H:107
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition: Fl_Rect.H:30
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:110
virtual void draw()=0
Draws the widget.
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:156
virtual Fl_Group * as_group()
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Widget.H:1213
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:158
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:102
int take_focus()
Gives the widget the keyboard focus.
Definition: Fl_Widget.cxx:150
virtual void resize(int x, int y, int w, int h)
Changes the size or position of the widget.
Definition: Fl_Widget.cxx:138
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:160
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition: fl_attr.h:46