diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-28 05:04:13 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-28 05:04:13 +0000 |
| commit | c94a59c3f7fb34947c02ee4fc153828e8e178feb (patch) | |
| tree | 09602036c4813543e85672f9cabd885bdb9a3664 /fluid | |
| parent | 2abfda36ab9e32bbd8c93ab43eb006fe6778146a (diff) | |
Add support to FLUID for widget class creation without the intermediate
class stuff.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4197 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Function_Type.cxx | 9 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 3 | ||||
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 3 | ||||
| -rw-r--r-- | fluid/Fl_Window_Type.cxx | 60 |
4 files changed, 64 insertions, 11 deletions
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index f464378aa..eb90b4f15 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -969,11 +969,14 @@ void Fl_Class_Type::open() { Fl_Class_Type Fl_Class_type; static Fl_Class_Type *current_class; +extern Fl_Widget_Class_Type *current_widget_class; extern int varused_test; void write_public(int state) { - if (!current_class || varused_test) return; - if (current_class->write_public_state == state) return; - current_class->write_public_state = state; + if ((!current_class && !current_widget_class) || varused_test) return; + if (current_class && current_class->write_public_state == state) return; + if (current_widget_class && current_widget_class->write_public_state == state) return; + if (current_class) current_class->write_public_state = state; + if (current_widget_class) current_widget_class->write_public_state = state; write_h(state ? "public:\n" : "private:\n"); } diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index ef9048da6..39e9a2148 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -490,6 +490,9 @@ public: class Fl_Widget_Class_Type : private Fl_Window_Type { public: + // state variables for output: + char write_public_state; // true when public: has been printed + void write_code1(); void write_code2(); Fl_Type *make(); diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 5557eb679..8923a97cb 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -62,6 +62,7 @@ const char* subclassname(Fl_Type* l) { Fl_Widget_Type* p = (Fl_Widget_Type*)l; const char* c = p->subclass(); if (c) return c; + if (l->is_class()) return "Fl_Group"; if (p->o->type() == FL_WINDOW+1) return "Fl_Double_Window"; } return l->type_name(); @@ -1454,7 +1455,7 @@ void Fl_Widget_Type::write_static() { user_data_type() ? user_data_type() : "void*"); const char* c = array_name(this); const char* k = class_name(1); - if (c && !k) { + if (c && !k && !is_class()) { write_c("\n"); if (!public_) write_c("static "); else write_h("extern %s *%s;\n", t, c); diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx index 7fe924488..beb526ceb 100644 --- a/fluid/Fl_Window_Type.cxx +++ b/fluid/Fl_Window_Type.cxx @@ -1291,6 +1291,7 @@ int Fl_Window_Type::read_fdesign(const char* propname, const char* value) { /////////////////////////////////////////////////////////////////////// Fl_Widget_Class_Type Fl_Widget_Class_type; +Fl_Widget_Class_Type *current_widget_class = 0; Fl_Type *Fl_Widget_Class_Type::make() { Fl_Type *p = Fl_Type::current; @@ -1322,23 +1323,68 @@ Fl_Type *Fl_Widget_Class_Type::make() { void Fl_Widget_Class_Type::write_code1() { +#if 0 Fl_Widget_Type::write_code1(); +#endif // 0 + + current_widget_class = this; + write_public_state = 1; + + const char *c = subclass(); + if (!c) c = "Fl_Group"; + + write_h("\nclass %s : public %s {\n", name(), c); + if (!strcmp(c, "Fl_Window") || + !strcmp(c, "Fl_Double_Window") || + !strcmp(c, "Fl_Gl_Window") || + !strcmp(c, "Fl_Overlay_Window")) { + write_h(" void _%s();\n", name()); + write_h("public:\n"); + write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", name()); + write_h(" %s(int W, int H, const char *L = 0);\n"); + + write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), name()); + write_c(" : %s(X, Y, W, H, L) {\n", c); + write_c(" _%s();\n", name()); + write_c("}\n\n"); + + write_c("%s::%s(int W, int H, const char *L)\n", name(), name()); + write_c(" : %s(0, 0, W, H, L) {\n", c); + write_c(" clear_flag(FL_FORCE_POSITION);\n"); + write_c(" _%s();\n", name()); + write_c("}\n\n"); + + write_c("void %s::_%s() {\n", name(), name()); + write_c(" %s *w = this;\n", name()); + } else { + write_h("public:\n"); + write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", name()); + + write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), name()); + write_c(" : %s(X, Y, W, H, L) {\n", c); + } + + write_c(" %s *o = this;\n", name()); + + write_widget_code(); } void Fl_Widget_Class_Type::write_code2() { write_extra_code(); - if (modal) write_c("%so->set_modal();\n", indent()); - else if (non_modal) write_c("%so->set_non_modal();\n", indent()); - if (!((Fl_Window*)o)->border()) write_c("%so->clear_border();\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()); if (xclass) { - write_c("%so->xclass(", indent()); + write_c("%sxclass(", indent()); write_cstring(xclass); write_c(");\n"); } - write_c("%so->end();\n", indent()); + write_c("%send();\n", indent()); if (((Fl_Window*)o)->resizable() == o) - write_c("%so->resizable(o);\n", indent()); - write_block_close(); + write_c("%sresizable(this);\n", indent()); + write_c("}\n"); + + write_h("};\n"); } |
