diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 462397a126..e730a61662 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -36,6 +36,7 @@ set(CPPFILES ui/about_panel.cxx ui/main_panel.cxx ui/panel.cxx + ui/template_panel.cxx widgets/bin_buttons.cxx widgets/code_viewers.cxx widgets/coord_input.cxx @@ -60,7 +61,6 @@ set(CPPFILES pixmaps.cxx shell_command.cxx codeview_panel.cxx - template_panel.cxx widget_browser.cxx widget_panel.cxx ) @@ -77,6 +77,7 @@ set(HEADERFILES ui/about_panel.h ui/main_panel.h ui/panel.h + ui/template_panel.h streams/code_writer.h streams/project_reader.h streams/project_writer.h @@ -105,7 +106,6 @@ set(HEADERFILES pixmaps.h shell_command.h codeview_panel.h - template_panel.h widget_browser.h widget_panel.h ) diff --git a/fluid/application/application.cxx b/fluid/application/application.cxx index 42faf6d304..a9da08057f 100644 --- a/fluid/application/application.cxx +++ b/fluid/application/application.cxx @@ -19,6 +19,7 @@ #include "project/project.h" #include "fluid.h" #include "widget_browser.h" +#include "ui/template_panel.h" #include #include "../src/flstring.h" @@ -244,3 +245,19 @@ char* Application::cutfname(int which) { return name[which]; } +/** + Open the template browser and load a new file from templates. + + If the current project was modified, FLUID will give the user the opportunity + to save the old project first. + + \return false if the operation was canceled or failed otherwise + */ +bool Application::new_project_from_template() { + // clear the current project first + if (new_project() == false) + return false; + + // Now let the panel do the work. + return fluid::ui::template_panel.load_template(); +} \ No newline at end of file diff --git a/fluid/application/application.h b/fluid/application/application.h index ce36182672..b5e8315c6e 100644 --- a/fluid/application/application.h +++ b/fluid/application/application.h @@ -64,6 +64,8 @@ class Application { const Fl_String &get_tmpdir(); /// Return the path and filename of a temporary file for cut or duplicated data. static char* cutfname(int which = 0); + /// Pop up the template dialog and create a new project from a template. + bool new_project_from_template(); }; }; // namespace FLUID diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 19f4b047c4..31f4e41e61 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -26,6 +26,7 @@ #include "application/application.h" #include "project/project.h" #include "ui/main_panel.h" +#include "ui/template_panel.h" #include "Fl_Type.h" #include "Fl_Function_Type.h" #include "Fl_Group_Type.h" @@ -43,7 +44,7 @@ #include "settings_panel.h" #include "function_panel.h" #include "codeview_panel.h" -#include "template_panel.h" +#include "ui/template_panel.h" #include "ui/about_panel.h" #include "autodoc.h" @@ -227,6 +228,8 @@ static void external_editor_timer(void*) { // Fluid.project.save(v != NULL, v != (void *)2); // } +#if 0 + /** Save a design template. \todo We should document the concept of templates. @@ -297,7 +300,6 @@ void save_as_template() { return; } -#if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ) // Get the screenshot, if any... Fl_Type *t; @@ -325,17 +327,9 @@ void save_as_template() { return; } -# if 0 // The original PPM output code... - strcpy(ext, ".ppm"); - fp = fl_fopen(filename, "wb"); - fprintf(fp, "P6\n%d %d 255\n", w, h); - fwrite(pixels, w * h, 3, fp); - fclose(fp); -# endif // 0 - delete[] pixels; -#endif // HAVE_LIBPNG && HAVE_LIBZ } +#endif //-> application::callbacks /** @@ -401,6 +395,7 @@ void quit_fluid() { exit(0); } +#if 0 //-> application::callbacks /** Open the template browser and load a new file from templates. @@ -510,6 +505,7 @@ bool new_project_from_template() { return true; } +#endif #ifdef __APPLE__ /** diff --git a/fluid/project/project.cxx b/fluid/project/project.cxx index 0a422d2f35..50072a2448 100644 --- a/fluid/project/project.cxx +++ b/fluid/project/project.cxx @@ -17,6 +17,7 @@ #include "project/project.h" #include "application/application.h" #include "ui/main_panel.h" +#include "ui/template_panel.h" #include "fluid.h" #include "streams/project_reader.h" #include "streams/project_writer.h" @@ -679,3 +680,11 @@ void Project::write_strings() { } } } + +/** + Save a design template. + \todo We should document the concept of templates. + */ +void Project::save_as_template() { + fluid::ui::template_panel.add(this); +} diff --git a/fluid/project/project.h b/fluid/project/project.h index ee287bb656..a493a3685b 100644 --- a/fluid/project/project.h +++ b/fluid/project/project.h @@ -130,6 +130,8 @@ class Project { const char *filename { nullptr }; /// Used as a counter to set the .fl project dir as the current directory. char in_project_dir { 0 }; + /// open a dialog box to save this project as a template + void save_as_template(); }; } // namespace fluid diff --git a/fluid/template_panel.fl b/fluid/template_panel.fl deleted file mode 100644 index 790702edc3..0000000000 --- a/fluid/template_panel.fl +++ /dev/null @@ -1,298 +0,0 @@ -# data file for the Fltk User Interface Designer (fluid) -version 1.0400 -header_name {.h} -code_name {.cxx} -comment {// -// FLUID template support for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2020 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 -// file is missing or damaged, see the license at: -// -// https://www.fltk.org/COPYING.php -// -// Please see the following page on how to report bugs and issues: -// -// https://www.fltk.org/bugs.php -// -} {in_source in_header -} - -decl {\#include "fluid.h"} {private local -} - -decl {\#include } {private local -} - -decl {\#include } {private local -} - -decl {\#include } {private local -} - -decl {\#include "fluid_filename.h"} {private local -} - -decl {\#include "../src/flstring.h"} {private local -} - -decl {\#include } {private local -} - -decl {\#include } {private local -} - -decl {\#include } {private local -} - -decl {\#include } {private local -} - -declblock {\#if defined(_WIN32) && !defined(__CYGWIN__)} {after {\#endif // _WIN32 && !__CYGWIN__} -} { - decl {\#include } {private local - } - decl {\#else} {private local - } - decl {\#include } {private local - } -} - -Function {make_template_panel()} {open -} { - Fl_Window template_panel { - label {New/Save Template} - callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); -if (img) img->release(); -template_preview->image(0); - -template_browser->deselect(); -template_name->value(""); -template_instance->value(""); -template_panel->hide();} open - xywh {478 284 460 355} type Double resizable modal visible - } { - Fl_Browser template_browser { - label {Available Templates:} - callback {if (Fl::event_clicks()) { - template_panel->hide(); - return; -} -Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); -if (img) img->release(); -template_preview->image(0); -template_preview->redraw(); - -int item = template_browser->value(); - -if (item <= 1) template_instance->deactivate(); -else template_instance->activate(); - -if (item < 1) { - template_submit->deactivate(); - template_delete->deactivate(); - return; -} - -template_submit->activate(); - -const char *flfile = (const char *)template_browser->data(item); -if (!flfile) { - template_delete->deactivate(); - return; -} - -template_name->value(template_browser->text(item)); - -template_delete->activate(); - -char pngfile[1024], *ext; - -strlcpy(pngfile, flfile, sizeof(pngfile)); -if ((ext = strrchr(pngfile, '.')) == NULL) return; -strcpy(ext, ".png"); - -img = Fl_Shared_Image::get(pngfile); - -if (img) { - template_preview->image(img); - template_preview->redraw(); -}} - xywh {10 28 180 250} type Hold labelfont 1 align 5 when 3 - } - Fl_Box template_preview { - xywh {200 28 250 250} box THIN_DOWN_BOX align 80 resizable - } - Fl_Input template_name { - label {Template Name:} - callback {if (strlen(template_name->value())) { - template_submit->activate(); - if (Fl::event_key() == FL_Enter) template_panel->hide(); -} else template_submit->deactivate();} - xywh {198 288 252 25} labelfont 1 when 3 textfont 4 - } - Fl_Input template_instance { - label {Instance Name:} - xywh {198 288 252 25} labelfont 1 textfont 4 hide - } - Fl_Group {} {open - xywh {10 323 440 25} - } { - Fl_Button template_delete { - label {Delete Template} - callback template_delete_cb - xywh {10 323 143 25} - } - Fl_Box {} { - xywh {153 323 126 25} resizable - } - Fl_Button {} { - label Cancel - callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); -if (img) img->release(); -template_preview->image(0); - -template_browser->deselect(); -template_name->value(""); -template_instance->value(""); -template_panel->hide();} - xywh {289 323 72 25} - } - Fl_Return_Button template_submit { - label Save - callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); -if (img) img->release(); -template_preview->image(0); - -template_panel->hide();} - xywh {371 323 79 25} - } - } - } -} - -Function {template_clear()} {return_type void -} { - code {int i; -void *filename; - -for (i = 1; i <= template_browser->size(); i ++) { - if ((filename = template_browser->data(i)) != NULL) free(filename); -} - -template_browser->deselect(); -template_browser->clear();} {} -} - -Function {template_delete_cb(Fl_Button *, void *)} {open return_type void -} { - code {int item = template_browser->value(); -if (item < 1) return; - -const char *name = template_browser->text(item); -const char *flfile = (const char *)template_browser->data(item); -if (!flfile) return; - -if (!fl_choice("Are you sure you want to delete the template \\"%s\\"?", - "Cancel", "Delete", 0, name)) return; - -if (fl_unlink(flfile)) { - fl_alert("Unable to delete template \\"%s\\":\\n%s", name, strerror(errno)); - return; -} - -char pngfile[1024], *ext; -strlcpy(pngfile, flfile, sizeof(pngfile)); -if ((ext = strrchr(pngfile, '.')) != NULL) { - strcpy(ext, ".png"); - fl_unlink(pngfile); -} - -template_browser->remove(item); -template_browser->do_callback();} {selected - } -} - -data tmpl_FLTK_License_fl {private local filename {templates/FLTK_License.fl} compressed -} - -data tmpl_1of7GUIs_fl {private local filename {templates/1of7GUIs.fl} compressed -} - -Function {template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen)} {open return_type void -} { - code {char filename[FL_PATH_MAX]; - strcpy(filename, path); - strcat(filename, name); - FILE *f = fopen(filename, "wb"); - if (!f) return; - uLong dstLen = inDstLen; - Bytef *dst = (Bytef*)::malloc(inDstLen); - if (uncompress(dst, &dstLen, (Bytef*)inSrc, (uLong)inSrcLen) != Z_OK) { /* error */ } - if (fwrite(dst, dstLen, 1, f) <= 0) { /* error */ } - fclose(f);} {} -} - -Function {template_load()} {open return_type void -} { - code {int i; -char name[1024], filename[1400], path[1024], *ptr; -struct dirent **files; -int num_files; - -fluid_prefs.getUserdataPath(path, sizeof(path)); -strlcat(path, "templates", sizeof(path)); -fl_make_path(path); - -int sample_templates_generated = 0; -fluid_prefs.get("sample_templates_generated", sample_templates_generated, 0); - -if (sample_templates_generated < 2) { - strcpy(filename, path); - strcat(filename, "/FLTK_License.fl"); - FILE *f = fopen(filename, "wb"); - if (f) { - fputs( -"\# data file for the Fltk User Interface Designer (fluid)\\nversion 1.0400\\nheader_name {.h}\\n" -"code_name {.cxx}\\ncomment {//\\n// @INSTANCE@ for the Fast Light Tool Kit (FLT" -"K).\\n//\\n// Copyright 1998-2023 by Bill Spitzak and others.\\n//\\n// This library is free sof" -"tware. Distribution and use rights are outlined in\\n// the file \\"COPYING\\" which should have " -"been included with this file. If this\\n// file is missing or damaged, see the license at:\\n" -"//\\n// https://www.fltk.org/COPYING.php\\n//\\n// Please see the following page on how to report " -"bugs and issues:\\n//\\n// https://www.fltk.org/bugs.php\\n//\\n} {selected in_source in_head" -"er\\n}\\n", f); - fclose(f); - } - - template_install(path, "/FLTK_License.fl", tmpl_FLTK_License_fl, sizeof(tmpl_FLTK_License_fl), tmpl_FLTK_License_fl_size); - template_install(path, "/1of7GUIs.fl", tmpl_1of7GUIs_fl, sizeof(tmpl_1of7GUIs_fl), tmpl_1of7GUIs_fl_size); - sample_templates_generated = 2; - fluid_prefs.set("sample_templates_generated", sample_templates_generated); - fluid_prefs.flush(); -} - -num_files = fl_filename_list(path, &files); - -for (i = 0; i < num_files; i ++) { - if (fl_filename_match(files[i]->d_name, "*.fl")) { - // Format the name as the filename with "_" replaced with " " - // and without the trailing ".fl"... - strlcpy(name, files[i]->d_name, sizeof(name)); - *strstr(name, ".fl") = '\\0'; - - for (ptr = name; *ptr; ptr ++) { - if (*ptr == '_') *ptr = ' '; - } - - // Add the template to the browser... - snprintf(filename, sizeof(filename), "%s/%s", path, files[i]->d_name); - template_browser->add(name, fl_strdup(filename)); - } - - free(files[i]); -} - -if (num_files > 0) free(files);} {} -} diff --git a/fluid/template_panel.h b/fluid/template_panel.h deleted file mode 100644 index cfbcc72c2a..0000000000 --- a/fluid/template_panel.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// FLUID template support for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2020 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 -// file is missing or damaged, see the license at: -// -// https://www.fltk.org/COPYING.php -// -// Please see the following page on how to report bugs and issues: -// -// https://www.fltk.org/bugs.php -// - -// generated by Fast Light User Interface Designer (fluid) version 1.0400 - -#ifndef template_panel_h -#define template_panel_h -#include -#include -extern Fl_Double_Window *template_panel; -#include -extern Fl_Browser *template_browser; -#include -extern Fl_Box *template_preview; -#include -extern Fl_Input *template_name; -extern Fl_Input *template_instance; -#include -#include -extern Fl_Button *template_delete; -#include -extern Fl_Return_Button *template_submit; -Fl_Double_Window* make_template_panel(); -void template_clear(); -void template_delete_cb(Fl_Button *, void *); -void template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen); -void template_load(); -#endif diff --git a/fluid/ui/about_panel.fl b/fluid/ui/about_panel.fl index fac4b8f5cd..58b58108d0 100644 --- a/fluid/ui/about_panel.fl +++ b/fluid/ui/about_panel.fl @@ -32,7 +32,7 @@ decl {\#include } {public global decl {void show_help(const char *name);} {public local } -declblock {namespace fluid \{} {open selected public map 1 after {\}} +declblock {namespace fluid \{} {open public map 1 after {\}} } { decl {class Project;} {public global } @@ -40,7 +40,7 @@ declblock {namespace fluid \{} {open selected public map 1 after {\}} } { class AboutPanel { comment {\\brief Show some information about FLUID -} open : Panel +} open selected : {public Panel} } { Function {make_panel()} {open private } { diff --git a/fluid/ui/about_panel.h b/fluid/ui/about_panel.h index a4c5a8e901..d6d96847c7 100644 --- a/fluid/ui/about_panel.h +++ b/fluid/ui/about_panel.h @@ -34,7 +34,7 @@ namespace ui { /** \brief Show some information about FLUID */ -class AboutPanel : Panel { +class AboutPanel : public Panel { Fl_Double_Window* make_panel(); public: Fl_Double_Window *panel_window; diff --git a/fluid/ui/main_panel.cxx b/fluid/ui/main_panel.cxx index 89df2296a6..468b0093e2 100644 --- a/fluid/ui/main_panel.cxx +++ b/fluid/ui/main_panel.cxx @@ -30,7 +30,7 @@ void show_help(const char *name); void MainPanel::cb_main_window_i(Fl_Double_Window*, void*) { //~fl~0~0000~b0a14477~~ quit_fluid(); -//~fl~3~0f48~69468f9f~~ +//~fl~3~cb28~69468f9f~~ } void MainPanel::cb_main_window(Fl_Double_Window* o, void* v) { ((MainPanel*)(o->user_data()))->cb_main_window_i(o,v); @@ -39,7 +39,7 @@ void MainPanel::cb_main_window(Fl_Double_Window* o, void* v) { void MainPanel::cb_New_i(Fl_Menu_*, void*) { //~fl~0~0000~ce60c4f9~~ Fluid.new_project(); -//~fl~2~5023~e4c3136e~~ +//~fl~2~37d4~e4c3136e~~ } void MainPanel::cb_New(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_New_i(o,v); @@ -48,7 +48,7 @@ void MainPanel::cb_New(Fl_Menu_* o, void* v) { void MainPanel::cb_Open_i(Fl_Menu_*, void*) { //~fl~0~0000~491c39d3~~ Fluid.open_project_from_file(""); -//~fl~2~f85f~632adcf7~~ +//~fl~2~df4a~632adcf7~~ } void MainPanel::cb_Open(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Open_i(o,v); @@ -57,7 +57,7 @@ void MainPanel::cb_Open(Fl_Menu_* o, void* v) { void MainPanel::cb_history_item_i(Fl_Menu_*, void* v) { //~fl~0~0000~6f4eacc4~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~f5ed~ded83595~~ +//~fl~2~9780~ded83595~~ } void MainPanel::cb_history_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_history_item_i(o,v); @@ -66,7 +66,7 @@ void MainPanel::cb_history_item(Fl_Menu_* o, void* v) { void MainPanel::cb__i(Fl_Menu_*, void* v) { //~fl~0~0000~ed45dc13~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~680c~ded83595~~ +//~fl~2~aedf~ded83595~~ } void MainPanel::cb_(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb__i(o,v); @@ -75,7 +75,7 @@ void MainPanel::cb_(Fl_Menu_* o, void* v) { void MainPanel::cb_1_i(Fl_Menu_*, void* v) { //~fl~0~0000~27beb8c2~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~2902~ded83595~~ +//~fl~2~8f1f~ded83595~~ } void MainPanel::cb_1(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_1_i(o,v); @@ -84,7 +84,7 @@ void MainPanel::cb_1(Fl_Menu_* o, void* v) { void MainPanel::cb_2_i(Fl_Menu_*, void* v) { //~fl~0~0000~5574efc6~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~8039~ded83595~~ +//~fl~2~0b58~ded83595~~ } void MainPanel::cb_2(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_2_i(o,v); @@ -93,7 +93,7 @@ void MainPanel::cb_2(Fl_Menu_* o, void* v) { void MainPanel::cb_3_i(Fl_Menu_*, void* v) { //~fl~0~0000~cf9620a8~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~6484~ded83595~~ +//~fl~2~9ab1~ded83595~~ } void MainPanel::cb_3(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_3_i(o,v); @@ -102,7 +102,7 @@ void MainPanel::cb_3(Fl_Menu_* o, void* v) { void MainPanel::cb_4_i(Fl_Menu_*, void* v) { //~fl~0~0000~3c007cd9~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~6514~ded83595~~ +//~fl~2~07c5~ded83595~~ } void MainPanel::cb_4(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_4_i(o,v); @@ -111,7 +111,7 @@ void MainPanel::cb_4(Fl_Menu_* o, void* v) { void MainPanel::cb_5_i(Fl_Menu_*, void* v) { //~fl~0~0000~0bb62eeb~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~339c~ded83595~~ +//~fl~2~339d~ded83595~~ } void MainPanel::cb_5(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_5_i(o,v); @@ -120,7 +120,7 @@ void MainPanel::cb_5(Fl_Menu_* o, void* v) { void MainPanel::cb_6_i(Fl_Menu_*, void* v) { //~fl~0~0000~d2b4e444~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~ee5a~ded83595~~ +//~fl~2~66c4~ded83595~~ } void MainPanel::cb_6(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_6_i(o,v); @@ -129,7 +129,7 @@ void MainPanel::cb_6(Fl_Menu_* o, void* v) { void MainPanel::cb_7_i(Fl_Menu_*, void* v) { //~fl~0~0000~48562b2a~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~ac2a~ded83595~~ +//~fl~2~f22f~ded83595~~ } void MainPanel::cb_7(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_7_i(o,v); @@ -138,7 +138,7 @@ void MainPanel::cb_7(Fl_Menu_* o, void* v) { void MainPanel::cb_8_i(Fl_Menu_*, void* v) { //~fl~0~0000~eee95ae7~~ Fluid.open_project_from_file(Fl_String((const char*)v)); -//~fl~2~dae5~ded83595~~ +//~fl~2~4117~ded83595~~ } void MainPanel::cb_8(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_8_i(o,v); @@ -147,7 +147,7 @@ void MainPanel::cb_8(Fl_Menu_* o, void* v) { void MainPanel::cb_Insert_i(Fl_Menu_*, void*) { //~fl~0~0000~bc1da369~~ Fluid.project.merge_project_file(""); -//~fl~2~05f1~573c1d2b~~ +//~fl~2~f333~573c1d2b~~ } void MainPanel::cb_Insert(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Insert_i(o,v); @@ -156,7 +156,7 @@ void MainPanel::cb_Insert(Fl_Menu_* o, void* v) { void MainPanel::cb_Save_i(Fl_Menu_*, long) { //~fl~0~0000~46f4b6d9~~ Fluid.project.save(false, true); -//~fl~2~56c4~acb8b95c~~ +//~fl~2~edd2~acb8b95c~~ } void MainPanel::cb_Save(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_Save_i(o,v); @@ -165,7 +165,7 @@ void MainPanel::cb_Save(Fl_Menu_* o, long v) { void MainPanel::cb_Save1_i(Fl_Menu_*, long) { //~fl~0~0000~726347b3~~ Fluid.project.save(true, false); -//~fl~2~2b8a~1d48635a~~ +//~fl~2~020c~1d48635a~~ } void MainPanel::cb_Save1(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_Save1_i(o,v); @@ -174,7 +174,7 @@ void MainPanel::cb_Save1(Fl_Menu_* o, long v) { void MainPanel::cb_Sa_i(Fl_Menu_*, long) { //~fl~0~0000~e89ef45a~~ Fluid.project.save(true, true); -//~fl~2~6a9b~cd324a13~~ +//~fl~2~31c5~cd324a13~~ } void MainPanel::cb_Sa(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_Sa_i(o,v); @@ -183,7 +183,7 @@ void MainPanel::cb_Sa(Fl_Menu_* o, long v) { void MainPanel::cb_Revert_i(Fl_Menu_*, void*) { //~fl~0~0000~ee29b042~~ Fluid.project.revert(); -//~fl~2~c339~a8f32d26~~ +//~fl~2~dba5~a8f32d26~~ } void MainPanel::cb_Revert(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Revert_i(o,v); @@ -191,8 +191,8 @@ void MainPanel::cb_Revert(Fl_Menu_* o, void* v) { void MainPanel::cb_New1_i(Fl_Menu_*, void*) { //~fl~0~0000~f180d6bc~~ - new_project_from_template(); -//~fl~2~07f7~15f05eaf~~ + Fluid.new_project_from_template(); +//~fl~2~27f2~3ce910fb~~ } void MainPanel::cb_New1(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_New1_i(o,v); @@ -200,8 +200,8 @@ void MainPanel::cb_New1(Fl_Menu_* o, void* v) { void MainPanel::cb_Save2_i(Fl_Menu_*, void*) { //~fl~0~0000~55c4d258~~ - save_as_template(); -//~fl~2~4ca1~a1e134e8~~ + Fluid.project.save_as_template(); +//~fl~2~853a~f0923265~~ } void MainPanel::cb_Save2(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Save2_i(o,v); @@ -210,7 +210,7 @@ void MainPanel::cb_Save2(Fl_Menu_* o, void* v) { void MainPanel::cb_Merge_i(Fl_Menu_*, void*) { //~fl~0~0000~e73b38ff~~ mergeback_code_files(); -//~fl~2~ead3~c78c4c03~~ +//~fl~2~a8c0~c78c4c03~~ } void MainPanel::cb_Merge(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Merge_i(o,v); @@ -219,7 +219,7 @@ void MainPanel::cb_Merge(Fl_Menu_* o, void* v) { void MainPanel::cb_Write_i(Fl_Menu_*, void*) { //~fl~0~0000~43310500~~ Fluid.project.write_code_files(); -//~fl~2~f3ed~b22d0143~~ +//~fl~2~bbe2~b22d0143~~ } void MainPanel::cb_Write(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Write_i(o,v); @@ -228,7 +228,7 @@ void MainPanel::cb_Write(Fl_Menu_* o, void* v) { void MainPanel::cb_Write1_i(Fl_Menu_*, void*) { //~fl~0~0000~72011616~~ Fluid.project.write_strings(); -//~fl~2~b8d5~6cdf81cd~~ +//~fl~2~f761~6cdf81cd~~ } void MainPanel::cb_Write1(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Write1_i(o,v); @@ -237,7 +237,7 @@ void MainPanel::cb_Write1(Fl_Menu_* o, void* v) { void MainPanel::cb_Print_i(Fl_Menu_*, void*) { //~fl~0~0000~06825cff~~ print_windows(); -//~fl~2~9ad9~d30809b1~~ +//~fl~2~a6f2~d30809b1~~ } void MainPanel::cb_Print(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Print_i(o,v); @@ -246,7 +246,7 @@ void MainPanel::cb_Print(Fl_Menu_* o, void* v) { void MainPanel::cb_Quit_i(Fl_Menu_*, void*) { //~fl~0~0000~dc315de7~~ quit_fluid(); -//~fl~2~3c5b~69468f9f~~ +//~fl~2~9050~69468f9f~~ } void MainPanel::cb_Quit(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Quit_i(o,v); @@ -255,7 +255,7 @@ void MainPanel::cb_Quit(Fl_Menu_* o, void* v) { void MainPanel::cb_Undo_i(Fl_Menu_*, void*) { //~fl~0~0000~af55f1fd~~ Fluid.project.undo.undo(); -//~fl~2~1151~cac4cbce~~ +//~fl~2~907e~cac4cbce~~ } void MainPanel::cb_Undo(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Undo_i(o,v); @@ -264,7 +264,7 @@ void MainPanel::cb_Undo(Fl_Menu_* o, void* v) { void MainPanel::cb_Redo_i(Fl_Menu_*, void*) { //~fl~0~0000~bb505c2e~~ Fluid.project.undo.redo(); -//~fl~2~9c20~c206962d~~ +//~fl~2~d963~c206962d~~ } void MainPanel::cb_Redo(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Redo_i(o,v); @@ -273,7 +273,7 @@ void MainPanel::cb_Redo(Fl_Menu_* o, void* v) { void MainPanel::cb_C_i(Fl_Menu_*, void*) { //~fl~0~0000~2692f0c3~~ Fluid.project.cut(); -//~fl~2~100c~0ef37003~~ +//~fl~2~8250~0ef37003~~ } void MainPanel::cb_C(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_C_i(o,v); @@ -282,7 +282,7 @@ void MainPanel::cb_C(Fl_Menu_* o, void* v) { void MainPanel::cb_Copy_i(Fl_Menu_*, void*) { //~fl~0~0000~7fb19826~~ Fluid.project.copy(); -//~fl~2~fd06~97dfd47d~~ +//~fl~2~7cba~97dfd47d~~ } void MainPanel::cb_Copy(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Copy_i(o,v); @@ -291,7 +291,7 @@ void MainPanel::cb_Copy(Fl_Menu_* o, void* v) { void MainPanel::cb_Paste_i(Fl_Menu_*, void*) { //~fl~0~0000~15667d46~~ Fluid.project.paste(); -//~fl~2~606d~d0653a32~~ +//~fl~2~17c9~d0653a32~~ } void MainPanel::cb_Paste(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Paste_i(o,v); @@ -300,7 +300,7 @@ void MainPanel::cb_Paste(Fl_Menu_* o, void* v) { void MainPanel::cb_Dupl_i(Fl_Menu_*, void*) { //~fl~0~0000~d56c2965~~ Fluid.project.duplicate(); -//~fl~2~5fff~94cecd98~~ +//~fl~2~ac53~94cecd98~~ } void MainPanel::cb_Dupl(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Dupl_i(o,v); @@ -309,7 +309,7 @@ void MainPanel::cb_Dupl(Fl_Menu_* o, void* v) { void MainPanel::cb_Delete_i(Fl_Menu_*, void*) { //~fl~0~0000~4783b5db~~ Fluid.project.user_delete(); -//~fl~2~18a1~c6f0868a~~ +//~fl~2~5a18~c6f0868a~~ } void MainPanel::cb_Delete(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Delete_i(o,v); @@ -318,7 +318,7 @@ void MainPanel::cb_Delete(Fl_Menu_* o, void* v) { void MainPanel::cb_Pr_i(Fl_Menu_*, void*) { //~fl~0~0000~f004ef31~~ open_widget_panel(); -//~fl~2~42e9~7d55f5ba~~ +//~fl~2~e631~7d55f5ba~~ } void MainPanel::cb_Pr(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Pr_i(o,v); @@ -327,7 +327,7 @@ void MainPanel::cb_Pr(Fl_Menu_* o, void* v) { void MainPanel::cb_Sort_i(Fl_Menu_*, void*) { //~fl~0~0000~cdd6b9ad~~ sort_selected(); -//~fl~2~9a81~69449227~~ +//~fl~2~ad58~69449227~~ } void MainPanel::cb_Sort(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Sort_i(o,v); @@ -336,7 +336,7 @@ void MainPanel::cb_Sort(Fl_Menu_* o, void* v) { void MainPanel::cb_Ung_i(Fl_Menu_*, void*) { //~fl~0~0000~247e91a1~~ ungroup_selected(); -//~fl~2~9244~b72976ec~~ +//~fl~2~1c90~b72976ec~~ } void MainPanel::cb_Ung(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Ung_i(o,v); @@ -345,7 +345,7 @@ void MainPanel::cb_Ung(Fl_Menu_* o, void* v) { void MainPanel::cb_overlay_item_i(Fl_Menu_*, void*) { //~fl~0~0000~bae04675~~ toggle_overlays(); -//~fl~2~4a7a~fff73fb6~~ +//~fl~2~70c0~fff73fb6~~ } void MainPanel::cb_overlay_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_overlay_item_i(o,v); @@ -354,7 +354,7 @@ void MainPanel::cb_overlay_item(Fl_Menu_* o, void* v) { void MainPanel::cb_guides_item_i(Fl_Menu_*, void*) { //~fl~0~0000~b0419082~~ toggle_guides(); -//~fl~2~aeab~c74d7e68~~ +//~fl~2~adfa~c74d7e68~~ } void MainPanel::cb_guides_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_guides_item_i(o,v); @@ -363,7 +363,7 @@ void MainPanel::cb_guides_item(Fl_Menu_* o, void* v) { void MainPanel::cb_restricted_item_i(Fl_Menu_*, void*) { //~fl~0~0000~32785a4c~~ toggle_restricted(); -//~fl~2~04c9~8b334efd~~ +//~fl~2~d44f~8b334efd~~ } void MainPanel::cb_restricted_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_restricted_item_i(o,v); @@ -372,7 +372,7 @@ void MainPanel::cb_restricted_item(Fl_Menu_* o, void* v) { void MainPanel::cb_widgetbin_item_i(Fl_Menu_*, void*) { //~fl~0~0000~2e1b6c51~~ toggle_widgetbin(); -//~fl~2~98de~6937afbe~~ +//~fl~2~db1e~6937afbe~~ } void MainPanel::cb_widgetbin_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_widgetbin_item_i(o,v); @@ -381,7 +381,7 @@ void MainPanel::cb_widgetbin_item(Fl_Menu_* o, void* v) { void MainPanel::cb_codeview_item_i(Fl_Menu_*, void*) { //~fl~0~0000~b0bd55c9~~ codeview_toggle_visibility(); -//~fl~2~e8f6~2a173cad~~ +//~fl~2~057c~2a173cad~~ } void MainPanel::cb_codeview_item(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_codeview_item_i(o,v); @@ -390,7 +390,7 @@ void MainPanel::cb_codeview_item(Fl_Menu_* o, void* v) { void MainPanel::cb_Settings_i(Fl_Menu_*, void*) { //~fl~0~0000~d48c28f5~~ show_settings(); -//~fl~2~2de2~12140035~~ +//~fl~2~d807~12140035~~ } void MainPanel::cb_Settings(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Settings_i(o,v); @@ -399,7 +399,7 @@ void MainPanel::cb_Settings(Fl_Menu_* o, void* v) { void MainPanel::cb_Grid_i(Fl_Menu_*, void*) { //~fl~0~0000~0acf8804~~ settings_show_grid(); -//~fl~2~9c64~3424b216~~ +//~fl~2~4ee6~3424b216~~ } void MainPanel::cb_Grid(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Grid_i(o,v); @@ -408,7 +408,7 @@ void MainPanel::cb_Grid(Fl_Menu_* o, void* v) { void MainPanel::cb_preset_menu_i(Fl_Menu_*, long) { //~fl~0~0000~3890aaa6~~ select_layout_preset(0); -//~fl~2~5cef~ef1d9921~~ +//~fl~2~282e~ef1d9921~~ } void MainPanel::cb_preset_menu(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_preset_menu_i(o,v); @@ -417,7 +417,7 @@ void MainPanel::cb_preset_menu(Fl_Menu_* o, long v) { void MainPanel::cb_Dialog_i(Fl_Menu_*, long) { //~fl~0~0000~86cb12ff~~ select_layout_preset(1); -//~fl~2~3509~57a1fe44~~ +//~fl~2~0083~57a1fe44~~ } void MainPanel::cb_Dialog(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_Dialog_i(o,v); @@ -426,7 +426,7 @@ void MainPanel::cb_Dialog(Fl_Menu_* o, long v) { void MainPanel::cb_itemToolbox_i(Fl_Menu_*, long) { //~fl~0~0000~72c1e1ed~~ select_layout_preset(2); -//~fl~2~7f08~451451aa~~ +//~fl~2~3b48~451451aa~~ } void MainPanel::cb_itemToolbox(Fl_Menu_* o, long v) { ((MainPanel*)(o->parent()->user_data()))->cb_itemToolbox_i(o,v); @@ -435,7 +435,7 @@ void MainPanel::cb_itemToolbox(Fl_Menu_* o, long v) { void MainPanel::cb_Rapid_i(Fl_Menu_*, void*) { //~fl~0~0000~95ffbc11~~ show_help("fluid.html"); -//~fl~2~1d8f~42995d97~~ +//~fl~2~3977~42995d97~~ } void MainPanel::cb_Rapid(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_Rapid_i(o,v); @@ -444,7 +444,7 @@ void MainPanel::cb_Rapid(Fl_Menu_* o, void* v) { void MainPanel::cb_FLTK_i(Fl_Menu_*, void*) { //~fl~0~0000~73bc7557~~ show_help("index.html"); -//~fl~2~52f0~d4640e18~~ +//~fl~2~dfea~d4640e18~~ } void MainPanel::cb_FLTK(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_FLTK_i(o,v); @@ -453,7 +453,7 @@ void MainPanel::cb_FLTK(Fl_Menu_* o, void* v) { void MainPanel::cb_About_i(Fl_Menu_*, void*) { //~fl~0~0000~65c5d175~~ fluid::ui::about_panel.show(); -//~fl~2~b3b7~ff6c50d1~~ +//~fl~2~205e~ff6c50d1~~ } void MainPanel::cb_About(Fl_Menu_* o, void* v) { ((MainPanel*)(o->parent()->user_data()))->cb_About_i(o,v); @@ -624,7 +624,7 @@ Fl_Double_Window* MainPanel::make_panel() { MainPanel::MainPanel() { //~fl~0~0000~2c43afec~~ main_window = nullptr; -//~fl~1~f9d7~deac3c13~~ +//~fl~1~ca21~deac3c13~~ } /** @@ -633,7 +633,7 @@ MainPanel::MainPanel() { MainPanel::~MainPanel() { //~fl~0~0000~08914570~~ delete main_window; -//~fl~1~c8a2~4bd6d899~~ +//~fl~1~306b~4bd6d899~~ } /** @@ -644,7 +644,7 @@ void MainPanel::build() { if (main_window == nullptr) { make_panel(); } -//~fl~1~5ddf~444c7294~~ +//~fl~1~857a~444c7294~~ } /** @@ -654,7 +654,7 @@ void MainPanel::show() { //~fl~0~0000~d600e79d~~ build(); main_window->show(); -//~fl~1~d9d1~653b75be~~ +//~fl~1~a09e~653b75be~~ } /** @@ -665,6 +665,6 @@ void MainPanel::hide() { if (main_window) { main_window->hide(); } -//~fl~1~08be~7d15f02b~~ +//~fl~1~3a6c~7d15f02b~~ } MainPanel fluid::ui::main_panel; diff --git a/fluid/ui/main_panel.fl b/fluid/ui/main_panel.fl index 69dcba157a..968eff8e19 100644 --- a/fluid/ui/main_panel.fl +++ b/fluid/ui/main_panel.fl @@ -26,527 +26,527 @@ comment {// } {uid 0001 in_source in_header } -decl {\#include "ui/panel.h"} {uid acd9 public global +decl {\#include "ui/panel.h"} {uid 495c public global } -decl {\#include "ui/about_panel.h"} {uid b782 private global +decl {\#include "ui/about_panel.h"} {uid d92f private global } -decl {\#include "application/application.h"} {uid 8ed8 private global +decl {\#include "application/application.h"} {uid 436d private global } -decl {\#include "project/project.h"} {uid 2f43 private global +decl {\#include "project/project.h"} {uid eb3c private global } -decl {\#include "codeview_panel.h"} {uid 9898 private global +decl {\#include "codeview_panel.h"} {uid 4733 private global } -decl {\#include "Fl_Group_Type.h"} {uid 128c private global +decl {\#include "Fl_Group_Type.h"} {uid 8db0 private global } -decl {\#include "factory.h"} {uid d4b3 private global +decl {\#include "factory.h"} {uid 1540 private global } -decl {\#include "shell_command.h"} {uid 3917 private global +decl {\#include "shell_command.h"} {uid dfaf private global } -decl {using namespace fluid::ui;} {uid c398 private global +decl {using namespace fluid::ui;} {uid 124e private global } -decl {void show_help(const char *name);} {uid 2e2f public local +decl {void show_help(const char *name);} {uid 81f9 public local } -declblock {namespace fluid \{} {uid 962d open public map 1 after {\}} +declblock {namespace fluid \{} {uid f985 open public map 1 after {\}} } { - decl {class Project;} {uid 3258 public global + decl {class Project;} {uid dffa public global } - declblock {namespace ui \{} {uid 816b open public map 1 after {\}} + declblock {namespace ui \{} {uid d378 open public map 1 after {\}} } { - class MainPanel {uid 7788 + class MainPanel {uid 6752 comment {\\brief FLUID Main Application Panel -} open : Panel +} open : {public Panel} } { - Function {make_panel()} {uid 6499 open private + Function {make_panel()} {uid 356f open private } { - Fl_Window main_window {uid 0f48 + Fl_Window main_window {uid cb28 label FLUID - callback {quit_fluid();} open selected + callback {quit_fluid();} open xywh {389 91 300 525} type Double color 7 selection_color 47 resizable hotspot size_range {280 200 0 0} visible } { - Fl_Menu_Bar main_menubar {uid ee62 open + Fl_Menu_Bar main_menubar {uid 4e7c open xywh {0 0 300 25} code0 {main_menubar->global();} } { - Submenu {} {uid 4cf3 + Submenu {} {uid 8f8b label {&File} open xywh {0 0 100 20} } { - MenuItem {} {uid 5023 + MenuItem {} {uid 37d4 label {&New} callback {Fluid.new_project();} xywh {0 0 100 20} shortcut 0x40006e } - MenuItem {} {uid f85f + MenuItem {} {uid df4a label {&Open...} callback {Fluid.open_project_from_file("");} xywh {0 0 100 20} shortcut 0x40006f } - Submenu {} {uid 22d1 + Submenu {} {uid ca60 label {Open Recent} open xywh {0 0 100 20} } { - MenuItem history_item {uid f5ed + MenuItem history_item {uid 9780 user_data {Fluid.history.full_path[0]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400031 code0 {o->label(Fluid.history.short_path[0]);} } - MenuItem {} {uid 680c + MenuItem {} {uid aedf user_data {Fluid.history.full_path[1]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400032 code0 {o->label(Fluid.history.short_path[1]);} } - MenuItem {} {uid 2902 + MenuItem {} {uid 8f1f user_data {Fluid.history.full_path[2]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400033 code0 {o->label(Fluid.history.short_path[2]);} } - MenuItem {} {uid 8039 + MenuItem {} {uid 0b58 user_data {Fluid.history.full_path[3]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400034 code0 {o->label(Fluid.history.short_path[3]);} } - MenuItem {} {uid 6484 + MenuItem {} {uid 9ab1 user_data {Fluid.history.full_path[4]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400035 code0 {o->label(Fluid.history.short_path[4]);} } - MenuItem {} {uid 6514 + MenuItem {} {uid 07c5 user_data {Fluid.history.full_path[5]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400036 code0 {o->label(Fluid.history.short_path[5]);} } - MenuItem {} {uid 339c + MenuItem {} {uid 339d user_data {Fluid.history.full_path[6]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400037 code0 {o->label(Fluid.history.short_path[6]);} } - MenuItem {} {uid ee5a + MenuItem {} {uid 66c4 user_data {Fluid.history.full_path[7]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400038 code0 {o->label(Fluid.history.short_path[7]);} } - MenuItem {} {uid ac2a + MenuItem {} {uid f22f user_data {Fluid.history.full_path[8]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} shortcut 0x400039 code0 {o->label(Fluid.history.short_path[8]);} } - MenuItem {} {uid dae5 + MenuItem {} {uid 4117 user_data {Fluid.history.full_path[9]} callback {Fluid.open_project_from_file(Fl_String((const char*)v));} xywh {0 0 100 20} divider code0 {o->label(Fluid.history.short_path[9]);} } - MenuItem {} {uid 49e9 + MenuItem {} {uid 9df7 label {Clear Menu} xywh {0 0 100 20} labelsize 11 deactivate } } - MenuItem {} {uid 05f1 + MenuItem {} {uid f333 label {&Insert...} callback {Fluid.project.merge_project_file("");} xywh {0 0 100 20} shortcut 0x400069 divider } - MenuItem {} {uid 56c4 + MenuItem {} {uid edd2 label {&Save} user_data 0 user_data_type long callback {Fluid.project.save(false, true);} xywh {0 0 100 20} shortcut 0x400073 } - MenuItem {} {uid 2b8a + MenuItem {} {uid 020c label {Save &As...} user_data 1 user_data_type long callback {Fluid.project.save(true, false);} xywh {0 0 100 20} shortcut 0x410073 } - MenuItem {} {uid 6a9b + MenuItem {} {uid 31c5 label {Sa&ve Copy...} user_data 2 user_data_type long callback {Fluid.project.save(true, true);} xywh {0 0 100 20} } - MenuItem {} {uid c339 + MenuItem {} {uid dba5 label {&Revert to Saved} callback {Fluid.project.revert();} xywh {0 0 100 20} divider } - MenuItem {} {uid 07f7 + MenuItem {} {uid 27f2 label {New &From Template...} - callback {new_project_from_template();} + callback {Fluid.new_project_from_template();} selected xywh {0 0 100 20} shortcut 0x41006e } - MenuItem {} {uid 4ca1 + MenuItem {} {uid 853a label {Save As &Template...} - callback {save_as_template();} + callback {Fluid.project.save_as_template();} xywh {0 0 100 20} divider } - MenuItem {} {uid ead3 + MenuItem {} {uid a8c0 label {&Merge Back from Code} callback {mergeback_code_files();} xywh {0 0 100 20} shortcut 0x41006d } - MenuItem {} {uid f3ed + MenuItem {} {uid bbe2 label {Write &Code} callback {Fluid.project.write_code_files();} xywh {0 0 100 20} shortcut 0x410063 } - MenuItem {} {uid b8d5 + MenuItem {} {uid f761 label {&Write Strings} callback {Fluid.project.write_strings();} xywh {0 0 100 20} shortcut 0x410077 divider } - MenuItem {} {uid 9ad9 + MenuItem {} {uid a6f2 label {&Print...} callback {print_windows();} xywh {0 0 100 20} shortcut 0x400070 divider } - MenuItem {} {uid 3c5b + MenuItem {} {uid 9050 label {&Quit} callback {quit_fluid();} xywh {0 0 100 20} shortcut 0x400071 } } - Submenu {} {uid 546c + Submenu {} {uid 4d0b label {&Edit} open xywh {0 0 100 20} } { - MenuItem {} {uid 1151 + MenuItem {} {uid 907e label {&Undo} callback {Fluid.project.undo.undo();} xywh {0 0 100 20} shortcut 0x40007a } - MenuItem {} {uid 9c20 + MenuItem {} {uid d963 label {&Redo} callback {Fluid.project.undo.redo();} xywh {0 0 100 20} shortcut 0x41007a divider } - MenuItem {} {uid 100c + MenuItem {} {uid 8250 label {C&ut} callback {Fluid.project.cut();} xywh {0 0 100 20} shortcut 0x400078 } - MenuItem {} {uid fd06 + MenuItem {} {uid 7cba label {&Copy} callback {Fluid.project.copy();} xywh {0 0 100 20} shortcut 0x400063 } - MenuItem {} {uid 606d + MenuItem {} {uid 17c9 label {&Paste} callback {Fluid.project.paste();} xywh {0 0 100 20} shortcut 0x400076 } - MenuItem {} {uid 5fff + MenuItem {} {uid ac53 label {Dupl&icate} callback {Fluid.project.duplicate();} xywh {0 0 100 20} shortcut 0x400075 } - MenuItem {} {uid 18a1 + MenuItem {} {uid 5a18 label {&Delete} callback {Fluid.project.user_delete();} xywh {0 0 100 20} shortcut 0xffff divider } - MenuItem {} {uid 3b19 + MenuItem {} {uid 063b label {Select &All} callback select_all_cb xywh {0 0 100 20} shortcut 0x400061 } - MenuItem {} {uid da36 + MenuItem {} {uid 4694 label {Select &None} callback select_none_cb xywh {0 0 100 20} shortcut 0x410061 divider } - MenuItem {} {uid 42e9 + MenuItem {} {uid e631 label {Pr&operties...} callback {open_widget_panel();} xywh {0 0 100 20} shortcut 0xffbe } - MenuItem {} {uid 9a81 + MenuItem {} {uid ad58 label {&Sort} callback {sort_selected();} xywh {0 0 100 20} } - MenuItem {} {uid 0fc3 + MenuItem {} {uid 8f4f label {&Earlier} callback earlier_cb xywh {0 0 100 20} shortcut 0xffbf } - MenuItem {} {uid 431e + MenuItem {} {uid 1329 label {&Later} callback later_cb xywh {0 0 100 20} shortcut 0xffc0 } - MenuItem {} {uid 9dc0 + MenuItem {} {uid b480 label {&Group} callback group_cb xywh {0 0 100 20} shortcut 0xffc4 } - MenuItem {} {uid 9244 + MenuItem {} {uid 1c90 label {Ung&roup} callback {ungroup_selected();} xywh {0 0 100 20} shortcut 0xffc5 divider } - MenuItem overlay_item {uid 4a7a + MenuItem overlay_item {uid 70c0 label {Hide O&verlays} callback {toggle_overlays();} xywh {0 0 100 20} shortcut 0x41006f } - MenuItem guides_item {uid aeab + MenuItem guides_item {uid adfa label {Hide Guides} callback {toggle_guides();} xywh {0 0 100 20} shortcut 0x410067 } - MenuItem restricted_item {uid 04c9 + MenuItem restricted_item {uid d44f label {Hide Restricted} callback {toggle_restricted();} xywh {0 0 100 20} shortcut 0x410072 } - MenuItem widgetbin_item {uid 98de + MenuItem widgetbin_item {uid db1e label {Show Widget &Bin} callback {toggle_widgetbin();} xywh {0 0 100 20} shortcut 0x80062 } - MenuItem codeview_item {uid e8f6 + MenuItem codeview_item {uid 057c label {Show Code View} callback {codeview_toggle_visibility();} xywh {0 0 100 20} shortcut 0x800e7 divider } - MenuItem {} {uid 2de2 + MenuItem {} {uid d807 label {Settings...} callback {show_settings();} xywh {0 0 100 20} shortcut 0x80070 } } - Submenu {} {uid 604f + Submenu {} {uid b287 label {&New} user_data New_Menu open xywh {0 0 100 20} } {} - Submenu {} {uid 839f + Submenu {} {uid 655b label {&Layout} open xywh {0 0 100 20} } { - Submenu {} {uid ee67 + Submenu {} {uid 0295 label {&Align} open xywh {0 0 100 20} } { - MenuItem {} {uid adce + MenuItem {} {uid 6e86 label {&Left} user_data 10 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid cbf2 + MenuItem {} {uid 25f3 label {&Center} user_data 11 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid f100 + MenuItem {} {uid 2726 label {&Right} user_data 12 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid 2678 + MenuItem {} {uid 0c4a label {item&Top} user_data 13 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid ad97 + MenuItem {} {uid d297 label {&Middle} user_data 14 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid 5a34 + MenuItem {} {uid a7fe label {&Bottom} user_data 15 user_data_type long callback align_widget_cb xywh {0 0 100 20} } } - Submenu {} {uid c707 + Submenu {} {uid d60e label {&Space Evenly} open xywh {0 0 100 20} } { - MenuItem {} {uid 2c5e + MenuItem {} {uid 1320 label {&Across} user_data 20 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid 1aa1 + MenuItem {} {uid d45b label {&Down} user_data 21 user_data_type long callback align_widget_cb xywh {0 0 100 20} } } - Submenu {} {uid b429 + Submenu {} {uid 6285 label {&Make Same Size} open xywh {0 0 100 20} } { - MenuItem {} {uid 475b + MenuItem {} {uid a647 label {&Width} user_data 30 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid 0bf5 + MenuItem {} {uid 06ae label {&Height} user_data 31 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid cc46 + MenuItem {} {uid 3529 label {&Both} user_data 32 user_data_type long callback align_widget_cb xywh {0 0 100 20} } } - Submenu {} {uid 779c + Submenu {} {uid fb7c label {&Center In Group} open xywh {0 0 100 20} } { - MenuItem {} {uid 3f2e + MenuItem {} {uid cb7d label {&Horizontal} user_data 40 user_data_type long callback align_widget_cb xywh {0 0 100 20} } - MenuItem {} {uid c92a + MenuItem {} {uid 274f label {&Vertical} user_data 41 user_data_type long callback align_widget_cb xywh {0 0 100 20} } } - MenuItem {} {uid 5873 + MenuItem {} {uid e7d9 label {Synchronized Resize} callback menu_layout_sync_resize_cb xywh {0 0 100 20} type Toggle divider } - MenuItem {} {uid 9c64 + MenuItem {} {uid 4ee6 label {&Grid and Size Settings...} callback {settings_show_grid();} xywh {0 0 100 20} shortcut 0x400067 divider } - Submenu suite_menu {uid 2f06 + Submenu suite_menu {uid 61e8 label Presets user_data main_layout_submenu_ open xywh {0 0 100 20} } {} - MenuItem preset_menu {uid 5cef + MenuItem preset_menu {uid 282e label Application user_data 0 user_data_type long callback {select_layout_preset(0);} xywh {0 0 100 20} type Radio } - MenuItem {} {uid 3509 + MenuItem {} {uid 0083 label Dialog user_data 1 user_data_type long callback {select_layout_preset(1);} xywh {0 0 100 20} type Radio } - MenuItem {} {uid 7f08 + MenuItem {} {uid 3b48 label itemToolbox user_data 2 user_data_type long callback {select_layout_preset(2);} xywh {0 0 100 20} type Radio } } - Submenu shell_submenu {uid 234f + Submenu shell_submenu {uid 2ede label {&Shell} user_data {Fd_Shell_Command_List::default_menu} xywh {0 0 100 20} } {} - Submenu {} {uid e1f8 + Submenu {} {uid ec0a label {&Help} open xywh {0 0 100 20} } { - MenuItem {} {uid 1d8f + MenuItem {} {uid 3977 label {&Rapid development with FLUID...} callback {show_help("fluid.html");} xywh {0 0 100 20} } - MenuItem {} {uid 52f0 + MenuItem {} {uid dfea label {&FLTK Programmers Manual...} callback {show_help("index.html");} xywh {0 0 100 20} divider } - MenuItem {} {uid b3b7 + MenuItem {} {uid 205e label {&About FLUID...} callback {fluid::ui::about_panel.show();} xywh {0 0 100 20} } } } - Fl_Browser widget_browser {uid 7b19 + Fl_Browser widget_browser {uid 65bb xywh {0 25 300 500} box FLAT_BOX resizable code0 {\#include "widget_browser.h"} class Widget_Browser } } } - Function {MainPanel()} {uid 689a + Function {MainPanel()} {uid 61e6 comment Constructor open } { - code {main_window = nullptr;} {uid f9d7 + code {main_window = nullptr;} {uid ca21 } } - Function {~MainPanel() override} {uid 86cc + Function {~MainPanel() override} {uid 6e64 comment {Virtual destructor.} open } { - code {delete main_window;} {uid c8a2 + code {delete main_window;} {uid 306b } } - Function {build() override} {uid 678c + Function {build() override} {uid 4c8f comment {Build the panel, don't show it yet.} open return_type void } { code {if (main_window == nullptr) { make_panel(); -}} {uid 5ddf +}} {uid 857a } } - Function {show() override} {uid 52ad + Function {show() override} {uid 7677 comment {Build if needed and show the panel.} open return_type void } { code {build(); -main_window->show();} {uid d9d1 +main_window->show();} {uid a09e } } - Function {hide() override} {uid 2fd1 + Function {hide() override} {uid 5881 comment {Hide the panel and retain for later.} open return_type void } { code {if (main_window) { main_window->hide(); -}} {uid 08be +}} {uid 3a6c } } } - decl {extern MainPanel main_panel;} {uid 00f0 public global + decl {extern MainPanel main_panel;} {uid 6893 public global } - decl {MainPanel fluid::ui::main_panel;} {uid 8be9 private global + decl {MainPanel fluid::ui::main_panel;} {uid a876 private global } } } diff --git a/fluid/ui/main_panel.h b/fluid/ui/main_panel.h index bea26caa83..6f7ac1631f 100644 --- a/fluid/ui/main_panel.h +++ b/fluid/ui/main_panel.h @@ -38,7 +38,7 @@ namespace ui { /** \brief FLUID Main Application Panel */ -class MainPanel : Panel { +class MainPanel : public Panel { Fl_Double_Window* make_panel(); public: Fl_Double_Window *main_window; diff --git a/fluid/template_panel.cxx b/fluid/ui/template_panel.cxx similarity index 54% rename from fluid/template_panel.cxx rename to fluid/ui/template_panel.cxx index 65bf44cbac..da63f3be24 100644 --- a/fluid/template_panel.cxx +++ b/fluid/ui/template_panel.cxx @@ -17,8 +17,16 @@ // generated by Fast Light User Interface Designer (fluid) version 1.0400 #include "template_panel.h" +using namespace fluid::ui; #include "fluid.h" +#include "widget_browser.h" +#include "application/application.h" +#include "project/project.h" +#include "streams/project_reader.h" +#include "streams/project_writer.h" #include +#include +#include "Fl_Window_Type.h" #include #include #include "fluid_filename.h" @@ -30,110 +38,189 @@ #if defined(_WIN32) && !defined(__CYGWIN__) #include #else -// #include +#include #endif // _WIN32 && !__CYGWIN__ +using namespace fluid::ui; -Fl_Double_Window *template_panel=(Fl_Double_Window *)0; +static int tmpl_FLTK_License_fl_size = 623; +static unsigned char tmpl_FLTK_License_fl[401] = /* data compressed and inlined from ../templates/FLTK_License.fl */ +{120,156,133,82,77,79,220,48,16,189,231,87,60,209,11,72,109,178,208,30,10, +39,218,165,84,43,208,22,137,237,161,39,228,196,147,120,132,99,71,246,132,176, +93,237,127,199,14,187,234,177,62,217,227,247,53,99,127,128,86,162,208,178,37, +180,62,64,12,225,214,202,51,126,71,10,88,57,161,208,170,134,112,67,145,59,151, +74,167,173,29,89,159,21,47,20,34,123,135,243,114,241,101,177,40,12,41,77,225, +201,169,158,176,43,205,190,104,188,166,227,177,121,125,205,133,190,39,39,216,85, +85,81,85,184,94,173,31,55,223,214,203,31,215,255,124,85,20,220,115,103,4,27, +239,45,238,88,112,122,123,191,185,59,43,139,119,210,210,15,219,48,3,206,47,47, +191,126,186,88,92,124,70,189,197,119,182,22,143,3,203,95,245,12,229,52,124,146, +11,241,200,218,24,142,176,92,7,21,182,72,219,54,16,33,250,86,38,21,168,196,13, +71,9,92,143,146,219,201,236,49,18,102,151,136,4,128,31,197,178,35,13,118,89,45, +39,157,199,117,178,252,245,240,103,181,254,121,130,201,112,99,16,141,31,173, +134,81,47,132,154,200,37,124,99,71,157,136,19,139,73,188,108,157,136,37,176,106, +231,99,150,155,165,210,77,207,49,178,235,144,102,161,85,175,58,210,31,17,83,206, +108,103,185,33,151,66,41,185,58,180,148,151,17,25,226,85,85,77,211,84,182,233, +201,74,31,186,234,144,169,28,204,112,128,62,88,82,137,123,212,106,189,181,126, +202,78,67,50,65,106,217,248,9,226,17,104,240,65,80,143,93,156,167,144,242,140, +20,255,107,152,241,71,183,61,118,145,44,53,50,15,235,41,250,49,164,175,147,118, +239,191,163,216,23,111,13,176,205,39}; + +static int tmpl_1of7GUIs_fl_size = 763; +static unsigned char tmpl_1of7GUIs_fl[486] = /* data compressed and inlined from ../templates/1of7GUIs.fl */ +{120,156,109,82,203,138,219,64,16,188,207,87,52,228,178,102,177,45,25,59, +187,142,73,14,121,56,187,36,224,92,76,142,102,36,181,164,206,142,102,196,60,252, +88,33,216,223,200,61,127,146,63,201,151,164,37,69,176,9,97,4,163,26,122,170, +170,171,231,5,100,210,75,200,73,33,228,198,130,47,17,182,202,63,192,222,161,133, +123,237,209,230,50,69,120,143,142,10,205,71,87,185,10,148,77,4,28,209,58,50,26, +226,89,180,140,34,1,37,202,12,237,65,203,10,161,153,149,173,72,77,134,35,76,207, +231,86,64,106,170,10,181,135,70,196,96,114,184,249,184,191,119,66,244,27,156, +164,131,4,81,67,106,81,122,204,128,177,4,87,147,158,154,60,239,202,59,107,149, +116,236,232,215,211,119,39,24,58,114,240,206,84,181,180,228,216,9,215,236,146, +111,152,250,233,206,18,235,116,36,58,131,109,208,169,103,167,82,137,47,214,20, +86,86,21,233,162,239,150,149,185,179,35,42,83,247,198,146,11,124,8,5,155,248, +68,142,229,125,167,41,238,66,37,245,180,211,9,126,204,68,246,140,80,88,19,234, +209,219,103,164,68,211,163,216,107,234,179,241,63,127,120,184,147,90,27,134,64, +26,22,81,188,156,9,81,122,95,187,87,243,249,77,17,200,205,10,242,101,72,102, +100,6,60,23,45,52,14,21,119,193,246,73,31,156,9,150,243,215,198,31,24,13,33,139, +86,136,177,43,104,248,130,169,81,119,23,197,86,29,190,146,206,204,169,63,22,74, +38,168,56,162,208,121,134,190,234,124,57,149,208,44,111,95,194,98,189,128,120, +189,132,213,170,5,127,169,121,198,38,36,252,12,44,231,250,40,187,191,35,57,226, +125,100,222,5,207,17,240,20,123,186,195,137,178,2,187,97,14,148,241,10,248,187, +141,96,177,24,102,31,65,243,119,233,244,205,81,170,128,87,209,100,211,114,11, +204,248,54,120,255,167,133,231,94,69,42,149,74,100,250,0,13,241,84,8,94,195,191, +76,52,80,77,54,130,174,175,55,226,255,66,212,9,13,238,214,235,103,238,134,245, +27,226,34,7,2}; +void show_help(const char *name); -static void cb_template_panel(Fl_Double_Window*, void*) { +void TemplatePanel::cb_panel_window_i(Fl_Double_Window*, void*) { +//~fl~0~0000~56d21b35~~ Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); if (img) img->release(); template_preview->image(0); - - template_browser->deselect(); + template_browser->deselect(); template_name->value(""); template_instance->value(""); - template_panel->hide(); + hide(); +//~fl~3~edfd~c3c40d88~~ +} +void TemplatePanel::cb_panel_window(Fl_Double_Window* o, void* v) { + ((TemplatePanel*)(o->user_data()))->cb_panel_window_i(o,v); } -Fl_Browser *template_browser=(Fl_Browser *)0; - -static void cb_template_browser(Fl_Browser*, void*) { +void TemplatePanel::cb_template_browser_i(Fl_Browser*, void*) { +//~fl~0~0000~a034eefc~~ if (Fl::event_clicks()) { - template_panel->hide(); + hide(); return; } Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); if (img) img->release(); template_preview->image(0); template_preview->redraw(); - - int item = template_browser->value(); - - if (item <= 1) template_instance->deactivate(); + int item = template_browser->value(); + if (item <= 1) template_instance->deactivate(); else template_instance->activate(); - - if (item < 1) { + if (item < 1) { template_submit->deactivate(); template_delete->deactivate(); return; } - - template_submit->activate(); - - const char *flfile = (const char *)template_browser->data(item); + template_submit->activate(); + const char *flfile = (const char *)template_browser->data(item); if (!flfile) { template_delete->deactivate(); return; } - - template_name->value(template_browser->text(item)); - - template_delete->activate(); - - char pngfile[1024], *ext; - - strlcpy(pngfile, flfile, sizeof(pngfile)); + template_name->value(template_browser->text(item)); + template_delete->activate(); + char pngfile[1024], *ext; + strlcpy(pngfile, flfile, sizeof(pngfile)); if ((ext = strrchr(pngfile, '.')) == NULL) return; strcpy(ext, ".png"); - - img = Fl_Shared_Image::get(pngfile); - - if (img) { + img = Fl_Shared_Image::get(pngfile); + if (img) { template_preview->image(img); template_preview->redraw(); } +//~fl~3~9f53~03211b11~~ +} +void TemplatePanel::cb_template_browser(Fl_Browser* o, void* v) { + ((TemplatePanel*)(o->parent()->user_data()))->cb_template_browser_i(o,v); } -Fl_Box *template_preview=(Fl_Box *)0; - -Fl_Input *template_name=(Fl_Input *)0; - -static void cb_template_name(Fl_Input*, void*) { +void TemplatePanel::cb_template_name_i(Fl_Input*, void*) { +//~fl~0~0000~333f7554~~ if (strlen(template_name->value())) { template_submit->activate(); - if (Fl::event_key() == FL_Enter) template_panel->hide(); + if (Fl::event_key() == FL_Enter) hide(); } else template_submit->deactivate(); +//~fl~3~94ec~3d702f14~~ } +void TemplatePanel::cb_template_name(Fl_Input* o, void* v) { + ((TemplatePanel*)(o->parent()->user_data()))->cb_template_name_i(o,v); +} + +void TemplatePanel::cb_template_delete_i(Fl_Button*, void*) { +//~fl~0~0000~156edfc1~~ + int item = template_browser->value(); + if (item < 1) return; + + const char *name = template_browser->text(item); + const char *flfile = (const char *)template_browser->data(item); + if (!flfile) return; + + if (!fl_choice("Are you sure you want to delete the template \"%s\"?", + "Cancel", "Delete", 0, name)) return; -Fl_Input *template_instance=(Fl_Input *)0; + if (fl_unlink(flfile)) { + fl_alert("Unable to delete template \"%s\":\n%s", name, strerror(errno)); + return; + } -Fl_Button *template_delete=(Fl_Button *)0; + char pngfile[1024], *ext; + strlcpy(pngfile, flfile, sizeof(pngfile)); + if ((ext = strrchr(pngfile, '.')) != NULL) { + strcpy(ext, ".png"); + fl_unlink(pngfile); + } + + template_browser->remove(item); + template_browser->do_callback(); +//~fl~3~3016~6fd453d2~~ +} +void TemplatePanel::cb_template_delete(Fl_Button* o, void* v) { + ((TemplatePanel*)(o->parent()->parent()->user_data()))->cb_template_delete_i(o,v); +} -static void cb_Cancel(Fl_Button*, void*) { +void TemplatePanel::cb_Cancel_i(Fl_Button*, void*) { +//~fl~0~0000~33ce2418~~ Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); if (img) img->release(); template_preview->image(0); - - template_browser->deselect(); + template_browser->deselect(); template_name->value(""); template_instance->value(""); - template_panel->hide(); + hide(); +//~fl~3~b573~c3c40d88~~ +} +void TemplatePanel::cb_Cancel(Fl_Button* o, void* v) { + ((TemplatePanel*)(o->parent()->parent()->user_data()))->cb_Cancel_i(o,v); } -Fl_Return_Button *template_submit=(Fl_Return_Button *)0; - -static void cb_template_submit(Fl_Return_Button*, void*) { +void TemplatePanel::cb_template_submit_i(Fl_Return_Button*, void*) { +//~fl~0~0000~804054e1~~ Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); if (img) img->release(); template_preview->image(0); - - template_panel->hide(); + hide(); +//~fl~3~ceb9~bc83306e~~ +} +void TemplatePanel::cb_template_submit(Fl_Return_Button* o, void* v) { + ((TemplatePanel*)(o->parent()->parent()->user_data()))->cb_template_submit_i(o,v); } -Fl_Double_Window* make_template_panel() { - { template_panel = new Fl_Double_Window(460, 355, "New/Save Template"); - template_panel->callback((Fl_Callback*)cb_template_panel); +Fl_Double_Window* TemplatePanel::make_panel() { + { panel_window = new Fl_Double_Window(460, 355, "New/Save Template"); + panel_window->callback((Fl_Callback*)cb_panel_window, (void*)(this)); { template_browser = new Fl_Browser(10, 28, 180, 250, "Available Templates:"); template_browser->type(2); template_browser->labelfont(1); @@ -159,7 +246,7 @@ Fl_Double_Window* make_template_panel() { } // Fl_Input* template_instance { Fl_Group* o = new Fl_Group(10, 323, 440, 25); { template_delete = new Fl_Button(10, 323, 143, 25, "Delete Template"); - template_delete->callback((Fl_Callback*)template_delete_cb); + template_delete->callback((Fl_Callback*)cb_template_delete); } // Fl_Button* template_delete { Fl_Box* o = new Fl_Box(153, 323, 126, 25); Fl_Group::current()->resizable(o); @@ -172,100 +259,78 @@ Fl_Double_Window* make_template_panel() { } // Fl_Return_Button* template_submit o->end(); } // Fl_Group* o - template_panel->set_modal(); - template_panel->end(); - } // Fl_Double_Window* template_panel - return template_panel; + panel_window->set_modal(); + panel_window->end(); + } // Fl_Double_Window* panel_window + return panel_window; } -void template_clear() { - int i; - void *filename; - - for (i = 1; i <= template_browser->size(); i ++) { - if ((filename = template_browser->data(i)) != NULL) free(filename); - } - - template_browser->deselect(); - template_browser->clear(); +/** + Constructor +*/ +TemplatePanel::TemplatePanel() { +//~fl~0~0000~46a7f024~~ + panel_window = nullptr; +//~fl~1~fc1f~89162831~~ } -void template_delete_cb(Fl_Button *, void *) { - int item = template_browser->value(); - if (item < 1) return; +/** + Virtual destructor. +*/ +TemplatePanel::~TemplatePanel() { +//~fl~0~0000~4471bb0c~~ + delete panel_window; +//~fl~1~5c04~d7fec351~~ +} - const char *name = template_browser->text(item); - const char *flfile = (const char *)template_browser->data(item); - if (!flfile) return; +/** + Build the panel, don't show it yet. +*/ +void TemplatePanel::build() { +//~fl~0~0000~dbf3c15a~~ + if (panel_window == nullptr) { + make_panel(); + } +//~fl~1~c0d3~3b33627a~~ +} - if (!fl_choice("Are you sure you want to delete the template \"%s\"?", - "Cancel", "Delete", 0, name)) return; +/** + Build if needed and show the panel. +*/ +void TemplatePanel::show() { +//~fl~0~0000~bfac66d7~~ + build(); + panel_window->show(); +//~fl~1~5ff4~94ddffa5~~ +} - if (fl_unlink(flfile)) { - fl_alert("Unable to delete template \"%s\":\n%s", name, strerror(errno)); - return; +/** + Hide the panel and retain for later. +*/ +void TemplatePanel::hide() { +//~fl~0~0000~3214eb68~~ + if (panel_window) { + panel_window->hide(); } +//~fl~1~0084~da452744~~ +} - char pngfile[1024], *ext; - strlcpy(pngfile, flfile, sizeof(pngfile)); - if ((ext = strrchr(pngfile, '.')) != NULL) { - strcpy(ext, ".png"); - fl_unlink(pngfile); +void TemplatePanel::template_clear() { +//~fl~0~0000~ad2e13f4~~ + int i; + void *filename; + + for (i = 1; i <= template_browser->size(); i ++) { + if ((filename = template_browser->data(i)) != NULL) free(filename); } - template_browser->remove(item); - template_browser->do_callback(); + template_browser->deselect(); + template_browser->clear(); +//~fl~1~250c~29159737~~ } -static int tmpl_FLTK_License_fl_size = 623; -static unsigned char tmpl_FLTK_License_fl[401] = /* data compressed and inlined from templates/FLTK_License.fl */ -{120,156,133,82,77,79,220,48,16,189,231,87,60,209,11,72,109,178,208,30,10, -39,218,165,84,43,208,22,137,237,161,39,228,196,147,120,132,99,71,246,132,176, -93,237,127,199,14,187,234,177,62,217,227,247,53,99,127,128,86,162,208,178,37, -180,62,64,12,225,214,202,51,126,71,10,88,57,161,208,170,134,112,67,145,59,151, -74,167,173,29,89,159,21,47,20,34,123,135,243,114,241,101,177,40,12,41,77,225, -201,169,158,176,43,205,190,104,188,166,227,177,121,125,205,133,190,39,39,216,85, -85,81,85,184,94,173,31,55,223,214,203,31,215,255,124,85,20,220,115,103,4,27, -239,45,238,88,112,122,123,191,185,59,43,139,119,210,210,15,219,48,3,206,47,47, -191,126,186,88,92,124,70,189,197,119,182,22,143,3,203,95,245,12,229,52,124,146, -11,241,200,218,24,142,176,92,7,21,182,72,219,54,16,33,250,86,38,21,168,196,13, -71,9,92,143,146,219,201,236,49,18,102,151,136,4,128,31,197,178,35,13,118,89,45, -39,157,199,117,178,252,245,240,103,181,254,121,130,201,112,99,16,141,31,173, -134,81,47,132,154,200,37,124,99,71,157,136,19,139,73,188,108,157,136,37,176,106, -231,99,150,155,165,210,77,207,49,178,235,144,102,161,85,175,58,210,31,17,83,206, -108,103,185,33,151,66,41,185,58,180,148,151,17,25,226,85,85,77,211,84,182,233, -201,74,31,186,234,144,169,28,204,112,128,62,88,82,137,123,212,106,189,181,126, -202,78,67,50,65,106,217,248,9,226,17,104,240,65,80,143,93,156,167,144,242,140, -20,255,107,152,241,71,183,61,118,145,44,53,50,15,235,41,250,49,164,175,147,118, -239,191,163,216,23,111,13,176,205,39}; - -static int tmpl_1of7GUIs_fl_size = 763; -static unsigned char tmpl_1of7GUIs_fl[486] = /* data compressed and inlined from templates/1of7GUIs.fl */ -{120,156,109,82,203,138,219,64,16,188,207,87,52,228,178,102,177,45,25,59, -187,142,73,14,121,56,187,36,224,92,76,142,102,36,181,164,206,142,102,196,60,252, -88,33,216,223,200,61,127,146,63,201,151,164,37,69,176,9,97,4,163,26,122,170, -170,171,231,5,100,210,75,200,73,33,228,198,130,47,17,182,202,63,192,222,161,133, -123,237,209,230,50,69,120,143,142,10,205,71,87,185,10,148,77,4,28,209,58,50,26, -226,89,180,140,34,1,37,202,12,237,65,203,10,161,153,149,173,72,77,134,35,76,207, -231,86,64,106,170,10,181,135,70,196,96,114,184,249,184,191,119,66,244,27,156, -164,131,4,81,67,106,81,122,204,128,177,4,87,147,158,154,60,239,202,59,107,149, -116,236,232,215,211,119,39,24,58,114,240,206,84,181,180,228,216,9,215,236,146, -111,152,250,233,206,18,235,116,36,58,131,109,208,169,103,167,82,137,47,214,20, -86,86,21,233,162,239,150,149,185,179,35,42,83,247,198,146,11,124,8,5,155,248, -68,142,229,125,167,41,238,66,37,245,180,211,9,126,204,68,246,140,80,88,19,234, -209,219,103,164,68,211,163,216,107,234,179,241,63,127,120,184,147,90,27,134,64, -26,22,81,188,156,9,81,122,95,187,87,243,249,77,17,200,205,10,242,101,72,102, -100,6,60,23,45,52,14,21,119,193,246,73,31,156,9,150,243,215,198,31,24,13,33,139, -86,136,177,43,104,248,130,169,81,119,23,197,86,29,190,146,206,204,169,63,22,74, -38,168,56,162,208,121,134,190,234,124,57,149,208,44,111,95,194,98,189,128,120, -189,132,213,170,5,127,169,121,198,38,36,252,12,44,231,250,40,187,191,35,57,226, -125,100,222,5,207,17,240,20,123,186,195,137,178,2,187,97,14,148,241,10,248,187, -141,96,177,24,102,31,65,243,119,233,244,205,81,170,128,87,209,100,211,114,11, -204,248,54,120,255,167,133,231,94,69,42,149,74,100,250,0,13,241,84,8,94,195,191, -76,52,80,77,54,130,174,175,55,226,255,66,212,9,13,238,214,235,103,238,134,245, -27,226,34,7,2}; - -void template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen) { +void TemplatePanel::template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen) { +//~fl~0~0000~d8f9602a~~ char filename[FL_PATH_MAX]; strcpy(filename, path); strcat(filename, name); @@ -276,9 +341,11 @@ void template_install(const char *path, const char *name, const uchar *inSrc, in if (uncompress(dst, &dstLen, (Bytef*)inSrc, (uLong)inSrcLen) != Z_OK) { /* error */ } if (fwrite(dst, dstLen, 1, f) <= 0) { /* error */ } fclose(f); +//~fl~1~c555~3fe8f272~~ } -void template_load() { +void TemplatePanel::template_load() { +//~fl~0~0000~08c6f161~~ int i; char name[1024], filename[1400], path[1024], *ptr; struct dirent **files; @@ -337,4 +404,168 @@ void template_load() { } if (num_files > 0) free(files); +//~fl~1~a81c~5909ec13~~ +} + +/** + Open the dialog box and offer the user to + save the given project as a new template +*/ +void TemplatePanel::add(fluid::Project *project) { +//~fl~0~0000~6a622b87~~ + build(); + template_clear(); + template_browser->add("New Template"); + template_load(); + template_name->show(); + template_name->value(""); + template_instance->hide(); + template_delete->show(); + template_delete->deactivate(); + template_submit->label("Save"); + template_submit->deactivate(); + panel_window->label("Add Template"); + // Show the panel and wait for the user to do something... + show(); + while (panel_window->shown()) Fl::wait(); + // Get the template name, return if it is empty... + const char *c = template_name->value(); + if (!c || !*c) return; + // Convert template name to filename_with_underscores + char savename[FL_PATH_MAX], *saveptr; + strlcpy(savename, c, sizeof(savename)); + for (saveptr = savename; *saveptr; saveptr ++) { + if (isspace(*saveptr)) *saveptr = '_'; + } + // Find the templates directory... + char filename[FL_PATH_MAX]; + fluid_prefs.getUserdataPath(filename, sizeof(filename)); + strlcat(filename, "templates", sizeof(filename)); + if (fl_access(filename, 0)) fl_make_path(filename); + strlcat(filename, "/", sizeof(filename)); + strlcat(filename, savename, sizeof(filename)); + char *ext = filename + strlen(filename); + if (ext >= (filename + sizeof(filename) - 5)) { + fl_alert("The template name \"%s\" is too long!", c); + return; + } + // Save the .fl file... + strcpy(ext, ".fl"); + if (!fl_access(filename, 0)) { + if (fl_choice("The template \"%s\" already exists.\n" + "Do you want to replace it?", "Cancel", + "Replace", NULL, c) == 0) return; + } + if (!stream::write_file(filename)) { + fl_alert("Error writing %s: %s", filename, strerror(errno)); + return; + } + // Get the screenshot, if any... + Fl_Type *t; + for (t = Fl_Type::first; t; t = t->next) { + // Find the first window... + if (t->is_a(ID_Window)) break; + } + if (!t) return; + // Grab a screenshot... + Fl_Window_Type *wt = (Fl_Window_Type *)t; + uchar *pixels; + int w, h; + if ((pixels = wt->read_image(w, h)) == NULL) return; + // Save to a PNG file... + strcpy(ext, ".png"); + errno = 0; + if (fl_write_png(filename, pixels, w, h, 3) != 0) { + delete[] pixels; + fl_alert("Error writing %s: %s", filename, strerror(errno)); + return; + } + delete[] pixels; +//~fl~1~1620~636b654e~~ +} + +/** + Open the panel and let the user choose a + template that is then loaded into the + current project. +*/ +bool TemplatePanel::load_template() { +//~fl~0~0000~63862b15~~ + // Setup the template panel... + build(); + + template_clear(); + template_browser->add("Blank"); + template_load(); + template_name->hide(); + template_name->value(""); + template_instance->show(); + template_instance->deactivate(); + template_instance->value(""); + template_delete->show(); + template_submit->label("Load"); + template_submit->deactivate(); + panel_window->label("Load Template"); + //if ( template_browser->size() == 1 ) { // only one item? + template_browser->value(1); // select it + template_browser->do_callback(); + //} + // Show the panel and wait for the user to do something... + show(); + while (panel_window->shown()) Fl::wait(); + // See if the user chose anything... + int item = template_browser->value(); + if (item < 1) return false; + // Load the template, if any... + const char *tname = (const char *)template_browser->data(item); + if (tname) { + // Grab the instance name... + const char *iname = template_instance->value(); + if (iname && *iname) { + // Copy the template to a temp file, then read it in... + char line[1024], *ptr, *next; + FILE *infile, *outfile; + if ((infile = fl_fopen(tname, "rb")) == NULL) { + fl_alert("Error reading template file \"%s\":\n%s", tname, + strerror(errno)); + Fluid.project.set_modflag(0); + Fluid.project.undo.clear(); + return false; + } + if ((outfile = fl_fopen(Fluid.cutfname(1), "wb")) == NULL) { + fl_alert("Error writing buffer file \"%s\":\n%s", Fluid.cutfname(1), + strerror(errno)); + fclose(infile); + Fluid.project.set_modflag(0); + Fluid.project.undo.clear(); + return false; + } + while (fgets(line, sizeof(line), infile)) { + // Replace @INSTANCE@ with the instance name... + for (ptr = line; (next = strstr(ptr, "@INSTANCE@")) != NULL; ptr = next + 10) { + fwrite(ptr, next - ptr, 1, outfile); + fputs(iname, outfile); + } + fputs(ptr, outfile); + } + fclose(infile); + fclose(outfile); + Fluid.project.undo.suspend(); + fluid::stream::read_file(Fluid.cutfname(1), 0); + fl_unlink(Fluid.cutfname(1)); + Fluid.project.undo.resume(); + } else { + // No instance name, so read the template without replacements... + Fluid.project.undo.suspend(); + fluid::stream::read_file(tname, 0); + Fluid.project.undo.resume(); + } + } + widget_browser->rebuild(); + Fluid.project.update_settings_dialog(); + Fluid.project.set_modflag(0); + Fluid.project.undo.clear(); + return true; +//~fl~1~9799~42199347~~ } +TemplatePanel fluid::ui::template_panel; diff --git a/fluid/ui/template_panel.fl b/fluid/ui/template_panel.fl new file mode 100644 index 0000000000..84739a484b --- /dev/null +++ b/fluid/ui/template_panel.fl @@ -0,0 +1,520 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0400 +use_FL_COMMAND +utf8_in_src +header_name {.h} +code_name {.cxx} +mergeback 1 +comment {// +// FLUID template support for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2020 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 +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// +} {uid cb36 in_source in_header +} + +decl {\#include "ui/panel.h"} {uid 4c2b public global +} + +decl {using namespace fluid::ui;} {uid d5e8 private global +} + +decl {\#include "fluid.h"} {uid 5e58 private local +} + +decl {\#include "widget_browser.h"} {uid fc8f selected private local +} + +decl {\#include "application/application.h"} {uid 0001 private local +} + +decl {\#include "project/project.h"} {uid dcdf private local +} + +decl {\#include "streams/project_reader.h"} {uid 0271 private local +} + +decl {\#include "streams/project_writer.h"} {uid 6a42 private local +} + +decl {\#include } {uid 1840 private local +} + +decl {\#include } {uid 4c40 private local +} + +decl {\#include "Fl_Window_Type.h"} {uid e2ca private local +} + +decl {\#include } {uid 1c66 private local +} + +decl {\#include } {uid 7704 private local +} + +decl {\#include "fluid_filename.h"} {uid ab66 private local +} + +decl {\#include "../src/flstring.h"} {uid bf56 private local +} + +decl {\#include } {uid c5d5 private local +} + +decl {\#include } {uid 3bef private local +} + +decl {\#include } {uid 01ed private local +} + +decl {\#include } {uid 8a73 private local +} + +declblock {\#if defined(_WIN32) && !defined(__CYGWIN__)} {uid 9f15 after {\#endif // _WIN32 && !__CYGWIN__} +} { + decl {\#include } {uid 4675 private local + } + decl {\#else} {uid bf91 private local + } + decl {\#include } {uid cc89 private local + } +} + +decl {using namespace fluid::ui;} {uid 6bd6 private global +} + +data tmpl_FLTK_License_fl {uid 644a private local filename {../templates/FLTK_License.fl} compressed +} + +data tmpl_1of7GUIs_fl {uid 68c8 private local filename {../templates/1of7GUIs.fl} compressed +} + +decl {void show_help(const char *name);} {uid 1c15 public local +} + +declblock {namespace fluid \{} {uid e1dd open public map 1 after {\}} +} { + decl {class Project;} {uid a6b9 public global + } + declblock {namespace ui \{} {uid c6e5 open public map 1 after {\}} + } { + class TemplatePanel {uid 09f8 open : {public Panel} + } { + Function {make_panel()} {uid 7ad7 open private + } { + Fl_Window panel_window {uid edfd + label {New/Save Template} + callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); +if (img) img->release(); +template_preview->image(0); + template_browser->deselect(); +template_name->value(""); +template_instance->value(""); +hide();} open + xywh {437 284 460 355} type Double resizable modal visible + } { + Fl_Browser template_browser {uid 9f53 + label {Available Templates:} + callback {if (Fl::event_clicks()) { + hide(); + return; +} +Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); +if (img) img->release(); +template_preview->image(0); +template_preview->redraw(); + int item = template_browser->value(); + if (item <= 1) template_instance->deactivate(); +else template_instance->activate(); + if (item < 1) { + template_submit->deactivate(); + template_delete->deactivate(); + return; +} + template_submit->activate(); + const char *flfile = (const char *)template_browser->data(item); +if (!flfile) { + template_delete->deactivate(); + return; +} + template_name->value(template_browser->text(item)); + template_delete->activate(); + char pngfile[1024], *ext; + strlcpy(pngfile, flfile, sizeof(pngfile)); +if ((ext = strrchr(pngfile, '.')) == NULL) return; +strcpy(ext, ".png"); + img = Fl_Shared_Image::get(pngfile); + if (img) { + template_preview->image(img); + template_preview->redraw(); +}} + xywh {10 28 180 250} type Hold labelfont 1 align 5 when 3 + } + Fl_Box template_preview {uid 3ab6 + xywh {200 28 250 250} box THIN_DOWN_BOX align 80 resizable + } + Fl_Input template_name {uid 94ec + label {Template Name:} + callback {if (strlen(template_name->value())) { + template_submit->activate(); + if (Fl::event_key() == FL_Enter) hide(); +} else template_submit->deactivate();} + xywh {198 288 252 25} labelfont 1 when 3 textfont 4 + } + Fl_Input template_instance {uid 4b09 + label {Instance Name:} + xywh {198 288 252 25} labelfont 1 textfont 4 hide + } + Fl_Group {} {uid 6266 open + xywh {10 323 440 25} + } { + Fl_Button template_delete {uid 3016 + label {Delete Template} + callback {int item = template_browser->value(); +if (item < 1) return; + +const char *name = template_browser->text(item); +const char *flfile = (const char *)template_browser->data(item); +if (!flfile) return; + +if (!fl_choice("Are you sure you want to delete the template \\"%s\\"?", + "Cancel", "Delete", 0, name)) return; + +if (fl_unlink(flfile)) { + fl_alert("Unable to delete template \\"%s\\":\\n%s", name, strerror(errno)); + return; +} + +char pngfile[1024], *ext; +strlcpy(pngfile, flfile, sizeof(pngfile)); +if ((ext = strrchr(pngfile, '.')) != NULL) { + strcpy(ext, ".png"); + fl_unlink(pngfile); +} + +template_browser->remove(item); +template_browser->do_callback();} + xywh {10 323 143 25} + } + Fl_Box {} {uid 29a7 + xywh {153 323 126 25} resizable + } + Fl_Button {} {uid b573 + label Cancel + callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); +if (img) img->release(); +template_preview->image(0); + template_browser->deselect(); +template_name->value(""); +template_instance->value(""); +hide();} + xywh {289 323 72 25} + } + Fl_Return_Button template_submit {uid ceb9 + label Save + callback {Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image(); +if (img) img->release(); +template_preview->image(0); + hide();} + xywh {371 323 79 25} + } + } + } + } + Function {TemplatePanel()} {uid ef42 + comment Constructor open + } { + code {panel_window = nullptr;} {uid fc1f + } + } + Function {~TemplatePanel() override} {uid 8867 + comment {Virtual destructor.} open + } { + code {delete panel_window;} {uid 5c04 + } + } + Function {build() override} {uid 20ce + comment {Build the panel, don't show it yet.} open return_type void + } { + code {if (panel_window == nullptr) { + make_panel(); +}} {uid c0d3 + } + } + Function {show() override} {uid 8d6e + comment {Build if needed and show the panel.} open return_type void + } { + code {build(); +panel_window->show();} {uid 5ff4 + } + } + Function {hide() override} {uid c5e4 + comment {Hide the panel and retain for later.} open return_type void + } { + code {if (panel_window) { + panel_window->hide(); +}} {uid 0084 + } + } + Function {template_clear()} {uid 08ba return_type void + } { + code {int i; +void *filename; + +for (i = 1; i <= template_browser->size(); i ++) { + if ((filename = template_browser->data(i)) != NULL) free(filename); +} + +template_browser->deselect(); +template_browser->clear();} {uid 250c + } + } + Function {template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen)} {uid 9548 return_type void + } { + code {char filename[FL_PATH_MAX]; + strcpy(filename, path); + strcat(filename, name); + FILE *f = fopen(filename, "wb"); + if (!f) return; + uLong dstLen = inDstLen; + Bytef *dst = (Bytef*)::malloc(inDstLen); + if (uncompress(dst, &dstLen, (Bytef*)inSrc, (uLong)inSrcLen) != Z_OK) { /* error */ } + if (fwrite(dst, dstLen, 1, f) <= 0) { /* error */ } + fclose(f);} {uid c555 + } + } + Function {template_load()} {uid 55c7 return_type void + } { + code {int i; +char name[1024], filename[1400], path[1024], *ptr; +struct dirent **files; +int num_files; + +fluid_prefs.getUserdataPath(path, sizeof(path)); +strlcat(path, "templates", sizeof(path)); +fl_make_path(path); + +int sample_templates_generated = 0; +fluid_prefs.get("sample_templates_generated", sample_templates_generated, 0); + +if (sample_templates_generated < 2) { + strcpy(filename, path); + strcat(filename, "/FLTK_License.fl"); + FILE *f = fopen(filename, "wb"); + if (f) { + fputs( +"\# data file for the Fltk User Interface Designer (fluid)\\nversion 1.0400\\nheader_name {.h}\\n" +"code_name {.cxx}\\ncomment {//\\n// @INSTANCE@ for the Fast Light Tool Kit (FLT" +"K).\\n//\\n// Copyright 1998-2023 by Bill Spitzak and others.\\n//\\n// This library is free sof" +"tware. Distribution and use rights are outlined in\\n// the file \\"COPYING\\" which should have " +"been included with this file. If this\\n// file is missing or damaged, see the license at:\\n" +"//\\n// https://www.fltk.org/COPYING.php\\n//\\n// Please see the following page on how to report " +"bugs and issues:\\n//\\n// https://www.fltk.org/bugs.php\\n//\\n} {selected in_source in_head" +"er\\n}\\n", f); + fclose(f); + } + + template_install(path, "/FLTK_License.fl", tmpl_FLTK_License_fl, sizeof(tmpl_FLTK_License_fl), tmpl_FLTK_License_fl_size); + template_install(path, "/1of7GUIs.fl", tmpl_1of7GUIs_fl, sizeof(tmpl_1of7GUIs_fl), tmpl_1of7GUIs_fl_size); + sample_templates_generated = 2; + fluid_prefs.set("sample_templates_generated", sample_templates_generated); + fluid_prefs.flush(); +} + +num_files = fl_filename_list(path, &files); + +for (i = 0; i < num_files; i ++) { + if (fl_filename_match(files[i]->d_name, "*.fl")) { + // Format the name as the filename with "_" replaced with " " + // and without the trailing ".fl"... + strlcpy(name, files[i]->d_name, sizeof(name)); + *strstr(name, ".fl") = '\\0'; + + for (ptr = name; *ptr; ptr ++) { + if (*ptr == '_') *ptr = ' '; + } + + // Add the template to the browser... + snprintf(filename, sizeof(filename), "%s/%s", path, files[i]->d_name); + template_browser->add(name, fl_strdup(filename)); + } + + free(files[i]); +} + +if (num_files > 0) free(files);} {uid a81c + } + } + Function {add(fluid::Project *project)} {uid 4986 + comment {Open the dialog box and offer the user to +save the given project as a new template} open return_type void + } { + code {build(); +template_clear(); +template_browser->add("New Template"); +template_load(); + template_name->show(); +template_name->value(""); + template_instance->hide(); + template_delete->show(); +template_delete->deactivate(); + template_submit->label("Save"); +template_submit->deactivate(); + panel_window->label("Add Template"); + // Show the panel and wait for the user to do something... +show(); +while (panel_window->shown()) Fl::wait(); + // Get the template name, return if it is empty... +const char *c = template_name->value(); +if (!c || !*c) return; + // Convert template name to filename_with_underscores +char savename[FL_PATH_MAX], *saveptr; +strlcpy(savename, c, sizeof(savename)); +for (saveptr = savename; *saveptr; saveptr ++) { + if (isspace(*saveptr)) *saveptr = '_'; +} + // Find the templates directory... +char filename[FL_PATH_MAX]; +fluid_prefs.getUserdataPath(filename, sizeof(filename)); + strlcat(filename, "templates", sizeof(filename)); +if (fl_access(filename, 0)) fl_make_path(filename); + strlcat(filename, "/", sizeof(filename)); +strlcat(filename, savename, sizeof(filename)); + char *ext = filename + strlen(filename); +if (ext >= (filename + sizeof(filename) - 5)) { + fl_alert("The template name \\"%s\\" is too long!", c); + return; +} + // Save the .fl file... +strcpy(ext, ".fl"); + if (!fl_access(filename, 0)) { + if (fl_choice("The template \\"%s\\" already exists.\\n" + "Do you want to replace it?", "Cancel", + "Replace", NULL, c) == 0) return; +} + if (!stream::write_file(filename)) { + fl_alert("Error writing %s: %s", filename, strerror(errno)); + return; +} + // Get the screenshot, if any... +Fl_Type *t; + for (t = Fl_Type::first; t; t = t->next) { + // Find the first window... + if (t->is_a(ID_Window)) break; +} + if (!t) return; + // Grab a screenshot... +Fl_Window_Type *wt = (Fl_Window_Type *)t; +uchar *pixels; +int w, h; + if ((pixels = wt->read_image(w, h)) == NULL) return; + // Save to a PNG file... +strcpy(ext, ".png"); + errno = 0; +if (fl_write_png(filename, pixels, w, h, 3) != 0) { + delete[] pixels; + fl_alert("Error writing %s: %s", filename, strerror(errno)); + return; +} + delete[] pixels;} {uid 1620 + } + } + Function {load_template()} {uid d2ad + comment {Open the panel and let the user choose a +template that is then loaded into the +current project.} open return_type bool + } { + code {// Setup the template panel... +build(); + +template_clear(); +template_browser->add("Blank"); +template_load(); + template_name->hide(); +template_name->value(""); + template_instance->show(); +template_instance->deactivate(); +template_instance->value(""); + template_delete->show(); + template_submit->label("Load"); +template_submit->deactivate(); + panel_window->label("Load Template"); + //if ( template_browser->size() == 1 ) { // only one item? +template_browser->value(1); // select it +template_browser->do_callback(); +//} + // Show the panel and wait for the user to do something... +show(); +while (panel_window->shown()) Fl::wait(); + // See if the user chose anything... +int item = template_browser->value(); +if (item < 1) return false; + // Load the template, if any... +const char *tname = (const char *)template_browser->data(item); + if (tname) { + // Grab the instance name... + const char *iname = template_instance->value(); + if (iname && *iname) { + // Copy the template to a temp file, then read it in... + char line[1024], *ptr, *next; + FILE *infile, *outfile; + if ((infile = fl_fopen(tname, "rb")) == NULL) { + fl_alert("Error reading template file \\"%s\\":\\n%s", tname, + strerror(errno)); + Fluid.project.set_modflag(0); + Fluid.project.undo.clear(); + return false; + } + if ((outfile = fl_fopen(Fluid.cutfname(1), "wb")) == NULL) { + fl_alert("Error writing buffer file \\"%s\\":\\n%s", Fluid.cutfname(1), + strerror(errno)); + fclose(infile); + Fluid.project.set_modflag(0); + Fluid.project.undo.clear(); + return false; + } + while (fgets(line, sizeof(line), infile)) { + // Replace @INSTANCE@ with the instance name... + for (ptr = line; (next = strstr(ptr, "@INSTANCE@")) != NULL; ptr = next + 10) { + fwrite(ptr, next - ptr, 1, outfile); + fputs(iname, outfile); + } + fputs(ptr, outfile); + } + fclose(infile); + fclose(outfile); + Fluid.project.undo.suspend(); + fluid::stream::read_file(Fluid.cutfname(1), 0); + fl_unlink(Fluid.cutfname(1)); + Fluid.project.undo.resume(); + } else { + // No instance name, so read the template without replacements... + Fluid.project.undo.suspend(); + fluid::stream::read_file(tname, 0); + Fluid.project.undo.resume(); + } +} +widget_browser->rebuild(); +Fluid.project.update_settings_dialog(); +Fluid.project.set_modflag(0); +Fluid.project.undo.clear(); +return true;} {uid 9799 + } + } + } + decl {extern TemplatePanel template_panel;} {uid eb33 public global + } + decl {TemplatePanel fluid::ui::template_panel;} {uid 96a5 private global + } + } +} diff --git a/fluid/ui/template_panel.h b/fluid/ui/template_panel.h new file mode 100644 index 0000000000..a48d382b04 --- /dev/null +++ b/fluid/ui/template_panel.h @@ -0,0 +1,81 @@ +// +// FLUID template support for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2020 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 +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// generated by Fast Light User Interface Designer (fluid) version 1.0400 + +#ifndef template_panel_h +#define template_panel_h +#include +#include "ui/panel.h" +extern void show_help(const char *name); +#include +#include +#include +#include +#include +#include +#include +namespace fluid { +class Project; +namespace ui { + +class TemplatePanel : public Panel { + Fl_Double_Window* make_panel(); +public: + Fl_Double_Window *panel_window; +private: + inline void cb_panel_window_i(Fl_Double_Window*, void*); + static void cb_panel_window(Fl_Double_Window*, void*); +public: + Fl_Browser *template_browser; +private: + inline void cb_template_browser_i(Fl_Browser*, void*); + static void cb_template_browser(Fl_Browser*, void*); +public: + Fl_Box *template_preview; + Fl_Input *template_name; +private: + inline void cb_template_name_i(Fl_Input*, void*); + static void cb_template_name(Fl_Input*, void*); +public: + Fl_Input *template_instance; + Fl_Button *template_delete; +private: + inline void cb_template_delete_i(Fl_Button*, void*); + static void cb_template_delete(Fl_Button*, void*); + inline void cb_Cancel_i(Fl_Button*, void*); + static void cb_Cancel(Fl_Button*, void*); +public: + Fl_Return_Button *template_submit; +private: + inline void cb_template_submit_i(Fl_Return_Button*, void*); + static void cb_template_submit(Fl_Return_Button*, void*); +public: + TemplatePanel(); + ~TemplatePanel() override; + void build() override; + void show() override; + void hide() override; + void template_clear(); + void template_install(const char *path, const char *name, const uchar *inSrc, int inSrcLen, int inDstLen); + void template_load(); + void add(fluid::Project *project); + bool load_template(); +}; +extern TemplatePanel template_panel; +} +} +#endif