Skip to content

Commit 3cc2553

Browse files
committed
Tooltip stringified
1 parent 3187d72 commit 3cc2553

8 files changed

Lines changed: 39 additions & 37 deletions

File tree

fluid/io/String_Writer.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ int fld::io::write_strings(Project &proj, const std::string &filename) {
7777
write_escaped_strings(fp, w->label());
7878
putc('\n', fp);
7979
}
80-
if (w->tooltip()) {
81-
write_escaped_strings(fp, w->tooltip());
80+
if (!w->tooltip().empty()) {
81+
write_escaped_strings(fp, w->tooltip().c_str());
8282
putc('\n', fp);
8383
}
8484
}
@@ -100,13 +100,13 @@ int fld::io::write_strings(Project &proj, const std::string &filename) {
100100
fputs("\"\n", fp);
101101
}
102102

103-
if (w->tooltip()) {
103+
if (!w->tooltip().empty()) {
104104
fputs("msgid \"", fp);
105-
write_escaped_strings(fp, w->tooltip());
105+
write_escaped_strings(fp, w->tooltip().c_str());
106106
fputs("\"\n", fp);
107107

108108
fputs("msgstr \"", fp);
109-
write_escaped_strings(fp, w->tooltip());
109+
write_escaped_strings(fp, w->tooltip().c_str());
110110
fputs("\"\n", fp);
111111
}
112112
}
@@ -128,9 +128,9 @@ int fld::io::write_strings(Project &proj, const std::string &filename) {
128128
fputs("\"\n", fp);
129129
}
130130

131-
if (w->tooltip()) {
131+
if (!w->tooltip().empty()) {
132132
fprintf(fp, "%d \"", i ++);
133-
write_escaped_strings(fp, w->tooltip());
133+
write_escaped_strings(fp, w->tooltip().c_str());
134134
fputs("\"\n", fp);
135135
}
136136
}

fluid/nodes/Function_Node.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Class_Node *current_class = nullptr;
5353
\param[in] sig function signature
5454
\return 1 if found.
5555
*/
56-
int has_toplevel_function(const char *rtype, const char *sig) {
56+
int has_toplevel_function(std::string const& rtype, std::string const& sig) {
5757
Node *child;
5858
for (child = Fluid.proj.tree.first; child; child = child->next) {
5959
if (!child->is_in_class() && child->is_a(Type::Function)) {
@@ -478,7 +478,7 @@ void Function_Node::write_code2(fld::io::Code_Writer& f) {
478478
*/
479479
int Function_Node::has_signature(std::string const& rtype, std::string const& sig) const {
480480
if (!name()) return 0;
481-
if ( (return_type() == rtype) && fl_filename_match(name(), sig.c_str()) ) {
481+
if ( ( return_type().empty() || (return_type() == rtype) ) && fl_filename_match(name(), sig.c_str()) ) {
482482
return 1;
483483
}
484484
return 0;

fluid/nodes/Function_Node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
extern class Class_Node *current_class;
3838

39-
int has_toplevel_function(const char* rtype, const char* sig);
39+
int has_toplevel_function(std::string const& rtype, std::string const& sig);
4040

4141
const char* c_check(const char* c, int type = 0);
4242

fluid/nodes/Node.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ int Node::msgnum() {
769769
Node *p;
770770

771771
for (count = 0, p = this; p;) {
772-
if (p->label()) count ++;
773-
if (p != this && p->is_widget() && ((Widget_Node *)p)->tooltip()) count ++;
772+
if (p->label())
773+
count ++;
774+
if (p != this && p->is_widget() && !((Widget_Node *)p)->tooltip().empty())
775+
count ++;
774776

775777
if (p->prev) p = p->prev;
776778
else p = p->parent;

fluid/nodes/Widget_Node.cxx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ Widget_Node::Widget_Node()
209209
for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = nullptr; }
210210
subclass_ = nullptr;
211211
hotspot_ = 0;
212-
tooltip_ = nullptr;
213212
image_name_ = nullptr;
214213
inactive_name_ = nullptr;
215214
image = nullptr;
@@ -234,7 +233,6 @@ Widget_Node::~Widget_Node() {
234233
win->redraw();
235234
}
236235
if (subclass_) free((void*)subclass_);
237-
if (tooltip_) free((void*)tooltip_);
238236
if (image_name_) {
239237
free((void*)image_name_);
240238
if (image) image->dec_ref();
@@ -258,9 +256,9 @@ void Widget_Node::subclass(const char *n) {
258256
redraw_browser();
259257
}
260258

261-
void Widget_Node::tooltip(const char *n) {
262-
storestring(n,tooltip_);
263-
o->tooltip(n);
259+
void Widget_Node::tooltip(std::string const& text) {
260+
tooltip_ = text;
261+
o->tooltip( tooltip_.c_str() );
264262
}
265263

266264
void Widget_Node::image_name(const char *n) {
@@ -1483,7 +1481,7 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) {
14831481
if (has_function("static void", buf))
14841482
write_extern_declaration = 0;
14851483
} else {
1486-
if (has_toplevel_function(nullptr, buf))
1484+
if (has_toplevel_function("", buf))
14871485
write_extern_declaration = 0;
14881486
}
14891487
if (write_extern_declaration)
@@ -1723,23 +1721,23 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) {
17231721
Fl_Widget* tplate = ((Widget_Node*)factory)->o;
17241722
const char *var = is_class() ? "this" : name() ? name() : "o";
17251723

1726-
if (tooltip() && *tooltip()) {
1724+
if (!tooltip().empty()) {
17271725
f.write_c("%s%s->tooltip(",f.indent(), var);
17281726
switch (Fluid.proj.i18n.type) {
17291727
case fld::I18n_Type::NONE : /* None */
1730-
f.write_cstring(tooltip());
1728+
f.write_cstring(tooltip().c_str());
17311729
break;
17321730
case fld::I18n_Type::GNU : /* GNU gettext */
17331731
f.write_c("%s(", Fluid.proj.i18n.gnu_function.c_str());
1734-
f.write_cstring(tooltip());
1732+
f.write_cstring(tooltip().c_str());
17351733
f.write_c(")");
17361734
break;
17371735
case fld::I18n_Type::POSIX : /* POSIX catgets */
17381736
f.write_c("catgets(%s,%s,%d,",
17391737
Fluid.proj.i18n.posix_file.empty() ? "_catalog" : Fluid.proj.i18n.posix_file.c_str(),
17401738
Fluid.proj.i18n.posix_set.c_str(),
17411739
msgnum() + 1);
1742-
f.write_cstring(tooltip());
1740+
f.write_cstring(tooltip().c_str());
17431741
f.write_c(")");
17441742
break;
17451743
}
@@ -1944,9 +1942,9 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) {
19441942
case 1: break;
19451943
case 2: f.write_string("protected"); break;
19461944
}
1947-
if (tooltip() && *tooltip()) {
1945+
if (!tooltip().empty()) {
19481946
f.write_string("tooltip");
1949-
f.write_word(tooltip());
1947+
f.write_word(tooltip().c_str());
19501948
}
19511949
if (image_name() && *image_name()) {
19521950
if (scale_image_w_ || scale_image_h_)
@@ -2417,7 +2415,7 @@ void Widget_Node::copy_properties() {
24172415
// copy all attributes common to all widget types
24182416
Fl_Widget *w = live_widget;
24192417
w->label(o->label());
2420-
w->tooltip(tooltip());
2418+
w->copy_tooltip( tooltip().c_str() );
24212419
w->type(o->type());
24222420
w->box(o->box());
24232421
w->color(o->color());

fluid/nodes/Widget_Node.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Widget_Node : public Node
4747

4848
const char *extra_code_[NUM_EXTRA_CODE];
4949
const char *subclass_;
50-
const char *tooltip_;
50+
std::string tooltip_;
5151
const char *image_name_;
5252
const char *inactive_name_;
5353
uchar hotspot_;
@@ -94,8 +94,10 @@ class Widget_Node : public Node
9494
void extra_code(int n,const char *);
9595
const char *subclass() const {return subclass_;}
9696
void subclass(const char *);
97-
const char *tooltip() const {return tooltip_;}
98-
void tooltip(const char *);
97+
98+
std::string tooltip() const { return tooltip_; }
99+
void tooltip(std::string const& text);
100+
99101
const char *image_name() const {return image_name_;}
100102
void image_name(const char *);
101103
const char *inactive_name() const {return inactive_name_;}

fluid/panels/widget_panel.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ static void cb_wp_gui_tooltip(Fl_Input* o, void* v) {
16681668
if (v == LOAD) {
16691669
if (current_widget->is_widget()) {
16701670
o->activate();
1671-
o->value(((Widget_Node*)current_widget)->tooltip());
1671+
o->value(((Widget_Node*)current_widget)->tooltip().c_str());
16721672
} else {
16731673
o->deactivate();
16741674
}
@@ -1680,7 +1680,7 @@ static void cb_wp_gui_tooltip(Fl_Input* o, void* v) {
16801680
}
16811681
if (mod) Fluid.proj.set_modflag(1);
16821682
}
1683-
//fl ▲ ----------~=~--=~~=~-=----------~---=~--~--=~~-----=~~ ▲ fl//
1683+
//fl ▲ ----------~=~--=~~=~-=-----------~--~--~~=--=-~----==- ▲ fl//
16841684
}
16851685

16861686
Fl_Group *wp_style_tab=(Fl_Group *)0;
@@ -3540,7 +3540,7 @@ Fl_Double_Window* make_widget_panel() {
35403540
o->callback((Fl_Callback*)propagate_load);
35413541
o->align(Fl_Align(FL_ALIGN_LEFT));
35423542
{ widget_image_input = new Fl_Input(95, 65, 200, 20);
3543-
widget_image_input->tooltip("The active image for the widget.");
3543+
widget_image_input->tooltip("image show when widget is active");
35443544
widget_image_input->labelfont(1);
35453545
widget_image_input->labelsize(11);
35463546
widget_image_input->textsize(11);
@@ -3565,7 +3565,7 @@ Fl_Double_Window* make_widget_panel() {
35653565
o->callback((Fl_Callback*)propagate_load);
35663566
o->align(Fl_Align(FL_ALIGN_LEFT));
35673567
{ widget_deimage_input = new Fl_Input(95, 90, 200, 20);
3568-
widget_deimage_input->tooltip("The inactive image for the widget.");
3568+
widget_deimage_input->tooltip("image show when widget is inactive");
35693569
widget_deimage_input->labelfont(1);
35703570
widget_deimage_input->labelsize(11);
35713571
widget_deimage_input->textsize(11);

fluid/panels/widget_panel.fl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Function {make_widget_panel()} {uid 03b3
490490
} {
491491
Fl_Tabs widget_tabs {uid 30ee
492492
callback {if (current_widget)
493-
propagate_load((Fl_Group *)o,v);}
493+
propagate_load((Fl_Group *)o,v);} open
494494
xywh {10 10 400 350} selection_color 12 labelsize 11 labelcolor 7 when 0
495495
code0 {o->show();}
496496
} {
@@ -505,7 +505,7 @@ Function {make_widget_panel()} {uid 03b3
505505
xywh {95 40 309 20} labelfont 1 labelsize 11 align 4
506506
} {
507507
Fl_Input wp_gui_label {uid b76b
508-
callback label_cb
508+
callback label_cb selected
509509
tooltip {The label text for the widget.
510510
Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 textsize 11 resizable
511511
}
@@ -535,7 +535,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
535535
}
536536
if (mod) Fluid.proj.set_modflag(1);
537537
}}
538-
tooltip {The active image for the widget.} xywh {95 65 200 20} labelfont 1 labelsize 11 textsize 11 resizable
538+
tooltip {image show when widget is active} xywh {95 65 200 20} labelfont 1 labelsize 11 textsize 11 resizable
539539
}
540540
Fl_Button {} {uid 2eaa
541541
label {Browse...}
@@ -585,7 +585,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
585585
}
586586
if (mod) Fluid.proj.set_modflag(1);
587587
}}
588-
tooltip {The inactive image for the widget.} xywh {95 90 200 20} labelfont 1 labelsize 11 textsize 11 resizable
588+
tooltip {image show when widget is inactive} xywh {95 90 200 20} labelfont 1 labelsize 11 textsize 11 resizable
589589
}
590590
Fl_Button {} {uid 803e
591591
label {Browse...}
@@ -1735,7 +1735,7 @@ unselectable, but not grayed out} xywh {225 260 75 20} selection_color 1 labelsi
17351735
callback {if (v == LOAD) {
17361736
if (current_widget->is_widget()) {
17371737
o->activate();
1738-
o->value(((Widget_Node*)current_widget)->tooltip());
1738+
o->value(((Widget_Node*)current_widget)->tooltip().c_str());
17391739
} else {
17401740
o->deactivate();
17411741
}

0 commit comments

Comments
 (0)