summaryrefslogtreecommitdiff
path: root/fluid/Fl_Grid_Type.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-11-05 14:53:42 +0100
committerMatthias Melcher <github@matthiasm.com>2023-11-05 14:53:47 +0100
commit032d3f5cf45a08ac35edf2cf6b2014730955ec2c (patch)
tree47900b9171cd981c211b601a5fd70f4811069b49 /fluid/Fl_Grid_Type.cxx
parent8c8742740362159f63c802cc38aa0fdd6b09ea5a (diff)
FLUID: Fixes child properties reader.
Diffstat (limited to 'fluid/Fl_Grid_Type.cxx')
-rw-r--r--fluid/Fl_Grid_Type.cxx77
1 files changed, 40 insertions, 37 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx
index c12e7974f..33c061291 100644
--- a/fluid/Fl_Grid_Type.cxx
+++ b/fluid/Fl_Grid_Type.cxx
@@ -33,11 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
-// ---- Fl_Grid_Type --------------------------------------------------- MARK: -
-
-const char grid_type_name[] = "Fl_Grid";
-
-Fl_Grid_Type Fl_Grid_type; // the "factory"
+// ---- Fl_Grid_Proxy --------------------------------------------------- MARK: -
// Override group's resize behavior to do nothing to children:
void Fl_Grid_Proxy::resize(int X, int Y, int W, int H) {
@@ -69,6 +65,12 @@ void Fl_Grid_Proxy::draw_overlay() {
fl_color(grid_color);
}
+// ---- Fl_Grid_Type --------------------------------------------------- MARK: -
+
+const char grid_type_name[] = "Fl_Grid";
+
+Fl_Grid_Type Fl_Grid_type; // the "factory"
+
Fl_Grid_Type::Fl_Grid_Type() {
}
@@ -254,45 +256,43 @@ void Fl_Grid_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child,
// NOTE: we have to do this in a loop just as ::read_property() in case a new
// property is added. In the current setup, all the remaining properties
// will be skipped
-void Fl_Grid_Type::read_parent_properties(Fd_Project_Reader &f, Fl_Type *child, const char *property) {
+void Fl_Grid_Type::read_parent_property(Fd_Project_Reader &f, Fl_Type *child, const char *property) {
if (!child->is_true_widget()) {
- super::read_parent_properties(f, child, property);
+ super::read_parent_property(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")) {
+ int row = -1, col = -1;
const char *value = f.read_word();
sscanf(value, "%d %d", &row, &col);
- property = f.read_word();
- }
- 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);
+ Fl_Grid::Cell *cell = grid->widget(child_widget, row, col);
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);
}
+ } else if (!strcmp(property, "colspan")) {
+ int colspan = atoi(f.read_word());
+ Fl_Grid::Cell *cell = grid->cell(child_widget);
+ if (cell) cell->colspan(colspan);
+ } else if (!strcmp(property, "rowspan")) {
+ int rowspan = atoi(f.read_word());
+ Fl_Grid::Cell *cell = grid->cell(child_widget);
+ if (cell) cell->rowspan(rowspan);
+ } else if (!strcmp(property, "align")) {
+ int align = atoi(f.read_word());
+ Fl_Grid::Cell *cell = grid->cell(child_widget);
+ if (cell) cell->align((Fl_Grid_Align)align);
+ } if (!strcmp(property, "minsize")) {
+ int min_w = 20, min_h = 20;
+ const char *value = f.read_word();
+ sscanf(value, "%d %d", &min_w, &min_h);
+ Fl_Grid::Cell *cell = grid->cell(child_widget);
+ if (cell) cell->minimum_size(min_w, min_h);
+ } else {
+ super::read_parent_property(f, child, property);
}
- super::read_parent_properties(f, child, property);
}
void Fl_Grid_Type::write_code1(Fd_Code_Writer& f) {
@@ -520,6 +520,15 @@ void Fl_Grid_Type::keyboard_move_child(Fl_Widget_Type *child, int key) {
}
}
+void Fl_Grid_Type::layout_widget() {
+ allow_layout++;
+ ((Fl_Grid*)o)->layout();
+ allow_layout--;
+}
+
+
+// ---- Widget Panel Callbacks ---------------------------------------- MARK: -
+
// FIXME: when changing the cell location, and another cell would be overridden,
// don't actually move the cell (hard to implement!) and activate
// a red button "replace". If clicked, user gets the option to delete
@@ -745,9 +754,3 @@ void grid_align_vertical_cb(Fl_Choice* i, void* v) {
}
}
-void Fl_Grid_Type::layout_widget() {
- allow_layout++;
- ((Fl_Grid*)o)->layout();
- allow_layout--;
-}
-