diff options
Diffstat (limited to 'fluid/panels/settings_panel.cxx')
| -rw-r--r-- | fluid/panels/settings_panel.cxx | 179 |
1 files changed, 92 insertions, 87 deletions
diff --git a/fluid/panels/settings_panel.cxx b/fluid/panels/settings_panel.cxx index e108e57e4..3b32fc665 100644 --- a/fluid/panels/settings_panel.cxx +++ b/fluid/panels/settings_panel.cxx @@ -24,7 +24,7 @@ #include <FL/fl_ask.H> #include "../src/flstring.h" #include <string.h> -using namespace fld::widget; + void scheme_cb(Fl_Scheme_Choice *, void *); int w_settings_shell_list_selected; @@ -371,10 +371,10 @@ Fl_Input *header_file_input=(Fl_Input *)0; static void cb_header_file_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.header_file_name.c_str()); + o->value(Fluid.proj.header_file_name()); } else { - if (strcmp(Fluid.proj.header_file_name.c_str(), o->value())) { - Fluid.proj.header_file_name = o->value(); + if (strcmp(Fluid.proj.header_file_name(), o->value())) { + Fluid.proj.set_header_file_name(o->value()); Fluid.proj.set_modflag(1); } } @@ -384,10 +384,10 @@ Fl_Input *code_file_input=(Fl_Input *)0; static void cb_code_file_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.code_file_name.c_str()); + o->value(Fluid.proj.code_file_name()); } else { - if (strcmp(Fluid.proj.code_file_name.c_str(), o->value())) { - Fluid.proj.code_file_name = o->value(); + if (strcmp(Fluid.proj.code_file_name(), o->value())) { + Fluid.proj.set_code_file_name(o->value()); Fluid.proj.set_modflag(1); } } @@ -410,10 +410,10 @@ Fl_Input *include_guard_input=(Fl_Input *)0; static void cb_include_guard_input(Fl_Input* o, void* v) { if (v == LOAD) { - o->value(Fluid.proj.include_guard.c_str()); + o->value(Fluid.proj.include_guard()); } else { - if (strcmp(Fluid.proj.include_guard.c_str(), o->value())) { - Fluid.proj.include_guard = o->value(); + if (strcmp(Fluid.proj.include_guard(), o->value())) { + Fluid.proj.set_include_guard(o->value()); Fluid.proj.set_modflag(1); } } @@ -510,11 +510,11 @@ Fl_Choice *layout_choice=(Fl_Choice *)0; static void cb_layout_choice(Fl_Choice* o, void* v) { if (v == LOAD) { - o->value(Fluid.layout_list.current_suite()); + o->value(Fluid.layout_list->current_suite()); } else { int index = o->value(); - Fluid.layout_list.current_suite(index); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->current_suite(index); + Fluid.layout_list->update_dialogs(); } } @@ -526,24 +526,25 @@ Fl_Menu_Item menu_layout_choice[] = { static void cb_2(Fl_Button*, void* v) { // Clone the current layout suite + char old_name[256]; if (v == LOAD) return; - std::string old_name = "Copy of "; - old_name.append(Fluid.layout_list[Fluid.layout_list.current_suite()].name_); - const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str()); - if (new_name == nullptr) + snprintf(old_name, sizeof(old_name), "Copy of %s", + (*Fluid.layout_list)[Fluid.layout_list->current_suite()].name_); + const char *new_name = fl_input("Enter a name for the new layout:", old_name); + if (new_name == 0) return; - Fluid.layout_list.add(new_name); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->add(new_name); + Fluid.layout_list->update_dialogs(); } Fl_Menu_Button *w_layout_menu=(Fl_Menu_Button *)0; static void cb_w_layout_menu(Fl_Menu_Button*, void* v) { if (v == LOAD) { - fld::app::Layout_Suite &suite = Fluid.layout_list[Fluid.layout_list.current_suite()]; + fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; if (suite.storage_ == FLD_TOOL_STORE_INTERNAL) { w_layout_menu_rename->deactivate(); for (int i=1; i<4; i++) w_layout_menu_storage[i]->deactivate(); @@ -553,44 +554,44 @@ static void cb_w_layout_menu(Fl_Menu_Button*, void* v) { for (int i=1; i<4; i++) w_layout_menu_storage[i]->activate(); w_layout_menu_delete->activate(); } - w_layout_menu_storage[static_cast<int>(suite.storage_)]->setonly(menu_w_layout_menu); + w_layout_menu_storage[(int)(suite.storage_)]->setonly(menu_w_layout_menu); } } static void cb_w_layout_menu_rename(Fl_Menu_*, void*) { // Rename the current layout suite - std::string old_name = Fluid.layout_list[Fluid.layout_list.current_suite()].name_; - const char *new_name = fl_input("Enter a new name for the layout:", old_name.c_str()); - if (new_name == nullptr) + const char *old_name = (*Fluid.layout_list)[Fluid.layout_list->current_suite()].name_; + const char *new_name = fl_input("Enter a new name for the layout:", old_name); + if (new_name == 0) return; - Fluid.layout_list.rename(new_name); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->rename(new_name); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_storage(Fl_Menu_*, void*) { - fld::app::Layout_Suite &suite = Fluid.layout_list[Fluid.layout_list.current_suite()]; + fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; suite.storage(FLD_TOOL_STORE_INTERNAL); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_storage1(Fl_Menu_*, void*) { - fld::app::Layout_Suite &suite = Fluid.layout_list[Fluid.layout_list.current_suite()]; + fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; suite.storage(FLD_TOOL_STORE_USER); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_storage2(Fl_Menu_*, void*) { - fld::app::Layout_Suite &suite = Fluid.layout_list[Fluid.layout_list.current_suite()]; + fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; suite.storage(FLD_TOOL_STORE_PROJECT); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_storage3(Fl_Menu_*, void*) { - fld::app::Layout_Suite &suite = Fluid.layout_list[Fluid.layout_list.current_suite()]; + fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; suite.storage(FLD_TOOL_STORE_FILE); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_load(Fl_Menu_*, void*) { @@ -603,33 +604,35 @@ static void cb_w_layout_menu_load(Fl_Menu_*, void*) { if (fnfc.show() != 0) return; const char *new_filename = fnfc.filename(); if (!new_filename) return; - Fluid.layout_list.load(new_filename); - //Fluid.layout_list.current_suite(n); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->load(new_filename); + //Fluid.layout_list->current_suite(n); + Fluid.layout_list->update_dialogs(); } static void cb_w_layout_menu_save(Fl_Menu_*, void*) { // Give the user a file chooser with a suggested name + char path[FL_PATH_MAX]; Fl_Native_File_Chooser fnfc; fnfc.title("Save Layout Settings:"); fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT); fnfc.filter("FLUID Layouts\t*.fll\n"); - std::string filename = Fluid.layout_list.filename_; - fnfc.directory(fl_filename_path_str(filename).c_str()); - fnfc.preset_file(fl_filename_name_str(filename).c_str()); + const char *filename = Fluid.layout_list->filename_.c_str(); + fl_filename_path(path, FL_PATH_MAX, filename); + fnfc.directory(path); + fnfc.preset_file(fl_filename_name(filename)); if (fnfc.show() != 0) return; const char *new_filename = fnfc.filename(); if (!new_filename) return; - Fluid.layout_list.filename_ = new_filename; - Fluid.layout_list.save(new_filename); + Fluid.layout_list->filename_ = new_filename; + Fluid.layout_list->save(new_filename); } static void cb_w_layout_menu_delete(Fl_Menu_*, void*) { // remove the current suite - Fluid.layout_list.remove(Fluid.layout_list.current_suite()); - Fluid.layout_list.update_dialogs(); + Fluid.layout_list->remove(Fluid.layout_list->current_suite()); + Fluid.layout_list->update_dialogs(); } Fl_Menu_Item menu_w_layout_menu[] = { @@ -894,7 +897,7 @@ static void cb_w_settings_shell_list(Fl_Browser* o, void* v) { w_settings_shell_list_selected = 0; for (int i=0; i<g_shell_config->list_size; i++) { Fd_Shell_Command *cmd = g_shell_config->list[i]; - o->add(cmd->name.c_str()); + o->add(cmd->name); if (cmd->storage == FLD_TOOL_STORE_USER) o->icon(i+1, w_settings_shell_fd_user->image()); else if (cmd->storage == FLD_TOOL_STORE_PROJECT) @@ -927,7 +930,7 @@ static void cb_a(Fl_Button*, void* v) { int selected = w_settings_shell_list_selected; Fd_Shell_Command *cmd = new Fd_Shell_Command("new shell command"); g_shell_config->insert(selected, cmd); - w_settings_shell_list->insert(selected+1, cmd->name.c_str()); + w_settings_shell_list->insert(selected+1, cmd->name); w_settings_shell_list->deselect(); w_settings_shell_list->value(selected+1); if (cmd->storage == FLD_TOOL_STORE_USER) { @@ -957,7 +960,7 @@ static void cb_w_settings_shell_dup(Fl_Button* o, void* v) { if (!selected) return; Fd_Shell_Command *cmd = new Fd_Shell_Command(g_shell_config->list[selected-1]); g_shell_config->insert(selected, cmd); - w_settings_shell_list->insert(selected+1, cmd->name.c_str()); + w_settings_shell_list->insert(selected+1, cmd->name); w_settings_shell_list->deselect(); w_settings_shell_list->value(selected+1); if (cmd->storage == FLD_TOOL_STORE_USER) { @@ -986,7 +989,7 @@ static void cb_w_settings_shell_remove(Fl_Button* o, void* v) { } else { if (!selected) return; int ret = fl_choice("Delete the shell command\n\"%s\"?\n\nThis can not be undone.", - "Delete", "Cancel", nullptr, g_shell_config->list[selected-1]->name.c_str()); + "Delete", "Cancel", 0, g_shell_config->list[selected-1]->name); if (ret==1) return; if (g_shell_config->at(selected-1)->storage == FLD_TOOL_STORE_PROJECT) Fluid.proj.set_modflag(1); g_shell_config->remove(selected-1); @@ -1064,14 +1067,14 @@ static void cb_Name(Fl_Input* o, void* v) { int selected = w_settings_shell_list_selected; if (v == LOAD) { if (selected) { - o->value(g_shell_config->list[selected-1]->name.c_str()); + o->value(g_shell_config->list[selected-1]->name); } else { o->value(""); } } else { if (selected) { Fd_Shell_Command *cmd = g_shell_config->list[selected-1]; - cmd->name = o->value(); + cmd->set_name(o->value()); w_settings_shell_list->text(selected, o->value()); if (cmd->storage == FLD_TOOL_STORE_PROJECT) Fluid.proj.set_modflag(1); } @@ -1082,14 +1085,14 @@ static void cb_Menu(Fl_Input* o, void* v) { int selected = w_settings_shell_list_selected; if (v == LOAD) { if (selected) { - o->value(g_shell_config->list[selected-1]->label.c_str()); + o->value(g_shell_config->list[selected-1]->label); } else { o->value(""); } } else { if (selected) { Fd_Shell_Command *cmd = g_shell_config->list[selected-1]; - cmd->label = o->value(); + cmd->set_label(o->value()); cmd->update_shell_menu(); if (cmd->storage == FLD_TOOL_STORE_PROJECT) Fluid.proj.set_modflag(1); } @@ -1134,7 +1137,7 @@ static void cb_Store(Fl_Choice* o, void* v) { fld::Tool_Store ts = (fld::Tool_Store)(o->mvalue()->argument()); if (cmd->storage == FLD_TOOL_STORE_PROJECT) Fluid.proj.set_modflag(1); cmd->storage = ts; - //w_settings_shell_list->text(selected, cmd->name.c_str()); + //w_settings_shell_list->text(selected, cmd->name); if (cmd->storage == FLD_TOOL_STORE_USER) w_settings_shell_list->icon(selected, w_settings_shell_fd_user->image()); else if (cmd->storage == FLD_TOOL_STORE_PROJECT) @@ -1194,14 +1197,16 @@ static void cb_w_settings_shell_command(Fl_Text_Editor* o, void* v) { int selected = w_settings_shell_list_selected; if (v == LOAD) { if (selected) { - o->buffer()->text(g_shell_config->list[selected-1]->command.c_str()); + o->buffer()->text(g_shell_config->list[selected-1]->command); } else { o->buffer()->text(""); } } else { if (selected) { Fd_Shell_Command *cmd = g_shell_config->list[selected-1]; - cmd->command = o->buffer()->text(); + char *txt = o->buffer()->text(); + cmd->set_command(txt); + free(txt); if (cmd->storage == FLD_TOOL_STORE_PROJECT) Fluid.proj.set_modflag(1); } } @@ -1226,7 +1231,7 @@ static void cb_w_settings_shell_text_macros(Fl_Menu_Button* o, void*) { int pos = w_settings_shell_command->insert_position(); w_settings_shell_command->buffer()->insert(pos, word); } - w_settings_shell_command->do_callback(w_settings_shell_command, (void*)nullptr); + w_settings_shell_command->do_callback(w_settings_shell_command, (void*)0); } } @@ -2446,18 +2451,18 @@ Fl_Choice *w_settings_user_commenttext=(Fl_Choice *)0; static void cb_Reset(Fl_Button* o, void* v) { if (v == LOAD) return; - Node_Browser::label_color = 72; - Node_Browser::label_font = FL_HELVETICA; - Node_Browser::class_color = FL_FOREGROUND_COLOR; - Node_Browser::class_font = FL_HELVETICA_BOLD; - Node_Browser::func_color = FL_FOREGROUND_COLOR; - Node_Browser::func_font = FL_HELVETICA; - Node_Browser::name_color = FL_FOREGROUND_COLOR; - Node_Browser::name_font = FL_HELVETICA; - Node_Browser::code_color = FL_FOREGROUND_COLOR; - Node_Browser::code_font = FL_HELVETICA; - Node_Browser::comment_color = FL_DARK_GREEN; - Node_Browser::comment_font = FL_DARK_GREEN; + fld::widget::Node_Browser::label_color = 72; + fld::widget::Node_Browser::label_font = FL_HELVETICA; + fld::widget::Node_Browser::class_color = FL_FOREGROUND_COLOR; + fld::widget::Node_Browser::class_font = FL_HELVETICA_BOLD; + fld::widget::Node_Browser::func_color = FL_FOREGROUND_COLOR; + fld::widget::Node_Browser::func_font = FL_HELVETICA; + fld::widget::Node_Browser::name_color = FL_FOREGROUND_COLOR; + fld::widget::Node_Browser::name_font = FL_HELVETICA; + fld::widget::Node_Browser::code_color = FL_FOREGROUND_COLOR; + fld::widget::Node_Browser::code_font = FL_HELVETICA; + fld::widget::Node_Browser::comment_color = FL_DARK_GREEN; + fld::widget::Node_Browser::comment_font = FL_DARK_GREEN; o->parent()->do_callback(o->parent(), LOAD); widget_browser->redraw(); widget_browser->save_prefs(); @@ -2466,7 +2471,7 @@ static void cb_Reset(Fl_Button* o, void* v) { static void cb_Close(Fl_Button*, void*) { if (g_shell_config) g_shell_config->write(Fluid.preferences, FLD_TOOL_STORE_USER); - Fluid.layout_list.write(Fluid.preferences, FLD_TOOL_STORE_USER); + Fluid.layout_list->write(Fluid.preferences, FLD_TOOL_STORE_USER); settings_window->hide(); } @@ -3422,17 +3427,17 @@ Fl_Double_Window* make_settings_window() { o->labelfont(1); o->labelsize(12); o->textsize(11); - o->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::label_font)); + o->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::label_font)); Fl_Group::current()->resizable(o); o->menu(fontmenu); } // Fl_Choice* o { Fl_Button* o = new Fl_Button(271, 112, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::label_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::label_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 112, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::label_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::label_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); @@ -3448,17 +3453,17 @@ Fl_Double_Window* make_settings_window() { o->labelfont(1); o->labelsize(12); o->textsize(11); - o->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::class_font)); + o->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::class_font)); Fl_Group::current()->resizable(o); o->menu(fontmenu); } // Fl_Choice* o { Fl_Button* o = new Fl_Button(271, 137, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::class_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::class_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 137, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::class_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::class_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); @@ -3474,17 +3479,17 @@ Fl_Double_Window* make_settings_window() { o->labelfont(1); o->labelsize(12); o->textsize(11); - o->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::func_font)); + o->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::func_font)); Fl_Group::current()->resizable(o); o->menu(fontmenu); } // Fl_Choice* o { Fl_Button* o = new Fl_Button(271, 162, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::func_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::func_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 162, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::func_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::func_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); @@ -3500,17 +3505,17 @@ Fl_Double_Window* make_settings_window() { o->labelfont(1); o->labelsize(12); o->textsize(11); - o->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::name_font)); + o->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::name_font)); Fl_Group::current()->resizable(o); o->menu(fontmenu); } // Fl_Choice* o { Fl_Button* o = new Fl_Button(271, 187, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::name_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::name_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 187, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::name_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::name_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); @@ -3526,17 +3531,17 @@ Fl_Double_Window* make_settings_window() { o->labelfont(1); o->labelsize(12); o->textsize(11); - o->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::code_font)); + o->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::code_font)); Fl_Group::current()->resizable(o); o->menu(fontmenu); } // Fl_Choice* o { Fl_Button* o = new Fl_Button(271, 212, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::code_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::code_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 212, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::code_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::code_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); @@ -3552,17 +3557,17 @@ Fl_Double_Window* make_settings_window() { w_settings_user_commenttext->labelfont(1); w_settings_user_commenttext->labelsize(12); w_settings_user_commenttext->textsize(11); - w_settings_user_commenttext->callback((Fl_Callback*)cb_Comments, (void*)(&Node_Browser::comment_font)); + w_settings_user_commenttext->callback((Fl_Callback*)cb_Comments, (void*)(&fld::widget::Node_Browser::comment_font)); Fl_Group::current()->resizable(w_settings_user_commenttext); o->menu(fontmenu); } // Fl_Choice* w_settings_user_commenttext { Fl_Button* o = new Fl_Button(271, 237, 51, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&Node_Browser::comment_color)); + o->callback((Fl_Callback*)cb_Color_Chip, (void*)(&fld::widget::Node_Browser::comment_color)); } // Fl_Button* o { Fl_Menu_Button* o = new Fl_Menu_Button(322, 237, 18, 20); o->labelsize(12); - o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&Node_Browser::comment_color)); + o->callback((Fl_Callback*)cb_Color_Choice, (void*)(&fld::widget::Node_Browser::comment_color)); o->menu(colormenu); } // Fl_Menu_Button* o o->end(); |
