FLTK
Fl_Group.H
1 //
2 // Group header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2020 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 
17 /* \file
18  Fl_Group, Fl_End classes . */
19 
20 #ifndef Fl_Group_H
21 #define Fl_Group_H
22 
23 #include "Fl_Widget.H"
24 
25 // Don't #include Fl_Rect.H because this would introduce lots
26 // of unnecessary dependencies on Fl_Rect.H
27 class Fl_Rect;
28 
29 
42 class FL_EXPORT Fl_Group : public Fl_Widget {
43 
44  union {
45  Fl_Widget** array_; // used if group has two or more children or NULL
46  Fl_Widget* child1_; // used if group has one child or NULL
47  };
48  Fl_Widget* savedfocus_;
49  Fl_Widget* resizable_;
50  int children_;
51  Fl_Rect *bounds_; // remembered initial sizes of children
52  int *sizes_; // remembered initial sizes of children (FLTK 1.3 compat.)
53 
54  int navigation(int);
55  static Fl_Group *current_;
56 
57  // unimplemented copy ctor and assignment operator
58  Fl_Group(const Fl_Group&);
59  Fl_Group& operator=(const Fl_Group&);
60 
61 protected:
62  void draw();
63  void draw_child(Fl_Widget& widget) const;
64  void draw_children();
65  void draw_outside_label(const Fl_Widget& widget) const ;
66  void update_child(Fl_Widget& widget) const;
67  Fl_Rect *bounds();
68  int *sizes(); // FLTK 1.3 compatibility
69 
70 public:
71 
72  int handle(int);
73  void begin();
74  void end();
75  static Fl_Group *current();
76  static void current(Fl_Group *g);
77 
81  int children() const {return children_;}
85  Fl_Widget* child(int n) const {return array()[n];}
86  int find(const Fl_Widget*) const;
90  int find(const Fl_Widget& o) const {return find(&o);}
91  Fl_Widget* const* array() const;
92 
93  void resize(int,int,int,int);
98  Fl_Group(int,int,int,int, const char * = 0);
99  virtual ~Fl_Group();
100  void add(Fl_Widget&);
104  void add(Fl_Widget* o) {add(*o);}
105  void insert(Fl_Widget&, int i);
110  void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));}
111  void remove(int index);
112  void remove(Fl_Widget&);
117  void remove(Fl_Widget* o) {remove(*o);}
118  void clear();
119 
124  void resizable(Fl_Widget& o) {resizable_ = &o;}
163  void resizable(Fl_Widget* o) {resizable_ = o;}
168  Fl_Widget* resizable() const {return resizable_;}
172  void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);}
173  void init_sizes();
174 
184  void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); }
192  unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
193 
194  // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
195  virtual Fl_Group* as_group() { return this; }
196 
197  // back compatibility functions:
198 
204  void focus(Fl_Widget* W) {W->take_focus();}
205 
207  Fl_Widget* & _ddfdesign_kludge() {return resizable_;}
208 
210  void forms_end();
211 };
212 
213 // dummy class used to end child groups in constructors for complex
214 // subclasses of Fl_Group:
235 class FL_EXPORT Fl_End {
236 public:
239 };
240 
241 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
void add_resizable(Fl_Widget &o)
Adds a widget to the group and makes it the resizable widget.
Definition: Fl_Group.H:172
Fl_Widget * resizable() const
Returns the group's resizable widget.
Definition: Fl_Group.H:168
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:102
virtual void draw()=0
Draws the widget.
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:81
This is a dummy class that allows you to end a Fl_Group in a constructor list of a class: ...
Definition: Fl_Group.H:235
void end()
Exactly the same as current(this->parent()).
Definition: Fl_Group.cxx:72
int take_focus()
Gives the widget the keyboard focus.
Definition: Fl_Widget.cxx:152
int find(const Fl_Widget &o) const
See int Fl_Group::find(const Fl_Widget *w) const.
Definition: Fl_Group.H:90
virtual Fl_Group * as_group()
Returns an Fl_Group pointer if this widget is an Fl_Group.
Definition: Fl_Group.H:195
void insert(Fl_Widget &o, Fl_Widget *before)
This does insert(w, find(before)).
Definition: Fl_Group.H:110
virtual void resize(int x, int y, int w, int h)
Changes the size or position of the widget.
Definition: Fl_Widget.cxx:140
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:42
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:136
Fl_Widget, Fl_Label classes .
void resizable(Fl_Widget &o)
Sets the group's resizable widget.
Definition: Fl_Group.H:124
unsigned int clip_children()
Returns the current clipping mode.
Definition: Fl_Group.H:192
void focus(Fl_Widget *W)
Definition: Fl_Group.H:204
void add(Fl_Widget *o)
See void Fl_Group::add(Fl_Widget &w)
Definition: Fl_Group.H:104
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:134
Fl_End()
All it does is calling Fl_Group::current()->end()
Definition: Fl_Group.H:238
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition: Fl_Rect.H:30
void clip_children(int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box...
Definition: Fl_Group.H:184
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:132
Fl_Widget * child(int n) const
Returns array()[n].
Definition: Fl_Group.H:85
Fl_Widget *& _ddfdesign_kludge()
This is for forms compatibility only.
Definition: Fl_Group.H:207
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:81
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:163