From 255e7fb39b83523c52855809bb9a80f647fe4cff Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 15 Oct 1998 14:19:34 +0000 Subject: [PATCH] Fluid fixes from Vincent PENNE. git-svn-id: file:///fltk/svn/fltk/trunk@12 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Function_Type.cxx | 12 +++++++----- fluid/Fl_Type.cxx | 2 ++ fluid/Fl_Type.h | 2 ++ fluid/Fl_Widget_Type.cxx | 3 ++- fluid/Fl_Window_Type.cxx | 9 ++++++++- fluid/about_panel.cxx | 3 ++- fluid/alignment_panel.cxx | 15 +++++++++++---- fluid/alignment_panel.fl | 11 ++++++++--- fluid/alignment_panel.h | 3 +++ fluid/code.cxx | 4 +++- fluid/file.cxx | 10 +++++++++- fluid/fluid.cxx | 1 + fluid/widget_panel.cxx | 5 +++-- src/fl_cursor.cxx | 2 +- 14 files changed, 62 insertions(+), 20 deletions(-) diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 21bdb5b37..32926e1ca 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -66,6 +66,8 @@ const char *c_check(const char *c, int type) { class Fl_Function_Type : public Fl_Type { const char* return_type; + const char* actual_return_type; + const char* star; char public_, constructor, havewidgets; public: Fl_Type *make(); @@ -166,21 +168,21 @@ void Fl_Function_Type::write_code1() { Fl_Type *child; const char* widget_type = 0; for (child = next; child && child->level > level; child = child->next) - if (child->is_widget()) { + if (child->is_widget() && child->level == level+1) { havewidgets = 1; widget_type = subclassname(child); - break; } write_c("\n"); if (ismain()) write_c("int main(int argc, char **argv) {\n"); else { const char* t = return_type; - const char* star = ""; + star = ""; if (!t) { if (havewidgets) {t = widget_type; star = "*";} else t = "void"; } + actual_return_type=t; const char* k = class_name(); if (k) { write_public(public_); @@ -200,7 +202,7 @@ void Fl_Function_Type::write_code1() { write_c("%s%s %s {\n", t, star, name()); } } - if (havewidgets) write_c(" %s* w;\n", widget_type); + if (havewidgets) write_c(" Fl_Window* w;\n"); indentation += 2; } @@ -209,7 +211,7 @@ void Fl_Function_Type::write_code2() { if (havewidgets) write_c(" w->show(argc, argv);\n"); write_c(" return Fl::run();\n"); } else if (havewidgets && !constructor) - write_c(" return w;\n"); + write_c(" return (%s%s)w;\n", actual_return_type, star); write_c("}\n"); indentation = 0; } diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index f57a970d4..c7179f42f 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -512,6 +512,8 @@ void delete_all(int selected_only) { f = g; } else f = f->next; } + if(!selected_only) include_H_from_C=1; + selection_changed(0); } diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 737423a1d..e6968d13d 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -140,3 +140,5 @@ const char *c_check(const char *c, int type = 0); // replace a string pointer with new value, strips leading/trailing blanks: int storestring(const char *n, const char * & p, int nostrip=0); + +extern bool include_H_from_C; diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 96c22acea..c979799ac 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -1267,7 +1267,7 @@ void Fl_Widget_Type::write_code1() { if (varused) write_c("{ %s* o = ", t); if (name()) write_c("%s = ", name()); if (is_window()) { - write_c("w = new %s(%d, %d", t, o->w(), o->h()); + write_c("new %s(%d, %d", t, o->w(), o->h()); // prevent type() code from being emitted: ((Fl_Widget_Type*)factory)->o->type(o->type()); } else { @@ -1279,6 +1279,7 @@ void Fl_Widget_Type::write_code1() { } write_c(");\n"); indentation += 2; + if (is_window()) write_c("%sw = o;\n", indent()); if (varused) write_widget_code(); } diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx index 044c8233f..d3fd4b323 100644 --- a/fluid/Fl_Window_Type.cxx +++ b/fluid/Fl_Window_Type.cxx @@ -21,6 +21,8 @@ int gridx = 5; int gridy = 5; int snap = 3; +bool include_H_from_C; + void alignment_cb(Fl_Input *i, long v) { int n = atoi(i->value()); if (n < 0) n = 0; @@ -35,7 +37,8 @@ extern const char* header_file_name; extern const char* code_file_name; void show_alignment_cb(Fl_Widget *, void *) { - make_alignment_window(); + if(alignment_window==0) make_alignment_window(); + include_H_from_C_button->value(include_H_from_C); header_file_input->value(header_file_name); code_file_input->value(code_file_name); char buf[128]; @@ -53,6 +56,10 @@ void code_input_cb(Fl_Input* i, void*) { printf("code file name set to %s\n", code_file_name); } +void include_H_from_C_button_cb(Fl_Light_Button* b, void*) { + include_H_from_C = b->value(); +} + //////////////////////////////////////////////////////////////// static Fl_Menu_Item window_type_menu[] = { diff --git a/fluid/about_panel.cxx b/fluid/about_panel.cxx index a880d39dd..78b48a6bb 100644 --- a/fluid/about_panel.cxx +++ b/fluid/about_panel.cxx @@ -19,7 +19,8 @@ static void cb_OK(Fl_Return_Button* o, void*) { Fl_Window* make_about_panel(const char *copyright) { Fl_Window* w; - { Fl_Window* o = about_panel = w = new Fl_Window(309, 221, "about fluid"); + { Fl_Window* o = about_panel = new Fl_Window(309, 221, "about fluid"); + w = o; o->box(FL_UP_BOX); o->color(97); o->selection_color(47); diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx index fa8c7c089..bb5691ab7 100644 --- a/fluid/alignment_panel.cxx +++ b/fluid/alignment_panel.cxx @@ -18,9 +18,12 @@ Fl_Input *header_file_input; Fl_Input *code_file_input; +Fl_Light_Button *include_H_from_C_button; + Fl_Window* make_alignment_window() { - Fl_Window *w; - { Fl_Window* o = alignment_window = w = new Fl_Window(210, 282, "fluid Preferences"); + Fl_Window* w; + { Fl_Window* o = alignment_window = new Fl_Window(210, 310, "fluid Preferences"); + w = o; { Fl_Box* o = new Fl_Box(10, 20, 190, 100, "ALIGNMENT:"); o->box(FL_ENGRAVED_FRAME); o->labelsize(10); @@ -44,9 +47,8 @@ Fl_Window* make_alignment_window() { o->callback((Fl_Callback*)alignment_cb, (void*)(3)); o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY); } - { Fl_Button* o = new Fl_Button(10, 250, 190, 20, "close"); + { Fl_Button* o = new Fl_Button(10, 280, 190, 20, "close"); o->callback((Fl_Callback*)cb_close); - w->hotspot(o); } { Fl_Box* o = new Fl_Box(10, 140, 190, 100, "OUTPUT FILE NAMES:"); o->box(FL_ENGRAVED_FRAME); @@ -67,6 +69,11 @@ Fl_Window* make_alignment_window() { o->callback((Fl_Callback*)code_input_cb, (void*)(1)); o->when(1); } + { Fl_Light_Button* o = include_H_from_C_button = new Fl_Light_Button(60, 250, 140, 20, "Include .H from .C"); + o->value(1); + o->callback((Fl_Callback*)include_H_from_C_button_cb); + } + o->set_modal(); o->end(); } return w; diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl index c2e7f9286..07e39fce9 100644 --- a/fluid/alignment_panel.fl +++ b/fluid/alignment_panel.fl @@ -8,8 +8,8 @@ snap 3 Function {make_alignment_window()} {open } { Fl_Window alignment_window { - label {fluid Preferences} open selected - xywh {303 187 210 282} visible + label {fluid Preferences} open + xywh {0 22 210 310} modal visible } { Fl_Box {} { label {ALIGNMENT:} @@ -39,7 +39,7 @@ Function {make_alignment_window()} {open Fl_Button {} { label close callback {alignment_window->hide();} - xywh {10 250 190 20} hotspot + xywh {10 280 190 20} } Fl_Box {} { label {OUTPUT FILE NAMES:} @@ -61,5 +61,10 @@ Function {make_alignment_window()} {open callback code_input_cb xywh {90 210 100 20} box THIN_DOWN_BOX when 1 } + Fl_Light_Button include_H_from_C_button { + label {Include .H from .C} + callback include_H_from_C_button_cb + xywh {60 250 140 20} value 1 + } } } diff --git a/fluid/alignment_panel.h b/fluid/alignment_panel.h index 437d7640f..ae545f5d1 100644 --- a/fluid/alignment_panel.h +++ b/fluid/alignment_panel.h @@ -4,14 +4,17 @@ #include #include #include +#include #include extern void alignment_cb(Fl_Input*, long); extern void code_input_cb(Fl_Input*, void*); extern void header_input_cb(Fl_Input*, void*); +extern void include_H_from_C_button_cb(Fl_Light_Button*, void*); extern Fl_Window *alignment_window; extern Fl_Input *horizontal_input; extern Fl_Input *vertical_input; extern Fl_Input *snap_input; extern Fl_Input *header_file_input; extern Fl_Input *code_file_input; +extern Fl_Light_Button *include_H_from_C_button; Fl_Window* make_alignment_window(); diff --git a/fluid/code.cxx b/fluid/code.cxx index 171593fff..a8028acc1 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -12,6 +12,7 @@ #include #include "Fl_Type.H" +#include "alignment_panel.H" static FILE *code_file; static FILE *header_file; @@ -240,7 +241,8 @@ int write_code(const char *s, const char *t) { for (p = Fl_Type::first; p; p = p->next) p->write_declare(); delete included_root; included_root = 0; - if (t) write_c("#include \"%s\"\n", filename_name(t)); + if (t && include_H_from_C) + write_c("#include \"%s\"\n", filename_name(t)); for (p = Fl_Type::first; p; p = p->next) p->write_static(); for (p = Fl_Type::first; p;) p = write_code(p); diff --git a/fluid/file.cxx b/fluid/file.cxx index 69bc97d17..282e33f5a 100644 --- a/fluid/file.cxx +++ b/fluid/file.cxx @@ -14,6 +14,7 @@ #include #include #include +#include "alignment_panel.H" //////////////////////////////////////////////////////////////// // BASIC FILE WRITING: @@ -298,6 +299,8 @@ int write_file(const char *filename, int selected_only) { if (!open_write(filename)) return 0; write_string("# data file for the Fltk User Interface Designer (fluid)\n" "version %.2f",FL_VERSION); + if(!include_H_from_C) + write_string("\ndo_not_include_H_from_C"); if (!selected_only) { write_string("\nheader_name"); write_word(header_file_name); write_string("\ncode_name"); write_word(code_file_name); @@ -365,6 +368,11 @@ static void read_children(Fl_Type *p, int paste) { continue; } + if (!strcmp(c,"do_not_include_H_from_C")) + { + include_H_from_C=0; + goto CONTINUE; + } if (!strcmp(c,"header_name")) { header_file_name = strdup(read_word()); goto CONTINUE; @@ -420,7 +428,7 @@ extern void deselect(); int read_file(const char *filename, int merge) { read_version = 0.0; if (!open_read(filename)) return 0; - if (merge) deselect(); else delete_all(); + if (merge) deselect(); else delete_all(); read_children(Fl_Type::current, merge); Fl_Type::current = 0; for (Fl_Type *o = Fl_Type::first; o; o = o->next) diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 384eb5104..3ad9e827c 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -365,6 +365,7 @@ int main(int argc,char **argv) { } const char *c = argv[i]; make_main_window(); + include_H_from_C=1; if (c) set_filename(c); if (!compile_only) { Fl::visual((Fl_Mode)(FL_DOUBLE|FL_INDEX)); diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx index 23ee01e19..46e74066a 100644 --- a/fluid/widget_panel.cxx +++ b/fluid/widget_panel.cxx @@ -5,8 +5,9 @@ Fl_Input *v_input[4]; Fl_Window* make_widget_panel() { - Fl_Window *w; - { Fl_Window* o = w = new Fl_Window(370, 480); + Fl_Window* w; + { Fl_Window* o = new Fl_Window(370, 480); + w = o; w->hotspot(o); { Fl_Input* o = new Fl_Input(90, 10, 210, 20, "name:"); o->box(FL_THIN_UP_BOX); diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx index e058c3f7c..ff787cfaa 100644 --- a/src/fl_cursor.cxx +++ b/src/fl_cursor.cxx @@ -62,7 +62,7 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) { #define CURSORSIZE 16 #define HOTXY 7 -struct TableEntry { +static struct TableEntry { uchar bits[CURSORSIZE*CURSORSIZE/8]; uchar mask[CURSORSIZE*CURSORSIZE/8]; Cursor cursor;