FLUID: more Fl_Grid settings

This commit is contained in:
Matthias Melcher 2023-10-22 01:50:06 +02:00
parent d102e466d6
commit b4fd7037ac
7 changed files with 1615 additions and 176 deletions

View File

@ -185,6 +185,9 @@ public:
void align(Fl_Grid_Align align) { align_ = align; }
Fl_Grid_Align align() const { return align_; }
void minimum_size(int w, int h) { if (w>=0) w_ = w; if (h>=0) h_ = h; }
void minimum_size(int *w, int *h) { if (w) *w = w_; if (h) *h = h_; }
}; // class Cell
private:
@ -286,12 +289,15 @@ public:
void col_width(int col, int value);
void col_width(const int *value, size_t size);
int col_width(int col) const;
void col_weight(int col, int value);
void col_weight(const int *value, size_t size);
int col_weight(int col) const;
void col_gap(int col, int value);
void col_gap(const int *value, size_t size);
int col_gap(int col) const;
void row_height(int row, int value);
void row_height(const int *value, size_t size);
@ -299,9 +305,11 @@ public:
void row_weight(int row, int value);
void row_weight(const int *value, size_t size);
int row_weight(int row) const;
void row_gap(int row, int value);
void row_gap(const int *value, size_t size);
int row_gap(int row) const;
/**
Enable or disable drawing of the grid helper lines for visualization.

View File

@ -27,6 +27,7 @@
#include <FL/Fl_Grid.H>
#include <FL/Fl_Value_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Choice.H>
#include "../src/flstring.h"
#include <stdio.h>
@ -44,7 +45,7 @@ Fl_Grid_Type::Fl_Grid_Type() {
Fl_Widget *Fl_Grid_Type::widget(int X,int Y,int W,int H) {
Fl_Grid *g = new Fl_Grid(X,Y,W,H);
g->layout(3, 3);
// g->show_grid(1, FL_RED);
g->show_grid(1, FL_RED);
Fl_Group::current(0);
return g;
}
@ -59,12 +60,16 @@ void Fl_Grid_Type::copy_properties()
int rg, cg;
s->gap(&rg, &cg);
d->gap(rg, cg);
// TODO: lots to do!
}
void Fl_Grid_Type::write_properties(Fd_Project_Writer &f)
{
super::write_properties(f);
Fl_Grid* grid = (Fl_Grid*)o;
int i, rows = grid->rows(), cols = grid->cols();
f.write_indent(level+1);
f.write_string("dimensions {%d %d}", rows, cols);
int lm, tm, rm, bm;
grid->margin(&lm, &tm, &rm, &bm);
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
@ -73,19 +78,37 @@ void Fl_Grid_Type::write_properties(Fd_Project_Writer &f)
grid->gap(&rg, &cg);
if (rg!=0 || cg!=0)
f.write_string("gap {%d %d}", rg, cg);
for (i=0; i<rows; i++) if (grid->row_height(i)!=0) break;
if (i<rows) {
f.write_indent(level+1);
f.write_string("rowheights {");
for (i=0; i<rows; i++) f.write_string("%d", grid->row_height(i));
f.write_string("}");
}
// TODO: add row_weight, row_gap, col_width, col_weight, col_gap
}
void Fl_Grid_Type::read_property(Fd_Project_Reader &f, const char *c)
{
Fl_Grid* grid = (Fl_Grid*)o;
if (!strcmp(c,"margin")) {
if (!strcmp(c,"dimensions")) {
int rows = 3, cols = 3;
if (sscanf(f.read_word(),"%d %d", &rows, &cols) == 2)
grid->layout(rows, cols);
} else if (!strcmp(c,"margin")) {
int lm, tm, rm, bm;
if (sscanf(f.read_word(),"%d %d %d %d", &lm, &tm, &rm, &bm) == 4)
grid->margin(lm, tm, rm, bm);
} else if (!strcmp(c,"gap")) {
int rg, cg;
if (sscanf(f.read_word(),"%d %d", &rg, &cg))
if (sscanf(f.read_word(),"%d %d", &rg, &cg) == 2)
grid->gap(rg, cg);
} else if (!strcmp(c,"rowheights")) {
int rows = grid->rows();
f.read_word(1); // "{"
for (int i=0; i<rows; i++) grid->row_height(i, f.read_int());
f.read_word(1); // "}"
// TODO: add row_weight, row_gap, col_width, col_weight, col_gap
} else {
super::read_property(f, c);
}
@ -95,25 +118,44 @@ void Fl_Grid_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child,
Fl_Grid *grid;
Fl_Widget *child_widget;
Fl_Grid::Cell *cell;
if (!child->is_true_widget()) goto err;
if (!child->is_true_widget()) return super::write_parent_properties(f, child, true);
grid = (Fl_Grid*)o;
child_widget = ((Fl_Widget_Type*)child)->o;
cell = grid->cell(child_widget);
if (!cell) goto err;
if (!cell) return super::write_parent_properties(f, child, true);
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());
int v = cell->colspan();
if (v>1) {
f.write_indent(level+3);
f.write_string("colspan %d", v);
}
v = cell->rowspan();
if (v>1) {
f.write_indent(level+3);
f.write_string("rowspan %d", v);
}
v = (int)cell->align();
if (v!=FL_GRID_FILL) {
f.write_indent(level+3);
f.write_string("align %d", v);
}
int min_w = 0, min_h = 0;
cell->minimum_size(&min_w, &min_h);
if (min_w!=20 || min_h!=20) {
f.write_indent(level+3);
f.write_string("minsize {%d %d}", min_w, min_h);
}
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) {
@ -130,7 +172,30 @@ void Fl_Grid_Type::read_parent_properties(Fd_Project_Reader &f, Fl_Type *child,
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);
if (!strcmp(property, "colspan")) {
colspan = atoi(f.read_word());
property = f.read_word();
}
if (!strcmp(property, "rowspan")) {
rowspan = atoi(f.read_word());
property = f.read_word();
}
if (!strcmp(property, "align")) {
align = atoi(f.read_word());
property = f.read_word();
}
if (row>=0 && col>=0) {
Fl_Grid::Cell *cell = grid->widget(child_widget, row, col, rowspan, colspan, (Fl_Grid_Align)align);
if (cell) {
int min_w = 20, min_h = 20;
if (!strcmp(property, "minsize")) {
const char *value = f.read_word();
sscanf(value, "%d %d", &min_w, &min_h);
property = f.read_word();
}
cell->minimum_size(min_w, min_h);
}
}
super::read_parent_properties(f, child, property);
}
@ -138,7 +203,8 @@ void Fl_Grid_Type::write_code1(Fd_Code_Writer& f) {
const char *var = name() ? name() : "o";
Fl_Grid* grid = (Fl_Grid*)o;
Fl_Widget_Type::write_code1(f);
f.write_c("%s%s->layout(%d, %d);\n", f.indent(), var, grid->rows(), grid->cols());
int i, rows = grid->rows(), cols = grid->cols();
f.write_c("%s%s->layout(%d, %d);\n", f.indent(), var, rows, cols);
int lm, tm, rm, bm;
grid->margin(&lm, &tm, &rm, &bm);
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
@ -147,16 +213,34 @@ void Fl_Grid_Type::write_code1(Fd_Code_Writer& f) {
grid->gap(&rg, &cg);
if (rg!=0 || cg!=0)
f.write_c("%s%s->gap(%d, %d);\n", f.indent(), var, rg, cg);
for (i=0; i<rows; i++) if (grid->row_height(i)!=0) break;
if (i<rows) {
f.write_c("%sstatic const int rowheights[] = { %d", f.indent(), grid->row_height(0));
for (i=1; i<rows; i++) f.write_c(", %d", grid->row_height(i));
f.write_c(" };\n");
f.write_c("%s%s->row_height(rowheights, %d);\n", f.indent(), var, rows);
}
// TODO: add row_weight, row_gap, col_width, col_weight, col_gap
}
void Fl_Grid_Type::write_code2(Fd_Code_Writer& f) {
const char *var = name() ? name() : "o";
Fl_Grid* grid = (Fl_Grid*)o;
bool first_cell = true;
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());
if (first_cell) {
f.write_c("%sFl_Grid::Cell *cell = NULL;\n", f.indent());
first_cell = false;
}
f.write_c("%scell = %s->widget(%s->child(%d), %d, %d, %d, %d, %d);\n",
f.indent(), var, var, i, cell->row(), cell->col(),
cell->rowspan(), cell->colspan(), cell->align());
int min_w = 20, min_h = 20;
cell->minimum_size(&min_w, &min_h);
f.write_c("%sif (cell) cell->minimum_size(%d, %d);\n", f.indent(), min_w, min_h);
}
}
super::write_code2(f);
@ -192,12 +276,17 @@ void Fl_Grid_Type::child_resized(Fl_Widget_Type *child_type) {
Fl_Grid *grid = (Fl_Grid*)o;
Fl_Widget *child = child_type->o;
Fl_Grid::Cell *cell = grid->cell(child);
if (cell) {
short r = cell->row(), c = cell->col(), rs = cell->rowspan(), cs = cell->colspan();
Fl_Grid_Align a = cell->align();
grid->remove_cell(r, c);
grid->widget(child, r, c, rs, cs, a);
} // else unmanaged by Fl_Grid
if (cell && ((cell->align()&FL_GRID_HORIZONTAL)==0)) {
int min_w = 0, min_h = 0;
cell->minimum_size(&min_w, &min_h);
cell->minimum_size(min_w, child->h());
}
if (cell && ((cell->align()&FL_GRID_VERTICAL)==0)) {
int min_w = 0, min_h = 0;
cell->minimum_size(&min_w, &min_h);
cell->minimum_size(child->w(), min_h);
}
// TODO: if the user resizes an FL_GRID_FILL widget, should we change the alignment?
}
void grid_cb(Fl_Value_Input* i, void* v, int what) {
@ -298,6 +387,8 @@ void grid_cols_cb(Fluid_Coord_Input* i, void* v) {
grid_cb(i, v, 7);
}
extern Fluid_Coord_Input *widget_grid_row_input, *widget_grid_col_input;
void grid_child_cb(Fluid_Coord_Input* i, void* v, int what) {
if ( !current_widget
|| !current_widget->parent
@ -315,32 +406,41 @@ void grid_child_cb(Fluid_Coord_Input* i, void* v, int what) {
case 9: v = cell->col(); break;
case 10: v = cell->rowspan(); break;
case 11: v = cell->colspan(); break;
case 12: cell->minimum_size(&v, NULL); break;
case 13: cell->minimum_size(NULL, &v); break;
}
}
i->value(v);
} else {
int mod = 0;
int v2 = 0, old_v = -1, v = (int)i->value();
int v2 = -1, old_v = -1, v = i->value();
if (i==widget_grid_row_input) v2 = widget_grid_col_input->value();
if (i==widget_grid_col_input) v2 = widget_grid_row_input->value();
Fl_Grid::Cell *cell = g->cell(current_widget->o);
Fl_Grid::Cell *new_cell = NULL;
if (cell) {
switch (what) {
case 8: old_v = cell->row(); v2 = cell->col(); break;
case 9: old_v = cell->col(); v2 = cell->row(); break;
case 10: old_v = cell->rowspan(); break;
case 11: old_v = cell->colspan(); break;
case 12: cell->minimum_size(&old_v, &v2); break;
case 13: cell->minimum_size(&v2, &old_v); 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;
case 10: cell->rowspan(v); break;
case 11: cell->colspan(v); break;
case 8: if (v>=0 && v2>=0) new_cell = g->widget(current_widget->o, v, v2); break;
case 9: if (v>=0 && v2>=0) new_cell = g->widget(current_widget->o, v2, v); break;
case 10: if (cell) cell->rowspan(v); break;
case 11: if (cell) cell->colspan(v); break;
case 12: if (cell) cell->minimum_size(v, v2); break;
case 13: if (cell) cell->minimum_size(v2, v); break;
}
if (!cell && new_cell)
new_cell->minimum_size(20, 20);
g->need_layout(true);
g->redraw();
mod = 1;
if (mod) set_modflag(1);
set_modflag(1);
}
}
}
@ -356,10 +456,47 @@ void grid_set_rowspan_cb(Fluid_Coord_Input* i, void* v) {
void grid_set_colspan_cb(Fluid_Coord_Input* i, void* v) {
grid_child_cb(i, v, 11);
}
void grid_align_cb(Fl_Choice* i, void* v) {
void grid_set_min_wdt_cb(Fluid_Coord_Input* i, void* v) {
grid_child_cb(i, v, 12);
}
void grid_set_min_hgt_cb(Fluid_Coord_Input* i, void* v) {
grid_child_cb(i, v, 13);
}
void grid_row_height(Fluid_Coord_Input* i, void* v) {
void grid_align_cb(Fl_Choice* i, void* v) {
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 a = FL_GRID_FILL;
Fl_Grid::Cell *cell = g->cell(current_widget->o);
if (cell) {
a = cell->align();
}
const Fl_Menu_Item *mi = i->find_item_with_argument(a);
if (mi) i->value(mi);
} else {
int v = FL_GRID_FILL, old_v = FL_GRID_FILL;
const Fl_Menu_Item *mi = i->mvalue();
if (mi) v = (int)mi->argument();
Fl_Grid::Cell *cell = g->cell(current_widget->o);
if (cell) {
old_v = cell->align();
}
if (old_v != v) {
cell->align((Fl_Grid_Align)v);
g->need_layout(true);
g->redraw();
set_modflag(1);
}
}
}
void grid_row_col_cb(Fluid_Coord_Input* i, void* v, int what) {
if ( !current_widget
|| !current_widget->parent
|| !current_widget->parent->is_a(ID_Grid))
@ -370,25 +507,63 @@ void grid_row_height(Fluid_Coord_Input* i, void* v) {
Fl_Grid::Cell *cell = g->cell(current_widget->o);
if (v == LOAD) {
if (cell) {
i->value(g->row_height(cell->row()));
int v = 0;
switch (what) {
case 0: v = g->row_height(cell->row()); break;
case 1: v = g->row_weight(cell->row()); break;
case 2: v = g->row_gap(cell->row()); break;
case 3: v = g->col_width(cell->col()); break;
case 4: v = g->col_weight(cell->col()); break;
case 5: v = g->col_gap(cell->col()); break;
}
i->value(v);
i->activate();
} else {
i->deactivate();
}
} else {
if (cell) {
g->row_height(cell->row(), i->value());
int v = i->value(), old_v = 0;
switch (what) {
case 0: old_v = g->row_height(cell->row()); break;
case 1: old_v = g->row_weight(cell->row()); break;
case 2: old_v = g->row_gap(cell->row()); break;
case 3: old_v = g->col_width(cell->col()); break;
case 4: old_v = g->col_weight(cell->col()); break;
case 5: old_v = g->col_gap(cell->col()); break;
}
if (old_v != v) {
switch (what) {
case 0: g->row_height(cell->row(), v); break;
case 1: g->row_weight(cell->row(), v); break;
case 2: g->row_gap(cell->row(), v); break;
case 3: g->col_width(cell->col(), v); break;
case 4: g->col_weight(cell->col(), v); break;
case 5: g->col_gap(cell->col(), v); break;
}
g->need_layout(true);
g->redraw();
set_modflag(1);
}
}
}
}
void grid_row_height(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 0);
}
void grid_row_weight(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 1);
}
void grid_row_gap(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 2);
}
void grid_col_width(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 3);
}
void grid_col_weight(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 4);
}
void grid_col_gap(Fluid_Coord_Input* i, void* v) {
grid_row_col_cb(i, v, 5);
}

View File

@ -118,10 +118,13 @@ Fl_Tabs *widget_tabs_repo=(Fl_Tabs *)0;
Fl_Group *widget_tab_grid=(Fl_Group *)0;
Fluid_Coord_Input *widget_grid_row_input=(Fluid_Coord_Input *)0;
Fluid_Coord_Input *widget_grid_col_input=(Fluid_Coord_Input *)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},
@ -1138,37 +1141,42 @@ access the Widget pointer and \'v\' to access the user value.");
{ 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_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
{ Fl_Group* o = new Fl_Group(96, 110, 314, 20, "Location:");
o->labelfont(1);
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
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
{ widget_grid_row_input = new Fluid_Coord_Input(96, 110, 55, 20, "Row:");
widget_grid_row_input->box(FL_DOWN_BOX);
widget_grid_row_input->color(FL_BACKGROUND2_COLOR);
widget_grid_row_input->selection_color(FL_SELECTION_COLOR);
widget_grid_row_input->labeltype(FL_NORMAL_LABEL);
widget_grid_row_input->labelfont(0);
widget_grid_row_input->labelsize(11);
widget_grid_row_input->labelcolor(FL_FOREGROUND_COLOR);
widget_grid_row_input->textsize(11);
widget_grid_row_input->callback((Fl_Callback*)grid_set_row_cb);
widget_grid_row_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
widget_grid_row_input->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* widget_grid_row_input
{ widget_grid_col_input = new Fluid_Coord_Input(156, 110, 55, 20, "Column:");
widget_grid_col_input->box(FL_DOWN_BOX);
widget_grid_col_input->color(FL_BACKGROUND2_COLOR);
widget_grid_col_input->selection_color(FL_SELECTION_COLOR);
widget_grid_col_input->labeltype(FL_NORMAL_LABEL);
widget_grid_col_input->labelfont(0);
widget_grid_col_input->labelsize(11);
widget_grid_col_input->labelcolor(FL_FOREGROUND_COLOR);
widget_grid_col_input->textsize(11);
widget_grid_col_input->callback((Fl_Callback*)grid_set_col_cb);
widget_grid_col_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
widget_grid_col_input->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* widget_grid_col_input
{ Fl_Choice* o = new Fl_Choice(215, 110, 185, 20, "Align:");
o->down_box(FL_BORDER_BOX);
o->labelsize(11);
@ -1188,7 +1196,7 @@ access the Widget pointer and \'v\' to access the user value.");
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:");
{ Fl_Group* o = new Fl_Group(96, 145, 314, 20, "Cell Span:");
o->labelfont(1);
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
@ -1225,75 +1233,49 @@ access the Widget pointer and \'v\' to access the user value.");
} // 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:");
{ Fl_Group* o = new Fl_Group(96, 180, 314, 20, "Size:");
o->labelfont(1);
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
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->callback((Fl_Callback*)grid_row_height);
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->callback((Fl_Callback*)grid_row_weight);
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->callback((Fl_Callback*)grid_row_gap);
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);
{ Fl_Box* o = new Fl_Box(400, 180, 1, 20);
o->hide();
Fl_Group::current()->resizable(o);
} // Fl_Box* o
{ Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 180, 55, 20, "Min.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->callback((Fl_Callback*)grid_set_min_wdt_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, 180, 55, 20, "Min.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->callback((Fl_Callback*)grid_set_min_hgt_cb);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
o->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* o
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(96, 250, 314, 20, "Column:");
{ Fl_Box* o = new Fl_Box(96, 214, 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, 250, 314, 20, "Row:");
o->labelfont(1);
o->labelsize(11);
o->callback((Fl_Callback*)propagate_load);
@ -1311,7 +1293,7 @@ access the Widget pointer and \'v\' to access the user value.");
o->when(FL_WHEN_RELEASE);
o->deactivate();
} // Fluid_Coord_Input* o
{ Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 250, 55, 20, "Width:");
{ Fluid_Coord_Input* o = new Fluid_Coord_Input(156, 250, 55, 20, "Height:");
o->box(FL_DOWN_BOX);
o->color(FL_BACKGROUND2_COLOR);
o->selection_color(FL_SELECTION_COLOR);
@ -1320,7 +1302,7 @@ access the Widget pointer and \'v\' to access the user value.");
o->labelsize(11);
o->labelcolor(FL_FOREGROUND_COLOR);
o->textsize(11);
o->callback((Fl_Callback*)grid_col_width);
o->callback((Fl_Callback*)grid_row_height);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
o->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* o
@ -1333,7 +1315,7 @@ access the Widget pointer and \'v\' to access the user value.");
o->labelsize(11);
o->labelcolor(FL_FOREGROUND_COLOR);
o->textsize(11);
o->callback((Fl_Callback*)grid_col_weight);
o->callback((Fl_Callback*)grid_row_weight);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
o->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* o
@ -1346,7 +1328,7 @@ access the Widget pointer and \'v\' to access the user value.");
o->labelsize(11);
o->labelcolor(FL_FOREGROUND_COLOR);
o->textsize(11);
o->callback((Fl_Callback*)grid_col_gap);
o->callback((Fl_Callback*)grid_row_gap);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
o->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* o
@ -1356,11 +1338,69 @@ access the Widget pointer and \'v\' to access the user value.");
} // 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!");
{ Fl_Group* o = new Fl_Group(96, 285, 314, 20, "Column:");
o->labelfont(1);
o->labelsize(11);
o->labelcolor((Fl_Color)1);
} // Fl_Box* o
o->callback((Fl_Callback*)propagate_load);
o->align(Fl_Align(FL_ALIGN_LEFT));
{ Fluid_Coord_Input* o = new Fluid_Coord_Input(96, 285, 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, 285, 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->callback((Fl_Callback*)grid_col_width);
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, 285, 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->callback((Fl_Callback*)grid_col_weight);
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, 285, 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->callback((Fl_Callback*)grid_col_gap);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
o->when(FL_WHEN_RELEASE);
} // Fluid_Coord_Input* o
{ Fl_Box* o = new Fl_Box(400, 285, 1, 20);
o->hide();
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
} // Fl_Group* o
widget_tab_grid->end();
} // Fl_Group* widget_tab_grid
o->hide();

View File

@ -874,7 +874,7 @@ wCallback->do_callback(wCallback, v);} open
}
}
}
Fl_Tabs widget_tabs_repo {selected
Fl_Tabs widget_tabs_repo {open
xywh {10 10 400 350} hide
code0 {o->hide();}
} {
@ -886,26 +886,30 @@ wCallback->do_callback(wCallback, v);} open
callback propagate_load open
xywh {10 30 400 330} labelsize 11
} {
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 {} {
label {Location:}
callback propagate_load open
xywh {96 110 314 20} labelfont 1 labelsize 11 align 4
} {
Fl_Input {} {
Fl_Input widget_grid_row_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 {} {
Fl_Input widget_grid_col_input {
label {Column:}
callback grid_set_col_cb
callback grid_set_col_cb selected
xywh {156 110 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Choice {} {
label {Align:}
callback grid_align_cb
callback grid_align_cb open
xywh {215 110 185 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11
} {
MenuItem {} {
@ -918,11 +922,6 @@ wCallback->do_callback(wCallback, v);} open
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
@ -983,7 +982,7 @@ wCallback->do_callback(wCallback, v);} open
xywh {96 74 155 20} labelfont 1 labelsize 12 align 20
}
Fl_Group {} {
label {Size:}
label {Cell Span:}
callback propagate_load open
xywh {96 145 314 20} labelfont 1 labelsize 11 align 4
} {
@ -1003,45 +1002,34 @@ wCallback->do_callback(wCallback, v);} open
class Fluid_Coord_Input
}
}
Fl_Group {} {
label {Size:}
callback propagate_load open
xywh {96 180 314 20} labelfont 1 labelsize 11 align 4
} {
Fl_Box {} {
xywh {400 180 1 20} hide resizable
}
Fl_Input {} {
label {Min.Width:}
callback grid_set_min_wdt_cb
xywh {96 180 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Min.Height:}
callback grid_set_min_hgt_cb
xywh {156 180 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
xywh {96 214 155 20} labelfont 1 labelsize 12 align 20
}
Fl_Group {} {
label {Row:}
callback propagate_load 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:}
callback grid_row_height
xywh {156 215 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Weight:}
callback grid_row_weight
xywh {216 215 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Gap:}
callback grid_row_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:}
callback propagate_load open
xywh {96 250 314 20} labelfont 1 labelsize 11 align 4
} {
Fl_Input {} {
@ -1050,20 +1038,20 @@ wCallback->do_callback(wCallback, v);} open
class Fluid_Coord_Input
}
Fl_Input {} {
label {Width:}
callback grid_col_width
label {Height:}
callback grid_row_height
xywh {156 250 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Weight:}
callback grid_col_weight
callback grid_row_weight
xywh {216 250 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Gap:}
callback grid_col_gap
callback grid_row_gap
xywh {276 250 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
@ -1071,13 +1059,41 @@ wCallback->do_callback(wCallback, v);} open
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 {} {
label {Column:}
callback propagate_load open
xywh {96 285 314 20} labelfont 1 labelsize 11 align 4
} {
Fl_Input {} {
label Index
xywh {96 285 55 20} labelsize 11 align 5 textsize 11 deactivate
class Fluid_Coord_Input
}
Fl_Input {} {
label {Width:}
callback grid_col_width
xywh {156 285 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Weight:}
callback grid_col_weight
xywh {216 285 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Input {} {
label {Gap:}
callback grid_col_gap
xywh {276 285 55 20} labelsize 11 align 5 textsize 11
class Fluid_Coord_Input
}
Fl_Box {} {
xywh {400 285 1 20} hide resizable
}
}
}
}
Fl_Group {} {open
Fl_Group {} {
xywh {10 370 400 20} labelsize 11
} {
Fl_Button wLiveMode {

1167
fluid/widget_panel.fl.bak Normal file

File diff suppressed because it is too large Load Diff

View File

@ -146,10 +146,14 @@ 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 Fluid_Coord_Input *widget_grid_row_input;
extern void grid_set_col_cb(Fluid_Coord_Input*, void*);
extern Fluid_Coord_Input *widget_grid_col_input;
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 grid_set_min_wdt_cb(Fluid_Coord_Input*, void*);
extern void grid_set_min_hgt_cb(Fluid_Coord_Input*, void*);
extern void grid_row_height(Fluid_Coord_Input*, void*);
extern void grid_row_weight(Fluid_Coord_Input*, void*);
extern void grid_row_gap(Fluid_Coord_Input*, void*);

View File

@ -922,6 +922,11 @@ void Fl_Grid::col_width(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::col_width(int col) const {
if (col >= 0 && col < cols_) return Cols_[col].minw_;
return 0;
}
/**
Set the weight of a column.
@ -987,6 +992,11 @@ void Fl_Grid::col_weight(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::col_weight(int col) const {
if (col >= 0 && col < cols_) return Cols_[col].weight_;
return 0;
}
/**
Set the gap of column \c col.
@ -1018,6 +1028,11 @@ void Fl_Grid::col_gap(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::col_gap(int col) const {
if (col >= 0 && col < cols_) return Cols_[col].gap_;
return 0;
}
/**
Set the minimal row height of row \c row.
@ -1056,6 +1071,11 @@ void Fl_Grid::row_height(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::row_height(int row) const {
if (row >= 0 && row < rows_) return Rows_[row].minh_;
return 0;
}
/**
Set the row weight of row \c row.
@ -1077,7 +1097,6 @@ void Fl_Grid::row_weight(int row, int value) {
\see Fl_Grid::col_weight(const int *value, size_t size) for
handling of the \p value array and \p size.
*/
void Fl_Grid::row_weight(const int *value, size_t size) {
Row *r = Rows_;
for (int i = 0; i < rows_; i++, value++, r++) {
@ -1088,6 +1107,11 @@ void Fl_Grid::row_weight(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::row_weight(int row) const {
if (row >= 0 && row < rows_) return Rows_[row].weight_;
return 0;
}
/**
Set the gap of row \c row.
@ -1120,6 +1144,11 @@ void Fl_Grid::row_gap(const int *value, size_t size) {
need_layout(1);
}
int Fl_Grid::row_gap(int row) const {
if (row >= 0 && row < rows_) return Rows_[row].gap_;
return 0;
}
/**
Output layout information of this Fl_Grid to stderr.