libxputty 0.1
Loading...
Searching...
No Matches
Functions
xtooltip.h File Reference

Go to the source code of this file.

Functions

void tooltip_set_text (Widget_t *w, const char *label)
 tooltip_set_text - set a (new) text to a tooltip for Widget_t
 
void add_tooltip (Widget_t *w, const char *label)
 add_tooltip - add a tooltip to Widget_t
 
Widget_tcreate_tooltip (Widget_t *parent, int width, int height)
 create_tooltip - create a tooltip for a Widget_t
 

Function Documentation

◆ add_tooltip()

void add_tooltip ( Widget_t w,
const char *  label 
)

add_tooltip - add a tooltip to Widget_t

Parameters
*w- pointer to the Widget_t request the tooltip
*label- the tooltip text

Definition at line 41 of file xtooltip.c.

41 {
42 Widget_t *wid = create_tooltip(w, 25, 25);
43 wid->label = label;
44 _get_width(wid);
45}
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
const char * label
Definition xwidget.h:463
Widget_t * create_tooltip(Widget_t *parent, int width, int height)
create_tooltip - create a tooltip for a Widget_t
Definition xtooltip.c:47
void _get_width(Widget_t *w)
_get_width - get the width of a tooltip text and resize the tooltip widget to match the size

References _get_width(), create_tooltip(), and Widget_t::label.

Referenced by open_directory_dialog(), open_file_dialog(), save_file_dialog(), and tooltip_set_text().

◆ create_tooltip()

Widget_t * create_tooltip ( Widget_t parent,
int  width,
int  height 
)

create_tooltip - create a tooltip for a Widget_t

Parameters
*parent- pointer to the Widget_t the tooltip should pop over
width- define the width of the tooltip
height- define the height of the tooltip
Returns
Widget_t* - pointer to the Widget_t button struct

Definition at line 47 of file xtooltip.c.

47 {
48
49 int x1, y1;
50 os_translate_coords(parent, parent->widget, os_get_root_window(parent->app, IS_WIDGET), 0, 0, &x1, &y1);
51 Widget_t *wid = create_window(parent->app, os_get_root_window(parent->app, IS_WIDGET), x1+10, y1+10, width, height);
53 os_set_transient_for_hint(parent, wid);
54 wid->flags &= ~USE_TRANSPARENCY;
56 wid->flags |= IS_TOOLTIP;
57 parent->flags |= HAS_TOOLTIP;
58 wid->scale.gravity = NONE;
59 childlist_add_child(parent->childlist, wid);
60 return wid;
61}
xevfunc expose_callback
Definition xwidget.h:85
Gravity gravity
Definition xwidget.h:347
Resize_t scale
Definition xwidget.h:525
Window widget
Definition xwidget.h:469
Childlist_t * childlist
Definition xwidget.h:499
long long flags
Definition xwidget.h:461
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
void childlist_add_child(Childlist_t *childlist, Widget_t *child)
childlist_add_child - internal use to add a child to the Childlist_t You usually didn't need to cal...
Definition xchildlist.c:42
void _draw_tooltip(void *w_, void *user_data)
_draw_tooltip - draw tooltip on expose call
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void os_translate_coords(Widget_t *w, Window from_window, Window to_window, int from_x, int from_y, int *to_x, int *to_y)
os_translate_coords - get x,y related to destination Window
void os_set_transient_for_hint(Widget_t *parent, Widget_t *w)
os_set_ transient_for_hint - set a Widget_t transient to a other Widget_t only work on linux,...
void os_set_window_attrb(Widget_t *w)
os_set_window_attrb - set the attribute mask to a Widget_t only work on linux, stub on Windows
Widget_t * create_window(Xputty *app, Window win, int x, int y, int width, int height)
*create_window - create a Window You need to create as least minimun one Window to get started....
Definition xwidget.c:163
@ NONE
Definition xwidget.h:328
@ IS_TOOLTIP
Definition xwidget.h:396
@ IS_WIDGET
Definition xwidget.h:388
@ HAS_TOOLTIP
Definition xwidget.h:404

References _draw_tooltip(), Widget_t::app, Widget_t::childlist, childlist_add_child(), create_window(), Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, HAS_TOOLTIP, IS_TOOLTIP, IS_WIDGET, NONE, os_get_root_window(), os_set_transient_for_hint(), os_set_window_attrb(), os_translate_coords(), Widget_t::scale, and Widget_t::widget.

Referenced by add_tooltip().

◆ tooltip_set_text()

void tooltip_set_text ( Widget_t w,
const char *  label 
)

tooltip_set_text - set a (new) text to a tooltip for Widget_t

Parameters
*w- pointer to the Widget_t request the tooltip
*label- the tooltip text

Definition at line 25 of file xtooltip.c.

25 {
26 Widget_t *wid = NULL;
27 bool is_tooltip = false;
28 int i = 0;
29 for(;i<w->childlist->elem;i++) {
30 wid = w->childlist->childs[i];
31 if (wid->flags & IS_TOOLTIP) {
32 wid->label = label;
33 _get_width(wid);
34 is_tooltip = true;
35 break;
36 }
37 }
38 if (!is_tooltip) add_tooltip(w, label);
39}
Widget_t ** childs
Definition xchildlist.h:51
void add_tooltip(Widget_t *w, const char *label)
add_tooltip - add a tooltip to Widget_t
Definition xtooltip.c:41

References _get_width(), add_tooltip(), Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, IS_TOOLTIP, and Widget_t::label.

Referenced by _draw_combobox(), _draw_combobox_entrys(), _draw_list(), _draw_listbox_item(), _draw_multi_list(), _update_list_view(), and _update_view().