From 89aa5726f8d772e0fec1ebcbdfa3b74aa7a217f8 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Mon, 5 Jan 2026 12:54:12 +0100 Subject: Fluid: Improve std::string output Fluid: Update Widget_Node to std::string Fluid: Image names to std::string Fluid: std::string tooltip Fluid: stringify Widget_Node::subtype Fluid:: extra_code --- fluid/app/shell_command.cxx | 8 +- fluid/io/Project_Writer.cxx | 6 +- fluid/io/Project_Writer.h | 3 + fluid/io/String_Writer.cxx | 14 ++-- fluid/nodes/Function_Node.cxx | 12 +-- fluid/nodes/Function_Node.h | 8 +- fluid/nodes/Menu_Node.cxx | 20 ++--- fluid/nodes/Menu_Node.h | 2 +- fluid/nodes/Node.cxx | 6 +- fluid/nodes/Widget_Node.cxx | 185 ++++++++++++++++++----------------------- fluid/nodes/Widget_Node.h | 66 +++++++-------- fluid/nodes/Window_Node.cxx | 20 ++--- fluid/panels/widget_panel.cxx | 22 ++--- fluid/panels/widget_panel.fl | 22 ++--- fluid/proj/i18n.cxx | 18 ++-- fluid/widgets/Node_Browser.cxx | 19 +++-- 16 files changed, 205 insertions(+), 226 deletions(-) diff --git a/fluid/app/shell_command.cxx b/fluid/app/shell_command.cxx index 337d17e2f..bd53a28af 100644 --- a/fluid/app/shell_command.cxx +++ b/fluid/app/shell_command.cxx @@ -615,15 +615,15 @@ void Fd_Shell_Command::read(class fld::io::Project_Reader *in) { void Fd_Shell_Command::write(class fld::io::Project_Writer *out) { out->write_string("\n command {"); - out->write_string("\n name "); out->write_word(name.c_str()); - out->write_string("\n label "); out->write_word(label.c_str()); + out->write_string("\n name "); out->write_word(name); + out->write_string("\n label "); out->write_word(label); if (shortcut) out->write_string("\n shortcut %d", shortcut); if (condition) out->write_string("\n condition %d", condition); if (!condition_data.empty()) { - out->write_string("\n condition_data "); out->write_word(condition_data.c_str()); + out->write_string("\n condition_data "); out->write_word(condition_data); } if (!command.empty()) { - out->write_string("\n command "); out->write_word(command.c_str()); + out->write_string("\n command "); out->write_word(command); } if (flags) out->write_string("\n flags %d", flags); out->write_string("\n }"); diff --git a/fluid/io/Project_Writer.cxx b/fluid/io/Project_Writer.cxx index 387c0093f..54af531e9 100644 --- a/fluid/io/Project_Writer.cxx +++ b/fluid/io/Project_Writer.cxx @@ -119,9 +119,9 @@ int Project_Writer::write_project(const char *filename, int selected_only, bool proj_.i18n.write(*this); if (!selected_only) { - write_string("\nheader_name"); write_word(proj_.header_file_name.c_str()); - write_string("\ncode_name"); write_word(proj_.code_file_name.c_str()); - write_string("\ninclude_guard"); write_word(proj_.include_guard.c_str()); + write_string("\nheader_name"); write_word(proj_.header_file_name); + write_string("\ncode_name"); write_word(proj_.code_file_name); + write_string("\ninclude_guard"); write_word(proj_.include_guard); Fluid.layout_list.write(this); if (g_shell_config) g_shell_config->write(this); diff --git a/fluid/io/Project_Writer.h b/fluid/io/Project_Writer.h index 4b21cf2fb..c95c9f7cb 100644 --- a/fluid/io/Project_Writer.h +++ b/fluid/io/Project_Writer.h @@ -21,6 +21,8 @@ #include +#include + class Node; namespace fld { @@ -52,6 +54,7 @@ public: int write_project(const char *filename, int selected_only, bool codeview); void NewFunction(); void write_word(const char *); + void write_word(const std::string& word) { write_word(word.c_str()); } void write_string(const char *,...) __fl_attr((__format__ (__printf__, 2, 3))); void write_indent(int n); void write_open(); diff --git a/fluid/io/String_Writer.cxx b/fluid/io/String_Writer.cxx index e96d2068e..4928e218a 100644 --- a/fluid/io/String_Writer.cxx +++ b/fluid/io/String_Writer.cxx @@ -77,8 +77,8 @@ int fld::io::write_strings(Project &proj, const std::string &filename) { write_escaped_strings(fp, w->label()); putc('\n', fp); } - if (w->tooltip()) { - write_escaped_strings(fp, w->tooltip()); + if (!w->tooltip().empty()) { + write_escaped_strings(fp, w->tooltip().c_str()); putc('\n', fp); } } @@ -100,13 +100,13 @@ int fld::io::write_strings(Project &proj, const std::string &filename) { fputs("\"\n", fp); } - if (w->tooltip()) { + if (!w->tooltip().empty()) { fputs("msgid \"", fp); - write_escaped_strings(fp, w->tooltip()); + write_escaped_strings(fp, w->tooltip().c_str()); fputs("\"\n", fp); fputs("msgstr \"", fp); - write_escaped_strings(fp, w->tooltip()); + write_escaped_strings(fp, w->tooltip().c_str()); fputs("\"\n", fp); } } @@ -128,9 +128,9 @@ int fld::io::write_strings(Project &proj, const std::string &filename) { fputs("\"\n", fp); } - if (w->tooltip()) { + if (!w->tooltip().empty()) { fprintf(fp, "%d \"", i ++); - write_escaped_strings(fp, w->tooltip()); + write_escaped_strings(fp, w->tooltip().c_str()); fputs("\"\n", fp); } } diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx index dc1e4958d..8404b931e 100644 --- a/fluid/nodes/Function_Node.cxx +++ b/fluid/nodes/Function_Node.cxx @@ -227,7 +227,7 @@ void Function_Node::write_properties(fld::io::Project_Writer &f) { if (declare_c_) f.write_string("C"); if (!return_type().empty()) { f.write_string("return_type"); - f.write_word(return_type().c_str()); + f.write_word(return_type()); } } @@ -436,7 +436,7 @@ void Function_Node::write_code1(fld::io::Code_Writer& f) { } if (havewidgets && child && !child->name()) - f.write_c("%s%s* w;\n", f.indent(1), subclassname(child)); + f.write_c("%s%s* w;\n", f.indent(1), subclassname(child).c_str()); f.indentation++; } @@ -655,7 +655,7 @@ void CodeBlock_Node::write_properties(fld::io::Project_Writer &f) { Node::write_properties(f); if (!end_code().empty()) { f.write_string("after"); - f.write_word(end_code().c_str()); + f.write_word(end_code()); } } @@ -907,7 +907,7 @@ void Data_Node::write_properties(fld::io::Project_Writer &f) { Decl_Node::write_properties(f); if (!filename().empty()) { f.write_string("filename"); - f.write_word(filename().c_str()); + f.write_word(filename()); } switch (output_format_) { case 1: f.write_string("textmode"); break; @@ -1202,7 +1202,7 @@ void DeclBlock_Node::write_properties(fld::io::Project_Writer &f) { if (write_map_ != CODE_IN_SOURCE) f.write_string("map %d", write_map_); f.write_string("after"); - f.write_word(end_code().c_str()); + f.write_word(end_code()); } /** @@ -1467,7 +1467,7 @@ void Class_Node::write_properties(fld::io::Project_Writer &f) { Node::write_properties(f); if (!base_class().empty()) { f.write_string(":"); - f.write_word(base_class().c_str()); + f.write_word(base_class()); } switch (public_) { case 0: f.write_string("private"); break; diff --git a/fluid/nodes/Function_Node.h b/fluid/nodes/Function_Node.h index ec1aadbfe..be16e5414 100644 --- a/fluid/nodes/Function_Node.h +++ b/fluid/nodes/Function_Node.h @@ -150,7 +150,7 @@ public: bool is_a(Type inType) const override { return (inType==Type::CodeBlock) ? true : super::is_a(inType); } void write_properties(fld::io::Project_Writer &f) override; void read_property(fld::io::Project_Reader &f, const char *) override; - std::string end_code() { return end_code_; } + std::string end_code() const { return end_code_; } void end_code(const std::string& c) { storestring(c, end_code_); } }; @@ -212,7 +212,7 @@ public: Type type() const override { return Type::Data; } bool is_a(Type inType) const override { return (inType==Type::Data) ? true : super::is_a(inType); } void filename(const std::string& fn) { storestring(fn, filename_); } - std::string filename() { return filename_; } + std::string filename() const { return filename_; } int output_format() { return output_format_; } void output_format(int fmt) { output_format_ = fmt; } }; @@ -253,7 +253,7 @@ public: int is_public() const override; Type type() const override { return Type::DeclBlock; } bool is_a(Type inType) const override { return (inType==Type::DeclBlock) ? true : super::is_a(inType); } - std::string end_code() { return end_code_; } + std::string end_code() const { return end_code_; } void end_code(const std::string& p) { storestring(p, end_code_); } int write_map() { return write_map_; } void write_map(int v) { write_map_ = v; } @@ -328,7 +328,7 @@ public: void read_property(fld::io::Project_Reader &f, const char *) override; /** Get base class access and name. */ - std::string base_class() { return base_class_; } + std::string base_class() const { return base_class_; } /** Set base class access and name, i.e. `public Fl_Widget`. */ void base_class(const std::string& name) { storestring(name, base_class_); } diff --git a/fluid/nodes/Menu_Node.cxx b/fluid/nodes/Menu_Node.cxx index dcaa2fc55..b29fb8293 100644 --- a/fluid/nodes/Menu_Node.cxx +++ b/fluid/nodes/Menu_Node.cxx @@ -326,8 +326,8 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { f.write_h_once("extern void %s(Fl_Menu_*, %s);", callback(), user_data_type() ? user_data_type() : "void*"); for (int n=0; n < NUM_EXTRA_CODE; n++) { - if (extra_code(n) && isdeclare(extra_code(n))) - f.write_h_once("%s", extra_code(n)); + if (!extra_code(n).empty() && isdeclare(extra_code(n).c_str())) + f.write_h_once("%s", extra_code(n).c_str()); } if (callback() && !is_name(callback()) && (callback()[0] != '[')) { // see if 'o' or 'v' used, to prevent unused argument warnings: @@ -638,9 +638,9 @@ void Menu_Item_Node::write_code1(fld::io::Code_Writer& f) { } } for (int n=0; n < NUM_EXTRA_CODE; n++) { - if (extra_code(n) && !isdeclare(extra_code(n))) { + if (!extra_code(n).empty() && !isdeclare(extra_code(n).c_str())) { start_menu_initialiser(f, menuItemInitialized, mname, i); - f.write_c("%s%s\n", f.indent(), extra_code(n)); + f.write_c("%s%s\n", f.indent(), extra_code(n).c_str()); } } if (menuItemInitialized) { @@ -837,11 +837,11 @@ Menu_Bar_Node::~Menu_Bar_Node() { */ bool Menu_Bar_Node::is_sys_menu_bar() { if (o->type()==1) return true; - return ( subclass() && (strcmp(subclass(), "Fl_Sys_Menu_Bar")==0) ); + return (subclass() == "Fl_Sys_Menu_Bar"); } -const char *Menu_Bar_Node::sys_menubar_name() { - if (subclass()) +std::string Menu_Bar_Node::sys_menubar_name() const { + if (!subclass().empty()) return subclass(); else return "Fl_Sys_Menu_Bar"; @@ -850,7 +850,7 @@ const char *Menu_Bar_Node::sys_menubar_name() { const char *Menu_Bar_Node::sys_menubar_proxy_name() { if (!_proxy_name) _proxy_name = (char*)::malloc(128); - ::snprintf(_proxy_name, 63, "%s_Proxy", sys_menubar_name()); + ::snprintf(_proxy_name, 63, "%s_Proxy", sys_menubar_name().c_str()); return _proxy_name; } @@ -868,8 +868,8 @@ void Menu_Bar_Node::write_static(fld::io::Code_Writer& f) { " : %s(x, y, w, h, l) { }\n" " void *_parent_class;\n" "};\n", - sys_menubar_proxy_name(), sys_menubar_name(), - sys_menubar_proxy_name(), sys_menubar_name() + sys_menubar_proxy_name(), sys_menubar_name().c_str(), + sys_menubar_proxy_name(), sys_menubar_name().c_str() ); } } diff --git a/fluid/nodes/Menu_Node.h b/fluid/nodes/Menu_Node.h index 59d3b06bb..181ab8243 100644 --- a/fluid/nodes/Menu_Node.h +++ b/fluid/nodes/Menu_Node.h @@ -300,7 +300,7 @@ public: Type type() const override { return Type::Menu_Bar; } bool is_a(Type inType) const override { return (inType==Type::Menu_Bar) ? true : super::is_a(inType); } bool is_sys_menu_bar(); - const char *sys_menubar_name(); + std::string sys_menubar_name() const; const char *sys_menubar_proxy_name(); protected: char *_proxy_name; diff --git a/fluid/nodes/Node.cxx b/fluid/nodes/Node.cxx index a84528b59..61d736f83 100644 --- a/fluid/nodes/Node.cxx +++ b/fluid/nodes/Node.cxx @@ -136,7 +136,7 @@ void print_project_tree() { for (Node *t = Fluid.proj.tree.first; t; t = t->next) { for (int i = t->level; i > 0; i--) fprintf(stderr, ". "); - fprintf(stderr, "%s\n", subclassname(t)); + fprintf(stderr, "%s\n", subclassname(t).c_str()); } } #endif @@ -783,7 +783,7 @@ int Node::msgnum() { for (count = 0, p = this; p;) { if (p->label()) count ++; - if (p != this && p->is_widget() && ((Widget_Node *)p)->tooltip()) count ++; + if (p != this && p->is_widget() && !((Widget_Node *)p)->tooltip().empty()) count ++; if (p->prev) p = p->prev; else p = p->parent; @@ -904,7 +904,7 @@ void Node::write(fld::io::Project_Writer &f) { if (is_class()) { auto p = ((Class_Node*)this)->prefix(); if (!p.empty()) - f.write_word(p.c_str()); + f.write_word(p); } f.write_word(name()); diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx index b74560f05..00531abc1 100644 --- a/fluid/nodes/Widget_Node.cxx +++ b/fluid/nodes/Widget_Node.cxx @@ -59,7 +59,7 @@ using namespace fld::proj; int Widget_Node::is_widget() const {return 1;} int Widget_Node::is_public() const {return public_;} -const char* subclassname(Node* l) { +std::string subclassname(Node* l) { if (l->is_a(Type::Menu_Bar)) { Menu_Bar_Node *mb = static_cast(l); if (mb->is_sys_menu_bar()) @@ -67,8 +67,8 @@ const char* subclassname(Node* l) { } if (l->is_widget()) { Widget_Node* p = (Widget_Node*)l; - const char* c = p->subclass(); - if (c) return c; + std::string c = p->subclass(); + if (!c.empty()) return c; if (l->is_class()) return "Fl_Group"; if (p->o->type() == FL_DOUBLE_WINDOW) return "Fl_Double_Window"; if (p->type() == Type::Input) { @@ -203,29 +203,6 @@ void Widget_Node::setlabel(const char *n) { redraw(); } -Widget_Node::Widget_Node() -: override_visible_(0) -{ - for (int n=0; nwindow(); @@ -233,44 +210,38 @@ Widget_Node::~Widget_Node() { if (win) win->redraw(); } - if (subclass_) free((void*)subclass_); - if (tooltip_) free((void*)tooltip_); - if (image_name_) { - free((void*)image_name_); - if (image) image->dec_ref(); - } - if (inactive_name_) { - free((void*)inactive_name_); - if (inactive) inactive->dec_ref(); - } - for (int n=0; ndec_ref(); + if (inactive) inactive->dec_ref(); } -void Widget_Node::extra_code(int m,const char *n) { - storestring(n,extra_code_[m]); +void Widget_Node::extra_code(int m, const std::string& n) { + storestring(n, extra_code_[m]); } extern void redraw_browser(); -void Widget_Node::subclass(const char *n) { - if (storestring(n,subclass_) && visible) + +void Widget_Node::subclass(const std::string& n) { + if (storestring(n, subclass_) && visible) redraw_browser(); } -void Widget_Node::tooltip(const char *n) { - storestring(n,tooltip_); - o->tooltip(n); +void Widget_Node::tooltip(const std::string& text) { + storestring(text, tooltip_); + if (text.empty()) { + o->tooltip(nullptr); + } else { + o->copy_tooltip(text.c_str()); + } } -void Widget_Node::image_name(const char *n) { - setimage(Image_Asset::find(n)); - storestring(n,image_name_); +void Widget_Node::image_name(const std::string& name) { + setimage(Image_Asset::find(name.c_str())); + storestring(name, image_name_); } -void Widget_Node::inactive_name(const char *n) { - setinactive(Image_Asset::find(n)); - storestring(n,inactive_name_); +void Widget_Node::inactive_name(const std::string& name) { + setinactive(Image_Asset::find(name.c_str())); + storestring(name, inactive_name_); } void Widget_Node::redraw() { @@ -1467,14 +1438,14 @@ int isdeclare(const char *c) { } void Widget_Node::write_static(fld::io::Code_Writer& f) { - const char* t = subclassname(this); - if (!subclass() || (is_class() && !strncmp(t, "Fl_", 3))) { + std::string t = subclassname(this); + if (subclass().empty() || (is_class() && (t.compare(0, 3, "Fl_")==0))) { f.write_h_once("#include "); - f.write_h_once("#include ", t); + f.write_h_once("#include ", t.c_str()); } for (int n=0; n < NUM_EXTRA_CODE; n++) { - if (extra_code(n) && isdeclare(extra_code(n))) - f.write_h_once("%s", extra_code(n)); + if (!extra_code(n).empty() && isdeclare(extra_code(n).c_str())) + f.write_h_once("%s", extra_code(n).c_str()); } if (callback() && is_name(callback())) { int write_extern_declaration = 1; @@ -1487,7 +1458,7 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { write_extern_declaration = 0; } if (write_extern_declaration) - f.write_h_once("extern void %s(%s*, %s);", callback(), t, + f.write_h_once("extern void %s(%s*, %s);", callback(), t.c_str(), user_data_type() ? user_data_type() : "void*"); } const char* k = class_name(1); @@ -1495,9 +1466,9 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { if (c && !k && !is_class()) { f.write_c("\n"); if (!public_) f.write_c("static "); - else f.write_h("extern %s *%s;\n", t, c); - if (strchr(c, '[') == nullptr) f.write_c("%s *%s=(%s *)0;\n", t, c, t); - else f.write_c("%s *%s={(%s *)0};\n", t, c, t); + else f.write_h("extern %s *%s;\n", t.c_str(), c); + if (strchr(c, '[') == nullptr) f.write_c("%s *%s=(%s *)0;\n", t.c_str(), c, t.c_str()); + else f.write_c("%s *%s={(%s *)0};\n", t.c_str(), c, t.c_str()); } if (callback() && !is_name(callback()) && (callback()[0] != '[')) { // see if 'o' or 'v' used, to prevent unused argument warnings: @@ -1512,9 +1483,9 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { } const char* cn = callback_name(f); if (k) { - f.write_c("\nvoid %s::%s_i(%s*", k, cn, t); + f.write_c("\nvoid %s::%s_i(%s*", k, cn, t.c_str()); } else { - f.write_c("\nstatic void %s(%s*", cn, t); + f.write_c("\nstatic void %s(%s*", cn, t.c_str()); } if (use_o) f.write_c(" o"); const char* ut = user_data_type() ? user_data_type() : "void*"; @@ -1535,7 +1506,7 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { f.tag(Mergeback::Tag::WIDGET_CALLBACK, Mergeback::Tag::GENERIC, get_uid()); f.write_c("}\n"); if (k) { - f.write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut); + f.write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t.c_str(), ut); f.write_c("%s((%s*)(o", f.indent(1), k); Node *q = nullptr; for (Node* p = parent; p && p->is_widget(); q = p, p = p->parent) @@ -1556,20 +1527,20 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { } void Widget_Node::write_code1(fld::io::Code_Writer& f) { - const char* t = subclassname(this); + std::string t = subclassname(this); const char *c = array_name(this); if (c) { if (class_name(1)) { f.write_public(public_); - f.write_h("%s%s *%s;\n", f.indent(1), t, c); + f.write_h("%s%s *%s;\n", f.indent(1), t.c_str(), c); } } if (class_name(1) && callback() && !is_name(callback())) { const char* cn = callback_name(f); const char* ut = user_data_type() ? user_data_type() : "void*"; f.write_public(0); - f.write_h("%sinline void %s_i(%s*, %s);\n", f.indent(1), cn, t, ut); - f.write_h("%sstatic void %s(%s*, %s);\n", f.indent(1), cn, t, ut); + f.write_h("%sinline void %s_i(%s*, %s);\n", f.indent(1), cn, t.c_str(), ut); + f.write_h("%sstatic void %s(%s*, %s);\n", f.indent(1), cn, t.c_str(), ut); } // figure out if local variable will be used (prevent compiler warnings): int wused = !name() && is_a(Type::Window); @@ -1589,13 +1560,14 @@ void Widget_Node::write_code1(fld::io::Code_Writer& f) { if (!f.varused) { for (int n=0; n < NUM_EXTRA_CODE; n++) - if (extra_code(n) && !isdeclare(extra_code(n))) + if (!extra_code(n).empty() && !isdeclare(extra_code(n).c_str())) { int instring = 0; int inname = 0; int incomment = 0; int incppcomment = 0; - for (ptr = extra_code(n); *ptr; ptr ++) { + std::string code = extra_code(n); + for (ptr = code.c_str(); *ptr; ptr ++) { if (instring) { if (*ptr == '\\') ptr++; else if (*ptr == '\"') instring = 0; @@ -1631,23 +1603,23 @@ void Widget_Node::write_code1(fld::io::Code_Writer& f) { f.write_c("%s{ ", f.indent()); write_comment_inline_c(f); - if (f.varused) f.write_c("%s* o = ", t); + if (f.varused) f.write_c("%s* o = ", t.c_str()); if (name()) f.write_c("%s = ", name()); if (is_a(Type::Window)) { // Handle special case where user is faking a Fl_Group type as a window, // there is no 2-argument constructor in that case: - if (!strstr(t, "Window")) - f.write_c("new %s(0, 0, %d, %d", t, o->w(), o->h()); + if (t.find("Window")==t.npos) + f.write_c("new %s(0, 0, %d, %d", t.c_str(), o->w(), o->h()); else - f.write_c("new %s(%d, %d", t, o->w(), o->h()); + f.write_c("new %s(%d, %d", t.c_str(), o->w(), o->h()); } else if (is_a(Type::Menu_Bar) && ((Menu_Bar_Node*)this)->is_sys_menu_bar() && is_in_class()) { f.write_c("(%s*)new %s(%d, %d, %d, %d", - t, ((Menu_Bar_Node*)this)->sys_menubar_proxy_name(), + t.c_str(), ((Menu_Bar_Node*)this)->sys_menubar_proxy_name(), o->x(), o->y(), o->w(), o->h()); } else { - f.write_c("new %s(%d, %d, %d, %d", t, o->x(), o->y(), o->w(), o->h()); + f.write_c("new %s(%d, %d, %d, %d", t.c_str(), o->x(), o->y(), o->w(), o->h()); } if (label() && *label()) { f.write_c(", "); @@ -1723,15 +1695,15 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { Fl_Widget* tplate = ((Widget_Node*)factory)->o; const char *var = is_class() ? "this" : name() ? name() : "o"; - if (tooltip() && *tooltip()) { + if (!tooltip().empty()) { f.write_c("%s%s->tooltip(",f.indent(), var); switch (Fluid.proj.i18n.type) { case fld::I18n_Type::NONE : /* None */ - f.write_cstring(tooltip()); + f.write_cstring(tooltip().c_str()); break; case fld::I18n_Type::GNU : /* GNU gettext */ f.write_c("%s(", Fluid.proj.i18n.gnu_function.c_str()); - f.write_cstring(tooltip()); + f.write_cstring(tooltip().c_str()); f.write_c(")"); break; case fld::I18n_Type::POSIX : /* POSIX catgets */ @@ -1739,7 +1711,7 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(), Fluid.proj.i18n.posix_set.c_str(), msgnum() + 1); - f.write_cstring(tooltip()); + f.write_cstring(tooltip().c_str()); f.write_c(")"); break; } @@ -1750,7 +1722,7 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { f.write_c("%s%s->type(%d);\n", f.indent(), var, ((Fl_Spinner*)o)->type()); else if (o->type() != tplate->type() && !is_a(Type::Window)) f.write_c("%s%s->type(%d);\n", f.indent(), var, o->type()); - if (o->box() != tplate->box() || subclass()) + if (o->box() != tplate->box() || !subclass().empty()) f.write_c("%s%s->box(FL_%s);\n", f.indent(), var, boxname(o->box())); // write shortcut command if needed @@ -1792,9 +1764,9 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { if (b->down_box()) f.write_c("%s%s->down_box(FL_%s);\n", f.indent(), var, boxname(b->down_box())); } - if (o->color() != tplate->color() || subclass()) + if (o->color() != tplate->color() || !subclass().empty()) write_color(f, "color", o->color()); - if (o->selection_color() != tplate->selection_color() || subclass()) + if (o->selection_color() != tplate->selection_color() || !subclass().empty()) write_color(f, "selection_color", o->selection_color()); if (image) { image->write_code(f, bind_image_, var); @@ -1824,14 +1796,14 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { f.write_c("%s->deimage()->data_h(), 0, 1);\n", var); } } - if (o->labeltype() != tplate->labeltype() || subclass()) + if (o->labeltype() != tplate->labeltype() || !subclass().empty()) f.write_c("%s%s->labeltype(FL_%s);\n", f.indent(), var, item_name(labeltypemenu, o->labeltype())); - if (o->labelfont() != tplate->labelfont() || subclass()) + if (o->labelfont() != tplate->labelfont() || !subclass().empty()) f.write_c("%s%s->labelfont(%d);\n", f.indent(), var, o->labelfont()); - if (o->labelsize() != tplate->labelsize() || subclass()) + if (o->labelsize() != tplate->labelsize() || !subclass().empty()) f.write_c("%s%s->labelsize(%d);\n", f.indent(), var, o->labelsize()); - if (o->labelcolor() != tplate->labelcolor() || subclass()) + if (o->labelcolor() != tplate->labelcolor() || !subclass().empty()) write_color(f, "labelcolor", o->labelcolor()); if (o->horizontal_label_margin() != tplate->horizontal_label_margin()) f.write_c("%s%s->horizontal_label_margin(%d);\n", f.indent(), var, o->horizontal_label_margin()); @@ -1900,7 +1872,7 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { } else if (ud) { f.write_c("%s%s->user_data((void*)(%s));\n", f.indent(), var, ud); } - if (o->align() != tplate->align() || subclass()) { + if (o->align() != tplate->align() || !subclass().empty()) { int i = o->align(); f.write_c("%s%s->align(Fl_Align(%s", f.indent(), var, item_name(alignmenu, i & ~FL_ALIGN_INSIDE)); @@ -1908,7 +1880,7 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { f.write_c("));\n"); } Fl_When ww = o->when(); - if (ww != tplate->when() || subclass()) + if (ww != tplate->when() || !subclass().empty()) f.write_c("%s%s->when(%s);\n", f.indent(), var, when_symbol_name(ww)); if (!o->visible() && o->parent()) f.write_c("%s%s->hide();\n", f.indent(), var); @@ -1928,13 +1900,13 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { void Widget_Node::write_extra_code(fld::io::Code_Writer& f) { for (int n=0; n < NUM_EXTRA_CODE; n++) - if (extra_code(n) && !isdeclare(extra_code(n))) - f.write_c("%s%s\n", f.indent(), extra_code(n)); + if (!extra_code(n).empty() && !isdeclare(extra_code(n).c_str())) + f.write_c("%s%s\n", f.indent(), extra_code(n).c_str()); } void Widget_Node::write_block_close(fld::io::Code_Writer& f) { f.indentation--; - f.write_c("%s} // %s* %s\n", f.indent(), subclassname(this), + f.write_c("%s} // %s* %s\n", f.indent(), subclassname(this).c_str(), name() ? name() : "o"); } @@ -1953,11 +1925,11 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) { case 1: break; case 2: f.write_string("protected"); break; } - if (tooltip() && *tooltip()) { + if (!tooltip().empty()) { f.write_string("tooltip"); f.write_word(tooltip()); } - if (image_name() && *image_name()) { + if (!image_name().empty()) { if (scale_image_w_ || scale_image_h_) f.write_string("scale_image {%d %d}", scale_image_w_, scale_image_h_); f.write_string("image"); @@ -1965,7 +1937,7 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) { f.write_string("compress_image %d", compress_image_); } if (bind_image_) f.write_string("bind_image 1"); - if (inactive_name() && *inactive_name()) { + if (!inactive_name().empty()) { if (scale_deimage_w_ || scale_deimage_h_) f.write_string("scale_deimage {%d %d}", scale_deimage_w_, scale_deimage_h_); f.write_string("deimage"); @@ -2067,12 +2039,12 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) { if (resizable()) f.write_string("resizable"); if (hotspot()) f.write_string(is_a(Type::Menu_Item) ? "divider" : "hotspot"); if (menu_headline()) f.write_string("headline"); - for (int n=0; n < NUM_EXTRA_CODE; n++) if (extra_code(n)) { + for (int n=0; n < NUM_EXTRA_CODE; n++) if (!extra_code(n).empty()) { f.write_indent(level+1); f.write_string("code%d",n); - f.write_word(extra_code(n)); + f.write_word(extra_code(n).c_str()); } - if (subclass()) { + if (!subclass().empty()) { f.write_indent(level+1); f.write_string("class"); f.write_word(subclass()); @@ -2107,7 +2079,7 @@ void Widget_Node::read_property(fld::io::Project_Reader &f, const char *c) { image_name(f.read_word()); // starting in 2023, `image` is always followed by `compress_image` // the code below is for compatibility with older .fl files - const char *ext = fl_filename_ext(image_name_); + const char *ext = fl_filename_ext(image_name().c_str()); // FIXME: if ( strcmp(ext, ".jpg") && strcmp(ext, ".png") && strcmp(ext, ".svg") @@ -2126,7 +2098,7 @@ void Widget_Node::read_property(fld::io::Project_Reader &f, const char *c) { inactive_name(f.read_word()); // starting in 2023, `deimage` is always followed by `compress_deimage` // the code below is for compatibility with older .fl files - const char *ext = fl_filename_ext(inactive_name_); + const char *ext = fl_filename_ext(inactive_name().c_str()); // FIXME: if ( strcmp(ext, ".jpg") && strcmp(ext, ".png") && strcmp(ext, ".svg") @@ -2253,11 +2225,11 @@ void Widget_Node::read_property(fld::io::Project_Reader &f, const char *c) { if (!strncmp(c,"code",4)) { int n = atoi(c+4); if (n >= 0 && n <= NUM_EXTRA_CODE) { - extra_code(n,f.read_word()); + extra_code(n, f.read_word()); return; } } else if (!strcmp(c,"extra_code")) { - extra_code(0,f.read_word()); + extra_code(0, f.read_word()); return; } Node::read_property(f, c); @@ -2311,8 +2283,8 @@ int Widget_Node::read_fdesign(const char* propname, const char* value) { user_data(value); } else if (!strcmp(propname,"shortcut")) { if (value[0]) { - char buf[128]; sprintf(buf,"o->shortcut(\"%s\");",value); - extra_code(0,buf); + char buf[128]; sprintf(buf,"o->shortcut(\"%s\");", value); + extra_code(0, buf); } } else if (!strcmp(propname,"style")) { if (!strncmp(value,"FL_NORMAL",9)) return 1; @@ -2426,7 +2398,10 @@ void Widget_Node::copy_properties() { // copy all attributes common to all widget types Fl_Widget *w = live_widget; w->label(o->label()); - w->tooltip(tooltip()); + if (tooltip().empty()) + w->tooltip(nullptr); + else + w->copy_tooltip(tooltip().c_str()); w->type(o->type()); w->box(o->box()); w->color(o->color()); diff --git a/fluid/nodes/Widget_Node.h b/fluid/nodes/Widget_Node.h index 0276cbcdf..d6e5ce590 100644 --- a/fluid/nodes/Widget_Node.h +++ b/fluid/nodes/Widget_Node.h @@ -1,7 +1,7 @@ // // Widget Node header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2025 by Bill Spitzak and others. +// Copyright 1998-2026 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 @@ -15,14 +15,14 @@ // // Type for creating all subclasses of Fl_Widget -// This should have the widget pointer in it, but it is still in the -// Node base class. #ifndef FLUID_NODES_WIDGET_NODE_H #define FLUID_NODES_WIDGET_NODE_H #include "nodes/Node.h" +#include + #define NUM_EXTRA_CODE 4 class Widget_Node; @@ -32,7 +32,7 @@ extern void* const LOAD; extern Node* current_node; // one of the selected ones extern Widget_Node* current_widget; // one of the selected ones -extern const char* subclassname(Node* l); +extern std::string subclassname(Node* l); extern int is_name(const char *c); void selection_changed(Node* new_current); Node *sort(Node *parent); @@ -45,12 +45,12 @@ class Widget_Node : public Node virtual Widget_Node *_make() = 0; // virtual constructor void setlabel(const char *) override; - const char *extra_code_[NUM_EXTRA_CODE]; - const char *subclass_; - const char *tooltip_; - const char *image_name_; - const char *inactive_name_; - uchar hotspot_; + std::string extra_code_[NUM_EXTRA_CODE]; + std::string subclass_; + std::string tooltip_; + std::string image_name_; + std::string inactive_name_; + uchar hotspot_ = 0; bool menu_headline_ { false }; @@ -60,7 +60,7 @@ protected: /// We can't open a window in batch mode, even if we want the "visible" flags /// set, so we need a second place to store this information while also /// disabling the output of the "hide" property by the Widget Type. - uchar override_visible_; + uchar override_visible_ = 0; void write_static(fld::io::Code_Writer& f) override; void write_code1(fld::io::Code_Writer& f) override; @@ -72,34 +72,34 @@ protected: Fl_Widget *live_widget; public: - Fl_Widget *o; - int public_; - int bind_image_; - int compress_image_; - int bind_deimage_; - int compress_deimage_; - int scale_image_w_, scale_image_h_; - int scale_deimage_w_, scale_deimage_h_; - - Image_Asset *image; + Fl_Widget *o = nullptr; + int public_ = 1; + int bind_image_ = 0; + int compress_image_ = 1; + int bind_deimage_ = 0; + int compress_deimage_ = 1; + int scale_image_w_ = 0, scale_image_h_ = 0; + int scale_deimage_w_ = 0, scale_deimage_h_ = 0; + + Image_Asset *image = nullptr; void setimage(Image_Asset *); - Image_Asset *inactive; + Image_Asset *inactive = nullptr; void setinactive(Image_Asset *); - Widget_Node(); + Widget_Node() = default; Node *make(Strategy strategy) override; void open() override; - const char *extra_code(int n) const {return extra_code_[n];} - void extra_code(int n,const char *); - const char *subclass() const {return subclass_;} - void subclass(const char *); - const char *tooltip() const {return tooltip_;} - void tooltip(const char *); - const char *image_name() const {return image_name_;} - void image_name(const char *); - const char *inactive_name() const {return inactive_name_;} - void inactive_name(const char *); + std::string extra_code(int n) const { return extra_code_[n]; } + void extra_code(int n, const std::string& code); + std::string subclass() const { return subclass_; } + void subclass(const std::string& name); + std::string tooltip() const { return tooltip_; } + void tooltip(const std::string& text); + std::string image_name() const { return image_name_; } + void image_name(const std::string& name); + std::string inactive_name() const { return inactive_name_; } + void inactive_name(const std::string& name); // Note: hotspot is misused by menu items to indicate a divider uchar hotspot() const {return hotspot_;} void hotspot(uchar v) {hotspot_ = v;} diff --git a/fluid/nodes/Window_Node.cxx b/fluid/nodes/Window_Node.cxx index e63debebe..0ea3b306f 100644 --- a/fluid/nodes/Window_Node.cxx +++ b/fluid/nodes/Window_Node.cxx @@ -1382,13 +1382,13 @@ void Widget_Class_Node::write_code1(fld::io::Code_Writer& f) { current_widget_class = this; write_public_state = 1; - const char *c = subclass(); - if (!c) c = "Fl_Group"; + std::string c = subclass(); + if (c.empty()) c = "Fl_Group"; f.write_c("\n"); write_comment_h(f); - f.write_h("\nclass %s : public %s {\n", name(), c); - if (strstr(c, "Window")) { + f.write_h("\nclass %s : public %s {\n", name(), c.c_str()); + if (c.find("Window")!=c.npos) { f.write_h("%svoid _%s();\n", f.indent(1), trimclassname(name())); f.write_h("public:\n"); f.write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n", f.indent(1), trimclassname(name())); @@ -1397,20 +1397,20 @@ void Widget_Class_Node::write_code1(fld::io::Code_Writer& f) { // a constructor with all four dimensions plus label f.write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name())); - f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c); + f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c.c_str()); f.write_c("%s_%s();\n", f.indent(1), trimclassname(name())); f.write_c("}\n\n"); // a constructor with just the size and label. The window manager will position the window f.write_c("%s::%s(int W, int H, const char *L) :\n", name(), trimclassname(name())); - f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c); + f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c.c_str()); f.write_c("%sclear_flag(16);\n", f.indent(1)); f.write_c("%s_%s();\n", f.indent(1), trimclassname(name())); f.write_c("}\n\n"); // a constructor that takes size and label from the Fluid database f.write_c("%s::%s() :\n", name(), trimclassname(name())); - f.write_c("%s%s(0, 0, %d, %d, ", f.indent(1), c, o->w(), o->h()); + f.write_c("%s%s(0, 0, %d, %d, ", f.indent(1), c.c_str(), o->w(), o->h()); const char *cstr = label(); if (cstr) f.write_cstring(cstr); else f.write_c("0"); @@ -1427,11 +1427,11 @@ void Widget_Class_Node::write_code1(fld::io::Code_Writer& f) { f.indent(1), trimclassname(name())); f.write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name())); if (wc_relative==1) - f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c); + f.write_c("%s%s(0, 0, W, H, L)\n{\n", f.indent(1), c.c_str()); else if (wc_relative==2) - f.write_c("%s%s(0, 0, %d, %d, L)\n{\n", f.indent(1), c, o->w(), o->h()); + f.write_c("%s%s(0, 0, %d, %d, L)\n{\n", f.indent(1), c.c_str(), o->w(), o->h()); else - f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c); + f.write_c("%s%s(X, Y, W, H, L)\n{\n", f.indent(1), c.c_str()); } // f.write_c("%s%s *o = this;\n", f.indent(1), name()); diff --git a/fluid/panels/widget_panel.cxx b/fluid/panels/widget_panel.cxx index f964f7278..a6f4129ae 100644 --- a/fluid/panels/widget_panel.cxx +++ b/fluid/panels/widget_panel.cxx @@ -629,7 +629,7 @@ static void cb_widget_image_input(Fl_Input* o, void* v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(Type::Window)) { o->activate(); - o->value(((Widget_Node*)current_widget)->image_name()); + o->value(((Widget_Node*)current_widget)->image_name().c_str()); } else o->deactivate(); } else { int mod = 0; @@ -639,7 +639,7 @@ static void cb_widget_image_input(Fl_Input* o, void* v) { } if (mod) Fluid.proj.set_modflag(1); } -//fl ▲ ----------=~-==-=~=-~~----------~~=-~~--=~~~~~-~=-~=~= ▲ fl// +//fl ▲ ----------=~-==-=~=-~~----------~~=-~==~~~-=-=~---=-=~ ▲ fl// } static void cb_Browse(Fl_Button* o, void* v) { @@ -679,7 +679,7 @@ static void cb_widget_deimage_input(Fl_Input* o, void* v) { if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(Type::Window)) { o->activate(); - o->value(((Widget_Node*)current_widget)->inactive_name()); + o->value(((Widget_Node*)current_widget)->inactive_name().c_str()); } else o->deactivate(); } else { int mod = 0; @@ -689,7 +689,7 @@ static void cb_widget_deimage_input(Fl_Input* o, void* v) { } if (mod) Fluid.proj.set_modflag(1); } -//fl ▲ ----------=~---=-~=~-=-----------~-~--=~~~~~-~-~=-~-=~ ▲ fl// +//fl ▲ ----------=~---=-~=~-=--------------~~~-~---~-~~=--=-- ▲ fl// } static void cb_Browse1(Fl_Button* o, void* v) { @@ -1702,7 +1702,7 @@ static void cb_wp_gui_tooltip(Fl_Input* o, void* v) { if (v == LOAD) { if (current_widget->is_widget()) { o->activate(); - o->value(((Widget_Node*)current_widget)->tooltip()); + o->value(((Widget_Node*)current_widget)->tooltip().c_str()); } else { o->deactivate(); } @@ -1714,7 +1714,7 @@ static void cb_wp_gui_tooltip(Fl_Input* o, void* v) { } if (mod) Fluid.proj.set_modflag(1); } -//fl ▲ ----------~==--==-~==~----------~---=~--~--=~~-----=~~ ▲ fl// +//fl ▲ ----------~==--==-~==~-----------~--~--~~=--=-~----==- ▲ fl// } Fl_Group *wp_style_tab=(Fl_Group *)0; @@ -2172,7 +2172,7 @@ static void cb_e(Fl_Input* o, void* v) { o->deactivate(); } else { o->activate(); - o->value(current_widget->subclass()); + o->value(current_widget->subclass().c_str()); } } else { int mod = 0; @@ -2183,7 +2183,7 @@ static void cb_e(Fl_Input* o, void* v) { } if (mod) Fluid.proj.set_modflag(1); } -//fl ▲ ----------~=~~--=~-=~=----------~~~-~~=~~~~=~---~~--~- ▲ fl// +//fl ▲ ----------~=~~--=~-=~=-----------~~==--=--~~~--=---=-= ▲ fl// } static void cb_f(Fl_Choice* o, void* v) { @@ -2303,19 +2303,19 @@ static void cb_v_input(Fl_Input* o, void* v) { //fl ▼ ---------------------- callback ~~-==~=~-~~==-=--~~--= ▼ fl// int n = fl_int(o->user_data()); if (v == LOAD) { - o->value(current_widget->extra_code(n)); + o->value(current_widget->extra_code(n).c_str()); } else { int mod = 0; const char *c = o->value(); const char *d = c_check(c&&c[0]=='#' ? c+1 : c); if (d) {fl_message("Error in %s: %s",o->label(),d); haderror = 1; return;} for (Widget_Node *w: Fluid.proj.tree.all_selected_widgets()) { - w->extra_code(n,c); + w->extra_code(n, c); mod = 1; } if (mod) Fluid.proj.set_modflag(1); } -//fl ▲ ----------~==--~-~=-~~----------~--~~~~~~==--~=-~~~-~- ▲ fl// +//fl ▲ ----------~==--~-~=-~~----------~~-=-=~=~-~--~-==---=~ ▲ fl// } static void cb_v_input1(Fl_Input* o, void* v) { diff --git a/fluid/panels/widget_panel.fl b/fluid/panels/widget_panel.fl index 18108bbbf..03c08272b 100644 --- a/fluid/panels/widget_panel.fl +++ b/fluid/panels/widget_panel.fl @@ -519,7 +519,7 @@ Function {make_widget_panel()} {uid 9310 } { Fl_Window {} {uid 30ee comment {Use a Double Window to avoid flickering.} open - xywh {406 252 420 400} type Double labelsize 11 align 80 resizable hotspot + xywh {444 254 420 400} type Double labelsize 11 align 80 resizable hotspot code0 {o->size_range(o->w(), o->h());} size_range {420 400 0 0} visible } { Fl_Wizard tabs_wizard {uid 647f @@ -534,7 +534,7 @@ Function {make_widget_panel()} {uid 9310 } { Fl_Group wp_gui_tab {uid b76b label GUI - callback propagate_load open + callback propagate_load open selected xywh {10 30 400 330} labelsize 11 when 0 resizable } { Fl_Group {} {uid d70c @@ -563,7 +563,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t callback {if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(Type::Window)) { o->activate(); - o->value(((Widget_Node*)current_widget)->image_name()); + o->value(((Widget_Node*)current_widget)->image_name().c_str()); } else o->deactivate(); } else { int mod = 0; @@ -613,7 +613,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t callback {if (v == LOAD) { if (current_widget->is_widget() && !current_widget->is_a(Type::Window)) { o->activate(); - o->value(((Widget_Node*)current_widget)->inactive_name()); + o->value(((Widget_Node*)current_widget)->inactive_name().c_str()); } else o->deactivate(); } else { int mod = 0; @@ -1089,7 +1089,7 @@ h, ph, sh, ch, and i} xywh {275 150 55 20} labelsize 11 align 5 textsize 11 o->show(); propagate_load(o, v); } -}} +}} open xywh {95 185 300 20} labelfont 1 labelsize 11 align 4 } { Fl_Value_Input {} {uid 4e4e @@ -1773,7 +1773,7 @@ unselectable, but not grayed out} xywh {225 260 75 20} selection_color 1 labelsi callback {if (v == LOAD) { if (current_widget->is_widget()) { o->activate(); - o->value(((Widget_Node*)current_widget)->tooltip()); + o->value(((Widget_Node*)current_widget)->tooltip().c_str()); } else { o->deactivate(); } @@ -2265,7 +2265,7 @@ if (v == LOAD) { o->deactivate(); } else { o->activate(); - o->value(current_widget->subclass()); + o->value(current_widget->subclass().c_str()); } } else { int mod = 0; @@ -2413,14 +2413,14 @@ if (v == LOAD) { user_data 0 callback {int n = fl_int(o->user_data()); if (v == LOAD) { - o->value(current_widget->extra_code(n)); + o->value(current_widget->extra_code(n).c_str()); } else { int mod = 0; const char *c = o->value(); const char *d = c_check(c&&c[0]=='\#' ? c+1 : c); if (d) {fl_message("Error in %s: %s",o->label(),d); haderror = 1; return;} for (Widget_Node *w: Fluid.proj.tree.all_selected_widgets()) { - w->extra_code(n,c); + w->extra_code(n, c); mod = 1; } if (mod) Fluid.proj.set_modflag(1); @@ -3797,7 +3797,7 @@ if (v == LOAD) { } } } - Fl_Tabs widget_tabs_repo {uid 3194 open + Fl_Tabs widget_tabs_repo {uid 3194 xywh {10 10 400 350} hide code0 {o->hide();} } { @@ -3805,7 +3805,7 @@ if (v == LOAD) { xywh {10 30 400 330} resizable } {} } - Fl_Group {} {uid 7667 + Fl_Group {} {uid 7667 open xywh {10 370 400 20} labelsize 11 } { Fl_Button wLiveMode {uid 9a1d diff --git a/fluid/proj/i18n.cxx b/fluid/proj/i18n.cxx index 247522dd3..d2b9b202c 100644 --- a/fluid/proj/i18n.cxx +++ b/fluid/proj/i18n.cxx @@ -74,20 +74,20 @@ void I18n::write(io::Project_Writer &f) const { case fld::I18n_Type::NONE: break; case fld::I18n_Type::GNU : /* GNU gettext */ - f.write_string("\ni18n_include"); f.write_word(gnu_include.c_str()); - f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional.c_str()); - f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function.c_str()); - f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function.c_str()); + f.write_string("\ni18n_include"); f.write_word(gnu_include); + f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional); + f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function); + f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function); break; case fld::I18n_Type::POSIX : /* POSIX catgets */ - f.write_string("\ni18n_include"); f.write_word(posix_include.c_str()); - f.write_string("\ni18n_conditional"); f.write_word(posix_conditional.c_str()); + f.write_string("\ni18n_include"); f.write_word(posix_include); + f.write_string("\ni18n_conditional"); f.write_word(posix_conditional); if (!posix_file.empty()) { f.write_string("\ni18n_pos_file"); - f.write_word(posix_file.c_str()); + f.write_word(posix_file); } - f.write_string("\ni18n_pos_set"); f.write_word(posix_set.c_str()); + f.write_string("\ni18n_pos_set"); f.write_word(posix_set); break; } } -} \ No newline at end of file +} diff --git a/fluid/widgets/Node_Browser.cxx b/fluid/widgets/Node_Browser.cxx index 745282e23..91611f876 100644 --- a/fluid/widgets/Node_Browser.cxx +++ b/fluid/widgets/Node_Browser.cxx @@ -393,27 +393,28 @@ void Node_Browser::item_draw(void *v, int X, int Y, int, int) const { // Indent=12 per level: Now write the text that comes after the graphics representation Y += comment_incr; if (l->is_widget() || l->is_class()) { - const char* c = subclassname(l); - if (!strncmp(c,"Fl_",3)) c += 3; + std::string c = subclassname(l); + if (c.compare(0, 3, "Fl_")==0) c.erase(0, 3); // -- class fl_font(class_font, textsize()); if (l->new_selected) fl_color(fl_contrast(class_color, FL_SELECTION_COLOR)); else fl_color(class_color); - fl_draw(c, X, Y+13); - X += int(fl_width(c)+fl_width('n')); - c = l->name(); - if (c) { + fl_draw(c.c_str(), X, Y+13); + X += int(fl_width(c.c_str())+fl_width('n')); + c = l->name() ? l->name() : ""; + if (!c.empty()) { // -- name fl_font(name_font, textsize()); if (l->new_selected) fl_color(fl_contrast(name_color, FL_SELECTION_COLOR)); else fl_color(name_color); - fl_draw(c, X, Y+13); - } else if ((c = l->label())) { + fl_draw(c.c_str(), X, Y+13); + } else if (l->label()) { // -- label + c = l->label(); fl_font(label_font, textsize()); if (l->new_selected) fl_color(fl_contrast(label_color, FL_SELECTION_COLOR)); else fl_color(label_color); - copy_trunc(buf, c, 32, 1, 0); // quoted string + copy_trunc(buf, c.c_str(), 32, 1, 0); // quoted string fl_draw(buf, X, Y+13); } } else { -- cgit v1.2.3