summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-10-21 13:18:50 +0200
committerMatthias Melcher <github@matthiasm.com>2023-10-21 13:20:11 +0200
commitf8d7ee6f5c0d018d5b8a8fa4565e386b81062348 (patch)
treee11ca81a5ca8267813783f3a3ee05c93651ede18
parent7a434575acc6cb8121ae790ab94250b331b412f4 (diff)
FLUID: adding a subset of Fl_Grid child parameters.
-rw-r--r--FL/Fl_Grid.H3
-rw-r--r--fluid/Fl_Grid_Type.cxx108
-rw-r--r--fluid/Fl_Grid_Type.h2
-rw-r--r--fluid/Fl_Type.cxx89
-rw-r--r--fluid/Fl_Type.h2
-rw-r--r--fluid/Fl_Widget_Type.cxx8
-rw-r--r--fluid/widget_panel.cxx279
-rw-r--r--fluid/widget_panel.fl205
-rw-r--r--fluid/widget_panel.h9
-rw-r--r--src/Fl_Grid.cxx2
10 files changed, 690 insertions, 17 deletions
diff --git a/FL/Fl_Grid.H b/FL/Fl_Grid.H
index 1e176a45f..2cf2392d0 100644
--- a/FL/Fl_Grid.H
+++ b/FL/Fl_Grid.H
@@ -172,6 +172,9 @@ public:
~Cell() {}
+ short row() const { return row_; }
+ short col() const { return col_; }
+
Fl_Widget *widget() { return widget_; }
void align(Fl_Grid_Align align) {
align_ = align;
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx
index ed5ab251a..73b36fdda 100644
--- a/fluid/Fl_Grid_Type.cxx
+++ b/fluid/Fl_Grid_Type.cxx
@@ -90,6 +90,49 @@ void Fl_Grid_Type::read_property(Fd_Project_Reader &f, const char *c)
}
}
+void Fl_Grid_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate) {
+ Fl_Grid *grid;
+ Fl_Widget *child_widget;
+ Fl_Grid::Cell *cell;
+ if (!child->is_true_widget()) goto err;
+ grid = (Fl_Grid*)o;
+ child_widget = ((Fl_Widget_Type*)child)->o;
+ cell = grid->cell(child_widget);
+ if (!cell) goto err;
+ if (encapsulate) {
+ f.write_indent(level+2);
+ f.write_string("parent_properties {");
+ }
+ f.write_indent(level+3);
+ f.write_string("location {%d %d}", cell->row(), cell->col());
+ super::write_parent_properties(f, child, false);
+ if (encapsulate) {
+ f.write_indent(level+2);
+ f.write_string("}");
+ }
+ return;
+err:
+ super::write_parent_properties(f, child, true);
+}
+
+void Fl_Grid_Type::read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property) {
+ if (!child->is_true_widget()) {
+ super::read_parent_properties(f, child, property);
+ return;
+ }
+ Fl_Grid *grid = (Fl_Grid*)o;
+ Fl_Widget *child_widget = ((Fl_Widget_Type*)child)->o;
+ int row = -1, col = -1, rowspan = 1, colspan = 1;
+ Fl_Grid_Align align = FL_GRID_FILL;
+ if (!strcmp(property, "location")) {
+ const char *value = f.read_word();
+ sscanf(value, "%d %d", &row, &col);
+ property = f.read_word();
+ }
+ if (row>=0 && col>=0) grid->widget(child_widget, row, col, rowspan, colspan, (Fl_Grid_Align)align);
+ super::read_parent_properties(f, child, property);
+}
+
void Fl_Grid_Type::write_code1(Fd_Code_Writer& f) {
const char *var = name() ? name() : "o";
Fl_Grid* grid = (Fl_Grid*)o;
@@ -106,6 +149,15 @@ void Fl_Grid_Type::write_code1(Fd_Code_Writer& f) {
}
void Fl_Grid_Type::write_code2(Fd_Code_Writer& f) {
+ const char *var = name() ? name() : "o";
+ Fl_Grid* grid = (Fl_Grid*)o;
+ for (int i=0; i<grid->children(); i++) {
+ Fl_Widget *c = grid->child(i);
+ Fl_Grid::Cell *cell = grid->cell(c);
+ if (cell) {
+ f.write_c("%s%s->widget(%s->child(%d), %d, %d);\n", f.indent(), var, var, i, cell->row(), cell->col());
+ }
+ }
super::write_code2(f);
}
@@ -189,7 +241,7 @@ void grid_col_gap_cb(Fl_Value_Input* i, void* v) {
void grid_cb(Fluid_Coord_Input* i, void* v, int what) {
if (v == LOAD) {
if (current_widget->is_a(ID_Grid)) {
- int v;
+ int v = 0;
Fl_Grid *g = ((Fl_Grid*)current_widget->o);
switch (what) {
case 6: v = g->rows(); break;
@@ -228,3 +280,57 @@ void grid_cols_cb(Fluid_Coord_Input* i, void* v) {
grid_cb(i, v, 7);
}
+void grid_child_cb(Fluid_Coord_Input* i, void* v, int what) {
+ if ( !current_widget
+ || !current_widget->parent
+ || !current_widget->parent->is_a(ID_Grid))
+ {
+ return;
+ }
+ Fl_Grid *g = ((Fl_Grid*)((Fl_Widget_Type*)current_widget->parent)->o);
+ if (v == LOAD) {
+ int v = -1;
+ Fl_Grid::Cell *cell = g->cell(current_widget->o);
+ if (cell) {
+ switch (what) {
+ case 8: v = cell->row(); break;
+ case 9: v = cell->col(); break;
+ }
+ }
+ i->value(v);
+ } else {
+ int mod = 0;
+ int v2 = 0, old_v = -1, v = (int)i->value();
+ Fl_Grid::Cell *cell = g->cell(current_widget->o);
+ if (cell) {
+ switch (what) {
+ case 8: old_v = cell->row(); v2 = cell->col(); break;
+ case 9: old_v = cell->col(); v2 = cell->row(); break;
+ }
+ }
+ if (old_v != v) {
+ switch (what) {
+ case 8: g->widget(current_widget->o, v, v2); break;
+ case 9: g->widget(current_widget->o, v2, v); break;
+ }
+ g->need_layout(true);
+ g->redraw();
+ mod = 1;
+ if (mod) set_modflag(1);
+ }
+ }
+}
+void grid_set_row_cb(Fluid_Coord_Input* i, void* v) {
+ grid_child_cb(i, v, 8);
+}
+void grid_set_col_cb(Fluid_Coord_Input* i, void* v) {
+ grid_child_cb(i, v, 9);
+}
+void grid_set_colspan_cb(Fluid_Coord_Input* i, void* v) {
+ grid_child_cb(i, v, 10);
+}
+void grid_set_rowspan_cb(Fluid_Coord_Input* i, void* v) {
+ grid_child_cb(i, v, 11);
+}
+void grid_align_cb(Fl_Choice* i, void* v) {
+}
diff --git a/fluid/Fl_Grid_Type.h b/fluid/Fl_Grid_Type.h
index e817a94b0..5ce325043 100644
--- a/fluid/Fl_Grid_Type.h
+++ b/fluid/Fl_Grid_Type.h
@@ -36,6 +36,8 @@ public:
bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Grid) ? true : super::is_a(inID); }
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
+ void write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate) FL_OVERRIDE;
+ void read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property) FL_OVERRIDE;
void copy_properties() FL_OVERRIDE;
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx
index 6ececdf4a..dc187c260 100644
--- a/fluid/Fl_Type.cxx
+++ b/fluid/Fl_Type.cxx
@@ -681,6 +681,7 @@ void Fl_Type::write(Fd_Project_Writer &f) {
f.write_word(name());
f.write_open(level);
write_properties(f);
+ if (parent) parent->write_parent_properties(f, this, true);
f.write_close(level);
if (!is_parent()) return;
// now do children:
@@ -736,10 +737,98 @@ void Fl_Type::read_property(Fd_Project_Reader &f, const char *c) {
open_ = 1;
else if (!strcmp(c,"selected"))
select(this,1);
+ else if (!strcmp(c,"parent_properties"))
+ if (parent) {
+ const char *cc = f.read_word(1);
+ if (strcmp(cc, "{")==0) {
+ cc = f.read_word();
+ parent->read_parent_properties(f, this, cc);
+ } else {
+ f.read_error("'parent_properties' must be followed by '{'");
+ }
+ } else {
+ f.read_error("Types using 'parent_properties' must have a parent");
+ f.read_word(); // skip the entire block (this should generate a warning)
+ }
else
f.read_error("Unknown property \"%s\"", c);
}
+/** Write parent properties into the child property list.
+
+ Some widgets store information for every child they manage. For example,
+ Fl_Grid stores the row and column position of every child. This method stores
+ this information with the child, but it is read and written by the parent.
+
+ Parent properties solve several issues. A child will keep parent properties
+ if copied from on grid into another. The parent does not have to keep lists
+ of properties that may diverge from the actual order or number of children.
+ And lastly, properties are read when they are actually needed and don't have
+ to be stored in some temporary array.
+
+ Parent properties are written as their own block at the end of the child's
+ property list. The block starts with the `parent_properties` keyword, followed
+ by a list of property/value pairs. The order of properties is significant,
+ however individual properties can be left out.
+
+ To avoid writing the `parent_properties` block unnecessarily, this method
+ should only generate it if `encapsulate` is set *and* the contained
+ properties are not at their default.
+
+ Lastly, this method should call the super class to give it a chance to append
+ its own properties.
+
+ \see Fl_Grid_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate)
+
+ \param[in] f the project file writer
+ \param[in] child write properties for this child, make sure it has the correct type
+ \param[in] encapsulate write the `parent_properties {}` block if true before writing any properties
+ */
+void Fl_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate) {
+ (void)f; (void)child; (void)encapsulate;
+ // nothing to do here
+ // put the following code into your implementation of write_parent_properties
+ // if there are actual non-default properties to write
+ // if (encapsulate) {
+ // f.write_indent(level+2);
+ // f.write_string("parent_properties {");
+ // }
+ // now write your properties as name/value pairs
+ // f.write_indent(level+3);
+ // f.write_string("location {%d %d}", cell->row(), cell->col());
+ // give the super class a chance to write its properties as well
+ // super::write_parent_properties(f, child, false);
+ // close the encapsulation
+ // if (encapsulate) {
+ // f.write_indent(level+2);
+ // f.write_string("}");
+ // }
+}
+
+/** Read parent per-child properties.
+
+ A parent widget can store properties for every child that it manages. This
+ method reads back those properties. The order of properties is significant,
+ but individual properties can be omitted.
+
+ \see Fl_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate)
+ \see Fl_Grid_Type::read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property)
+
+ \param[in] f the project file writer
+ \param[in] child read properties for this child
+ \param[in] property the name of a property, or "}" when we reach the end of the list
+ */
+void Fl_Type::read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property) {
+ (void)child;
+ for (;;) {
+ if (strcmp(property, "}")==0) break;
+ f.read_error("Unknown parent property \"%s\"", property);
+ f.read_word(); // ignore property value
+ property = f.read_word(); // read next property name
+ }
+}
+
+
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
/**
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index 56bfde744..b33690f58 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -195,6 +195,8 @@ public:
virtual void write(Fd_Project_Writer &f);
virtual void write_properties(Fd_Project_Writer &f);
virtual void read_property(Fd_Project_Reader &f, const char *);
+ virtual void write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool encapsulate);
+ virtual void read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property);
virtual int read_fdesign(const char*, const char*);
virtual void postprocess_read() { }
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 5c8ed99b5..f1e7e5170 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -2658,6 +2658,14 @@ static void load_panel() {
}
}
}
+ if (current_widget && current_widget->parent->is_a(ID_Grid)) {
+ if (widget_tab_grid->parent()!=widget_tabs)
+ widget_tabs->add(widget_tab_grid);
+ } else {
+ if (widget_tab_grid->parent()==widget_tabs) {
+ widget_tabs_repo->add(widget_tab_grid);
+ }
+ }
if (numselected)
propagate_load(the_panel, LOAD);
else
diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx
index efc280df2..ed9e17edd 100644
--- a/fluid/widget_panel.cxx
+++ b/fluid/widget_panel.cxx
@@ -18,8 +18,11 @@
#include "widget_panel.h"
#include "Fl_Widget_Type.h"
+#include <FL/Fl_Grid.H>
-static void cb_(Fl_Tabs* o, void* v) {
+Fl_Tabs *widget_tabs=(Fl_Tabs *)0;
+
+static void cb_widget_tabs(Fl_Tabs* o, void* v) {
propagate_load((Fl_Group *)o,v);
}
@@ -94,7 +97,7 @@ Fl_Menu_Item menu_3[] = {
Fl_Input *v_input[4]={(Fl_Input *)0};
-static void cb_1(Fl_Tile*, void* v) {
+static void cb_(Fl_Tile*, void* v) {
wComment->do_callback(wComment, v);
wCallback->do_callback(wCallback, v);
}
@@ -111,6 +114,27 @@ Fl_Menu_Item menu_4[] = {
Fl_Box *w_when_box=(Fl_Box *)0;
+Fl_Tabs *widget_tabs_repo=(Fl_Tabs *)0;
+
+Fl_Group *widget_tab_grid=(Fl_Group *)0;
+
+Fl_Menu_Item menu_Align[] = {
+ {"GRID_CENTER", 0, 0, (void*)(FL_GRID_CENTER), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_FILL", 0, 0, (void*)(FL_GRID_FILL), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_PROPORTIONAL", 0, 0, (void*)(FL_GRID_PROPORTIONAL), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_HORIZONTAL", 0, 0, (void*)(FL_GRID_HORIZONTAL), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_VERTICAL", 0, 0, (void*)(FL_GRID_VERTICAL), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_LEFT", 0, 0, (void*)(FL_GRID_LEFT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_TOP_LEFT", 0, 0, (void*)(FL_GRID_TOP_LEFT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_TOP", 0, 0, (void*)(FL_GRID_TOP), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_TOP_RIGHT", 0, 0, (void*)(FL_GRID_TOP_RIGHT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_RIGHT", 0, 0, (void*)(FL_GRID_RIGHT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_BOTTOM_LEFT", 0, 0, (void*)(FL_GRID_BOTTOM_LEFT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_BOTTOM", 0, 0, (void*)(FL_GRID_BOTTOM), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"GRID_BOTTOM_RIGHT", 0, 0, (void*)(FL_GRID_BOTTOM_RIGHT), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {0,0,0,0,0,0,0,0,0}
+};
+
Fl_Button *wLiveMode=(Fl_Button *)0;
Fl_Button *overlay_button=(Fl_Button *)0;
@@ -126,12 +150,12 @@ Fl_Double_Window* make_widget_panel() {
o->labelsize(11);
o->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE));
o->hotspot(o);
- { Fl_Tabs* o = new Fl_Tabs(10, 10, 400, 350);
- o->selection_color((Fl_Color)12);
- o->labelsize(11);
- o->labelcolor(FL_BACKGROUND2_COLOR);
- o->callback((Fl_Callback*)cb_);
- o->when(FL_WHEN_NEVER);
+ { Fl_Tabs* o = widget_tabs = new Fl_Tabs(10, 10, 400, 350);
+ widget_tabs->selection_color((Fl_Color)12);
+ widget_tabs->labelsize(11);
+ widget_tabs->labelcolor(FL_BACKGROUND2_COLOR);
+ widget_tabs->callback((Fl_Callback*)cb_widget_tabs);
+ widget_tabs->when(FL_WHEN_NEVER);
{ Fl_Group* o = new Fl_Group(10, 30, 400, 330, "GUI");
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
@@ -1004,7 +1028,7 @@ sized to fit the container.");
v_input[3]->callback((Fl_Callback*)v_input_cb, (void*)(3));
} // Fl_Input* v_input[3]
{ Fl_Tile* o = new Fl_Tile(95, 175, 310, 130);
- o->callback((Fl_Callback*)cb_1);
+ o->callback((Fl_Callback*)cb_);
{ Fl_Group* o = new Fl_Group(95, 175, 310, 48);
o->box(FL_FLAT_BOX);
{ wComment = new Fl_Text_Editor(95, 175, 310, 45, "Comment:");
@@ -1100,9 +1124,240 @@ access the Widget pointer and \'v\' to access the user value.");
} // Fl_Group* o
o->end();
} // Fl_Group* o
- o->end();
- Fl_Group::current()->resizable(o);
- } // Fl_Tabs* o
+ o->show();
+ widget_tabs->end();
+ Fl_Group::current()->resizable(widget_tabs);
+ } // Fl_Tabs* widget_tabs
+ { Fl_Tabs* o = widget_tabs_repo = new Fl_Tabs(10, 10, 400, 350);
+ widget_tabs_repo->hide();
+ { Fl_Group* o = new Fl_Group(10, 30, 400, 330);
+ o->hide();
+ o->end();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Group* o
+ { widget_tab_grid = new Fl_Group(10, 30, 400, 330, "Grid");
+ widget_tab_grid->labelsize(11);
+ widget_tab_grid->callback((Fl_Callback*)propagate_load);
+ { Fl_Group* o = new Fl_Group(96, 110, 314, 20, "Location:");
+ o->labelfont(1);
+ o->labelsize(11);
+ o->callback((Fl_Callback*)position_group_cb);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 110, 55, 20, "Row:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->callback((Fl_Callback*)grid_set_row_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 110, 55, 20, "Column:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->callback((Fl_Callback*)grid_set_col_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fl_Choice* o = new Fl_Choice(215, 110, 185, 20, "Align:");
+ o->down_box(FL_BORDER_BOX);
+ o->labelsize(11);
+ o->textsize(11);
+ o->callback((Fl_Callback*)grid_align_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->menu(menu_Align);
+ } // Fl_Choice* o
+ { Fl_Box* o = new Fl_Box(400, 110, 1, 20);
+ o->hide();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Box* o
+ o->end();
+ } // Fl_Group* o
+ { Fl_Box* o = new Fl_Box(96, 74, 155, 20, "-- Widget --");
+ o->labelfont(1);
+ o->labelsize(12);
+ o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Group* o = new Fl_Group(96, 145, 314, 20, "Size:");
+ o->labelfont(1);
+ o->labelsize(11);
+ o->callback((Fl_Callback*)position_group_cb);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { Fl_Box* o = new Fl_Box(400, 145, 1, 20);
+ o->hide();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Box* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 145, 55, 20, "Row Span:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->callback((Fl_Callback*)grid_set_rowspan_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 145, 55, 20, "Col Span:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->callback((Fl_Callback*)grid_set_colspan_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ o->end();
+ } // Fl_Group* o
+ { Fl_Box* o = new Fl_Box(96, 179, 155, 20, "-- Grid --");
+ o->labelfont(1);
+ o->labelsize(12);
+ o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
+ } // Fl_Box* o
+ { Fl_Group* o = new Fl_Group(96, 215, 314, 20, "Row:");
+ o->labelfont(1);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 215, 55, 20, "Index");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ o->deactivate();
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 215, 55, 20, "Height:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(216, 215, 55, 20, "Weight:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(276, 215, 55, 20, "Gap:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fl_Box* o = new Fl_Box(400, 215, 1, 20);
+ o->hide();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Box* o
+ o->end();
+ } // Fl_Group* o
+ { Fl_Group* o = new Fl_Group(96, 250, 314, 20, "Column:");
+ o->labelfont(1);
+ o->labelsize(11);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 250, 55, 20, "Index");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ o->deactivate();
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 250, 55, 20, "Width:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(216, 250, 55, 20, "Weight:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fluid_Coord_Input* o = new Fluid_Coord_Input(276, 250, 55, 20, "Gap:");
+ o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
+ o->labelsize(11);
+ o->labelcolor(FL_FOREGROUND_COLOR);
+ o->textsize(11);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ o->when(FL_WHEN_RELEASE);
+ } // Fluid_Coord_Input* o
+ { Fl_Box* o = new Fl_Box(400, 250, 1, 20);
+ o->hide();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Box* o
+ o->end();
+ } // Fl_Group* o
+ { Fl_Box* o = new Fl_Box(25, 43, 370, 28, "The Fl_Grid implementation in FLUID is still experimental!");
+ o->labelfont(1);
+ o->labelsize(11);
+ o->labelcolor((Fl_Color)1);
+ } // Fl_Box* o
+ widget_tab_grid->end();
+ } // Fl_Group* widget_tab_grid
+ o->hide();
+ widget_tabs_repo->end();
+ } // Fl_Tabs* widget_tabs_repo
{ Fl_Group* o = new Fl_Group(10, 370, 400, 20);
o->labelsize(11);
{ wLiveMode = new Fl_Button(10, 370, 80, 20, "Live &Resize");
diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl
index bbaa004d3..cdafc553c 100644
--- a/fluid/widget_panel.fl
+++ b/fluid/widget_panel.fl
@@ -23,6 +23,9 @@ comment {//
decl {\#include "Fl_Widget_Type.h"} {private global
}
+decl {\#include <FL/Fl_Grid.H>} {selected private global
+}
+
decl {\#include "custom_widgets.h"} {public global
}
@@ -34,13 +37,14 @@ Function {make_widget_panel()} {
xywh {566 244 420 400} type Double labelsize 11 align 80 resizable hotspot
code0 {o->size_range(o->w(), o->h());} size_range {420 400 0 0} visible
} {
- Fl_Tabs {} {
- callback {propagate_load((Fl_Group *)o,v);} open
+ Fl_Tabs widget_tabs {
+ callback {propagate_load((Fl_Group *)o,v);}
xywh {10 10 400 350} selection_color 12 labelsize 11 labelcolor 7 when 0 resizable
+ code0 {o->show();}
} {
Fl_Group {} {
label GUI
- callback propagate_load open selected
+ callback propagate_load open
xywh {10 30 400 330} labelsize 11 when 0 resizable
} {
Fl_Group {} {
@@ -870,6 +874,201 @@ wCallback->do_callback(wCallback, v);} open
}
}
}
+ Fl_Tabs widget_tabs_repo {
+ xywh {10 10 400 350} hide
+ code0 {o->hide();}
+ } {
+ Fl_Group {} {open
+ xywh {10 30 400 330} hide resizable
+ } {}
+ Fl_Group widget_tab_grid {
+ label Grid
+ callback propagate_load open
+ xywh {10 30 400 330} labelsize 11
+ } {
+ Fl_Group {} {
+ label {Location:}
+ callback position_group_cb open
+ xywh {96 110 314 20} labelfont 1 labelsize 11 align 4
+ } {
+ Fl_Input {} {
+ label {Row:}
+ callback grid_set_row_cb
+ xywh {96 110 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Column:}
+ callback grid_set_col_cb
+ xywh {156 110 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Choice {} {
+ label {Align:}
+ callback grid_align_cb
+ xywh {215 110 185 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11
+ } {
+ MenuItem {} {
+ label GRID_CENTER
+ user_data FL_GRID_CENTER user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_FILL
+ user_data FL_GRID_FILL user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_PROPORTIONAL
+ user_data FL_GRID_PROPORTIONAL user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_HORIZONTAL
+ user_data FL_GRID_HORIZONTAL user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_VERTICAL
+ user_data FL_GRID_VERTICAL user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_LEFT
+ user_data FL_GRID_LEFT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_TOP_LEFT
+ user_data FL_GRID_TOP_LEFT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_TOP
+ user_data FL_GRID_TOP user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_TOP_RIGHT
+ user_data FL_GRID_TOP_RIGHT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_RIGHT
+ user_data FL_GRID_RIGHT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_BOTTOM_LEFT
+ user_data FL_GRID_BOTTOM_LEFT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_BOTTOM
+ user_data FL_GRID_BOTTOM user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ MenuItem {} {
+ label GRID_BOTTOM_RIGHT
+ user_data FL_GRID_BOTTOM_RIGHT user_data_type long
+ xywh {10 10 31 20} labelsize 11
+ }
+ }
+ Fl_Box {} {
+ xywh {400 110 1 20} hide resizable
+ }
+ }
+ Fl_Box {} {
+ label {-- Widget --}
+ xywh {96 74 155 20} labelfont 1 labelsize 12 align 20
+ }
+ Fl_Group {} {
+ label {Size:}
+ callback position_group_cb open
+ xywh {96 145 314 20} labelfont 1 labelsize 11 align 4
+ } {
+ Fl_Box {} {
+ xywh {400 145 1 20} hide resizable
+ }
+ Fl_Input {} {
+ label {Row Span:}
+ callback grid_set_rowspan_cb
+ xywh {96 145 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Col Span:}
+ callback grid_set_colspan_cb
+ xywh {156 145 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ }
+ Fl_Box {} {
+ label {-- Grid --}
+ xywh {96 179 155 20} labelfont 1 labelsize 12 align 20
+ }
+ Fl_Group {} {
+ label {Row:} open
+ xywh {96 215 314 20} labelfont 1 labelsize 11 align 4
+ } {
+ Fl_Input {} {
+ label Index
+ xywh {96 215 55 20} labelsize 11 align 5 textsize 11 deactivate
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Height:}
+ xywh {156 215 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Weight:}
+ xywh {216 215 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Gap:}
+ xywh {276 215 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Box {} {
+ xywh {400 215 1 20} hide resizable
+ }
+ }
+ Fl_Group {} {
+ label {Column:} open
+ xywh {96 250 314 20} labelfont 1 labelsize 11 align 4
+ } {
+ Fl_Input {} {
+ label Index
+ xywh {96 250 55 20} labelsize 11 align 5 textsize 11 deactivate
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Width:}
+ xywh {156 250 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Weight:}
+ xywh {216 250 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Input {} {
+ label {Gap:}
+ xywh {276 250 55 20} labelsize 11 align 5 textsize 11
+ class Fluid_Coord_Input
+ }
+ Fl_Box {} {
+ xywh {400 250 1 20} hide resizable
+ }
+ }
+ Fl_Box {} {
+ label {The Fl_Grid implementation in FLUID is still experimental!}
+ xywh {25 43 370 28} labelfont 1 labelsize 11 labelcolor 1
+ }
+ }
+ }
Fl_Group {} {open
xywh {10 370 400 20} labelsize 11
} {
diff --git a/fluid/widget_panel.h b/fluid/widget_panel.h
index 0fdd5ed31..4440175c3 100644
--- a/fluid/widget_panel.h
+++ b/fluid/widget_panel.h
@@ -22,6 +22,7 @@
#include "custom_widgets.h"
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Tabs.H>
+extern Fl_Tabs *widget_tabs;
#include <FL/Fl_Group.H>
extern void propagate_load(Fl_Group*, void*);
#include <FL/Fl_Input.H>
@@ -142,6 +143,13 @@ extern void when_cb(Fl_Menu_Button*, void*);
#include <FL/Fl_Input_Choice.H>
extern void user_data_type_cb(Fl_Input_Choice*, void*);
extern Fl_Box *w_when_box;
+extern Fl_Tabs *widget_tabs_repo;
+extern Fl_Group *widget_tab_grid;
+extern void grid_set_row_cb(Fluid_Coord_Input*, void*);
+extern void grid_set_col_cb(Fluid_Coord_Input*, void*);
+extern void grid_align_cb(Fl_Choice*, void*);
+extern void grid_set_rowspan_cb(Fluid_Coord_Input*, void*);
+extern void grid_set_colspan_cb(Fluid_Coord_Input*, void*);
extern void live_mode_cb(Fl_Button*, void*);
extern Fl_Button *wLiveMode;
extern void overlay_cb(Fl_Button*, void*);
@@ -155,4 +163,5 @@ extern Fl_Menu_Item menu_Children[];
extern Fl_Menu_Item menu_2[];
extern Fl_Menu_Item menu_3[];
extern Fl_Menu_Item menu_4[];
+extern Fl_Menu_Item menu_Align[];
#endif
diff --git a/src/Fl_Grid.cxx b/src/Fl_Grid.cxx
index c3b3e1334..da9c34ebc 100644
--- a/src/Fl_Grid.cxx
+++ b/src/Fl_Grid.cxx
@@ -322,7 +322,7 @@ void Fl_Grid::draw() {
This is called automatically when the Fl_Grid is resized. You need to
call it once after you added widgets or moved widgets between cells.
- Calling it once after all modfications are completed is enough.
+ Calling it once after all modifications are completed is enough.
\todo Document when and why to call layout() w/o args. See Fl_Flex::layout()