diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-11-05 14:53:42 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-11-05 14:53:47 +0100 |
| commit | 032d3f5cf45a08ac35edf2cf6b2014730955ec2c (patch) | |
| tree | 47900b9171cd981c211b601a5fd70f4811069b49 | |
| parent | 8c8742740362159f63c802cc38aa0fdd6b09ea5a (diff) | |
FLUID: Fixes child properties reader.
| -rw-r--r-- | fluid/Fl_Grid_Type.cxx | 77 | ||||
| -rw-r--r-- | fluid/Fl_Grid_Type.h | 2 | ||||
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 1 | ||||
| -rw-r--r-- | fluid/Fl_Type.cxx | 24 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 2 | ||||
| -rw-r--r-- | fluid/code.cxx | 1 | ||||
| -rw-r--r-- | fluid/file.cxx | 3 |
7 files changed, 55 insertions, 55 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--; -} - diff --git a/fluid/Fl_Grid_Type.h b/fluid/Fl_Grid_Type.h index 6f509ff84..5ab87b8a5 100644 --- a/fluid/Fl_Grid_Type.h +++ b/fluid/Fl_Grid_Type.h @@ -46,7 +46,7 @@ public: 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 read_parent_property(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_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index 8cd63d95f..0a21ed296 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -24,7 +24,6 @@ #include "fluid.h" #include "Fl_Window_Type.h" -#include "alignment_panel.h" #include "file.h" #include "code.h" #include "Fluid_Image.h" diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index dc514e90a..2b8fee400 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -786,8 +786,11 @@ void Fl_Type::read_property(Fd_Project_Reader &f, const char *c) { if (parent) { const char *cc = f.read_word(1); if (strcmp(cc, "{")==0) { - cc = f.read_word(); - parent->read_parent_properties(f, this, cc); + for (;;) { + cc = f.read_word(); + if (!cc || cc[0]==0 || strcmp(cc, "}")==0) break; + parent->read_parent_property(f, this, cc); + } } else { f.read_error("'parent_properties' must be followed by '{'"); } @@ -850,27 +853,22 @@ void Fl_Type::write_parent_properties(Fd_Project_Writer &f, Fl_Type *child, bool // } } -/** Read parent per-child properties. +/** Read one parent per-child property. 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. + method reads back those properties. This function is virtual, so if a Type + does not support a property, it will propagate to its super class. \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) + \see Fl_Grid_Type::read_parent_property(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 Fl_Type::read_parent_property(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 - } + f.read_error("Unknown parent property \"%s\"", property); } diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index f1ab02025..ea6d083d9 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -212,7 +212,7 @@ public: 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 void read_parent_property(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/code.cxx b/fluid/code.cxx index 0caf267f6..c9590f178 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -19,7 +19,6 @@ #include "Fl_Group_Type.h" #include "Fl_Window_Type.h" #include "Fl_Function_Type.h" -#include "alignment_panel.h" #include "file.h" #include "undo.h" diff --git a/fluid/file.cxx b/fluid/file.cxx index 9694d5623..3f0fafd47 100644 --- a/fluid/file.cxx +++ b/fluid/file.cxx @@ -504,7 +504,8 @@ void Fd_Project_Reader::read_error(const char *format, ...) { will return the string `"{"`, if clear, a `{` is seen as the start of a word \return a pointer to the internal buffer, containing a copy of the word. Don't free the buffer! Note that most (all?) other file operations will - overwrite this buffer. + overwrite this buffer. If wantbrace is not set, but we read a leading '{', + the returned string will be stripped of its leading and trailing braces. */ const char *Fd_Project_Reader::read_word(int wantbrace) { int x; |
