FLTK 1.4.4: Fl_Group.H Source File

FLTK 1.4.4

Loading...
Searching...
No Matches
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
20
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
56 class 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:
283 class FL_EXPORT Fl_End {
284public:
286 Fl_End() {Fl_Group::current()->end();}
287};
288
289#endif
Fl_Widget.H
Fl_Widget and Fl_Label classes.
Fl_End::Fl_End
Fl_End()
All it does is calling Fl_Group::current()->end().
Definition Fl_Group.H:286
Fl_Group
The Fl_Group class is the main FLTK container widget.
Definition Fl_Group.H:56
Fl_Group::on_remove
virtual void on_remove(int)
Allow derived groups to act when a child widget is removed from the group.
Definition Fl_Group.cxx:571
Fl_Group::end
void end()
Exactly the same as current(this->parent()).
Definition Fl_Group.cxx:73
Fl_Group::add_resizable
void add_resizable(Fl_Widget &o)
Adds a widget to the group and makes it the resizable widget.
Definition Fl_Group.H:219
Fl_Group::on_move
virtual int on_move(int, int)
Allow derived groups to act when a widget is moved within the group.
Definition Fl_Group.cxx:499
Fl_Group::add
void add(Fl_Widget *o)
See void Fl_Group::add(Fl_Widget &w).
Definition Fl_Group.H:133
Fl_Group::bounds
Fl_Rect * bounds()
Returns the internal array of widget sizes and positions.
Definition Fl_Group.cxx:741
Fl_Group::add
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group.
Definition Fl_Group.cxx:560
Fl_Group::focus
void focus(Fl_Widget *W)
Definition Fl_Group.H:252
Fl_Group::child
Fl_Widget * child(int n) const
Returns the n'th child.
Definition Fl_Group.H:110
Fl_Group::draw_child
void draw_child(Fl_Widget &widget) const
Forces a child to redraw.
Definition Fl_Group.cxx:973
Fl_Group::children
int children() const
Returns how many child widgets the group has.
Definition Fl_Group.H:98
Fl_Group::_ddfdesign_kludge
Fl_Widget *& _ddfdesign_kludge()
This is for forms compatibility only.
Definition Fl_Group.H:255
Fl_Group::on_insert
virtual int on_insert(Fl_Widget *, int)
Allow derived groups to act when a widget is added as a child.
Definition Fl_Group.cxx:475
Fl_Group::sizes
int * sizes()
Returns the internal array of widget sizes and positions.
Definition Fl_Group.cxx:799
Fl_Group::remove
void remove(Fl_Widget *o)
Removes the widget o from the group.
Definition Fl_Group.H:146
Fl_Group::draw_children
void draw_children()
Draws all children of the group.
Definition Fl_Group.cxx:920
Fl_Group::begin
void begin()
Sets the current group so you can build the widget tree by just constructing the widgets.
Definition Fl_Group.cxx:67
Fl_Group::update_child
void update_child(Fl_Widget &widget) const
Draws a child only if it needs it.
Definition Fl_Group.cxx:959
Fl_Group::resizable
void resizable(Fl_Widget &o)
Sets the group's resizable widget.
Definition Fl_Group.H:156
Fl_Group::array
Fl_Widget *const * array() const
Returns a pointer to the array of children.
Definition Fl_Group.cxx:41
Fl_Group::find
int find(const Fl_Widget *) const
Searches the child array for the widget and returns the index.
Definition Fl_Group.cxx:50
Fl_Group::clip_children
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
Fl_Group::clip_children
unsigned int clip_children()
Returns the current clipping mode.
Definition Fl_Group.H:239
Fl_Group::insert
void insert(Fl_Widget &o, Fl_Widget *before)
This does insert(w, find(before)).
Definition Fl_Group.H:139
Fl_Group::draw_outside_label
void draw_outside_label(const Fl_Widget &widget) const
Parents normally call this to draw outside labels of child widgets.
Definition Fl_Group.cxx:984
Fl_Group::resizable
Fl_Widget * resizable() const
Returns the group's resizable widget.
Definition Fl_Group.H:215
Fl_Group::as_group
Fl_Group * as_group() FL_OVERRIDE
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition Fl_Group.H:242
Fl_Group::current
static Fl_Group * current()
Returns the currently active group.
Definition Fl_Group.cxx:82
Fl_Group::resizable
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
Fl_Group::find
int find(const Fl_Widget &o) const
See int Fl_Group::find(const Fl_Widget *w) const.
Definition Fl_Group.H:119
Fl_Rect
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition Fl_Rect.H:30
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
Fl_Widget::draw
virtual void draw()=0
Draws the widget.
Fl_Widget::flags
unsigned int flags() const
Gets the widget flags mask.
Definition Fl_Widget.H:158
Fl_Widget::CLIP_CHILDREN
@ CLIP_CHILDREN
all drawing within this widget will be clipped (Fl_Group)
Definition Fl_Widget.H:178
Fl_Widget::as_group
virtual Fl_Group * as_group()
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition Fl_Widget.H:1215
Fl_Widget::set_flag
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition Fl_Widget.H:160
Fl_Widget::handle
virtual int handle(int event)
Handles the specified event.
Definition Fl_Widget.cxx:102
Fl_Widget::take_focus
int take_focus()
Gives the widget the keyboard focus.
Definition Fl_Widget.cxx:150
Fl_Widget::resize
virtual void resize(int x, int y, int w, int h)
Changes the size or position of the widget.
Definition Fl_Widget.cxx:138
Fl_Widget::clear_flag
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition Fl_Widget.H:162
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46