mirror of
https://github.com/fltk/fltk.git
synced 2026-05-24 00:06:20 +08:00
Removing all globals in file writer (#653 ) Fix some static analyser complaints Valgrind: handle width==0 in GfxDrivers on Wayland and X11 Don't use `Fl_Input_::static_value`, it accesses previous buffer that may be deleted Project file write encapsulated, removing globals Encapsulating project file reader, removing states in glbals Project i/o increased source code readability
This commit is contained in:
+193
-193
File diff suppressed because it is too large
Load Diff
+31
-31
@@ -50,8 +50,8 @@ public:
|
||||
Fl_Function_Type();
|
||||
~Fl_Function_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void open() FL_OVERRIDE;
|
||||
int ismain() {return name_ == 0;}
|
||||
const char *type_name() FL_OVERRIDE {return "Function";}
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
int is_code_block() const FL_OVERRIDE {return 1;}
|
||||
int is_public() const FL_OVERRIDE;
|
||||
int pixmapID() FL_OVERRIDE { return 7; }
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int has_signature(const char *, const char*) const;
|
||||
};
|
||||
|
||||
@@ -78,9 +78,9 @@ class Fl_Code_Type : public Fl_Type {
|
||||
public:
|
||||
Fl_Code_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write() FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE { }
|
||||
void write(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE { }
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "code";}
|
||||
int is_code_block() const FL_OVERRIDE {return 0;}
|
||||
@@ -101,16 +101,16 @@ public:
|
||||
Fl_CodeBlock_Type();
|
||||
~Fl_CodeBlock_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "codeblock";}
|
||||
int is_code_block() const FL_OVERRIDE {return 1;}
|
||||
int is_parent() const FL_OVERRIDE {return 1;}
|
||||
int is_public() const FL_OVERRIDE { return -1; }
|
||||
int pixmapID() FL_OVERRIDE { return 9; }
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
};
|
||||
|
||||
// ---- Fl_Decl_Type declaration
|
||||
@@ -124,12 +124,12 @@ protected:
|
||||
public:
|
||||
Fl_Decl_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE { }
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE { }
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "decl";}
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int is_public() const FL_OVERRIDE;
|
||||
int pixmapID() FL_OVERRIDE { return 10; }
|
||||
};
|
||||
@@ -144,12 +144,12 @@ public:
|
||||
Fl_Data_Type();
|
||||
~Fl_Data_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE {}
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE {}
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "data";}
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int pixmapID() FL_OVERRIDE { return 49; }
|
||||
};
|
||||
|
||||
@@ -163,12 +163,12 @@ public:
|
||||
Fl_DeclBlock_Type();
|
||||
~Fl_DeclBlock_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "declblock";}
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int is_parent() const FL_OVERRIDE {return 1;}
|
||||
int is_decl_block() const FL_OVERRIDE {return 1;}
|
||||
int is_public() const FL_OVERRIDE;
|
||||
@@ -184,13 +184,13 @@ class Fl_Comment_Type : public Fl_Type {
|
||||
public:
|
||||
Fl_Comment_Type();
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE { }
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE { }
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "comment";}
|
||||
const char *title() FL_OVERRIDE; // string for browser
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int is_public() const FL_OVERRIDE { return 1; }
|
||||
int is_comment() const FL_OVERRIDE { return 1; }
|
||||
int pixmapID() FL_OVERRIDE { return 46; }
|
||||
@@ -211,8 +211,8 @@ public:
|
||||
Fl_Class_Type* parent_class; // save class if nested
|
||||
//
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void open() FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "class";}
|
||||
int is_parent() const FL_OVERRIDE {return 1;}
|
||||
@@ -220,8 +220,8 @@ public:
|
||||
int is_class() const FL_OVERRIDE {return 1;}
|
||||
int is_public() const FL_OVERRIDE;
|
||||
int pixmapID() FL_OVERRIDE { return 12; }
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
|
||||
// class prefix attribute access
|
||||
void prefix(const char* p);
|
||||
|
||||
+51
-51
@@ -131,18 +131,18 @@ void ungroup_cb(Fl_Widget *, void *) {
|
||||
set_modflag(1);
|
||||
}
|
||||
|
||||
void Fl_Group_Type::write_code1() {
|
||||
Fl_Widget_Type::write_code1();
|
||||
void Fl_Group_Type::write_code1(Fd_Code_Writer& f) {
|
||||
Fl_Widget_Type::write_code1(f);
|
||||
}
|
||||
|
||||
void Fl_Group_Type::write_code2() {
|
||||
void Fl_Group_Type::write_code2(Fd_Code_Writer& f) {
|
||||
const char *var = name() ? name() : "o";
|
||||
write_extra_code();
|
||||
write_c("%s%s->end();\n", indent(), var);
|
||||
write_extra_code(f);
|
||||
f.write_c("%s%s->end();\n", f.indent(), var);
|
||||
if (resizable()) {
|
||||
write_c("%sFl_Group::current()->resizable(%s);\n", indent(), var);
|
||||
f.write_c("%sFl_Group::current()->resizable(%s);\n", f.indent(), var);
|
||||
}
|
||||
write_block_close();
|
||||
write_block_close(f);
|
||||
}
|
||||
|
||||
// This is called when o is created. If it is in the tab group make
|
||||
@@ -247,95 +247,95 @@ void Fl_Flex_Type::copy_properties()
|
||||
d->gap( s->gap() );
|
||||
}
|
||||
|
||||
void Fl_Flex_Type::write_properties()
|
||||
void Fl_Flex_Type::write_properties(Fd_Project_Writer &f)
|
||||
{
|
||||
Fl_Group_Type::write_properties();
|
||||
Fl_Flex* f = (Fl_Flex*)o;
|
||||
Fl_Group_Type::write_properties(f);
|
||||
Fl_Flex* flex = (Fl_Flex*)o;
|
||||
int lm, tm, rm, bm;
|
||||
f->margin(&lm, &tm, &rm, &bm);
|
||||
flex->margin(&lm, &tm, &rm, &bm);
|
||||
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
|
||||
write_string("margin {%d %d %d %d}", lm, tm, rm, bm);
|
||||
if (f->gap())
|
||||
write_string("gap %d", f->gap());
|
||||
f.write_string("margin {%d %d %d %d}", lm, tm, rm, bm);
|
||||
if (flex->gap())
|
||||
f.write_string("gap %d", flex->gap());
|
||||
int nSet = 0;
|
||||
for (int i=0; i<f->children(); i++)
|
||||
if (f->fixed(f->child(i)))
|
||||
for (int i=0; i<flex->children(); i++)
|
||||
if (flex->fixed(flex->child(i)))
|
||||
nSet++;
|
||||
if (nSet) {
|
||||
write_string("fixed_size_tuples {%d", nSet);
|
||||
for (int i=0; i<f->children(); i++) {
|
||||
Fl_Widget *ci = f->child(i);
|
||||
if (f->fixed(ci))
|
||||
write_string(" %d %d", i, f->horizontal() ? ci->w() : ci->h());
|
||||
f.write_string("fixed_size_tuples {%d", nSet);
|
||||
for (int i=0; i<flex->children(); i++) {
|
||||
Fl_Widget *ci = flex->child(i);
|
||||
if (flex->fixed(ci))
|
||||
f.write_string(" %d %d", i, flex->horizontal() ? ci->w() : ci->h());
|
||||
}
|
||||
write_string("}");
|
||||
f.write_string("}");
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Flex_Type::read_property(const char *c)
|
||||
void Fl_Flex_Type::read_property(Fd_Project_Reader &f, const char *c)
|
||||
{
|
||||
Fl_Flex* f = (Fl_Flex*)o;
|
||||
Fl_Flex* flex = (Fl_Flex*)o;
|
||||
suspend_auto_layout = 1;
|
||||
if (!strcmp(c,"margin")) {
|
||||
int lm, tm, rm, bm;
|
||||
if (sscanf(read_word(),"%d %d %d %d",&lm,&tm,&rm,&bm) == 4)
|
||||
f->margin(lm, tm, rm, bm);
|
||||
if (sscanf(f.read_word(),"%d %d %d %d",&lm,&tm,&rm,&bm) == 4)
|
||||
flex->margin(lm, tm, rm, bm);
|
||||
} else if (!strcmp(c,"gap")) {
|
||||
int g;
|
||||
if (sscanf(read_word(),"%d",&g))
|
||||
f->gap(g);
|
||||
if (sscanf(f.read_word(),"%d",&g))
|
||||
flex->gap(g);
|
||||
} else if (!strcmp(c,"fixed_size_tuples")) {
|
||||
read_word(1); // must be '{'
|
||||
const char *nStr = read_word(1); // number of indices in table
|
||||
f.read_word(1); // must be '{'
|
||||
const char *nStr = f.read_word(1); // number of indices in table
|
||||
fixedSizeTupleSize = atoi(nStr);
|
||||
fixedSizeTuple = new int[fixedSizeTupleSize*2];
|
||||
for (int i=0; i<fixedSizeTupleSize; i++) {
|
||||
const char *ix = read_word(1); // child at that index is fixed in size
|
||||
const char *ix = f.read_word(1); // child at that index is fixed in size
|
||||
fixedSizeTuple[i*2] = atoi(ix);
|
||||
const char *size = read_word(1); // fixed size of that child
|
||||
const char *size = f.read_word(1); // fixed size of that child
|
||||
fixedSizeTuple[i*2+1] = atoi(size);
|
||||
}
|
||||
read_word(1); // must be '}'
|
||||
f.read_word(1); // must be '}'
|
||||
} else {
|
||||
Fl_Group_Type::read_property(c);
|
||||
Fl_Group_Type::read_property(f, c);
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Flex_Type::postprocess_read()
|
||||
{
|
||||
if (fixedSizeTupleSize==0) return;
|
||||
Fl_Flex* f = (Fl_Flex*)o;
|
||||
Fl_Flex* flex = (Fl_Flex*)o;
|
||||
for (int i=0; i<fixedSizeTupleSize; i++) {
|
||||
int ix = fixedSizeTuple[2*i];
|
||||
int size = fixedSizeTuple[2*i+1];
|
||||
if (ix>=0 && ix<f->children()) {
|
||||
Fl_Widget *ci = f->child(ix);
|
||||
f->fixed(ci, size);
|
||||
if (ix>=0 && ix<flex->children()) {
|
||||
Fl_Widget *ci = flex->child(ix);
|
||||
flex->fixed(ci, size);
|
||||
}
|
||||
}
|
||||
fixedSizeTupleSize = 0;
|
||||
delete[] fixedSizeTuple;
|
||||
fixedSizeTuple = NULL;
|
||||
f->layout();
|
||||
flex->layout();
|
||||
suspend_auto_layout = 0;
|
||||
}
|
||||
|
||||
void Fl_Flex_Type::write_code2() {
|
||||
void Fl_Flex_Type::write_code2(Fd_Code_Writer& f) {
|
||||
const char *var = name() ? name() : "o";
|
||||
Fl_Flex* f = (Fl_Flex*)o;
|
||||
Fl_Flex* flex = (Fl_Flex*)o;
|
||||
int lm, tm, rm, bm;
|
||||
f->margin(&lm, &tm, &rm, &bm);
|
||||
flex->margin(&lm, &tm, &rm, &bm);
|
||||
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
|
||||
write_c("%s%s->margin(%d, %d, %d, %d);\n", indent(), var, lm, tm, rm, bm);
|
||||
if (f->gap())
|
||||
write_c("%s%s->gap(%d);\n", indent(), var, f->gap());
|
||||
for (int i=0; i<f->children(); ++i) {
|
||||
Fl_Widget *ci = f->child(i);
|
||||
if (f->fixed(ci))
|
||||
write_c("%s%s->fixed(%s->child(%d), %d);\n", indent(), var, var, i,
|
||||
f->horizontal() ? ci->w() : ci->h());
|
||||
f.write_c("%s%s->margin(%d, %d, %d, %d);\n", f.indent(), var, lm, tm, rm, bm);
|
||||
if (flex->gap())
|
||||
f.write_c("%s%s->gap(%d);\n", f.indent(), var, flex->gap());
|
||||
for (int i=0; i<flex->children(); ++i) {
|
||||
Fl_Widget *ci = flex->child(i);
|
||||
if (flex->fixed(ci))
|
||||
f.write_c("%s%s->fixed(%s->child(%d), %d);\n", f.indent(), var, var, i,
|
||||
flex->horizontal() ? ci->w() : ci->h());
|
||||
}
|
||||
Fl_Group_Type::write_code2();
|
||||
Fl_Group_Type::write_code2(f);
|
||||
}
|
||||
|
||||
void Fl_Flex_Type::add_child(Fl_Type* a, Fl_Type* b) {
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
igroup *g = new igroup(X,Y,W,H); Fl_Group::current(0); return g;}
|
||||
Fl_Widget_Type *_make() FL_OVERRIDE {return new Fl_Group_Type();}
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
||||
void move_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
||||
void remove_child(Fl_Type*) FL_OVERRIDE;
|
||||
@@ -91,12 +91,12 @@ public:
|
||||
Fl_Widget *widget(int X,int Y,int W,int H) FL_OVERRIDE {
|
||||
Fl_Flex *g = new Fl_Flex(X,Y,W,H); Fl_Group::current(0); return g;}
|
||||
int pixmapID() FL_OVERRIDE { return 56; }
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
Fl_Widget *enter_live_mode(int top=0) FL_OVERRIDE;
|
||||
void copy_properties() FL_OVERRIDE;
|
||||
void postprocess_read() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
||||
void move_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
||||
void remove_child(Fl_Type*) FL_OVERRIDE;
|
||||
|
||||
+97
-98
@@ -227,7 +227,7 @@ int isdeclare(const char *c);
|
||||
// Search backwards to find the parent menu button and return it's name.
|
||||
// Also put in i the index into the button's menu item array belonging
|
||||
// to this menu item.
|
||||
const char* Fl_Menu_Item_Type::menu_name(int& i) {
|
||||
const char* Fl_Menu_Item_Type::menu_name(Fd_Code_Writer& f, int& i) {
|
||||
i = 0;
|
||||
Fl_Type* t = prev;
|
||||
while (t && t->is_menu_item()) {
|
||||
@@ -238,20 +238,21 @@ const char* Fl_Menu_Item_Type::menu_name(int& i) {
|
||||
t = t->prev;
|
||||
i++;
|
||||
}
|
||||
return unique_id(t, "menu", t->name(), t->label());
|
||||
if (!t) return "\n#error Fl_Menu_Item_Type::menu_name, invalid f\n";
|
||||
return f.unique_id(t, "menu", t->name(), t->label());
|
||||
}
|
||||
|
||||
void Fl_Menu_Item_Type::write_static() {
|
||||
void Fl_Menu_Item_Type::write_static(Fd_Code_Writer& f) {
|
||||
if (image && label() && label()[0]) {
|
||||
write_declare("#include <FL/Fl.H>");
|
||||
write_declare("#include <FL/Fl_Multi_Label.H>");
|
||||
f.write_h_once("#include <FL/Fl.H>");
|
||||
f.write_h_once("#include <FL/Fl_Multi_Label.H>");
|
||||
}
|
||||
if (callback() && is_name(callback()) && !user_defined(callback()))
|
||||
write_declare("extern void %s(Fl_Menu_*, %s);", callback(),
|
||||
f.write_h_once("extern void %s(Fl_Menu_*, %s);", callback(),
|
||||
user_data_type() ? user_data_type() : "void*");
|
||||
for (int n=0; n < NUM_EXTRA_CODE; n++) {
|
||||
if (extra_code(n) && isdeclare(extra_code(n)))
|
||||
write_declare("%s", extra_code(n));
|
||||
f.write_h_once("%s", extra_code(n));
|
||||
}
|
||||
if (callback() && !is_name(callback())) {
|
||||
// see if 'o' or 'v' used, to prevent unused argument warnings:
|
||||
@@ -264,48 +265,46 @@ void Fl_Menu_Item_Type::write_static() {
|
||||
do d++; while (is_id(*d));
|
||||
while (*d && !is_id(*d)) d++;
|
||||
}
|
||||
const char* cn = callback_name();
|
||||
const char* cn = callback_name(f);
|
||||
const char* k = class_name(1);
|
||||
if (k) {
|
||||
write_c("\nvoid %s::%s_i(Fl_Menu_*", k, cn);
|
||||
f.write_c("\nvoid %s::%s_i(Fl_Menu_*", k, cn);
|
||||
} else {
|
||||
write_c("\nstatic void %s(Fl_Menu_*", cn);
|
||||
f.write_c("\nstatic void %s(Fl_Menu_*", cn);
|
||||
}
|
||||
if (use_o) write_c(" o");
|
||||
if (use_o) f.write_c(" o");
|
||||
const char* ut = user_data_type() ? user_data_type() : "void*";
|
||||
write_c(", %s", ut);
|
||||
if (use_v) write_c(" v");
|
||||
write_c(") {\n");
|
||||
write_c_indented(callback(), 1, 0);
|
||||
f.write_c(", %s", ut);
|
||||
if (use_v) f.write_c(" v");
|
||||
f.write_c(") {\n");
|
||||
f.write_c_indented(callback(), 1, 0);
|
||||
if (*(d-1) != ';' && *(d-1) != '}') {
|
||||
const char *p = strrchr(callback(), '\n');
|
||||
if (p) p ++;
|
||||
else p = callback();
|
||||
// Only add trailing semicolon if the last line is not a preprocessor
|
||||
// statement...
|
||||
if (*p != '#' && *p) write_c(";");
|
||||
if (*p != '#' && *p) f.write_c(";");
|
||||
}
|
||||
write_c("\n}\n");
|
||||
f.write_c("\n}\n");
|
||||
if (k) {
|
||||
write_c("void %s::%s(Fl_Menu_* o, %s v) {\n", k, cn, ut);
|
||||
write_c("%s((%s*)(o", indent(1), k);
|
||||
f.write_c("void %s::%s(Fl_Menu_* o, %s v) {\n", k, cn, ut);
|
||||
f.write_c("%s((%s*)(o", f.indent(1), k);
|
||||
Fl_Type* t = parent; while (t->is_menu_item()) t = t->parent;
|
||||
Fl_Type *q = 0;
|
||||
// Go up one more level for Fl_Input_Choice, as these are groups themselves
|
||||
if (t && !strcmp(t->type_name(), "Fl_Input_Choice"))
|
||||
write_c("->parent()");
|
||||
f.write_c("->parent()");
|
||||
for (t = t->parent; t && t->is_widget() && !is_class(); q = t, t = t->parent)
|
||||
write_c("->parent()");
|
||||
f.write_c("->parent()");
|
||||
if (!q || strcmp(q->type_name(), "widget_class"))
|
||||
write_c("->user_data()");
|
||||
write_c("))->%s_i(o,v);\n}\n", cn);
|
||||
f.write_c("->user_data()");
|
||||
f.write_c("))->%s_i(o,v);\n}\n", cn);
|
||||
}
|
||||
}
|
||||
if (image) {
|
||||
if (image->written != write_number) {
|
||||
image->write_static(compress_image_);
|
||||
image->written = write_number;
|
||||
}
|
||||
if (!f.c_contains(image))
|
||||
image->write_static(f, compress_image_);
|
||||
}
|
||||
if (next && next->is_menu_item()) return;
|
||||
// okay, when we hit last item in the menu we have to write the
|
||||
@@ -313,20 +312,20 @@ void Fl_Menu_Item_Type::write_static() {
|
||||
const char* k = class_name(1);
|
||||
if (k) {
|
||||
int i;
|
||||
write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(i));
|
||||
f.write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(f, i));
|
||||
} else {
|
||||
int i;
|
||||
write_c("\nFl_Menu_Item %s[] = {\n", menu_name(i));
|
||||
f.write_c("\nFl_Menu_Item %s[] = {\n", menu_name(f, i));
|
||||
}
|
||||
Fl_Type* t = prev; while (t && t->is_menu_item()) t = t->prev;
|
||||
for (Fl_Type* q = t->next; q && q->is_menu_item(); q = q->next) {
|
||||
((Fl_Menu_Item_Type*)q)->write_item();
|
||||
((Fl_Menu_Item_Type*)q)->write_item(f);
|
||||
int thislevel = q->level; if (q->is_parent()) thislevel++;
|
||||
int nextlevel =
|
||||
(q->next && q->next->is_menu_item()) ? q->next->level : t->level+1;
|
||||
while (thislevel > nextlevel) {write_c(" {0,0,0,0,0,0,0,0,0},\n"); thislevel--;}
|
||||
while (thislevel > nextlevel) {f.write_c(" {0,0,0,0,0,0,0,0,0},\n"); thislevel--;}
|
||||
}
|
||||
write_c(" {0,0,0,0,0,0,0,0,0}\n};\n");
|
||||
f.write_c(" {0,0,0,0,0,0,0,0,0}\n};\n");
|
||||
|
||||
if (k) {
|
||||
// Write menu item variables...
|
||||
@@ -338,12 +337,12 @@ void Fl_Menu_Item_Type::write_static() {
|
||||
if (c==m->name()) {
|
||||
// assign a menu item address directly to a variable
|
||||
int i;
|
||||
const char* n = ((Fl_Menu_Item_Type *)q)->menu_name(i);
|
||||
write_c("Fl_Menu_Item* %s::%s = %s::%s + %d;\n", k, c, k, n, i);
|
||||
const char* n = ((Fl_Menu_Item_Type *)q)->menu_name(f, i);
|
||||
f.write_c("Fl_Menu_Item* %s::%s = %s::%s + %d;\n", k, c, k, n, i);
|
||||
} else {
|
||||
// if the name is an array, only define the array.
|
||||
// The actual assignment is in write_code1()
|
||||
write_c("Fl_Menu_Item* %s::%s;\n", k, c);
|
||||
// The actual assignment is in write_code1(Fd_Code_Writer& f)
|
||||
f.write_c("Fl_Menu_Item* %s::%s;\n", k, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,7 +362,7 @@ int Fl_Menu_Item_Type::flags() {
|
||||
return i;
|
||||
}
|
||||
|
||||
void Fl_Menu_Item_Type::write_item() {
|
||||
void Fl_Menu_Item_Type::write_item(Fd_Code_Writer& f) {
|
||||
static const char * const labeltypes[] = {
|
||||
"FL_NORMAL_LABEL",
|
||||
"FL_NO_LABEL",
|
||||
@@ -375,120 +374,120 @@ void Fl_Menu_Item_Type::write_item() {
|
||||
"FL_IMAGE_LABEL"
|
||||
};
|
||||
|
||||
write_comment_inline_c(" ");
|
||||
write_c(" {");
|
||||
write_comment_inline_c(f, " ");
|
||||
f.write_c(" {");
|
||||
if (label() && label()[0])
|
||||
switch (g_project.i18n_type) {
|
||||
case 1:
|
||||
// we will call i18n when the menu is instantiated for the first time
|
||||
write_c("%s(", g_project.i18n_static_function.value());
|
||||
write_cstring(label());
|
||||
write_c(")");
|
||||
f.write_c("%s(", g_project.i18n_static_function.value());
|
||||
f.write_cstring(label());
|
||||
f.write_c(")");
|
||||
break;
|
||||
case 2:
|
||||
// fall through: strings can't be translated before a catalog is choosen
|
||||
default:
|
||||
write_cstring(label());
|
||||
f.write_cstring(label());
|
||||
}
|
||||
else
|
||||
write_c("\"\"");
|
||||
f.write_c("\"\"");
|
||||
if (((Fl_Button*)o)->shortcut()) {
|
||||
int s = ((Fl_Button*)o)->shortcut();
|
||||
if (g_project.use_FL_COMMAND && (s & (FL_CTRL|FL_META))) {
|
||||
write_c(", FL_COMMAND|0x%x, ", s & ~(FL_CTRL|FL_META));
|
||||
f.write_c(", FL_COMMAND|0x%x, ", s & ~(FL_CTRL|FL_META));
|
||||
} else {
|
||||
write_c(", 0x%x, ", s);
|
||||
f.write_c(", 0x%x, ", s);
|
||||
}
|
||||
} else
|
||||
write_c(", 0, ");
|
||||
f.write_c(", 0, ");
|
||||
if (callback()) {
|
||||
const char* k = is_name(callback()) ? 0 : class_name(1);
|
||||
if (k) {
|
||||
write_c(" (Fl_Callback*)%s::%s,", k, callback_name());
|
||||
f.write_c(" (Fl_Callback*)%s::%s,", k, callback_name(f));
|
||||
} else {
|
||||
write_c(" (Fl_Callback*)%s,", callback_name());
|
||||
f.write_c(" (Fl_Callback*)%s,", callback_name(f));
|
||||
}
|
||||
} else
|
||||
write_c(" 0,");
|
||||
f.write_c(" 0,");
|
||||
if (user_data())
|
||||
write_c(" (void*)(%s),", user_data());
|
||||
f.write_c(" (void*)(%s),", user_data());
|
||||
else
|
||||
write_c(" 0,");
|
||||
write_c(" %d, (uchar)%s, %d, %d, %d", flags(),
|
||||
f.write_c(" 0,");
|
||||
f.write_c(" %d, (uchar)%s, %d, %d, %d", flags(),
|
||||
labeltypes[o->labeltype()], o->labelfont(), o->labelsize(), o->labelcolor());
|
||||
write_c("},\n");
|
||||
f.write_c("},\n");
|
||||
}
|
||||
|
||||
void start_menu_initialiser(int &initialized, const char *name, int index) {
|
||||
void start_menu_initialiser(Fd_Code_Writer& f, int &initialized, const char *name, int index) {
|
||||
if (!initialized) {
|
||||
initialized = 1;
|
||||
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), name, index);
|
||||
indentation++;
|
||||
f.write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", f.indent(), name, index);
|
||||
f.indentation++;
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Menu_Item_Type::write_code1() {
|
||||
int i; const char* mname = menu_name(i);
|
||||
void Fl_Menu_Item_Type::write_code1(Fd_Code_Writer& f) {
|
||||
int i; const char* mname = menu_name(f, i);
|
||||
|
||||
if (!prev->is_menu_item()) {
|
||||
// for first menu item, declare the array
|
||||
if (class_name(1)) {
|
||||
write_h("%sstatic Fl_Menu_Item %s[];\n", indent(1), mname);
|
||||
f.write_h("%sstatic Fl_Menu_Item %s[];\n", f.indent(1), mname);
|
||||
} else {
|
||||
write_h("extern Fl_Menu_Item %s[];\n", mname);
|
||||
f.write_h("extern Fl_Menu_Item %s[];\n", mname);
|
||||
}
|
||||
}
|
||||
|
||||
const char *c = array_name(this);
|
||||
if (c) {
|
||||
if (class_name(1)) {
|
||||
write_public(public_);
|
||||
write_h("%sstatic Fl_Menu_Item *%s;\n", indent(1), c);
|
||||
f.write_public(public_);
|
||||
f.write_h("%sstatic Fl_Menu_Item *%s;\n", f.indent(1), c);
|
||||
} else {
|
||||
if (c==name())
|
||||
write_h("#define %s (%s+%d)\n", c, mname, i);
|
||||
f.write_h("#define %s (%s+%d)\n", c, mname, i);
|
||||
else
|
||||
write_h("extern Fl_Menu_Item *%s;\n", c);
|
||||
f.write_h("extern Fl_Menu_Item *%s;\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (callback()) {
|
||||
if (!is_name(callback()) && class_name(1)) {
|
||||
const char* cn = callback_name();
|
||||
const char* cn = callback_name(f);
|
||||
const char* ut = user_data_type() ? user_data_type() : "void*";
|
||||
write_public(0);
|
||||
write_h("%sinline void %s_i(Fl_Menu_*, %s);\n", indent(1), cn, ut);
|
||||
write_h("%sstatic void %s(Fl_Menu_*, %s);\n", indent(1), cn, ut);
|
||||
f.write_public(0);
|
||||
f.write_h("%sinline void %s_i(Fl_Menu_*, %s);\n", f.indent(1), cn, ut);
|
||||
f.write_h("%sstatic void %s(Fl_Menu_*, %s);\n", f.indent(1), cn, ut);
|
||||
}
|
||||
}
|
||||
|
||||
int menuItemInitialized = 0;
|
||||
// if the name is an array variable, assign the value here
|
||||
if (name() && strchr(name(), '[')) {
|
||||
write_c("%s%s = &%s[%d];\n", indent_plus(1), name(), mname, i);
|
||||
f.write_c("%s%s = &%s[%d];\n", f.indent_plus(1), name(), mname, i);
|
||||
}
|
||||
if (image) {
|
||||
start_menu_initialiser(menuItemInitialized, mname, i);
|
||||
start_menu_initialiser(f, menuItemInitialized, mname, i);
|
||||
if (label() && label()[0]) {
|
||||
write_c("%sFl_Multi_Label *ml = new Fl_Multi_Label;\n", indent());
|
||||
write_c("%sml->labela = (char*)", indent());
|
||||
image->write_inline();
|
||||
write_c(";\n");
|
||||
f.write_c("%sFl_Multi_Label *ml = new Fl_Multi_Label;\n", f.indent());
|
||||
f.write_c("%sml->labela = (char*)", f.indent());
|
||||
image->write_inline(f);
|
||||
f.write_c(";\n");
|
||||
if (g_project.i18n_type==0) {
|
||||
write_c("%sml->labelb = o->label();\n", indent());
|
||||
f.write_c("%sml->labelb = o->label();\n", f.indent());
|
||||
} else if (g_project.i18n_type==1) {
|
||||
write_c("%sml->labelb = %s(o->label());\n",
|
||||
indent(), g_project.i18n_function.value());
|
||||
f.write_c("%sml->labelb = %s(o->label());\n",
|
||||
f.indent(), g_project.i18n_function.value());
|
||||
} else if (g_project.i18n_type==2) {
|
||||
write_c("%sml->labelb = catgets(%s,%s,i+%d,o->label());\n",
|
||||
indent(), g_project.i18n_file[0] ? g_project.i18n_file.value() : "_catalog",
|
||||
f.write_c("%sml->labelb = catgets(%s,%s,i+%d,o->label());\n",
|
||||
f.indent(), g_project.i18n_file[0] ? g_project.i18n_file.value() : "_catalog",
|
||||
g_project.i18n_set.value(), msgnum());
|
||||
}
|
||||
write_c("%sml->typea = FL_IMAGE_LABEL;\n", indent());
|
||||
write_c("%sml->typeb = FL_NORMAL_LABEL;\n", indent());
|
||||
write_c("%sml->label(o);\n", indent());
|
||||
f.write_c("%sml->typea = FL_IMAGE_LABEL;\n", f.indent());
|
||||
f.write_c("%sml->typeb = FL_NORMAL_LABEL;\n", f.indent());
|
||||
f.write_c("%sml->label(o);\n", f.indent());
|
||||
} else {
|
||||
image->write_code(0, "o");
|
||||
image->write_code(f, 0, "o");
|
||||
}
|
||||
}
|
||||
if (g_project.i18n_type && label() && label()[0]) {
|
||||
@@ -497,30 +496,30 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
// label was already copied a few lines up
|
||||
} else if ( t==FL_NORMAL_LABEL || t==FL_SHADOW_LABEL
|
||||
|| t==FL_ENGRAVED_LABEL || t==FL_EMBOSSED_LABEL) {
|
||||
start_menu_initialiser(menuItemInitialized, mname, i);
|
||||
start_menu_initialiser(f, menuItemInitialized, mname, i);
|
||||
if (g_project.i18n_type==1) {
|
||||
write_c("%so->label(%s(o->label()));\n",
|
||||
indent(), g_project.i18n_function.value());
|
||||
f.write_c("%so->label(%s(o->label()));\n",
|
||||
f.indent(), g_project.i18n_function.value());
|
||||
} else if (g_project.i18n_type==2) {
|
||||
write_c("%so->label(catgets(%s,%s,i+%d,o->label()));\n",
|
||||
indent(), g_project.i18n_file[0] ? g_project.i18n_file.value() : "_catalog",
|
||||
f.write_c("%so->label(catgets(%s,%s,i+%d,o->label()));\n",
|
||||
f.indent(), g_project.i18n_file[0] ? g_project.i18n_file.value() : "_catalog",
|
||||
g_project.i18n_set.value(), msgnum());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int n=0; n < NUM_EXTRA_CODE; n++) {
|
||||
if (extra_code(n) && !isdeclare(extra_code(n))) {
|
||||
start_menu_initialiser(menuItemInitialized, mname, i);
|
||||
write_c("%s%s\n", indent(), extra_code(n));
|
||||
start_menu_initialiser(f, menuItemInitialized, mname, i);
|
||||
f.write_c("%s%s\n", f.indent(), extra_code(n));
|
||||
}
|
||||
}
|
||||
if (menuItemInitialized) {
|
||||
indentation--;
|
||||
write_c("%s}\n",indent());
|
||||
f.indentation--;
|
||||
f.write_c("%s}\n",f.indent());
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_Menu_Item_Type::write_code2() {}
|
||||
void Fl_Menu_Item_Type::write_code2(Fd_Code_Writer&) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// This is the base class for widgets that contain a menu (ie
|
||||
@@ -612,12 +611,12 @@ Fl_Type* Fl_Menu_Type::click_test(int, int) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void Fl_Menu_Type::write_code2() {
|
||||
void Fl_Menu_Type::write_code2(Fd_Code_Writer& f) {
|
||||
if (next && next->is_menu_item()) {
|
||||
write_c("%s%s->menu(%s);\n", indent(), name() ? name() : "o",
|
||||
unique_id(this, "menu", name(), label()));
|
||||
f.write_c("%s%s->menu(%s);\n", f.indent(), name() ? name() : "o",
|
||||
f.unique_id(this, "menu", name(), label()));
|
||||
}
|
||||
Fl_Widget_Type::write_code2();
|
||||
Fl_Widget_Type::write_code2(f);
|
||||
}
|
||||
|
||||
void Fl_Menu_Type::copy_properties() {
|
||||
|
||||
@@ -41,12 +41,12 @@ public:
|
||||
int is_button() const FL_OVERRIDE {return 1;} // this gets shortcut to work
|
||||
Fl_Widget* widget(int,int,int,int) FL_OVERRIDE {return 0;}
|
||||
Fl_Widget_Type* _make() FL_OVERRIDE {return 0;}
|
||||
virtual const char* menu_name(int& i);
|
||||
virtual const char* menu_name(Fd_Code_Writer& f, int& i);
|
||||
int flags();
|
||||
void write_static() FL_OVERRIDE;
|
||||
void write_item();
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_static(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_item(Fd_Code_Writer& f);
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
int pixmapID() FL_OVERRIDE { return 16; }
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
void move_child(Fl_Type*, Fl_Type*) FL_OVERRIDE {build_menu();}
|
||||
void remove_child(Fl_Type*) FL_OVERRIDE {build_menu();}
|
||||
Fl_Type* click_test(int x, int y) FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void copy_properties() FL_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
+88
-81
@@ -160,9 +160,14 @@ void later_cb(Fl_Widget*,void*) {
|
||||
widget_browser->rebuild();
|
||||
}
|
||||
|
||||
/** \brief Delete all children of a Type.
|
||||
*/
|
||||
static void delete_children(Fl_Type *p) {
|
||||
Fl_Type *f;
|
||||
// find all types following p that are higher in level, effectively finding
|
||||
// the last child of the last child
|
||||
for (f = p; f && f->next && f->next->level > p->level; f = f->next) {/*empty*/}
|
||||
// now loop back up to p, deleting all children on the way
|
||||
for (; f != p; ) {
|
||||
Fl_Type *g = f->prev;
|
||||
delete f;
|
||||
@@ -178,7 +183,9 @@ void delete_all(int selected_only) {
|
||||
Fl_Type *g = f->next;
|
||||
delete f;
|
||||
f = g;
|
||||
} else f = f->next;
|
||||
} else {
|
||||
f = f->next;
|
||||
}
|
||||
}
|
||||
if(!selected_only) {
|
||||
// reset the setting for the external shell command
|
||||
@@ -281,11 +288,11 @@ Fl_Type::Fl_Type() {
|
||||
*/
|
||||
Fl_Type::~Fl_Type() {
|
||||
// warning: destructor only works for widgets that have been add()ed.
|
||||
if (prev) prev->next = next; else first = next;
|
||||
if (next) next->prev = prev; else last = prev;
|
||||
if (Fl_Type::last==this) Fl_Type::last = prev;
|
||||
if (Fl_Type::first==this) Fl_Type::first = next;
|
||||
if (current == this) current = 0;
|
||||
if (prev) prev->next = next; // else first = next; // don't do that! The Type may not be part of the main list
|
||||
if (next) next->prev = prev; // else last = prev;
|
||||
if (Fl_Type::last == this) Fl_Type::last = prev;
|
||||
if (Fl_Type::first == this) Fl_Type::first = next;
|
||||
if (current == this) current = NULL;
|
||||
if (parent) parent->remove_child(this);
|
||||
if (name_) free((void*)name_);
|
||||
if (label_) free((void*)label_);
|
||||
@@ -576,76 +583,76 @@ void Fl_Type::move_before(Fl_Type* g) {
|
||||
|
||||
|
||||
// write a widget and all its children:
|
||||
void Fl_Type::write() {
|
||||
write_indent(level);
|
||||
write_word(type_name());
|
||||
void Fl_Type::write(Fd_Project_Writer &f) {
|
||||
f.write_indent(level);
|
||||
f.write_word(type_name());
|
||||
|
||||
if (is_class()) {
|
||||
const char * p = ((Fl_Class_Type*)this)->prefix();
|
||||
if (p && strlen(p))
|
||||
write_word(p);
|
||||
}
|
||||
if (is_class()) {
|
||||
const char * p = ((Fl_Class_Type*)this)->prefix();
|
||||
if (p && strlen(p))
|
||||
f.write_word(p);
|
||||
}
|
||||
|
||||
write_word(name());
|
||||
write_open(level);
|
||||
write_properties();
|
||||
write_close(level);
|
||||
if (!is_parent()) return;
|
||||
// now do children:
|
||||
write_open(level);
|
||||
Fl_Type *child;
|
||||
for (child = next; child && child->level > level; child = child->next)
|
||||
if (child->level == level+1) child->write();
|
||||
write_close(level);
|
||||
f.write_word(name());
|
||||
f.write_open(level);
|
||||
write_properties(f);
|
||||
f.write_close(level);
|
||||
if (!is_parent()) return;
|
||||
// now do children:
|
||||
f.write_open(level);
|
||||
Fl_Type *child;
|
||||
for (child = next; child && child->level > level; child = child->next)
|
||||
if (child->level == level+1) child->write(f);
|
||||
f.write_close(level);
|
||||
}
|
||||
|
||||
void Fl_Type::write_properties() {
|
||||
void Fl_Type::write_properties(Fd_Project_Writer &f) {
|
||||
// repeat this for each attribute:
|
||||
if (label()) {
|
||||
write_indent(level+1);
|
||||
write_word("label");
|
||||
write_word(label());
|
||||
f.write_indent(level+1);
|
||||
f.write_word("label");
|
||||
f.write_word(label());
|
||||
}
|
||||
if (user_data()) {
|
||||
write_indent(level+1);
|
||||
write_word("user_data");
|
||||
write_word(user_data());
|
||||
f.write_indent(level+1);
|
||||
f.write_word("user_data");
|
||||
f.write_word(user_data());
|
||||
}
|
||||
if (user_data_type()) {
|
||||
write_word("user_data_type");
|
||||
write_word(user_data_type());
|
||||
f.write_word("user_data_type");
|
||||
f.write_word(user_data_type());
|
||||
}
|
||||
if (callback()) {
|
||||
write_indent(level+1);
|
||||
write_word("callback");
|
||||
write_word(callback());
|
||||
f.write_indent(level+1);
|
||||
f.write_word("callback");
|
||||
f.write_word(callback());
|
||||
}
|
||||
if (comment()) {
|
||||
write_indent(level+1);
|
||||
write_word("comment");
|
||||
write_word(comment());
|
||||
f.write_indent(level+1);
|
||||
f.write_word("comment");
|
||||
f.write_word(comment());
|
||||
}
|
||||
if (is_parent() && open_) write_word("open");
|
||||
if (selected) write_word("selected");
|
||||
if (is_parent() && open_) f.write_word("open");
|
||||
if (selected) f.write_word("selected");
|
||||
}
|
||||
|
||||
void Fl_Type::read_property(const char *c) {
|
||||
void Fl_Type::read_property(Fd_Project_Reader &f, const char *c) {
|
||||
if (!strcmp(c,"label"))
|
||||
label(read_word());
|
||||
label(f.read_word());
|
||||
else if (!strcmp(c,"user_data"))
|
||||
user_data(read_word());
|
||||
user_data(f.read_word());
|
||||
else if (!strcmp(c,"user_data_type"))
|
||||
user_data_type(read_word());
|
||||
user_data_type(f.read_word());
|
||||
else if (!strcmp(c,"callback"))
|
||||
callback(read_word());
|
||||
callback(f.read_word());
|
||||
else if (!strcmp(c,"comment"))
|
||||
comment(read_word());
|
||||
comment(f.read_word());
|
||||
else if (!strcmp(c,"open"))
|
||||
open_ = 1;
|
||||
else if (!strcmp(c,"selected"))
|
||||
select(this,1);
|
||||
else
|
||||
read_error("Unknown property \"%s\"", c);
|
||||
f.read_error("Unknown property \"%s\"", c);
|
||||
}
|
||||
|
||||
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
|
||||
@@ -654,86 +661,86 @@ int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
|
||||
Write a comment into the header file.
|
||||
\param[in] pre indent the comment by this string
|
||||
*/
|
||||
void Fl_Type::write_comment_h(const char *pre)
|
||||
void Fl_Type::write_comment_h(Fd_Code_Writer& f, const char *pre)
|
||||
{
|
||||
if (comment() && *comment()) {
|
||||
write_h("%s/**\n", pre);
|
||||
f.write_h("%s/**\n", pre);
|
||||
const char *s = comment();
|
||||
write_h("%s ", pre);
|
||||
f.write_h("%s ", pre);
|
||||
while(*s) {
|
||||
if (*s=='\n') {
|
||||
if (s[1]) {
|
||||
write_h("\n%s ", pre);
|
||||
f.write_h("\n%s ", pre);
|
||||
}
|
||||
} else {
|
||||
write_h("%c", *s); // FIXME this is much too slow!
|
||||
f.write_h("%c", *s); // FIXME this is much too slow!
|
||||
}
|
||||
s++;
|
||||
}
|
||||
write_h("\n%s*/\n", pre);
|
||||
f.write_h("\n%s*/\n", pre);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Write a comment into the source file.
|
||||
*/
|
||||
void Fl_Type::write_comment_c(const char *pre)
|
||||
void Fl_Type::write_comment_c(Fd_Code_Writer& f, const char *pre)
|
||||
{
|
||||
if (comment() && *comment()) {
|
||||
write_c("%s/**\n", pre);
|
||||
f.write_c("%s/**\n", pre);
|
||||
const char *s = comment();
|
||||
write_c("%s ", pre);
|
||||
f.write_c("%s ", pre);
|
||||
while(*s) {
|
||||
if (*s=='\n') {
|
||||
if (s[1]) {
|
||||
write_c("\n%s ", pre);
|
||||
f.write_c("\n%s ", pre);
|
||||
}
|
||||
} else {
|
||||
write_c("%c", *s); // FIXME this is much too slow!
|
||||
f.write_c("%c", *s); // FIXME this is much too slow!
|
||||
}
|
||||
s++;
|
||||
}
|
||||
write_c("\n%s*/\n", pre);
|
||||
f.write_c("\n%s*/\n", pre);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Write a comment into the source file.
|
||||
*/
|
||||
void Fl_Type::write_comment_inline_c(const char *pre)
|
||||
void Fl_Type::write_comment_inline_c(Fd_Code_Writer& f, const char *pre)
|
||||
{
|
||||
if (comment() && *comment()) {
|
||||
const char *s = comment();
|
||||
if (strchr(s, '\n')==0L) {
|
||||
// single line comment
|
||||
if (pre) write_c("%s", pre);
|
||||
write_c("// %s\n", s);
|
||||
if (!pre) write_c("%s", indent_plus(1));
|
||||
if (pre) f.write_c("%s", pre);
|
||||
f.write_c("// %s\n", s);
|
||||
if (!pre) f.write_c("%s", f.indent_plus(1));
|
||||
} else {
|
||||
write_c("%s/*\n", pre?pre:"");
|
||||
f.write_c("%s/*\n", pre?pre:"");
|
||||
if (pre)
|
||||
write_c("%s ", pre);
|
||||
f.write_c("%s ", pre);
|
||||
else
|
||||
write_c("%s ", indent_plus(1));
|
||||
f.write_c("%s ", f.indent_plus(1));
|
||||
while(*s) {
|
||||
if (*s=='\n') {
|
||||
if (s[1]) {
|
||||
if (pre)
|
||||
write_c("\n%s ", pre);
|
||||
f.write_c("\n%s ", pre);
|
||||
else
|
||||
write_c("\n%s ", indent_plus(1));
|
||||
f.write_c("\n%s ", f.indent_plus(1));
|
||||
}
|
||||
} else {
|
||||
write_c("%c", *s); // FIXME this is much too slow!
|
||||
f.write_c("%c", *s); // FIXME this is much too slow!
|
||||
}
|
||||
s++;
|
||||
}
|
||||
if (pre)
|
||||
write_c("\n%s */\n", pre);
|
||||
f.write_c("\n%s */\n", pre);
|
||||
else
|
||||
write_c("\n%s */\n", indent_plus(1));
|
||||
f.write_c("\n%s */\n", f.indent_plus(1));
|
||||
if (!pre)
|
||||
write_c("%s", indent_plus(1));
|
||||
f.write_c("%s", f.indent_plus(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -777,9 +784,9 @@ int Fl_Type::user_defined(const char* cbname) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *Fl_Type::callback_name() {
|
||||
const char *Fl_Type::callback_name(Fd_Code_Writer& f) {
|
||||
if (is_name(callback())) return callback();
|
||||
return unique_id(this, "cb", name(), label());
|
||||
return f.unique_id(this, "cb", name(), label());
|
||||
}
|
||||
|
||||
const char* Fl_Type::class_name(const int need_nest) const {
|
||||
@@ -818,15 +825,15 @@ const Fl_Class_Type *Fl_Type::is_in_class() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Type::write_static() {
|
||||
void Fl_Type::write_static(Fd_Code_Writer&) {
|
||||
}
|
||||
|
||||
void Fl_Type::write_code1() {
|
||||
write_h("// Header for %s\n", title());
|
||||
write_c("// Code for %s\n", title());
|
||||
void Fl_Type::write_code1(Fd_Code_Writer& f) {
|
||||
f.write_h("// Header for %s\n", title());
|
||||
f.write_c("// Code for %s\n", title());
|
||||
}
|
||||
|
||||
void Fl_Type::write_code2() {
|
||||
void Fl_Type::write_code2(Fd_Code_Writer&) {
|
||||
}
|
||||
|
||||
/// \}
|
||||
|
||||
+15
-10
@@ -20,10 +20,15 @@
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#include "code.h"
|
||||
|
||||
class Fl_Type;
|
||||
class Fl_Group_Type;
|
||||
class Fl_Window_Type;
|
||||
|
||||
class Fd_Project_Reader;
|
||||
class Fd_Project_Writer;
|
||||
|
||||
typedef enum {
|
||||
kAddAsLastChild = 0,
|
||||
kAddAfterCurrent
|
||||
@@ -72,7 +77,7 @@ public: // things that should not be public:
|
||||
Fl_Type *first_child();
|
||||
|
||||
Fl_Type *factory;
|
||||
const char *callback_name();
|
||||
const char *callback_name(Fd_Code_Writer& f);
|
||||
|
||||
int code_position, header_position;
|
||||
int code_position_end, header_position_end;
|
||||
@@ -121,19 +126,19 @@ public:
|
||||
virtual void open(); // what happens when you double-click
|
||||
|
||||
// read and write data to a saved file:
|
||||
virtual void write();
|
||||
virtual void write_properties();
|
||||
virtual void read_property(const char *);
|
||||
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 int read_fdesign(const char*, const char*);
|
||||
virtual void postprocess_read() { }
|
||||
|
||||
// write code, these are called in order:
|
||||
virtual void write_static(); // write static stuff to .c file
|
||||
virtual void write_code1(); // code and .h before children
|
||||
virtual void write_code2(); // code and .h after children
|
||||
void write_comment_h(const char *ind=""); // write the commentary text into the header file
|
||||
void write_comment_c(const char *ind=""); // write the commentary text into the source file
|
||||
void write_comment_inline_c(const char *ind=0L); // write the commentary text
|
||||
virtual void write_static(Fd_Code_Writer& f); // write static stuff to .c file
|
||||
virtual void write_code1(Fd_Code_Writer& f); // code and .h before children
|
||||
virtual void write_code2(Fd_Code_Writer& f); // code and .h after children
|
||||
void write_comment_h(Fd_Code_Writer& f, const char *ind=""); // write the commentary text into the header file
|
||||
void write_comment_c(Fd_Code_Writer& f, const char *ind=""); // write the commentary text into the source file
|
||||
void write_comment_inline_c(Fd_Code_Writer& f, const char *ind=0L); // write the commentary text
|
||||
|
||||
// live mode
|
||||
virtual Fl_Widget *enter_live_mode(int top=0); // build wdgets needed for live mode
|
||||
|
||||
+280
-270
File diff suppressed because it is too large
Load Diff
@@ -51,13 +51,13 @@ class Fl_Widget_Type : public Fl_Type {
|
||||
|
||||
protected:
|
||||
|
||||
void write_static() FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_widget_code();
|
||||
void write_extra_code();
|
||||
void write_block_close();
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_color(const char*, Fl_Color);
|
||||
void write_static(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_widget_code(Fd_Code_Writer& f);
|
||||
void write_extra_code(Fd_Code_Writer& f);
|
||||
void write_block_close(Fd_Code_Writer& f);
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_color(Fd_Code_Writer& f, const char*, Fl_Color);
|
||||
Fl_Widget *live_widget;
|
||||
|
||||
public:
|
||||
@@ -101,8 +101,8 @@ public:
|
||||
int is_widget() const FL_OVERRIDE;
|
||||
int is_public() const FL_OVERRIDE;
|
||||
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int read_fdesign(const char*, const char*) FL_OVERRIDE;
|
||||
|
||||
Fl_Widget *enter_live_mode(int top=0) FL_OVERRIDE;
|
||||
|
||||
+91
-91
@@ -941,7 +941,7 @@ void Fl_Window_Type::draw_overlay() {
|
||||
}
|
||||
|
||||
// Check spacing and alignment between individual widgets
|
||||
if (drag && selection->is_widget()) {
|
||||
if (drag && selection && selection->is_widget()) {
|
||||
for (Fl_Type *q=next; q && q->level>level; q = q->next)
|
||||
if (q != selection && q->is_widget()) {
|
||||
Fl_Widget_Type *qw = (Fl_Widget_Type*)q;
|
||||
@@ -1354,7 +1354,7 @@ int Fl_Window_Type::handle(int event) {
|
||||
// or in the same group, add after selection. Otherwise, just add
|
||||
// at the end of the selected group.
|
||||
if ( Fl_Type::current_dnd->group()
|
||||
&& selection->group()
|
||||
&& selection && selection->group()
|
||||
&& Fl_Type::current_dnd->group()==selection->group())
|
||||
{
|
||||
Fl_Type *cc = Fl_Type::current;
|
||||
@@ -1460,7 +1460,7 @@ int Fl_Window_Type::handle(int event) {
|
||||
for (Fl_Widget *o1 = myo->o; o1; o1 = o1->parent())
|
||||
if (!o1->visible()) goto CONTINUE;
|
||||
if (Fl::event_inside(myo->o)) selection = myo;
|
||||
if (myo->o->x()>=x1 && myo->o->y()>y1 &&
|
||||
if (myo && myo->o && myo->o->x()>=x1 && myo->o->y()>y1 &&
|
||||
myo->o->x()+myo->o->w()<mx && myo->o->y()+myo->o->h()<my) {
|
||||
n++;
|
||||
select(myo, toggle ? !myo->selected : 1);
|
||||
@@ -1468,7 +1468,7 @@ int Fl_Window_Type::handle(int event) {
|
||||
CONTINUE:;
|
||||
}
|
||||
// if nothing in box, select what was clicked on:
|
||||
if (!n) {
|
||||
if (selection && !n) {
|
||||
select(selection, toggle ? !selection->selected : 1);
|
||||
}
|
||||
}
|
||||
@@ -1538,47 +1538,47 @@ int Fl_Window_Type::handle(int event) {
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void Fl_Window_Type::write_code1() {
|
||||
Fl_Widget_Type::write_code1();
|
||||
void Fl_Window_Type::write_code1(Fd_Code_Writer& f) {
|
||||
Fl_Widget_Type::write_code1(f);
|
||||
}
|
||||
|
||||
void Fl_Window_Type::write_code2() {
|
||||
void Fl_Window_Type::write_code2(Fd_Code_Writer& f) {
|
||||
const char *var = is_class() ? "this" : name() ? name() : "o";
|
||||
write_extra_code();
|
||||
if (modal) write_c("%s%s->set_modal();\n", indent(), var);
|
||||
else if (non_modal) write_c("%s%s->set_non_modal();\n", indent(), var);
|
||||
write_extra_code(f);
|
||||
if (modal) f.write_c("%s%s->set_modal();\n", f.indent(), var);
|
||||
else if (non_modal) f.write_c("%s%s->set_non_modal();\n", f.indent(), var);
|
||||
if (!((Fl_Window*)o)->border()) {
|
||||
write_c("%s%s->clear_border();\n", indent(), var);
|
||||
f.write_c("%s%s->clear_border();\n", f.indent(), var);
|
||||
}
|
||||
if (xclass) {
|
||||
write_c("%s%s->xclass(", indent(), var);
|
||||
write_cstring(xclass);
|
||||
write_c(");\n");
|
||||
f.write_c("%s%s->xclass(", f.indent(), var);
|
||||
f.write_cstring(xclass);
|
||||
f.write_c(");\n");
|
||||
}
|
||||
if (sr_max_w || sr_max_h) {
|
||||
write_c("%s%s->size_range(%d, %d, %d, %d);\n", indent(), var,
|
||||
f.write_c("%s%s->size_range(%d, %d, %d, %d);\n", f.indent(), var,
|
||||
sr_min_w, sr_min_h, sr_max_w, sr_max_h);
|
||||
} else if (sr_min_w || sr_min_h) {
|
||||
write_c("%s%s->size_range(%d, %d);\n", indent(), var, sr_min_w, sr_min_h);
|
||||
f.write_c("%s%s->size_range(%d, %d);\n", f.indent(), var, sr_min_w, sr_min_h);
|
||||
}
|
||||
write_c("%s%s->end();\n", indent(), var);
|
||||
f.write_c("%s%s->end();\n", f.indent(), var);
|
||||
if (((Fl_Window*)o)->resizable() == o)
|
||||
write_c("%s%s->resizable(%s);\n", indent(), var, var);
|
||||
write_block_close();
|
||||
f.write_c("%s%s->resizable(%s);\n", f.indent(), var, var);
|
||||
write_block_close(f);
|
||||
}
|
||||
|
||||
void Fl_Window_Type::write_properties() {
|
||||
Fl_Widget_Type::write_properties();
|
||||
if (modal) write_string("modal");
|
||||
else if (non_modal) write_string("non_modal");
|
||||
if (!((Fl_Window*)o)->border()) write_string("noborder");
|
||||
if (xclass) {write_string("xclass"); write_word(xclass);}
|
||||
void Fl_Window_Type::write_properties(Fd_Project_Writer &f) {
|
||||
Fl_Widget_Type::write_properties(f);
|
||||
if (modal) f.write_string("modal");
|
||||
else if (non_modal) f.write_string("non_modal");
|
||||
if (!((Fl_Window*)o)->border()) f.write_string("noborder");
|
||||
if (xclass) {f.write_string("xclass"); f.write_word(xclass);}
|
||||
if (sr_min_w || sr_min_h || sr_max_w || sr_max_h)
|
||||
write_string("size_range {%d %d %d %d}", sr_min_w, sr_min_h, sr_max_w, sr_max_h);
|
||||
if (o->visible()) write_string("visible");
|
||||
f.write_string("size_range {%d %d %d %d}", sr_min_w, sr_min_h, sr_max_w, sr_max_h);
|
||||
if (o->visible()) f.write_string("visible");
|
||||
}
|
||||
|
||||
void Fl_Window_Type::read_property(const char *c) {
|
||||
void Fl_Window_Type::read_property(Fd_Project_Reader &f, const char *c) {
|
||||
if (!strcmp(c,"modal")) {
|
||||
modal = 1;
|
||||
} else if (!strcmp(c,"non_modal")) {
|
||||
@@ -1588,18 +1588,18 @@ void Fl_Window_Type::read_property(const char *c) {
|
||||
} else if (!strcmp(c,"noborder")) {
|
||||
((Fl_Window*)o)->border(0);
|
||||
} else if (!strcmp(c,"xclass")) {
|
||||
storestring(read_word(),xclass);
|
||||
storestring(f.read_word(),xclass);
|
||||
((Fl_Window*)o)->xclass(xclass);
|
||||
} else if (!strcmp(c,"size_range")) {
|
||||
int mw, mh, MW, MH;
|
||||
if (sscanf(read_word(),"%d %d %d %d",&mw,&mh,&MW,&MH) == 4) {
|
||||
if (sscanf(f.read_word(),"%d %d %d %d",&mw,&mh,&MW,&MH) == 4) {
|
||||
sr_min_w = mw; sr_min_h = mh; sr_max_w = MW; sr_max_h = MH;
|
||||
}
|
||||
} else if (!strcmp(c,"xywh")) {
|
||||
Fl_Widget_Type::read_property(c);
|
||||
Fl_Widget_Type::read_property(f, c);
|
||||
pasteoffset = 0; // make it not apply to contents
|
||||
} else {
|
||||
Fl_Widget_Type::read_property(c);
|
||||
Fl_Widget_Type::read_property(f, c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1659,21 +1659,21 @@ Fl_Type *Fl_Widget_Class_Type::make(Strategy strategy) {
|
||||
return myo;
|
||||
}
|
||||
|
||||
void Fl_Widget_Class_Type::write_properties() {
|
||||
Fl_Window_Type::write_properties();
|
||||
void Fl_Widget_Class_Type::write_properties(Fd_Project_Writer &f) {
|
||||
Fl_Window_Type::write_properties(f);
|
||||
if (wc_relative==1)
|
||||
write_string("position_relative");
|
||||
f.write_string("position_relative");
|
||||
else if (wc_relative==2)
|
||||
write_string("position_relative_rescale");
|
||||
f.write_string("position_relative_rescale");
|
||||
}
|
||||
|
||||
void Fl_Widget_Class_Type::read_property(const char *c) {
|
||||
void Fl_Widget_Class_Type::read_property(Fd_Project_Reader &f, const char *c) {
|
||||
if (!strcmp(c,"position_relative")) {
|
||||
wc_relative = 1;
|
||||
} else if (!strcmp(c,"position_relative_rescale")) {
|
||||
wc_relative = 2;
|
||||
} else {
|
||||
Fl_Window_Type::read_property(c);
|
||||
Fl_Window_Type::read_property(f, c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1690,9 +1690,9 @@ static const char *trimclassname(const char *n) {
|
||||
}
|
||||
|
||||
|
||||
void Fl_Widget_Class_Type::write_code1() {
|
||||
void Fl_Widget_Class_Type::write_code1(Fd_Code_Writer& f) {
|
||||
#if 0
|
||||
Fl_Widget_Type::write_code1();
|
||||
Fl_Widget_Type::write_code1(Fd_Code_Writer& f);
|
||||
#endif // 0
|
||||
|
||||
current_widget_class = this;
|
||||
@@ -1701,80 +1701,80 @@ void Fl_Widget_Class_Type::write_code1() {
|
||||
const char *c = subclass();
|
||||
if (!c) c = "Fl_Group";
|
||||
|
||||
write_c("\n");
|
||||
write_comment_h();
|
||||
write_h("\nclass %s : public %s {\n", name(), c);
|
||||
f.write_c("\n");
|
||||
write_comment_h(f);
|
||||
f.write_h("\nclass %s : public %s {\n", name(), c);
|
||||
if (strstr(c, "Window")) {
|
||||
write_h("%svoid _%s();\n", indent(1), trimclassname(name()));
|
||||
write_h("public:\n");
|
||||
write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n", indent(1), trimclassname(name()));
|
||||
write_h("%s%s(int W, int H, const char *L = 0);\n", indent(1), trimclassname(name()));
|
||||
write_h("%s%s();\n", indent(1), trimclassname(name()));
|
||||
f.write_h("%svoid _%s();\n", f.indent(1), trimclassname(name()));
|
||||
f.write_h("public:\n");
|
||||
f.write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n", f.indent(1), trimclassname(name()));
|
||||
f.write_h("%s%s(int W, int H, const char *L = 0);\n", f.indent(1), trimclassname(name()));
|
||||
f.write_h("%s%s();\n", f.indent(1), trimclassname(name()));
|
||||
|
||||
// a constructor with all four dimensions plus label
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(X, Y, W, H, L)\n{\n", indent(1), c);
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
f.write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c);
|
||||
f.write_c("%s_%s();\n", f.indent(1), trimclassname(name()));
|
||||
f.write_c("}\n\n");
|
||||
|
||||
// a constructor with just the size and label. The window manager will position the window
|
||||
write_c("%s::%s(int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(0, 0, W, H, L)\n{\n", indent(1), c);
|
||||
write_c("%sclear_flag(16);\n", indent(1));
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
f.write_c("%s::%s(int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c);
|
||||
f.write_c("%sclear_flag(16);\n", f.indent(1));
|
||||
f.write_c("%s_%s();\n", f.indent(1), trimclassname(name()));
|
||||
f.write_c("}\n\n");
|
||||
|
||||
// a constructor that takes size and label from the Fluid database
|
||||
write_c("%s::%s() :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(0, 0, %d, %d, ", indent(1), c, o->w(), o->h());
|
||||
f.write_c("%s::%s() :\n", name(), trimclassname(name()));
|
||||
f.write_c("%s%s(0, 0, %d, %d, ", f.indent(1), c, o->w(), o->h());
|
||||
const char *cstr = label();
|
||||
if (cstr) write_cstring(cstr);
|
||||
else write_c("0");
|
||||
write_c(")\n{\n");
|
||||
write_c("%sclear_flag(16);\n", indent(1));
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
if (cstr) f.write_cstring(cstr);
|
||||
else f.write_c("0");
|
||||
f.write_c(")\n{\n");
|
||||
f.write_c("%sclear_flag(16);\n", f.indent(1));
|
||||
f.write_c("%s_%s();\n", f.indent(1), trimclassname(name()));
|
||||
f.write_c("}\n\n");
|
||||
|
||||
write_c("void %s::_%s() {\n", name(), trimclassname(name()));
|
||||
// write_c("%s%s *w = this;\n", indent(1), name());
|
||||
f.write_c("void %s::_%s() {\n", name(), trimclassname(name()));
|
||||
// f.write_c("%s%s *w = this;\n", f.indent(1), name());
|
||||
} else {
|
||||
write_h("public:\n");
|
||||
write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n",
|
||||
indent(1), trimclassname(name()));
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
f.write_h("public:\n");
|
||||
f.write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n",
|
||||
f.indent(1), trimclassname(name()));
|
||||
f.write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
if (wc_relative==1)
|
||||
write_c("%s%s(0, 0, W, H, L)\n{\n", indent(1), c);
|
||||
f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c);
|
||||
else if (wc_relative==2)
|
||||
write_c("%s%s(0, 0, %d, %d, L)\n{\n", indent(1), c, o->w(), o->h());
|
||||
f.write_c("%s%s(0, 0, %d, %d, L)\n{\n", f.indent(1), c, o->w(), o->h());
|
||||
else
|
||||
write_c("%s%s(X, Y, W, H, L)\n{\n", indent(1), c);
|
||||
f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c);
|
||||
}
|
||||
|
||||
// write_c("%s%s *o = this;\n", indent(1), name());
|
||||
// f.write_c("%s%s *o = this;\n", f.indent(1), name());
|
||||
|
||||
indentation++;
|
||||
write_widget_code();
|
||||
f.indentation++;
|
||||
write_widget_code(f);
|
||||
}
|
||||
|
||||
void Fl_Widget_Class_Type::write_code2() {
|
||||
write_extra_code();
|
||||
void Fl_Widget_Class_Type::write_code2(Fd_Code_Writer& f) {
|
||||
write_extra_code(f);
|
||||
if (wc_relative==1)
|
||||
write_c("%sposition(X, Y);\n", indent());
|
||||
f.write_c("%sposition(X, Y);\n", f.indent());
|
||||
else if (wc_relative==2)
|
||||
write_c("%sresize(X, Y, W, H);\n", indent());
|
||||
if (modal) write_c("%sset_modal();\n", indent());
|
||||
else if (non_modal) write_c("%sset_non_modal();\n", indent());
|
||||
if (!((Fl_Window*)o)->border()) write_c("%sclear_border();\n", indent());
|
||||
f.write_c("%sresize(X, Y, W, H);\n", f.indent());
|
||||
if (modal) f.write_c("%sset_modal();\n", f.indent());
|
||||
else if (non_modal) f.write_c("%sset_non_modal();\n", f.indent());
|
||||
if (!((Fl_Window*)o)->border()) f.write_c("%sclear_border();\n", f.indent());
|
||||
if (xclass) {
|
||||
write_c("%sxclass(", indent());
|
||||
write_cstring(xclass);
|
||||
write_c(");\n");
|
||||
f.write_c("%sxclass(", f.indent());
|
||||
f.write_cstring(xclass);
|
||||
f.write_c(");\n");
|
||||
}
|
||||
write_c("%send();\n", indent());
|
||||
f.write_c("%send();\n", f.indent());
|
||||
if (((Fl_Window*)o)->resizable() == o)
|
||||
write_c("%sresizable(this);\n", indent());
|
||||
indentation--;
|
||||
write_c("}\n");
|
||||
f.write_c("%sresizable(this);\n", f.indent());
|
||||
f.indentation--;
|
||||
f.write_c("}\n");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -51,8 +51,8 @@ protected:
|
||||
void newposition(Fl_Widget_Type *,int &x,int &y,int &w,int &h);
|
||||
int handle(int);
|
||||
void setlabel(const char *) FL_OVERRIDE;
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
Fl_Widget_Type *_make() FL_OVERRIDE {return 0;} // we don't call this
|
||||
Fl_Widget *widget(int,int,int,int) FL_OVERRIDE {return 0;}
|
||||
int recalc; // set by fix_overlay()
|
||||
@@ -84,8 +84,8 @@ public:
|
||||
void fix_overlay(); // Update the bounding box, etc
|
||||
uchar *read_image(int &ww, int &hh); // Read an image of the window
|
||||
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
int read_fdesign(const char*, const char*) FL_OVERRIDE;
|
||||
|
||||
void add_child(Fl_Type*, Fl_Type*) FL_OVERRIDE;
|
||||
@@ -118,11 +118,11 @@ public:
|
||||
char write_public_state; // true when public: has been printed
|
||||
char wc_relative; // if 1, reposition all children, if 2, reposition and resize
|
||||
|
||||
void write_properties() FL_OVERRIDE;
|
||||
void read_property(const char *) FL_OVERRIDE;
|
||||
void write_properties(Fd_Project_Writer &f) FL_OVERRIDE;
|
||||
void read_property(Fd_Project_Reader &f, const char *) FL_OVERRIDE;
|
||||
|
||||
void write_code1() FL_OVERRIDE;
|
||||
void write_code2() FL_OVERRIDE;
|
||||
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
|
||||
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
|
||||
const char *type_name() FL_OVERRIDE {return "widget_class";}
|
||||
int pixmapID() FL_OVERRIDE { return 48; }
|
||||
|
||||
+117
-148
@@ -46,38 +46,28 @@ void Fluid_Image::deimage(Fl_Widget *o) {
|
||||
if (o->window() != o) o->deimage(img);
|
||||
}
|
||||
|
||||
static int pixmap_header_written = 0;
|
||||
static int bitmap_header_written = 0;
|
||||
static int image_header_written = 0;
|
||||
static int jpeg_header_written = 0;
|
||||
static int png_header_written = 0;
|
||||
static int gif_header_written = 0;
|
||||
static int animated_gif_header_written = 0;
|
||||
static int bmp_header_written = 0;
|
||||
static int svg_header_written = 0;
|
||||
|
||||
/** Write the contents of the name() file as binary source code.
|
||||
\param fmt short name of file contents for error message
|
||||
\return 0 if the file could not be opened or read */
|
||||
size_t Fluid_Image::write_static_binary(const char* fmt) {
|
||||
size_t Fluid_Image::write_static_binary(Fd_Code_Writer& f, const char* fmt) {
|
||||
size_t nData = 0;
|
||||
enter_project_dir();
|
||||
FILE *f = fl_fopen(name(), "rb");
|
||||
FILE *in = fl_fopen(name(), "rb");
|
||||
leave_project_dir();
|
||||
if (!f) {
|
||||
write_file_error(fmt);
|
||||
if (!in) {
|
||||
write_file_error(f, fmt);
|
||||
return 0;
|
||||
} else {
|
||||
fseek(f, 0, SEEK_END);
|
||||
nData = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fseek(in, 0, SEEK_END);
|
||||
nData = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
if (nData) {
|
||||
char *data = (char*)calloc(nData, 1);
|
||||
if (fread(data, nData, 1, f)==0) { /* ignore */ }
|
||||
write_cdata(data, (int)nData);
|
||||
if (fread(data, nData, 1, in)==0) { /* ignore */ }
|
||||
f.write_cdata(data, (int)nData);
|
||||
free(data);
|
||||
}
|
||||
fclose(f);
|
||||
fclose(in);
|
||||
}
|
||||
return nData;
|
||||
}
|
||||
@@ -85,41 +75,38 @@ size_t Fluid_Image::write_static_binary(const char* fmt) {
|
||||
/** Write the contents of the name() file as textual source code.
|
||||
\param fmt short name of file contents for error message
|
||||
\return 0 if the file could not be opened or read */
|
||||
size_t Fluid_Image::write_static_text(const char* fmt) {
|
||||
size_t Fluid_Image::write_static_text(Fd_Code_Writer& f, const char* fmt) {
|
||||
size_t nData = 0;
|
||||
enter_project_dir();
|
||||
FILE *f = fl_fopen(name(), "rb");
|
||||
FILE *in = fl_fopen(name(), "rb");
|
||||
leave_project_dir();
|
||||
if (!f) {
|
||||
write_file_error(fmt);
|
||||
if (!in) {
|
||||
write_file_error(f, fmt);
|
||||
return 0;
|
||||
} else {
|
||||
fseek(f, 0, SEEK_END);
|
||||
nData = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fseek(in, 0, SEEK_END);
|
||||
nData = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
if (nData) {
|
||||
char *data = (char*)calloc(nData+1, 1);
|
||||
if (fread(data, nData, 1, f)==0) { /* ignore */ }
|
||||
write_cstring(data, (int)nData);
|
||||
if (fread(data, nData, 1, in)==0) { /* ignore */ }
|
||||
f.write_cstring(data, (int)nData);
|
||||
free(data);
|
||||
}
|
||||
fclose(f);
|
||||
fclose(in);
|
||||
}
|
||||
return nData;
|
||||
}
|
||||
|
||||
void Fluid_Image::write_static_rgb(const char* idata_name) {
|
||||
void Fluid_Image::write_static_rgb(Fd_Code_Writer& f, const char* idata_name) {
|
||||
// Write image data...
|
||||
write_c("\n");
|
||||
if (image_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_Image.H>\n");
|
||||
image_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
const int extra_data = img->ld() ? (img->ld()-img->w()*img->d()) : 0;
|
||||
write_cdata(img->data()[0], (img->w() * img->d() + extra_data) * img->h());
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_RGB_Image", "%s, %d, %d, %d, %d", idata_name, img->w(), img->h(), img->d(), img->ld());
|
||||
f.write_cdata(img->data()[0], (img->w() * img->d() + extra_data) * img->h());
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_RGB_Image", "%s, %d, %d, %d, %d", idata_name, img->w(), img->h(), img->d(), img->ld());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,126 +119,102 @@ void Fluid_Image::write_static_rgb(const char* idata_name) {
|
||||
|
||||
\param compressed write data in the original compressed file format
|
||||
*/
|
||||
void Fluid_Image::write_static(int compressed) {
|
||||
void Fluid_Image::write_static(Fd_Code_Writer& f, int compressed) {
|
||||
if (!img) return;
|
||||
const char *idata_name = unique_id(this, "idata", fl_filename_name(name()), 0);
|
||||
function_name_ = unique_id(this, "image", fl_filename_name(name()), 0);
|
||||
const char *idata_name = f.unique_id(this, "idata", fl_filename_name(name()), 0);
|
||||
function_name_ = f.unique_id(this, "image", fl_filename_name(name()), 0);
|
||||
|
||||
if (is_animated_gif_) {
|
||||
// Write animated gif image data...
|
||||
write_c("\n");
|
||||
if (animated_gif_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_Anim_GIF_Image.H>\n");
|
||||
animated_gif_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("AnimGIF");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_Anim_GIF_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_Anim_GIF_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "AnimGIF");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_Anim_GIF_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
} else if (compressed && fl_ascii_strcasecmp(fl_filename_ext(name()), ".gif")==0) {
|
||||
// Write gif image data...
|
||||
write_c("\n");
|
||||
if (gif_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_GIF_Image.H>\n");
|
||||
gif_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("GIF");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_GIF_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_GIF_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "GIF");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_GIF_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
} else if (compressed && fl_ascii_strcasecmp(fl_filename_ext(name()), ".bmp")==0) {
|
||||
// Write bmp image data...
|
||||
write_c("\n");
|
||||
if (bmp_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_BMP_Image.H>\n");
|
||||
bmp_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("BMP");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_BMP_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_BMP_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "BMP");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_BMP_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
} else if (img->count() > 1) {
|
||||
// Write Pixmap data...
|
||||
write_c("\n");
|
||||
if (pixmap_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_Pixmap.H>\n");
|
||||
pixmap_header_written = write_number;
|
||||
}
|
||||
write_c("static const char *%s[] = {\n", idata_name);
|
||||
write_cstring(img->data()[0], (int)strlen(img->data()[0]));
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_Pixmap.H>\n");
|
||||
f.write_c("static const char *%s[] = {\n", idata_name);
|
||||
f.write_cstring(img->data()[0], (int)strlen(img->data()[0]));
|
||||
|
||||
int i;
|
||||
int ncolors, chars_per_color;
|
||||
sscanf(img->data()[0], "%*d%*d%d%d", &ncolors, &chars_per_color);
|
||||
|
||||
if (ncolors < 0) {
|
||||
write_c(",\n");
|
||||
write_cstring(img->data()[1], ncolors * -4);
|
||||
f.write_c(",\n");
|
||||
f.write_cstring(img->data()[1], ncolors * -4);
|
||||
i = 2;
|
||||
} else {
|
||||
for (i = 1; i <= ncolors; i ++) {
|
||||
write_c(",\n");
|
||||
write_cstring(img->data()[i], (int)strlen(img->data()[i]));
|
||||
f.write_c(",\n");
|
||||
f.write_cstring(img->data()[i], (int)strlen(img->data()[i]));
|
||||
}
|
||||
}
|
||||
for (; i < img->count(); i ++) {
|
||||
write_c(",\n");
|
||||
write_cstring(img->data()[i], img->w() * chars_per_color);
|
||||
f.write_c(",\n");
|
||||
f.write_cstring(img->data()[i], img->w() * chars_per_color);
|
||||
}
|
||||
write_c("\n};\n");
|
||||
write_initializer("Fl_Pixmap", "%s", idata_name);
|
||||
f.write_c("\n};\n");
|
||||
write_initializer(f, "Fl_Pixmap", "%s", idata_name);
|
||||
} else if (img->d() == 0) {
|
||||
// Write Bitmap data...
|
||||
write_c("\n");
|
||||
if (bitmap_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_Bitmap.H>\n");
|
||||
bitmap_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
write_cdata(img->data()[0], ((img->w() + 7) / 8) * img->h());
|
||||
write_c(";\n");
|
||||
write_initializer( "Fl_Bitmap", "%s, %d, %d, %d", idata_name, ((img->w() + 7) / 8) * img->h(), img->w(), img->h());
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_Bitmap.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
f.write_cdata(img->data()[0], ((img->w() + 7) / 8) * img->h());
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_Bitmap", "%s, %d, %d, %d", idata_name, ((img->w() + 7) / 8) * img->h(), img->w(), img->h());
|
||||
} else if (compressed && fl_ascii_strcasecmp(fl_filename_ext(name()), ".jpg")==0) {
|
||||
// Write jpeg image data...
|
||||
write_c("\n");
|
||||
if (jpeg_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_JPEG_Image.H>\n");
|
||||
jpeg_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("JPEG");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_JPEG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_JPEG_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "JPEG");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_JPEG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
} else if (compressed && fl_ascii_strcasecmp(fl_filename_ext(name()), ".png")==0) {
|
||||
// Write png image data...
|
||||
write_c("\n");
|
||||
if (png_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_PNG_Image.H>\n");
|
||||
png_header_written = write_number;
|
||||
}
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("PNG");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_PNG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_PNG_Image.H>\n");
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "PNG");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_PNG_Image", "\"%s\", %s, %d", fl_filename_name(name()), idata_name, nData);
|
||||
} else if (fl_ascii_strcasecmp(fl_filename_ext(name()), ".svg")==0 || fl_ascii_strcasecmp(fl_filename_ext(name()), ".svgz")==0) {
|
||||
bool gzipped = (strcmp(fl_filename_ext(name()), ".svgz") == 0);
|
||||
// Write svg image data...
|
||||
if (compressed) {
|
||||
write_c("\n");
|
||||
if (svg_header_written != write_number) {
|
||||
write_c("#include <FL/Fl_SVG_Image.H>\n");
|
||||
svg_header_written = write_number;
|
||||
}
|
||||
f.write_c("\n");
|
||||
f.write_c_once("#include <FL/Fl_SVG_Image.H>\n");
|
||||
if (gzipped) {
|
||||
write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary("SVGZ");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_SVG_Image", "\"%s\", %s, %ld", fl_filename_name(name()), idata_name, nData);
|
||||
f.write_c("static const unsigned char %s[] =\n", idata_name);
|
||||
size_t nData = write_static_binary(f, "SVGZ");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_SVG_Image", "\"%s\", %s, %ld", fl_filename_name(name()), idata_name, nData);
|
||||
} else {
|
||||
write_c("static const char %s[] =\n", idata_name);
|
||||
write_static_text("SVG");
|
||||
write_c(";\n");
|
||||
write_initializer("Fl_SVG_Image", "\"%s\", %s", fl_filename_name(name()), idata_name);
|
||||
f.write_c("static const char %s[] =\n", idata_name);
|
||||
write_static_text(f, "SVG");
|
||||
f.write_c(";\n");
|
||||
write_initializer(f, "Fl_SVG_Image", "\"%s\", %s", fl_filename_name(name()), idata_name);
|
||||
}
|
||||
} else {
|
||||
// if FLUID runs from the command line, make sure that the image is not
|
||||
@@ -264,24 +227,24 @@ void Fluid_Image::write_static(int compressed) {
|
||||
svg_image = rgb_image->as_svg_image();
|
||||
if (svg_image) {
|
||||
svg_image->resize(svg_image->w(), svg_image->h());
|
||||
write_static_rgb(idata_name);
|
||||
write_static_rgb(f, idata_name);
|
||||
} else {
|
||||
write_file_error("RGB_from_SVG");
|
||||
write_file_error(f, "RGB_from_SVG");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
write_static_rgb(idata_name);
|
||||
write_static_rgb(f, idata_name);
|
||||
}
|
||||
}
|
||||
|
||||
void Fluid_Image::write_file_error(const char *fmt) {
|
||||
write_c("#warning Cannot read %s file \"%s\": %s\n", fmt, name(), strerror(errno));
|
||||
void Fluid_Image::write_file_error(Fd_Code_Writer& f, const char *fmt) {
|
||||
f.write_c("#warning Cannot read %s file \"%s\": %s\n", fmt, name(), strerror(errno));
|
||||
enter_project_dir();
|
||||
write_c("// Searching in path \"%s\"\n", fl_getcwd(0, FL_PATH_MAX));
|
||||
f.write_c("// Searching in path \"%s\"\n", fl_getcwd(0, FL_PATH_MAX));
|
||||
leave_project_dir();
|
||||
}
|
||||
|
||||
void Fluid_Image::write_initializer(const char *type_name, const char *format, ...) {
|
||||
void Fluid_Image::write_initializer(Fd_Code_Writer& f, const char *type_name, const char *format, ...) {
|
||||
/* Outputs code that returns (and initializes if needed) an Fl_Image as follows:
|
||||
static Fl_Image *'function_name_'() {
|
||||
static Fl_Image *image = NULL;
|
||||
@@ -291,32 +254,32 @@ void Fluid_Image::write_initializer(const char *type_name, const char *format, .
|
||||
} */
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
write_c("static Fl_Image *%s() {\n", function_name_);
|
||||
f.write_c("static Fl_Image *%s() {\n", function_name_);
|
||||
if (is_animated_gif_)
|
||||
write_c("%sFl_GIF_Image::animate = true;\n", indent(1));
|
||||
write_c("%sstatic Fl_Image *image = NULL;\n", indent(1));
|
||||
write_c("%sif (!image)\n", indent(1));
|
||||
write_c("%simage = new %s(", indent(2), type_name);
|
||||
vwrite_c(format, ap);
|
||||
write_c(");\n");
|
||||
write_c("%sreturn image;\n", indent(1));
|
||||
write_c("}\n");
|
||||
f.write_c("%sFl_GIF_Image::animate = true;\n", f.indent(1));
|
||||
f.write_c("%sstatic Fl_Image *image = NULL;\n", f.indent(1));
|
||||
f.write_c("%sif (!image)\n", f.indent(1));
|
||||
f.write_c("%simage = new %s(", f.indent(2), type_name);
|
||||
f.vwrite_c(format, ap);
|
||||
f.write_c(");\n");
|
||||
f.write_c("%sreturn image;\n", f.indent(1));
|
||||
f.write_c("}\n");
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void Fluid_Image::write_code(int bind, const char *var, int inactive) {
|
||||
void Fluid_Image::write_code(Fd_Code_Writer& f, int bind, const char *var, int inactive) {
|
||||
/* Outputs code that attaches an image to an Fl_Widget or Fl_Menu_Item.
|
||||
This code calls a function output before by Fluid_Image::write_initializer() */
|
||||
if (img) {
|
||||
write_c("%s%s->%s%s( %s() );\n", indent(), var, bind ? "bind_" : "", inactive ? "deimage" : "image", function_name_);
|
||||
f.write_c("%s%s->%s%s( %s() );\n", f.indent(), var, bind ? "bind_" : "", inactive ? "deimage" : "image", function_name_);
|
||||
if (is_animated_gif_)
|
||||
write_c("%s((Fl_Anim_GIF_Image*)(%s()))->canvas(%s, Fl_Anim_GIF_Image::DONT_RESIZE_CANVAS);\n", indent(), function_name_, var);
|
||||
f.write_c("%s((Fl_Anim_GIF_Image*)(%s()))->canvas(%s, Fl_Anim_GIF_Image::DONT_RESIZE_CANVAS);\n", f.indent(), function_name_, var);
|
||||
}
|
||||
}
|
||||
|
||||
void Fluid_Image::write_inline(int inactive) {
|
||||
void Fluid_Image::write_inline(Fd_Code_Writer& f, int inactive) {
|
||||
if (img)
|
||||
write_c("%s()", function_name_);
|
||||
f.write_c("%s()", function_name_);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +308,10 @@ Fluid_Image* Fluid_Image::find(const char *iname) {
|
||||
enter_project_dir();
|
||||
FILE *f = fl_fopen(iname,"rb");
|
||||
if (!f) {
|
||||
read_error("%s : %s",iname,strerror(errno));
|
||||
if (batch_mode)
|
||||
fprintf(stderr, "Can't open image file:\n%s\n%s",iname,strerror(errno));
|
||||
else
|
||||
fl_message("Can't open image file:\n%s\n%s",iname,strerror(errno));
|
||||
leave_project_dir();
|
||||
return 0;
|
||||
}
|
||||
@@ -356,7 +322,10 @@ Fluid_Image* Fluid_Image::find(const char *iname) {
|
||||
if (!ret->img || !ret->img->w() || !ret->img->h()) {
|
||||
delete ret;
|
||||
ret = 0;
|
||||
read_error("%s : unrecognized image format", iname);
|
||||
if (batch_mode)
|
||||
fprintf(stderr, "Can't read image file:\n%s\nunrecognized image format",iname);
|
||||
else
|
||||
fl_message("Can't read image file:\n%s\nunrecognized image format",iname);
|
||||
}
|
||||
leave_project_dir();
|
||||
if (!ret) return 0;
|
||||
|
||||
+10
-8
@@ -23,6 +23,8 @@
|
||||
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
|
||||
#include "code.h"
|
||||
|
||||
class Fluid_Image {
|
||||
bool is_animated_gif_;
|
||||
const char *name_;
|
||||
@@ -32,9 +34,9 @@ class Fluid_Image {
|
||||
protected:
|
||||
Fluid_Image(const char *name); // no public constructor
|
||||
~Fluid_Image(); // no public destructor
|
||||
size_t write_static_binary(const char* fmt);
|
||||
size_t write_static_text(const char* fmt);
|
||||
void write_static_rgb(const char* idata_name);
|
||||
size_t write_static_binary(Fd_Code_Writer& f, const char* fmt);
|
||||
size_t write_static_text(Fd_Code_Writer& f, const char* fmt);
|
||||
void write_static_rgb(Fd_Code_Writer& f, const char* idata_name);
|
||||
public:
|
||||
int written;
|
||||
static Fluid_Image* find(const char *);
|
||||
@@ -42,11 +44,11 @@ public:
|
||||
void increment();
|
||||
void image(Fl_Widget *); // set the image of this widget
|
||||
void deimage(Fl_Widget *); // set the deimage of this widget
|
||||
void write_static(int compressed);
|
||||
void write_initializer(const char *type_name, const char *format, ...);
|
||||
void write_code(int bind, const char *var, int inactive = 0);
|
||||
void write_inline(int inactive = 0);
|
||||
void write_file_error(const char *fmt);
|
||||
void write_static(Fd_Code_Writer& f, int compressed);
|
||||
void write_initializer(Fd_Code_Writer& f, const char *type_name, const char *format, ...);
|
||||
void write_code(Fd_Code_Writer& f, int bind, const char *var, int inactive = 0);
|
||||
void write_inline(Fd_Code_Writer& f, int inactive = 0);
|
||||
void write_file_error(Fd_Code_Writer& f, const char *fmt);
|
||||
const char *name() const {return name_;}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ void show_help(const char *name);
|
||||
Fl_Double_Window *about_panel=(Fl_Double_Window *)0;
|
||||
|
||||
#include <FL/Fl_Anim_GIF_Image.H>
|
||||
|
||||
static const unsigned char idata_fluid[] =
|
||||
{71,73,70,56,57,97,96,0,96,0,132,31,0,0,1,0,3,31,63,46,48,45,0,54,108,78,80,
|
||||
77,64,123,116,124,126,123,125,173,98,107,166,116,171,204,63,220,233,19,253,254,
|
||||
|
||||
+271
-189
File diff suppressed because it is too large
Load Diff
+50
-19
@@ -20,28 +20,59 @@
|
||||
#include <FL/fl_attr.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int indentation;
|
||||
extern int write_number;
|
||||
extern int write_sourceview;
|
||||
class Fl_Type;
|
||||
struct Fd_Identifier_Tree;
|
||||
struct Fd_Text_Tree;
|
||||
struct Fd_Pointer_Tree;
|
||||
|
||||
int is_id(char c);
|
||||
const char* unique_id(void* o, const char*, const char*, const char*);
|
||||
const char *indent();
|
||||
const char *indent(int set);
|
||||
const char *indent_plus(int offset);
|
||||
int write_declare(const char *, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_cstring(const char *,int length);
|
||||
void write_cstring(const char *);
|
||||
void write_cdata(const char *,int length);
|
||||
void vwrite_c(const char* format, va_list args);
|
||||
void write_c(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_cc(const char *, int, const char*, const char*);
|
||||
void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_hc(const char *, int, const char*, const char*);
|
||||
void write_c_indented(const char *textlines, int inIndent, char inTrailwWith);
|
||||
int write_code(const char *cfile, const char *hfile);
|
||||
int write_strings(const char *sfile);
|
||||
void write_public(int state); // writes pubic:/private: as needed
|
||||
|
||||
class Fd_Code_Writer
|
||||
{
|
||||
protected:
|
||||
FILE *code_file;
|
||||
FILE *header_file;
|
||||
Fd_Identifier_Tree* id_root;
|
||||
Fd_Text_Tree *text_in_header;
|
||||
Fd_Text_Tree *text_in_code;
|
||||
Fd_Pointer_Tree *ptr_in_code;
|
||||
|
||||
public:
|
||||
int indentation;
|
||||
bool write_sourceview;
|
||||
// silly thing to prevent declaring unused variables:
|
||||
// When this symbol is on, all attempts to write code don't write
|
||||
// anything, but set a variable if it looks like the variable "o" is used:
|
||||
int varused_test;
|
||||
int varused;
|
||||
|
||||
public:
|
||||
Fd_Code_Writer();
|
||||
~Fd_Code_Writer();
|
||||
const char* unique_id(void* o, const char*, const char*, const char*);
|
||||
void indent_more() { indentation++; }
|
||||
void indent_less() { indentation--; }
|
||||
const char *indent();
|
||||
const char *indent(int set);
|
||||
const char *indent_plus(int offset);
|
||||
int write_h_once(const char *, ...) __fl_attr((__format__ (__printf__, 2, 3)));
|
||||
int write_c_once(const char *, ...) __fl_attr((__format__ (__printf__, 2, 3)));
|
||||
bool c_contains(void* ptr);
|
||||
void write_cstring(const char *,int length);
|
||||
void write_cstring(const char *);
|
||||
void write_cdata(const char *,int length);
|
||||
void vwrite_c(const char* format, va_list args);
|
||||
void write_c(const char*, ...) __fl_attr((__format__ (__printf__, 2, 3)));
|
||||
void write_cc(const char *, int, const char*, const char*);
|
||||
void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 2, 3)));
|
||||
void write_hc(const char *, int, const char*, const char*);
|
||||
void write_c_indented(const char *textlines, int inIndent, char inTrailwWith);
|
||||
Fl_Type* write_code(Fl_Type* p);
|
||||
int write_code(const char *cfile, const char *hfile, bool to_sourceview=false);
|
||||
void write_public(int state); // writes pubic:/private: as needed
|
||||
};
|
||||
|
||||
#endif // _FLUID_CODE_H
|
||||
|
||||
+454
-404
File diff suppressed because it is too large
Load Diff
+50
-15
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Fluid file routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2023 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@@ -21,22 +21,57 @@
|
||||
|
||||
#include <FL/fl_attr.h>
|
||||
|
||||
extern double read_version;
|
||||
class Fl_Type;
|
||||
|
||||
extern int fdesign_flip;
|
||||
extern int fdesign_magic;
|
||||
|
||||
void write_word(const char *);
|
||||
void write_string(const char *,...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_indent(int n);
|
||||
void write_open(int);
|
||||
void write_close(int n);
|
||||
|
||||
void read_error(const char *format, ...);
|
||||
const char *read_word(int wantbrace = 0);
|
||||
|
||||
int write_file(const char *, int selected_only = 0);
|
||||
|
||||
int read_file(const char *, int merge, Strategy strategy=kAddAsLastChild);
|
||||
void read_fdesign();
|
||||
int write_file(const char *, int selected_only = 0);
|
||||
|
||||
class Fd_Project_Reader
|
||||
{
|
||||
protected:
|
||||
FILE *fin;
|
||||
int lineno;
|
||||
const char *fname;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
void expand_buffer(int length);
|
||||
|
||||
public:
|
||||
double read_version;
|
||||
|
||||
public:
|
||||
Fd_Project_Reader();
|
||||
~Fd_Project_Reader();
|
||||
int open_read(const char *s);
|
||||
int close_read();
|
||||
int read_quoted();
|
||||
void read_children(Fl_Type *p, int paste, Strategy strategy, char skip_options=0);
|
||||
int read_project(const char *, int merge, Strategy strategy=kAddAsLastChild);
|
||||
void read_error(const char *format, ...);
|
||||
const char *read_word(int wantbrace = 0);
|
||||
int read_fdesign_line(const char*& name, const char*& value);
|
||||
void read_fdesign();
|
||||
};
|
||||
|
||||
class Fd_Project_Writer
|
||||
{
|
||||
protected:
|
||||
FILE *fout;
|
||||
int needspace;
|
||||
|
||||
public:
|
||||
Fd_Project_Writer();
|
||||
~Fd_Project_Writer();
|
||||
int open_write(const char *s);
|
||||
int close_write();
|
||||
int write_project(const char *filename, int selected_only);
|
||||
void write_word(const char *);
|
||||
void write_string(const char *,...) __fl_attr((__format__ (__printf__, 2, 3)));
|
||||
void write_indent(int n);
|
||||
void write_open(int);
|
||||
void write_close(int n);
|
||||
};
|
||||
|
||||
#endif // _FLUID_FILE_H
|
||||
|
||||
+11
-8
@@ -981,11 +981,14 @@ void new_from_template_cb(Fl_Widget *w, void *v) {
|
||||
with the extension \c code_file_name which are both
|
||||
settable by the user.
|
||||
|
||||
In batch_mode, the function will either be silent, or write an error message
|
||||
to \c stderr and exit with exit code 1.
|
||||
If the code filename has not been set yet, a "save file as" dialog will be
|
||||
presented to the user.
|
||||
|
||||
In interactive mode, we will pop up an error message, or, if the user
|
||||
hasn't isabled that, pop up a confirmation message.
|
||||
In batch_mode, the function will either be silent, or, if opening or writing
|
||||
the files fails, write an error message to \c stderr and exit with exit code 1.
|
||||
|
||||
In interactive mode, it will pop up an error message, or, if the user
|
||||
hasn't disabled that, pop up a confirmation message.
|
||||
|
||||
\return 1 if the operation failed, 0 if it succeeded
|
||||
*/
|
||||
@@ -1013,7 +1016,8 @@ int write_code_files() {
|
||||
strlcpy(hname, g_project.header_file_name, FL_PATH_MAX);
|
||||
}
|
||||
if (!batch_mode) enter_project_dir();
|
||||
int x = write_code(cname,hname);
|
||||
Fd_Code_Writer f;
|
||||
int x = f.write_code(cname, hname);
|
||||
if (!batch_mode) leave_project_dir();
|
||||
strlcat(cname, " and ", FL_PATH_MAX);
|
||||
strlcat(cname, hname, FL_PATH_MAX);
|
||||
@@ -1931,9 +1935,9 @@ void update_sourceview_cb(Fl_Button*, void*)
|
||||
g_project.header_file_name = sv_header_filename;
|
||||
|
||||
// generate the code and load the files
|
||||
write_sourceview = 1;
|
||||
Fd_Code_Writer f;
|
||||
// generate files
|
||||
if (write_code(sv_source_filename, sv_header_filename))
|
||||
if (f.write_code(sv_source_filename, sv_header_filename, true))
|
||||
{
|
||||
// load file into source editor
|
||||
int pos = sv_source->top_line();
|
||||
@@ -1946,7 +1950,6 @@ void update_sourceview_cb(Fl_Button*, void*)
|
||||
// update the source code highlighting
|
||||
update_sourceview_position();
|
||||
}
|
||||
write_sourceview = 0;
|
||||
|
||||
g_project.code_file_name = code_file_name_bak;
|
||||
g_project.header_file_name = header_file_name_bak;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2023 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
|
||||
@@ -5,7 +5,7 @@ code_name {.cxx}
|
||||
comment {//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2023 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@@ -17,7 +17,7 @@ comment {//
|
||||
//
|
||||
// https://www.fltk.org/bugs.php
|
||||
//
|
||||
} {in_source in_header
|
||||
} {selected in_source in_header
|
||||
}
|
||||
|
||||
decl {\#include "fluid.h"} {private local
|
||||
@@ -483,7 +483,7 @@ Function {make_comment_panel()} {open
|
||||
xywh {780 296 550 280} type Double labelsize 11 resizable
|
||||
code0 {o->size_range(320, 180);} modal visible
|
||||
} {
|
||||
Fl_Text_Editor comment_input {selected
|
||||
Fl_Text_Editor comment_input {
|
||||
xywh {110 10 430 230} box DOWN_BOX labelsize 11 textfont 4 textsize 11 textcolor 58 resizable
|
||||
code0 {o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);}
|
||||
code1 {o->buffer(new Fl_Text_Buffer());}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2023 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
|
||||
@@ -112,6 +112,7 @@ Fl_Menu_Item menu_print_page_size[] = {
|
||||
};
|
||||
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
||||
static const char *idata_print_color[] = {
|
||||
"24 24 17 1",
|
||||
" \tc None",
|
||||
@@ -157,7 +158,9 @@ static const char *idata_print_color[] = {
|
||||
" %%%%%% ****** "
|
||||
};
|
||||
static Fl_Image *image_print_color() {
|
||||
static Fl_Image *image = new Fl_Pixmap(idata_print_color);
|
||||
static Fl_Image *image = NULL;
|
||||
if (!image)
|
||||
image = new Fl_Pixmap(idata_print_color);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -206,7 +209,9 @@ static const char *idata_print_gray[] = {
|
||||
" %%%%%% ****** "
|
||||
};
|
||||
static Fl_Image *image_print_gray() {
|
||||
static Fl_Image *image = new Fl_Pixmap(idata_print_gray);
|
||||
static Fl_Image *image = NULL;
|
||||
if (!image)
|
||||
image = new Fl_Pixmap(idata_print_gray);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ decl {\#include "fluid.h"} {private local
|
||||
decl {\#include <FL/fl_string_functions.h>} {private local
|
||||
}
|
||||
|
||||
decl {\#include "../src/flstring.h"} {private local
|
||||
decl {\#include "../src/flstring.h"} {selected private local
|
||||
}
|
||||
|
||||
decl {\#include <stdlib.h>} {private local
|
||||
@@ -39,7 +39,7 @@ Function {make_print_panel()} {open
|
||||
} {
|
||||
Fl_Window print_panel {
|
||||
label Print
|
||||
xywh {465 222 465 235} type Double hide modal
|
||||
xywh {465 222 465 235} type Double modal visible
|
||||
} {
|
||||
Fl_Group print_panel_controls {open
|
||||
xywh {10 10 447 216}
|
||||
@@ -213,7 +213,7 @@ print_collate_group[1 - i]->hide();}
|
||||
label {Printer Properties}
|
||||
callback {print_properties_panel->hide();
|
||||
print_update_status();}
|
||||
xywh {462 486 290 130} type Double hide modal
|
||||
xywh {462 486 290 130} type Double modal visible
|
||||
} {
|
||||
Fl_Choice print_page_size {
|
||||
label {Page Size:}
|
||||
@@ -233,16 +233,16 @@ print_update_status();}
|
||||
xywh {110 45 170 40} labelfont 1 labelsize 12 align 4
|
||||
} {
|
||||
Fl_Button {print_output_mode[0]} {
|
||||
image {pixmaps/print_color.xpm} xywh {110 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX value 1 color 7 selection_color 0
|
||||
image {pixmaps/print_color.xpm} compress_image 0 xywh {110 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX value 1 color 7 selection_color 0
|
||||
}
|
||||
Fl_Button {print_output_mode[1]} {
|
||||
image {pixmaps/print_color.xpm} xywh {150 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
image {pixmaps/print_color.xpm} compress_image 0 xywh {150 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
}
|
||||
Fl_Button {print_output_mode[2]} {
|
||||
image {pixmaps/print_gray.xpm} xywh {200 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
image {pixmaps/print_gray.xpm} compress_image 0 xywh {200 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
}
|
||||
Fl_Button {print_output_mode[3]} {
|
||||
image {pixmaps/print_gray.xpm} xywh {240 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
image {pixmaps/print_gray.xpm} compress_image 0 xywh {240 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0
|
||||
}
|
||||
}
|
||||
Fl_Return_Button {} {
|
||||
@@ -328,7 +328,7 @@ if (defname[0]) {
|
||||
print_update_status();} {}
|
||||
}
|
||||
|
||||
Function {print_update_status()} {open selected return_type void
|
||||
Function {print_update_status()} {open return_type void
|
||||
} {
|
||||
code {FILE *lpstat;
|
||||
char command[1024];
|
||||
|
||||
@@ -138,7 +138,7 @@ Fl_Double_Window* make_template_panel() {
|
||||
template_browser->labelfont(1);
|
||||
template_browser->callback((Fl_Callback*)cb_template_browser);
|
||||
template_browser->align(Fl_Align(FL_ALIGN_TOP_LEFT));
|
||||
template_browser->when(3);
|
||||
template_browser->when(FL_WHEN_CHANGED | FL_WHEN_NOT_CHANGED);
|
||||
} // Fl_Browser* template_browser
|
||||
{ template_preview = new Fl_Box(200, 28, 250, 250);
|
||||
template_preview->box(FL_THIN_DOWN_BOX);
|
||||
@@ -149,7 +149,7 @@ Fl_Double_Window* make_template_panel() {
|
||||
template_name->labelfont(1);
|
||||
template_name->textfont(4);
|
||||
template_name->callback((Fl_Callback*)cb_template_name);
|
||||
template_name->when(3);
|
||||
template_name->when(FL_WHEN_CHANGED | FL_WHEN_NOT_CHANGED);
|
||||
} // Fl_Input* template_name
|
||||
{ template_instance = new Fl_Input(198, 288, 252, 25, "Instance Name:");
|
||||
template_instance->labelfont(1);
|
||||
|
||||
@@ -299,7 +299,7 @@ void Widget_Browser::item_draw(void *v, int X, int Y, int, int) const {
|
||||
if (show_comments && l->comment()) {
|
||||
copy_trunc(buf, l->comment(), 80, 0);
|
||||
comment_incr = textsize()-1;
|
||||
Fl_Color comment_color = fl_color_average(FL_DARK_GREEN, FL_BLACK, 0.9);
|
||||
Fl_Color comment_color = fl_color_average(FL_DARK_GREEN, FL_BLACK, 0.9f);
|
||||
if (l->new_selected) fl_color(fl_contrast(comment_color, FL_SELECTION_COLOR));
|
||||
else fl_color(fl_contrast(comment_color, color()));
|
||||
fl_font(textfont()+FL_ITALIC, textsize()-2);
|
||||
|
||||
@@ -49,7 +49,7 @@ Function {make_widget_panel()} {
|
||||
xywh {95 40 309 20} labelfont 1 labelsize 11 align 4
|
||||
} {
|
||||
Fl_Input {} {
|
||||
callback label_cb
|
||||
callback label_cb selected
|
||||
tooltip {The label text for the widget.
|
||||
Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 textsize 11 resizable
|
||||
}
|
||||
@@ -110,7 +110,7 @@ or compressed in the original file format} xywh {364 90 20 20} type Toggle
|
||||
code3 {\#include "pixmaps.h"}
|
||||
}
|
||||
Fl_Button {} {
|
||||
callback bind_deimage_cb selected
|
||||
callback bind_deimage_cb
|
||||
tooltip {bind the image to the widget, so it will be deleted automatically} xywh {384 90 20 20} type Toggle
|
||||
code0 {o->image(bind_pixmap);}
|
||||
code3 {\#include "pixmaps.h"}
|
||||
|
||||
@@ -1271,6 +1271,7 @@ double Fl_Cairo_Graphics_Driver::width(unsigned int utf32) {
|
||||
|
||||
double Fl_Cairo_Graphics_Driver::width(const char* str, int n) {
|
||||
if (!font_descriptor()) return -1;
|
||||
if ((str == NULL) || (n == 0)) return 0.;
|
||||
if (n == fl_utf8len(*str)) { // str contains a single unicode character
|
||||
int l;
|
||||
unsigned c = fl_utf8decode(str, str+n, &l);
|
||||
|
||||
@@ -1273,6 +1273,7 @@ double Fl_Xlib_Graphics_Driver::width_unscaled(unsigned int utf32) {
|
||||
}
|
||||
|
||||
double Fl_Xlib_Graphics_Driver::width_unscaled(const char* str, int n) {
|
||||
if ((str == NULL) || (n == 0)) return 0.;
|
||||
if (n == fl_utf8len(*str)) { // str contains a single unicode character
|
||||
int l;
|
||||
unsigned c = fl_utf8decode(str, str+n, &l);
|
||||
|
||||
+3
-2
@@ -18,7 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Scheme_Choice.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
@@ -82,7 +82,8 @@ void bt(const char *name, Fl_Boxtype type, int square=0) {
|
||||
N++;
|
||||
x = x*W+10;
|
||||
y = y*H+10;
|
||||
Fl_Box *b = new Fl_Box(type,x,y,square ? H-20 : W-20,H-20,name);
|
||||
Fl_Button *b = new Fl_Button(x,y,square ? H-20 : W-20,H-20,name);
|
||||
b->box(type);
|
||||
b->labelsize(11);
|
||||
if (inactive) {
|
||||
b->color(FL_GREEN);
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ Function {} {open
|
||||
Fl_Slider {} {
|
||||
label FL_HORIZONTAL
|
||||
user_data {"Fl_Slider FL_HORIZONTAL"}
|
||||
callback callback
|
||||
callback callback selected
|
||||
xywh {140 80 130 20} type Horizontal selection_color 1 labelsize 8
|
||||
}
|
||||
Fl_Slider {} {
|
||||
@@ -125,7 +125,7 @@ Function {} {open
|
||||
Fl_Scrollbar {} {
|
||||
label {FL_VERTICAL (0) ->}
|
||||
user_data {"Fl_Scrollbar FL_VERTICAL"}
|
||||
callback callback selected
|
||||
callback callback
|
||||
tooltip {Vertical Scrollbar} xywh {405 30 20 90} labelsize 8 align 13 maximum 100 value 20
|
||||
}
|
||||
Fl_Box {} {
|
||||
|
||||
Reference in New Issue
Block a user