source: NonGTP/FLTK/include/fltk/Group.h @ 773

Revision 773, 3.3 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1//
2// "$Id: Group.h 4571 2005-09-16 08:02:58Z spitzak $"
3//
4// Group is the base class for all container widgets. For historical
5// reasons it also provides a default version of layout.
6//
7// Copyright 1998-2003 by Bill Spitzak and others.
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Library General Public
11// License as published by the Free Software Foundation; either
12// version 2 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17// Library General Public License for more details.
18//
19// You should have received a copy of the GNU Library General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22// USA.
23//
24// Please report all bugs and problems to "fltk-bugs@fltk.org".
25//
26
27#ifndef fltk_Group_h
28#define fltk_Group_h
29
30#ifndef fltk_Widget_h
31# include "Widget.h"
32#endif
33
34namespace fltk {
35
36class FL_API Group : public Widget {
37public:
38
39  int children() const {return children_;}
40  Widget* child(int n) const {return array_[n];}
41
42  void draw();
43  void layout();
44  int handle(int);
45
46  void begin() {current_ = this;}
47  void end() {current_ = (Group*)parent();}
48  static Group *current() {return current_;}
49  static void current(Group *g) {current_ = g;}
50
51  int find(const Widget*) const;
52  int find(const Widget& o) const {return find(&o);}
53
54  Group(int,int,int,int, const char * = 0, bool begin=false);
55  virtual ~Group();
56  void add(Widget&);
57  void add(Widget* o) {add(*o);}
58  void insert(Widget&, int index);
59  void insert(Widget& o, Widget* before) {insert(o,find(before));}
60  void remove(int index);
61  void remove(Widget& o) {remove(find(o));}
62  void remove(Widget* o) {remove(find(*o));}
63  void remove_all();
64  void replace(int index, Widget&);
65  void replace(Widget& old, Widget& o) {replace(find(old),o);}
66  void swap(int indexA, int indexB);
67  void clear();
68
69  void resizable(Widget& o) {resizable_ = &o;}
70  void resizable(Widget* o) {resizable_ = o;}
71  Widget* resizable() const {return resizable_;}
72  void add_resizable(Widget& o) {resizable_ = &o; add(o);}
73  void init_sizes();
74  bool resize(int,int,int,int)  ;
75  bool resize(int w, int h) {return resize(x(),y(),w,h);}
76
77  void focus_index(int v) {focus_index_ = v;}
78  void set_focus(Widget* w) {focus_index_ = find(w);}
79  int  focus_index() const {return focus_index_;}
80  static int navigation_key();
81
82  // back compatability function:
83  friend FL_FORMS_API void end_group(); // forms emulation function
84  void fix_old_positions();
85
86  Flags resize_align() const {return resize_align_;}
87  void resize_align(Flags f) {resize_align_ = f;}
88
89protected:
90
91  void draw_child(Widget&) const;
92  void update_child(Widget&) const;
93  void draw_outside_label(Widget&) const ;
94  int* sizes();
95  void layout(const Rectangle&, int layout_damage);
96
97private:
98
99  int children_;
100  int focus_index_;
101  Widget** array_;
102  Widget* resizable_;
103  Flags resize_align_;
104  int *sizes_; // remembered initial sizes of children
105
106  static Group *current_;
107
108};
109
110}
111
112#endif
113
114//
115// End of "$Id: Group.h 4571 2005-09-16 08:02:58Z spitzak $".
116//
Note: See TracBrowser for help on using the repository browser.