FLUID: Fixes child properties reader.
This commit is contained in:
parent
8c87427403
commit
032d3f5cf4
@ -33,11 +33,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// ---- Fl_Grid_Type --------------------------------------------------- MARK: -
|
// ---- Fl_Grid_Proxy --------------------------------------------------- MARK: -
|
||||||
|
|
||||||
const char grid_type_name[] = "Fl_Grid";
|
|
||||||
|
|
||||||
Fl_Grid_Type Fl_Grid_type; // the "factory"
|
|
||||||
|
|
||||||
// Override group's resize behavior to do nothing to children:
|
// Override group's resize behavior to do nothing to children:
|
||||||
void Fl_Grid_Proxy::resize(int X, int Y, int W, int H) {
|
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_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() {
|
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
|
// 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
|
// property is added. In the current setup, all the remaining properties
|
||||||
// will be skipped
|
// 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()) {
|
if (!child->is_true_widget()) {
|
||||||
super::read_parent_properties(f, child, property);
|
super::read_parent_property(f, child, property);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Fl_Grid *grid = (Fl_Grid*)o;
|
Fl_Grid *grid = (Fl_Grid*)o;
|
||||||
Fl_Widget *child_widget = ((Fl_Widget_Type*)child)->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")) {
|
if (!strcmp(property, "location")) {
|
||||||
|
int row = -1, col = -1;
|
||||||
const char *value = f.read_word();
|
const char *value = f.read_word();
|
||||||
sscanf(value, "%d %d", &row, &col);
|
sscanf(value, "%d %d", &row, &col);
|
||||||
property = f.read_word();
|
Fl_Grid::Cell *cell = grid->widget(child_widget, row, col);
|
||||||
}
|
|
||||||
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) {
|
if (cell) {
|
||||||
int min_w = 20, min_h = 20;
|
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);
|
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) {
|
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,
|
// FIXME: when changing the cell location, and another cell would be overridden,
|
||||||
// don't actually move the cell (hard to implement!) and activate
|
// don't actually move the cell (hard to implement!) and activate
|
||||||
// a red button "replace". If clicked, user gets the option to delete
|
// 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--;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||||
void read_property(Fd_Project_Reader &f, const char *) 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 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 copy_properties() FL_OVERRIDE;
|
||||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "fluid.h"
|
#include "fluid.h"
|
||||||
#include "Fl_Window_Type.h"
|
#include "Fl_Window_Type.h"
|
||||||
#include "alignment_panel.h"
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "code.h"
|
#include "code.h"
|
||||||
#include "Fluid_Image.h"
|
#include "Fluid_Image.h"
|
||||||
|
@ -786,8 +786,11 @@ void Fl_Type::read_property(Fd_Project_Reader &f, const char *c) {
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
const char *cc = f.read_word(1);
|
const char *cc = f.read_word(1);
|
||||||
if (strcmp(cc, "{")==0) {
|
if (strcmp(cc, "{")==0) {
|
||||||
cc = f.read_word();
|
for (;;) {
|
||||||
parent->read_parent_properties(f, this, cc);
|
cc = f.read_word();
|
||||||
|
if (!cc || cc[0]==0 || strcmp(cc, "}")==0) break;
|
||||||
|
parent->read_parent_property(f, this, cc);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
f.read_error("'parent_properties' must be followed by '{'");
|
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
|
A parent widget can store properties for every child that it manages. This
|
||||||
method reads back those properties. The order of properties is significant,
|
method reads back those properties. This function is virtual, so if a Type
|
||||||
but individual properties can be omitted.
|
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_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] f the project file writer
|
||||||
\param[in] child read properties for this child
|
\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
|
\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;
|
(void)child;
|
||||||
for (;;) {
|
f.read_error("Unknown parent property \"%s\"", property);
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ public:
|
|||||||
virtual void write_properties(Fd_Project_Writer &f);
|
virtual void write_properties(Fd_Project_Writer &f);
|
||||||
virtual void read_property(Fd_Project_Reader &f, const char *);
|
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 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 int read_fdesign(const char*, const char*);
|
||||||
virtual void postprocess_read() { }
|
virtual void postprocess_read() { }
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "Fl_Group_Type.h"
|
#include "Fl_Group_Type.h"
|
||||||
#include "Fl_Window_Type.h"
|
#include "Fl_Window_Type.h"
|
||||||
#include "Fl_Function_Type.h"
|
#include "Fl_Function_Type.h"
|
||||||
#include "alignment_panel.h"
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "undo.h"
|
#include "undo.h"
|
||||||
|
|
||||||
|
@ -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
|
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.
|
\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
|
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) {
|
const char *Fd_Project_Reader::read_word(int wantbrace) {
|
||||||
int x;
|
int x;
|
||||||
|
Loading…
Reference in New Issue
Block a user