FLTK 1.4.3
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_; }
99
110 Fl_Widget *child(int n) const {
111 if (n < 0 || n > children() - 1) return NULL;
112 return array()[n];
113 }
114
115 int find(const Fl_Widget*) const;
119 int find(const Fl_Widget& o) const {return find(&o);}
120 Fl_Widget* const* array() const;
121
122 void resize(int,int,int,int) FL_OVERRIDE;
127 Fl_Group(int,int,int,int, const char * = 0);
128 virtual ~Fl_Group();
129 void add(Fl_Widget&);
133 void add(Fl_Widget* o) {add(*o);}
134 void insert(Fl_Widget&, int i);
139 void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
140 void remove(int index);
141 void remove(Fl_Widget&);
146 void remove(Fl_Widget* o) {remove(*o);}
147 void clear();
148
149 /* delete child n (by index) */
150 virtual int delete_child(int n);
151
156 void resizable(Fl_Widget& o) {resizable_ = &o;}
210 void resizable(Fl_Widget* o) {resizable_ = o;}
215 Fl_Widget* resizable() const {return resizable_;}
219 void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
220 void init_sizes();
221
231 void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
239 unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
240
241 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
242 Fl_Group* as_group() FL_OVERRIDE { return this; }
243 Fl_Group const* as_group() const FL_OVERRIDE { return this; }
244
245 // back compatibility functions:
246
252 void focus(Fl_Widget* W) {W->take_focus();}
253
255 Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
256
258 void forms_end();
259};
260
261// dummy class used to end child groups in constructors for complex
262// subclasses of Fl_Group:
283class FL_EXPORT Fl_End {
284public:
287};
288
289#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:283
Fl_End()
All it does is calling Fl_Group::current()->end()
Definition: Fl_Group.H:286
The Fl_Group class is the main 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:219
void add(Fl_Widget *o)
See void Fl_Group::add(Fl_Widget &w)
Definition: Fl_Group.H:133
void focus(Fl_Widget *W)
Definition: Fl_Group.H:252
Fl_Widget * child(int n) const
Returns the n'th child.
Definition: Fl_Group.H:110
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:255
void remove(Fl_Widget *o)
Removes the widget o from the group.
Definition: Fl_Group.H:146
void resizable(Fl_Widget &o)
Sets the group's resizable widget.
Definition: Fl_Group.H:156
void clip_children(int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box.
Definition: Fl_Group.H:231
unsigned int clip_children()
Returns the current clipping mode.
Definition: Fl_Group.H:239
void insert(Fl_Widget &o, Fl_Widget *before)
This does insert(w, find(before)).
Definition: Fl_Group.H:139
Fl_Widget * resizable() const
Returns the group's resizable widget.
Definition: Fl_Group.H:215
Fl_Group * as_group() FL_OVERRIDE
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Group.H:242
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:210
int find(const Fl_Widget &o) const
See int Fl_Group::find(const Fl_Widget *w) const.
Definition: Fl_Group.H:119
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:112
virtual void draw()=0
Draws the widget.
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:158
virtual Fl_Group * as_group()
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Widget.H:1215
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:160
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:162
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition: fl_attr.h:46