diff options
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | fluid/Fl_Function_Type.cxx | 386 | ||||
| -rw-r--r-- | fluid/Fl_Type.cxx | 6 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 14 | ||||
| -rw-r--r-- | fluid/code.cxx | 11 | ||||
| -rw-r--r-- | fluid/factory.cxx | 2 | ||||
| -rw-r--r-- | fluid/function_panel.cxx | 112 | ||||
| -rw-r--r-- | fluid/function_panel.fl | 114 | ||||
| -rw-r--r-- | fluid/function_panel.h | 12 | ||||
| -rw-r--r-- | fluid/pixmaps/flData.xpm | 29 | ||||
| -rw-r--r-- | src/Fl_File_Chooser2.cxx | 2 |
11 files changed, 594 insertions, 96 deletions
@@ -1,5 +1,7 @@ CHANGES IN FLTK 1.3.0 + - Added binary data type to Fluid + - File chosser preview would hang if a device was choosen - Replaced _WIN32 symbols that had come with UTF-8 and the new Fl_Table widget with WIN32 - Fixed a buffer overflow in fl_utf8from_mb() (STR #2279) diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index d2e1f2c82..86a70c3a2 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -30,6 +30,7 @@ #include <FL/Fl_File_Chooser.H> #include "Fl_Type.h" #include <FL/fl_show_input.H> +#include <FL/Fl_File_Chooser.H> #include "../src/flstring.h" #include <stdio.h> #include <stdlib.h> @@ -41,7 +42,11 @@ extern const char* i18n_file; extern const char* i18n_set; extern char i18n_program[]; +extern int compile_only; + extern void redraw_browser(); +extern void goto_source_dir(); +extern void leave_source_dir(); //////////////////////////////////////////////////////////////// // quick check of any C code for legality, returns an error message @@ -51,14 +56,14 @@ static char buffer[128]; // for error messages // check a quoted string ending in either " or ' or >: const char *_q_check(const char * & c, int type) { for (;;) switch (*c++) { - case '\0': - sprintf(buffer,"missing %c",type); - return buffer; - case '\\': - if (*c) c++; - break; - default: - if (*(c-1) == type) return 0; + case '\0': + sprintf(buffer,"missing %c",type); + return buffer; + case '\\': + if (*c) c++; + break; + default: + if (*(c-1) == type) return 0; } } @@ -66,50 +71,50 @@ const char *_q_check(const char * & c, int type) { const char *_c_check(const char * & c, int type) { const char *d; for (;;) switch (*c++) { - case 0: - if (!type) return 0; - sprintf(buffer, "missing %c", type); - return buffer; - case '/': - // Skip comments as needed... - if (*c == '/') { - while (*c != '\n' && *c) c++; - } else if (*c == '*') { - c++; - while ((*c != '*' || c[1] != '/') && *c) c++; - if (*c == '*') c+=2; - else { - return "missing '*/'"; + case 0: + if (!type) return 0; + sprintf(buffer, "missing %c", type); + return buffer; + case '/': + // Skip comments as needed... + if (*c == '/') { + while (*c != '\n' && *c) c++; + } else if (*c == '*') { + c++; + while ((*c != '*' || c[1] != '/') && *c) c++; + if (*c == '*') c+=2; + else { + return "missing '*/'"; + } } - } - break; - case '#': - // treat cpp directives as a comment: - while (*c != '\n' && *c) c++; - break; - case '{': - if (type==')') goto UNEXPECTED; - d = _c_check(c,'}'); - if (d) return d; - break; - case '(': - d = _c_check(c,')'); - if (d) return d; - break; - case '\"': - d = _q_check(c,'\"'); - if (d) return d; - break; - case '\'': - d = _q_check(c,'\''); - if (d) return d; - break; - case '}': - case ')': - UNEXPECTED: - if (type == *(c-1)) return 0; - sprintf(buffer, "unexpected %c", *(c-1)); - return buffer; + break; + case '#': + // treat cpp directives as a comment: + while (*c != '\n' && *c) c++; + break; + case '{': + if (type==')') goto UNEXPECTED; + d = _c_check(c,'}'); + if (d) return d; + break; + case '(': + d = _c_check(c,')'); + if (d) return d; + break; + case '\"': + d = _q_check(c,'\"'); + if (d) return d; + break; + case '\'': + d = _q_check(c,'\''); + if (d) return d; + break; + case '}': + case ')': + UNEXPECTED: + if (type == *(c-1)) return 0; + sprintf(buffer, "unexpected %c", *(c-1)); + return buffer; } } @@ -232,7 +237,7 @@ void Fl_Function_Type::open() { if (mod) set_modflag(1); break; } - BREAK2: +BREAK2: function_panel->hide(); } @@ -399,7 +404,7 @@ void Fl_Function_Type::write_code2() { havechildren = 1; if (child->is_window() && child->name()) var = child->name(); } - + if (ismain()) { if (havewidgets) write_c(" %s->show(argc, argv);\n", var); if (havechildren) write_c(" return Fl::run();\n"); @@ -457,7 +462,7 @@ void Fl_Code_Type::open() { free(c); break; } - BREAK2: +BREAK2: code_panel->hide(); } @@ -526,7 +531,7 @@ void Fl_CodeBlock_Type::open() { storestring(c, after); break; } - BREAK2: +BREAK2: codeblock_panel->hide(); } @@ -548,13 +553,13 @@ void Fl_CodeBlock_Type::write_code2() { int Fl_Decl_Type::is_public() const { - Fl_Type *p = parent; - while (p && !p->is_decl_block()) p = p->parent; - if(p && p->is_public() && public_) - return public_; - else if(!p) - return public_; - return 0; + Fl_Type *p = parent; + while (p && !p->is_decl_block()) p = p->parent; + if(p && p->is_public() && public_) + return public_; + else if(!p) + return public_; + return 0; } Fl_Type *Fl_Decl_Type::make() { @@ -572,17 +577,25 @@ Fl_Type *Fl_Decl_Type::make() { void Fl_Decl_Type::write_properties() { Fl_Type::write_properties(); switch (public_) { + case 0: write_string("private"); break; case 1: write_string("public"); break; case 2: write_string("protected"); break; } - if (!static_) write_string("global"); + if (static_) + write_string("local"); + else + write_string("global"); } void Fl_Decl_Type::read_property(const char *c) { if (!strcmp(c,"public")) { public_ = 1; + } else if (!strcmp(c,"private")) { + public_ = 0; } else if (!strcmp(c,"protected")) { public_ = 2; + } else if (!strcmp(c,"local")) { + static_ = 1; } else if (!strcmp(c,"global")) { static_ = 0; } else { @@ -645,7 +658,7 @@ void Fl_Decl_Type::open() { if (c) free((void*)c); break; } - BREAK2: +BREAK2: decl_panel->hide(); } @@ -656,11 +669,11 @@ void Fl_Decl_Type::write_code1() { if (!c) return; // handle a few keywords differently if inside a class if (is_in_class() && ( - !strncmp(c,"class",5) && isspace(c[5]) - || !strncmp(c,"typedef",7) && isspace(c[7]) - || !strncmp(c,"FL_EXPORT",9) && isspace(c[9]) - || !strncmp(c,"struct",6) && isspace(c[6]) - ) ) { + !strncmp(c,"class",5) && isspace(c[5]) + || !strncmp(c,"typedef",7) && isspace(c[7]) + || !strncmp(c,"FL_EXPORT",9) && isspace(c[9]) + || !strncmp(c,"struct",6) && isspace(c[6]) + ) ) { write_public(public_); write_comment_h(" "); write_h(" %s\n", c); @@ -673,7 +686,7 @@ void Fl_Decl_Type::write_code1() { || !strncmp(c,"typedef",7) && isspace(c[7]) || !strncmp(c,"using",5) && isspace(c[5]) || !strncmp(c,"FL_EXPORT",9) && isspace(c[9]) -// || !strncmp(c,"struct",6) && isspace(c[6]) + // || !strncmp(c,"struct",6) && isspace(c[6]) ) { if (public_) { write_comment_h(); @@ -688,7 +701,7 @@ void Fl_Decl_Type::write_code1() { const char* e = c+strlen(c), *csc = c; while (csc<e && (csc[0]!='/' || csc[1]!='/')) csc++; if (csc!=e) e = csc; // comment found - // lose all trailing semicolons so I can add one: + // lose all trailing semicolons so I can add one: while (e>c && e[-1]==' ') e--; while (e>c && e[-1]==';') e--; if (class_name(1)) { @@ -719,6 +732,211 @@ void Fl_Decl_Type::write_code2() {} //////////////////////////////////////////////////////////////// +Fl_Type *Fl_Data_Type::make() { + Fl_Type *p = Fl_Type::current; + while (p && !p->is_decl_block()) p = p->parent; + Fl_Data_Type *o = new Fl_Data_Type(); + o->public_ = 1; + o->static_ = 1; + o->filename_ = 0; + char buf[32]; sprintf(buf, "data_%08x", (unsigned int)o); + o->name(buf); + o->add(p); + o->factory = this; + return o; +} + +void Fl_Data_Type::write_properties() { + Fl_Decl_Type::write_properties(); + if (filename_) { + write_string("filename"); + write_word(filename_); + } +} + +void Fl_Data_Type::read_property(const char *c) { + if (!strcmp(c,"filename")) { + storestring(read_word(), filename_, 1); + } else { + Fl_Decl_Type::read_property(c); + } +} + +void Fl_Data_Type::open() { + if (!data_panel) make_data_panel(); + data_input->static_value(name()); + if (is_in_class()) { + data_class_choice->value(public_); + data_class_choice->show(); + data_choice->hide(); + } else { + data_choice->value((public_&1)|((static_&1)<<1)); + data_choice->show(); + data_class_choice->hide(); + } + data_filename->value(filename_?filename_:""); + const char *c = comment(); + data_comment_input->buffer()->text(c?c:""); + data_panel->show(); + const char* message = 0; + for (;;) { // repeat as long as there are errors + if (message) fl_alert(message); + for (;;) { + Fl_Widget* w = Fl::readqueue(); + if (w == data_panel_cancel) goto BREAK2; + else if (w == data_panel_ok) break; + else if (w == data_filebrowser) { + goto_source_dir(); + const char *fn = fl_file_chooser("Load Binary Data", 0L, data_filename->value(), 1); + leave_source_dir(); + if (fn) { + if (strcmp(fn, data_filename->value())) + set_modflag(1); + data_filename->value(fn); + } + } + else if (!w) Fl::wait(); + } + // store the variable name: + const char*c = data_input->value(); + char *s = strdup(c), *p = s, *q, *n; + for (;;++p) { + if (!isspace((unsigned char)(*p))) break; + } + n = p; + if ( (!isalpha((unsigned char)(*p))) && ((*p)!='_') && ((*p)!=':') ) goto OOPS; + ++p; + for (;;++p) { + if ( (!isalnum((unsigned char)(*p))) && ((*p)!='_') && ((*p)!=':') ) break; + } + q = p; + for (;;++q) { + if (!*q) break; + if (!isspace((unsigned char)(*q))) goto OOPS; + } + if (n==q) { + OOPS: message = "variable name must be a C identifier"; + free((void*)s); + continue; + } + *p = 0; + name(n); + free(s); + // store flags + if (is_in_class()) { + if (public_!=data_class_choice->value()) { + set_modflag(1); + public_ = data_class_choice->value(); + } + } else { + if (public_!=(data_choice->value()&1)) { + set_modflag(1); + public_ = (data_choice->value()&1); + } + if (static_!=((data_choice->value()>>1)&1)) { + set_modflag(1); + static_ = ((data_choice->value()>>1)&1); + } + } + // store the filename + c = data_filename->value(); + if (filename_ && strcmp(filename_, data_filename->value())) + set_modflag(1); + else if (!filename_ && *c) + set_modflag(1); + if (filename_) { free((void*)filename_); filename_ = 0L; } + if (c && *c) filename_ = strdup(c); + // store the comment + c = data_comment_input->buffer()->text(); + if (c && *c) { + if (!comment() || strcmp(c, comment())) redraw_browser(); + comment(c); + } else { + if (comment()) redraw_browser(); + comment(0); + } + if (c) free((void*)c); + break; + } +BREAK2: + data_panel->hide(); +} + +Fl_Data_Type Fl_Data_type; + +void Fl_Data_Type::write_code1() { + const char *message = 0; + const char *c = name(); + if (!c) return; + const char *fn = filename_; + char *data = 0; + size_t nData = -1; + // path should be set correctly already + if (filename_ && !write_sourceview) { + FILE *f = fopen(filename_, "rb"); + if (!f) { + message = "Can't include binary file. Can't open"; + } else { + fseek(f, 0, SEEK_END); + nData = ftell(f); + fseek(f, 0, SEEK_SET); + if (nData) { + data = (char*)calloc(nData, 1); + fread(data, nData, 1, f); + } + fclose(f); + } + } else { + fn = "<no filename>"; + } + if (is_in_class()) { + write_public(public_); + write_comment_h(" "); + write_h(" static unsigned char %s[];\n", c); + write_c("unsigned char %s::%s[] = /* binary data included from %s */\n", class_name(1), c, fn); + if (message) write_c("#error %s %s\n", message, fn); + write_cdata(data, nData); + write_c(";\n"); + } else { + // the "header only" option does not apply here! + if (public_) { + if (static_) { + write_h("extern unsigned char %s[];\n", c); + write_comment_c(); + write_c("unsigned char %s[] = /* binary data included from %s */\n", c, fn); + if (message) write_c("#error %s %s\n", message, fn); + write_cdata(data, nData); + write_c(";\n"); + } else { + write_comment_h(); + write_h("#error Unsupported declaration loading binary data %s\n", fn); + write_h("unsigned char %s[] = { 1, 2, 3 };\n", c); + } + } else { + write_comment_c(); + if (static_) + write_c("static "); + write_c("unsigned char %s[] = /* binary data included from %s */\n", c, fn); + if (message) write_c("#error %s %s\n", message, fn); + write_cdata(data, nData); + write_c(";\n"); + } + } + // if we are in interactive mode, we pop up a warning dialog + // giving the error: (compile_only && !write_sourceview) + if (message && !write_sourceview) { + if (compile_only) + fprintf(stderr, "FLUID ERROR: %s %s\n", message, fn); + else + fl_alert("%s\n%s\n", message, fn); + } + if (data) free(data); +} + +void Fl_Data_Type::write_code2() {} + +//////////////////////////////////////////////////////////////// + int Fl_DeclBlock_Type::is_public() const {return public_;} Fl_Type *Fl_DeclBlock_Type::make() { @@ -787,7 +1005,7 @@ void Fl_DeclBlock_Type::open() { } break; } - BREAK2: +BREAK2: declblock_panel->hide(); } @@ -796,14 +1014,14 @@ Fl_DeclBlock_Type Fl_DeclBlock_type; void Fl_DeclBlock_Type::write_code1() { const char* c = name(); if (public_) - write_h("%s\n", c); + write_h("%s\n", c); write_c("%s\n", c); } void Fl_DeclBlock_Type::write_code2() { const char* c = after; if (public_) - write_h("%s\n", c); + write_h("%s\n", c); write_c("%s\n", c); } @@ -895,9 +1113,9 @@ void Fl_Comment_Type::open() { if (comment_predefined->value()==1) { // add the current comment to the database const char *xname = fl_input( - "Please enter a name to reference the current\ncomment in your database.\n\n" - "Use forward slashes '/' to create submenus.", - "My Comment"); + "Please enter a name to reference the current\ncomment in your database.\n\n" + "Use forward slashes '/' to create submenus.", + "My Comment"); if (xname) { char *name = strdup(xname); for (char*s=name;*s;s++) if (*s==':') *s = ';'; @@ -973,7 +1191,7 @@ void Fl_Comment_Type::open() { if (mod) set_modflag(1); break; } - BREAK2: +BREAK2: title_buf[0] = 0; comment_panel->hide(); } @@ -1138,9 +1356,9 @@ void Fl_Class_Type::open() { c_comment_input->buffer()->text(c?c:""); class_panel->show(); const char* message = 0; - + char *na=0,*pr=0,*p=0; // name and prefix substrings - + for (;;) { // repeat as long as there are errors if (message) fl_alert(message); for (;;) { @@ -1158,7 +1376,7 @@ void Fl_Class_Type::open() { if (p<s) goto OOPS; while (p>=s && is_id(*p)) p--; if ( (p<s && !is_id(*(p+1))) || !*(p+1) ) { - OOPS: message = "class name must be C++ identifier"; + OOPS: message = "class name must be C++ identifier"; free((void*)s); continue; } @@ -1190,7 +1408,7 @@ void Fl_Class_Type::open() { if (c) free((void*)c); break; } - BREAK2: +BREAK2: class_panel->hide(); } @@ -1218,9 +1436,9 @@ void Fl_Class_Type::write_code1() { write_h("\n"); write_comment_h(); if (prefix() && strlen(prefix())) - write_h("class %s %s ", prefix(), name()); + write_h("class %s %s ", prefix(), name()); else - write_h("class %s ", name()); + write_h("class %s ", name()); if (subclass_of) write_h(": %s ", subclass_of); write_h("{\n"); } diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index af20bd9fd..5a9b1750e 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -66,6 +66,7 @@ static Fl_Pixmap protected_pixmap(protected_xpm); #include "pixmaps/flCode.xpm" #include "pixmaps/flCodeBlock.xpm" #include "pixmaps/flComment.xpm" +#include "pixmaps/flData.xpm" #include "pixmaps/flDeclaration.xpm" #include "pixmaps/flDeclarationBlock.xpm" #include "pixmaps/flClass.xpm" @@ -153,6 +154,7 @@ static Fl_Pixmap valueinput_pixmap(flValueInput_xpm); static Fl_Pixmap valueoutput_pixmap(flValueOutput_xpm); static Fl_Pixmap spinner_pixmap(flSpinner_xpm); static Fl_Pixmap widgetclass_pixmap(flWidgetClass_xpm); +static Fl_Pixmap data_pixmap(flData_xpm); Fl_Pixmap *pixmap[] = { 0, &window_pixmap, &button_pixmap, &checkbutton_pixmap, &roundbutton_pixmap, /* 0..4 */ &box_pixmap, &group_pixmap, &function_pixmap, &code_pixmap, &codeblock_pixmap, &declaration_pixmap, /* 5..10 */ @@ -160,10 +162,10 @@ Fl_Pixmap *pixmap[] = { 0, &window_pixmap, &button_pixmap, &checkbutton_pixmap, &menuitem_pixmap, &menubar_pixmap, &submenu_pixmap, &scroll_pixmap, &tile_pixmap, &wizard_pixmap, /* 16..21 */ &pack_pixmap, &returnbutton_pixmap, &lightbutton_pixmap, &repeatbutton_pixmap, &menubutton_pixmap, /* 22..26 */ &output_pixmap, &textdisplay_pixmap, &textedit_pixmap, &fileinput_pixmap, &browser_pixmap, /* 27..32 */ - &checkbrowser_pixmap, &filebrowser_pixmap, &clock_pixmap, &help_pixmap, &progress_pixmap, /* 33..36 */ + &checkbrowser_pixmap, &filebrowser_pixmap, &clock_pixmap, &help_pixmap, &progress_pixmap, /* 33..36 */ &slider_pixmap, &scrollbar_pixmap, &valueslider_pixmap, &adjuster_pixmap, &counter_pixmap, /* 37..41 */ &dial_pixmap, &roller_pixmap, &valueinput_pixmap, &valueoutput_pixmap, &comment_pixmap, /* 42..46 */ - &spinner_pixmap, &widgetclass_pixmap /* 47..48 */ }; + &spinner_pixmap, &widgetclass_pixmap, &data_pixmap }; /* 47..49 */ extern int show_comments; diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index e80842ab8..b8d860373 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -213,6 +213,7 @@ public: }; class Fl_Decl_Type : public Fl_Type { +protected: char public_; char static_; public: @@ -227,6 +228,19 @@ public: int pixmapID() { return 10; } }; +class Fl_Data_Type : public Fl_Decl_Type { + const char *filename_; +public: + Fl_Type *make(); + void write_code1(); + void write_code2(); + void open(); + virtual const char *type_name() {return "data";} + void write_properties(); + void read_property(const char *); + int pixmapID() { return 49; } +}; + class Fl_DeclBlock_Type : public Fl_Type { const char* after; char public_; diff --git a/fluid/code.cxx b/fluid/code.cxx index 5354fe5cf..a96bbd720 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -235,6 +235,17 @@ void write_cdata(const char *s, int length) { varused = 1; return; } + if (write_sourceview) { + if (length>=0) + fprintf(code_file, "{ /* ... %d bytes of binary data... */ }", length); + else + fprintf(code_file, "{ /* ... binary data... */ }"); + return; + } + if (length==-1) { + fprintf(code_file, "{ /* ... undefined size binary data... */ }"); + return; + } const unsigned char *w = (const unsigned char *)s; const unsigned char *e = w+length; int linelength = 1; diff --git a/fluid/factory.cxx b/fluid/factory.cxx index fae67a929..912654811 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -915,6 +915,7 @@ int Fl_Value_Slider_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { extern class Fl_Function_Type Fl_Function_type; extern class Fl_Code_Type Fl_Code_type; extern class Fl_CodeBlock_Type Fl_CodeBlock_type; +extern class Fl_Data_Type Fl_Data_type; extern class Fl_Decl_Type Fl_Decl_type; extern class Fl_DeclBlock_Type Fl_DeclBlock_type; extern class Fl_Comment_Type Fl_Comment_type; @@ -988,6 +989,7 @@ Fl_Menu_Item New_Menu[] = { {"Class",0,cb,(void*)&Fl_Class_type}, {"Widget Class",0,cb,(void*)&Fl_Widget_Class_type}, {"Comment",0,cb,(void*)&Fl_Comment_type}, + {"Binary Data",0,cb,(void*)&Fl_Data_type}, {0}, {"Group",0,0,0,FL_SUBMENU}, {0,0,cb,(void*)&Fl_Window_type}, diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx index e36a9439b..ba409afb0 100644 --- a/fluid/function_panel.cxx +++ b/fluid/function_panel.cxx @@ -420,6 +420,112 @@ n int foo();\", a #directive like \"#include <foo.h>\", a comment like \"//foo\ return decl_panel; } +Fl_Double_Window *data_panel=(Fl_Double_Window *)0; + +Fl_Choice *data_choice=(Fl_Choice *)0; + +Fl_Menu_Item menu_data_choice[] = { + {"in source file only", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {"in header file only", 0, 0, 0, 16, FL_NORMAL_LABEL, 0, 11, 0}, + {"\"static\" in source file", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {"in source and \"extern\" in header", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {0,0,0,0,0,0,0,0,0} +}; + +Fl_Choice *data_class_choice=(Fl_Choice *)0; + +Fl_Menu_Item menu_data_class_choice[] = { + {"private", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {"public", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {"protected", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {0,0,0,0,0,0,0,0,0} +}; + +Fl_Input *data_input=(Fl_Input *)0; + +Fl_Input *data_filename=(Fl_Input *)0; + +Fl_Button *data_filebrowser=(Fl_Button *)0; + +Fl_Return_Button *data_panel_ok=(Fl_Return_Button *)0; + +Fl_Button *data_panel_cancel=(Fl_Button *)0; + +Fl_Text_Editor *data_comment_input=(Fl_Text_Editor *)0; + +Fl_Double_Window* make_data_panel() { + { data_panel = new Fl_Double_Window(343, 237, "Binary Data Properties"); + data_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE)); + { Fl_Group* o = new Fl_Group(10, 10, 270, 20); + { Fl_Box* o = new Fl_Box(200, 10, 80, 20); + Fl_Group::current()->resizable(o); + } // Fl_Box* o + { data_choice = new Fl_Choice(10, 10, 185, 20); + data_choice->down_box(FL_BORDER_BOX); + data_choice->labelsize(11); + data_choice->textsize(11); + data_choice->menu(menu_data_choice); + } // Fl_Choice* data_choice + { data_class_choice = new Fl_Choice(10, 10, 75, 20); + data_class_choice->down_box(FL_BORDER_BOX); + data_class_choice->labelsize(11); + data_class_choice->textsize(11); + data_class_choice->menu(menu_data_class_choice); + } // Fl_Choice* data_class_choice + o->end(); + } // Fl_Group* o + { data_input = new Fl_Input(10, 52, 320, 20, "Variable Name:"); + data_input->tooltip("Binary Data variables are declared \"const unsigned char []\"."); + data_input->labelfont(1); + data_input->labelsize(11); + data_input->textfont(4); + data_input->textsize(11); + data_input->align(Fl_Align(133)); + data_input->when(FL_WHEN_NEVER); + } // Fl_Input* data_input + { data_filename = new Fl_Input(10, 90, 280, 20, "Filename:"); + data_filename->tooltip("Name and path of binary file that will be included."); + data_filename->labelfont(1); + data_filename->labelsize(11); + data_filename->textfont(4); + data_filename->textsize(11); + data_filename->align(Fl_Align(133)); + data_filename->when(FL_WHEN_NEVER); + } // Fl_Input* data_filename + { data_filebrowser = new Fl_Button(290, 90, 40, 20, "@fileopen"); + data_filebrowser->labelcolor((Fl_Color)134); + } // Fl_Button* data_filebrowser + { Fl_Group* o = new Fl_Group(10, 205, 320, 20); + { data_panel_ok = new Fl_Return_Button(200, 205, 60, 20, "OK"); + data_panel_ok->labelsize(11); + data_panel_ok->window()->hotspot(data_panel_ok); + } // Fl_Return_Button* data_panel_ok + { data_panel_cancel = new Fl_Button(270, 205, 60, 20, "Cancel"); + data_panel_cancel->shortcut(0xff1b); + data_panel_cancel->labelsize(11); + } // Fl_Button* data_panel_cancel + { Fl_Box* o = new Fl_Box(10, 205, 185, 20); + Fl_Group::current()->resizable(o); + } // Fl_Box* o + o->end(); + } // Fl_Group* o + { data_comment_input = new Fl_Text_Editor(10, 130, 320, 65, "Comment:"); + data_comment_input->tooltip("Declaration comment in Doxygen format"); + data_comment_input->box(FL_DOWN_BOX); + data_comment_input->labelfont(1); + data_comment_input->labelsize(11); + data_comment_input->textfont(4); + data_comment_input->textsize(11); + data_comment_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + Fl_Group::current()->resizable(data_comment_input); + data_comment_input->buffer(new Fl_Text_Buffer()); + } // Fl_Text_Editor* data_comment_input + data_panel->size_range(343, 237); + data_panel->end(); + } // Fl_Double_Window* data_panel + return data_panel; +} + Fl_Double_Window *class_panel=(Fl_Double_Window *)0; Fl_Light_Button *c_public_button=(Fl_Light_Button *)0; @@ -657,6 +763,12 @@ Fl_Window* make_widgetbin() { o->callback((Fl_Callback*)type_make_cb, (void*)("declblock")); o->image(pixmap[11]); } // Fl_Button* o + { Fl_Button* o = new Fl_Button(55, 55, 24, 24); + o->tooltip("Binary Data"); + o->box(FL_THIN_UP_BOX); + o->callback((Fl_Callback*)type_make_cb, (void*)("data")); + o->image(pixmap[49]); + } // Fl_Button* o o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(87, 3, 79, 79); diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index 426f0ef56..5fa9dd8ec 100644 --- a/fluid/function_panel.fl +++ b/fluid/function_panel.fl @@ -31,22 +31,28 @@ comment {// } {in_source in_header } -decl {\#include <FL/Fl_Pixmap.H>} {} +decl {\#include <FL/Fl_Pixmap.H>} {private local +} -decl {\#include "Fl_Type.h"} {} +decl {\#include "Fl_Type.h"} {private local +} -decl {\#include "undo.h"} {} +decl {\#include "undo.h"} {private local +} -decl {extern class Fl_Pixmap *pixmap[];} {} +decl {extern class Fl_Pixmap *pixmap[];} {private local +} -decl {extern class Fl_Type *Fl_Type_make(const char*);} {} +decl {extern class Fl_Type *Fl_Type_make(const char*);} {private local +} -decl {extern void select_only(Fl_Type*);} {} +decl {extern void select_only(Fl_Type*);} {private local +} -decl {extern void exit_cb(Fl_Widget*, void*);} {global +decl {extern void exit_cb(Fl_Widget*, void*);} {private global } -decl {extern void toggle_widgetbin_cb(Fl_Widget*, void*);} {global +decl {extern void toggle_widgetbin_cb(Fl_Widget*, void*);} {private global } Function {make_function_panel()} {} { @@ -322,6 +328,90 @@ Function {make_decl_panel()} {} { } } +Function {make_data_panel()} {open +} { + Fl_Window data_panel { + label {Binary Data Properties} open + xywh {414 355 343 237} type Double align 80 resizable size_range {343 237 0 0} visible + } { + Fl_Group {} {open + xywh {10 10 270 20} + } { + Fl_Box {} { + xywh {200 10 80 20} resizable + } + Fl_Choice data_choice {open + xywh {10 10 185 20} down_box BORDER_BOX labelsize 11 textsize 11 + } { + MenuItem {} { + label {in source file only} + xywh {0 0 100 20} labelsize 11 + } + MenuItem {} { + label {in header file only} + xywh {0 0 100 20} labelsize 11 hide + } + MenuItem {} { + label {"static" in source file} + xywh {0 0 100 20} labelsize 11 + } + MenuItem {} { + label {in source and "extern" in header} + xywh {0 0 100 20} labelsize 11 + } + } + Fl_Choice data_class_choice {open + xywh {10 10 75 20} down_box BORDER_BOX labelsize 11 textsize 11 + } { + MenuItem {} { + label private + xywh {10 10 100 20} labelsize 11 + } + MenuItem {} { + label public + xywh {10 10 100 20} labelsize 11 + } + MenuItem {} { + label protected + xywh {10 10 100 20} labelsize 11 + } + } + } + Fl_Input data_input { + label {Variable Name:} + tooltip {Binary Data variables are declared "const unsigned char []".} xywh {10 52 320 20} labelfont 1 labelsize 11 align 133 when 0 textfont 4 textsize 11 + } + Fl_Input data_filename { + label {Filename:} + tooltip {Name and path of binary file that will be included.} xywh {10 90 280 20} labelfont 1 labelsize 11 align 133 when 0 textfont 4 textsize 11 + } + Fl_Button data_filebrowser { + label {@fileopen} + xywh {290 90 40 20} labelcolor 134 + } + Fl_Group {} {open + xywh {10 205 320 20} + } { + Fl_Return_Button data_panel_ok { + label OK selected + xywh {200 205 60 20} labelsize 11 hotspot + } + Fl_Button data_panel_cancel { + label Cancel + xywh {270 205 60 20} shortcut 0xff1b labelsize 11 + } + Fl_Box {} { + xywh {10 205 185 20} resizable + } + } + Fl_Text_Editor data_comment_input { + label {Comment:} + tooltip {Declaration comment in Doxygen format} xywh {10 130 320 65} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable + code0 {data_comment_input->buffer(new Fl_Text_Buffer());} + } + } +} + Function {make_class_panel()} {} { Fl_Window class_panel { label {Class Properties} open @@ -441,7 +531,7 @@ Function {make_widgetbin()} {} { callback {if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape) exit_cb((Fl_Widget*)o, v); else - toggle_widgetbin_cb((Fl_Widget*)o, v);} open selected + toggle_widgetbin_cb((Fl_Widget*)o, v);} xywh {410 171 550 85} type Single align 80 non_modal visible } { Fl_Group {} { @@ -495,6 +585,12 @@ else tooltip {Declaration Block} xywh {30 55 24 24} box THIN_UP_BOX code0 {o->image(pixmap[11]);} } + Fl_Button {} { + user_data {"data"} + callback type_make_cb + tooltip {Binary Data} xywh {55 55 24 24} box THIN_UP_BOX + code0 {o->image(pixmap[49]);} + } } Fl_Group {} { xywh {87 3 79 79} diff --git a/fluid/function_panel.h b/fluid/function_panel.h index d602c4421..aa151bc24 100644 --- a/fluid/function_panel.h +++ b/fluid/function_panel.h @@ -82,6 +82,18 @@ extern Fl_Text_Editor *decl_comment_input; Fl_Double_Window* make_decl_panel(); extern Fl_Menu_Item menu_decl_choice[]; extern Fl_Menu_Item menu_decl_class_choice[]; +extern Fl_Double_Window *data_panel; +extern Fl_Choice *data_choice; +extern Fl_Choice *data_class_choice; +extern Fl_Input *data_input; +extern Fl_Input *data_filename; +extern Fl_Button *data_filebrowser; +extern Fl_Return_Button *data_panel_ok; +extern Fl_Button *data_panel_cancel; +extern Fl_Text_Editor *data_comment_input; +Fl_Double_Window* make_data_panel(); +extern Fl_Menu_Item menu_data_choice[]; +extern Fl_Menu_Item menu_data_class_choice[]; extern Fl_Double_Window *class_panel; extern Fl_Light_Button *c_public_button; extern Fl_Input *c_name_input; diff --git a/fluid/pixmaps/flData.xpm b/fluid/pixmaps/flData.xpm new file mode 100644 index 000000000..a01582ca2 --- /dev/null +++ b/fluid/pixmaps/flData.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static const char *flData_xpm[] = { +/* width height ncolors chars_per_pixel */ +"16 16 6 1", +/* colors */ +". c none", +"a c #000000", +"b c #c0e0c0", +"c c #000000", +" c #000000", +"- c #607006", +/* pixels */ +"................", +"................", +"...aaaaaaaaaaaaa", +"...abbbbbbbbbbbc", +"...ab b- -b bbbc", +"..abb b b b bbc.", +"..abb b- -b bbc.", +"..abbbbbbbbbbbc.", +".abbbbbbbbbbbc..", +".ab b b- -bbbc..", +".ab b b b bbbc..", +"abb b b- -bbc...", +"abbbbbbbbbbbc...", +"acccccccccccc...", +"................", +"................", +}; diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index e785c3be2..6c93f90a0 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1288,7 +1288,7 @@ Fl_File_Chooser::update_preview() { const char *filename; // Current filename const char *newlabel = 0; // New label text - Fl_Shared_Image *image = 0, // New image + Fl_Shared_Image *image = 0, // New image *oldimage; // Old image int pbw, pbh; // Width and height of preview box int w, h; // Width and height of preview image |
