Tooltips now support rich text, like in the QT components.

[GB.GTK]
* BUG: Tooltips now support rich text, like in the QT components.

[GB.GTK3]
* BUG: Tooltips now support rich text, like in the QT components.
This commit is contained in:
gambas 2019-05-24 01:58:28 +02:00
parent 0bfe40ac76
commit baa18e8522
3 changed files with 24 additions and 12 deletions

View file

@ -831,7 +831,7 @@ BEGIN_PROPERTY(CWIDGET_tooltip)
return;
}
CONTROL->setToolTip(GB.ToZeroString(PROP(GB_STRING)));
CONTROL->setTooltip(GB.ToZeroString(PROP(GB_STRING)));
END_PROPERTY

View file

@ -314,6 +314,7 @@ void gControl::initAll(gContainer *parent)
_use_wheel = false;
_scrollbar = SCROLL_NONE;
_input_method = NULL;
_tooltip = NULL;
onFinish = NULL;
onFocusEvent = NULL;
@ -389,7 +390,10 @@ gControl::~gControl()
//fprintf(stderr, "~gControl: %s\n", name());
setName(NULL);
if (_name)
g_free(_name);
if (_tooltip)
g_free(_tooltip);
controls = g_list_remove(controls, this);
controls_destroyed = g_list_remove(controls_destroyed, this);
@ -724,16 +728,22 @@ void gControl::setIgnore (bool vl)
if (pr) pr->performArrange();
}
char* gControl::toolTip()
void gControl::setTooltip(char *vl)
{
char *text = gtk_widget_get_tooltip_text(border);
gt_free_later(text);
return text;
}
void gControl::setToolTip(char* vl)
{
gtk_widget_set_tooltip_text(border, vl ? vl : "");
char *pango;
if (_tooltip) g_free(_tooltip);
_tooltip = NULL;
if (vl) _tooltip = g_strdup(vl);
if (_tooltip)
{
pango = gt_html_to_pango_string(_tooltip, -1, false);
gtk_widget_set_tooltip_markup(border, pango);
g_free(pango);
}
else
gtk_widget_set_tooltip_markup(border, NULL);
}
gFont* gControl::font()

View file

@ -92,7 +92,8 @@ public:
void setLeft(int l);
void setMouse(int m);
virtual void updateCursor(GdkCursor *cursor);
void setToolTip(char *vl);
char *tooltip() { return _tooltip; }
void setTooltip(char *vl);
void setTop(int t);
virtual void setVisible(bool v);
virtual void setWidth(int w);
@ -215,6 +216,7 @@ public:
short _mouse;
gControl *_proxy, *_proxy_for;
gColor _bg, _fg;
char *_tooltip;
#ifdef GTK3
GtkStyleProvider *_css;
const char *_bg_name;