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

Go to the source code of this file.

Functions

void _draw_image (void *w_, void *user_data)
 _draw_image - internal draw the image to the buffer
 

Function Documentation

◆ _draw_image()

void _draw_image ( void *  w_,
void *  user_data 
)

_draw_image - internal draw the image to the buffer

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

Definition at line 39 of file xdrawing_area_private.c.

39 {
40 Widget_t *w = (Widget_t*)w_;
41 Metrics_t metrics;
42 os_get_window_metrics(w, &metrics);
43 int width_t = metrics.width;
44 int height_t = metrics.height;
45
46 if (!w->image) {
47 cairo_text_extents_t extents;
49 cairo_set_font_size (w->crb, w->app->big_font/w->scale.ascale);
50 cairo_text_extents(w->crb,"Missing Image" , &extents);
51 cairo_move_to (w->crb, (w->width -extents.width)*0.5, (w->height - extents.height)*0.5);
52 cairo_show_text(w->crb, "Missing Image");
53 cairo_new_path (w->crb);
54
55 cairo_set_line_width(w->crb,3);
56 _rounded_iframe(w->crb, 5, 5, width_t-10, height_t-10);
57 cairo_stroke(w->crb);
58 }
59
60 if (w->image) {
61 int width, height;
62 os_get_surface_size(w->image, &width, &height);
63 double x = (double)width_t/(double)(width);
64 double y = (double)height_t/(double)height;
65 double x1 = (double)(width)/(double)width_t;
66 double y1 = (double)height/(double)height_t;
67 cairo_scale(w->crb, x,y);
68 cairo_set_source_surface (w->crb, w->image, 0, 0);
69 cairo_paint (w->crb);
70 cairo_scale(w->crb, x1,y1);
71 }
72}
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
int width
Definition xwidget.h:521
cairo_surface_t * image
Definition xwidget.h:491
cairo_t * crb
Definition xwidget.h:489
int height
Definition xwidget.h:523
Xputty * app
Definition xwidget.h:465
int big_font
Definition xputty.h:250
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_base_color_scheme(Widget_t *w, Color_state st)
use_base_color_scheme - use base Colors to paint on Widget_t
Definition xcolor.c:259
void _rounded_iframe(cairo_t *cr, float x, float y, float w, float h)
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
void os_get_surface_size(cairo_surface_t *surface, int *width, int *height)
os_get_surface_size - get the size of the cairo surface

References _rounded_iframe(), Widget_t::app, Resize_t::ascale, Xputty::big_font, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::height, Widget_t::image, os_get_surface_size(), os_get_window_metrics(), Widget_t::scale, use_base_color_scheme(), Metrics_t::width, and Widget_t::width.

Referenced by add_image().