libxputty 0.1
Loading...
Searching...
No Matches
Functions
xlabel_private.c File Reference

Go to the source code of this file.

Functions

void _draw_label (void *w_, void *user_data)
 _draw_label - internal draw the label to the buffer
 

Function Documentation

◆ _draw_label()

void _draw_label ( void *  w_,
void *  user_data 
)

_draw_label - internal draw the label to the buffer

Parameters
*w_- void pointer to the Widget_t label
*user_data- void pointer to attached user_data

Definition at line 25 of file xlabel_private.c.

25 {
26 Widget_t *w = (Widget_t*)w_;
27 Metrics_t metrics;
28 os_get_window_metrics(w, &metrics);
29 int width = metrics.width-2;
30 int height = metrics.height-2;
31 if (!metrics.visible) return;
32
33 cairo_text_extents_t extents;
35 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
36 cairo_text_extents(w->crb,w->label , &extents);
37
38 cairo_move_to (w->crb, (width*0.5)-(extents.width/2), height-(extents.height/4));
39 cairo_show_text(w->crb, w->label);
40 cairo_new_path (w->crb);
41}
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
float ascale
Definition xwidget.h:369
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
cairo_t * crb
Definition xwidget.h:489
const char * label
Definition xwidget.h:463
Xputty * app
Definition xwidget.h:465
int normal_font
Definition xputty.h:248
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
Definition xcolor.c:222
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
Definition xcolor.c:266
void os_get_window_metrics(Widget_t *w, Metrics_t *metrics)
os_get_window_metrics - Get the Merics_t struct related to a Widget_t

References Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::label, Xputty::normal_font, os_get_window_metrics(), Widget_t::scale, use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by add_label().