FLTK 1.5.0
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
21#ifndef Fl_Group_H
22#define Fl_Group_H
23
24#include "Fl_Widget.H"
25
26#include <vector>
27
28// Don't #include Fl_Rect.H because this would introduce lots
29// of unnecessary dependencies on Fl_Rect.H
30class Fl_Rect;
31
32
59class FL_EXPORT Fl_Group : public Fl_Widget {
60
61 std::vector<Fl_Widget *>child_; // vector of children
62 Fl_Widget* savedfocus_;
63 Fl_Widget* resizable_;
64 Fl_Rect *bounds_; // remembered initial sizes of children
65 int *sizes_; // remembered initial sizes of children (FLTK 1.3 compat.)
66
67 int navigation(int);
68 static Fl_Group *current_;
69
70 // unimplemented copy ctor and assignment operator
71 Fl_Group(const Fl_Group&);
72 Fl_Group& operator=(const Fl_Group&);
73
74protected:
75 void draw() FL_OVERRIDE;
76 void draw_child(Fl_Widget& widget) const;
77 void draw_children();
78 void draw_outside_label(const Fl_Widget& widget) const ;
79 void update_child(Fl_Widget& widget) const;
80 Fl_Rect *bounds();
81 int *sizes(); // FLTK 1.3 compatibility
82 virtual int on_insert(Fl_Widget*, int);
83 virtual int on_move(int, int);
84 virtual void on_remove(int);
85
86public:
87
88 int handle(int) FL_OVERRIDE;
89 void begin();
90 void end();
91 static Fl_Group *current();
92 static void current(Fl_Group *g);
93
97 int children() const { return (int)child_.size(); }
98
109 Fl_Widget *child(int n) const {
110 if (n < 0 || n > children() - 1) return nullptr;
111 return child_[n];
112 }
113
114 int find(const Fl_Widget*) const;
118 int find(const Fl_Widget& o) const { return find(&o); }
119
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:59
void end()
Exactly the same as current(this->parent()).
Definition Fl_Group.cxx:76
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:109
int children() const
Returns how many child widgets the group has.
Definition Fl_Group.H:97
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:85
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:118
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:38