00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_GROUP_H_
00023 #define _FL_GROUP_H_
00024
00025 #include "Fl_Widget.h"
00026 #include "Fl_Data_Source.h"
00027 #include "Fl_Widget_List.h"
00028 #include "Fl_Int_List.h"
00029
00051 enum Fl_Group_Grow_Mode {
00052 FL_GROUP_NO_GROW = 0,
00053 FL_GROUP_GROW_HORIZONTAL,
00054 FL_GROUP_GROW_VERTICAL,
00055 FL_GROUP_GROW_BOTH
00056 };
00057
00058 class FL_API Fl_Group : public Fl_Widget {
00059 public:
00060
00062 Fl_Group(int x, int y, int w, int h, const char *l=0);
00063
00065 Fl_Group(const char* l = 0,int layout_size=30,Fl_Align layout_al=FL_ALIGN_TOP,int label_w=-1);
00066
00073 virtual ~Fl_Group();
00074
00076 int children() const { return m_array.size(); }
00077
00079 Fl_Widget* child(int n) const { return m_array[n]; }
00080
00082 Fl_Widget_List &array() { return m_array; }
00083
00090 void draw_group_box() const;
00091
00092 virtual void preferred_size(int &w, int &h) const { }
00093 virtual void draw();
00094 virtual void layout();
00095 virtual int handle(int);
00096
00102 virtual void begin() { Fl_Group::m_current = this; }
00103
00107 virtual void end() { Fl_Group::m_current = (Fl_Group*)parent(); }
00108
00109
00110
00111
00112
00113 static Fl_Group *current() { return Fl_Group::m_current; }
00114
00120 static void current(Fl_Group *g) { Fl_Group::m_current = g; }
00121
00123 int find(const Fl_Widget *w) const;
00124
00126 int find(const Fl_Widget &w) const { return find(&w); }
00127
00128 virtual void clear();
00129
00130 void insert(Fl_Widget& o, Fl_Widget* before) { insert(o,find(before)); }
00131 void insert(Fl_Widget&, int index);
00132
00133 void remove(Fl_Widget& o) { remove(find(o)); }
00134 void remove(Fl_Widget* o) { remove(find(*o)); }
00135 void remove(int index);
00136
00137 void replace(int index, Fl_Widget&);
00138 void replace(Fl_Widget& old, Fl_Widget& o) { replace(find(old),o); };
00139
00140 void add(Fl_Widget& o) { insert(o, children()); }
00141 void add(Fl_Widget* o) { add(*o); }
00142
00143 void resizable(Fl_Widget& o) { m_resizable = &o; }
00144 void resizable(Fl_Widget* o) { m_resizable = o; }
00145 Fl_Widget* resizable() const { return m_resizable; }
00146 void add_resizable(Fl_Widget& o) { m_resizable = &o; add(o); }
00147
00148 void init_sizes();
00149 int *store_sizes();
00150
00151 void focus(int i) { m_focus = i; }
00152 void focus(Fl_Widget* w) { focus(find(w)); }
00153 int focus() const { return m_focus; }
00154 static int navigation_key();
00155
00156
00157 virtual void reset();
00158
00159
00160 void data_source(Fl_Data_Source *ds);
00161 Fl_Data_Source* data_source() const { return m_data_source; }
00162 virtual bool load_data(Fl_Data_Source *ds);
00163 virtual bool save_data(Fl_Data_Source *ds);
00164
00165 uchar layout_spacing() const { return m_layout_spacing; }
00166 void layout_spacing(const uchar offset) { m_layout_spacing = offset; }
00167
00168 Fl_Group_Grow_Mode auto_grow() const { return m_auto_grow; }
00169 void auto_grow(Fl_Group_Grow_Mode agm) { m_auto_grow = agm; }
00170
00171 protected:
00172 void draw_child(Fl_Widget&) const;
00173 void update_child(Fl_Widget&) const;
00174 void draw_outside_label(Fl_Widget&) const;
00175
00176 private:
00177
00179 void ctor_init();
00180
00181 uchar m_layout_spacing;
00182 int m_focus;
00183
00184 Fl_Widget_List m_array;
00185 Fl_Int_List m_sizes;
00186
00187 Fl_Widget *m_resizable;
00188 Fl_Data_Source *m_data_source;
00189
00190 static Fl_Group *m_current;
00191
00192 Fl_Group_Grow_Mode m_auto_grow;
00193 int m_auto_grow_min_width;
00194 int m_auto_grow_min_height;
00195 };
00196
00197
00198
00199 class FL_API Fl_End {
00200 public:
00201 Fl_End() {Fl_Group::current()->end();}
00202 Fl_End(Fl_Group* g) {Fl_Group::current(g);}
00203 };
00204
00205 #endif