libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xvaluedisplay_private.h File Reference
#include "xvaluedisplay.h"
Include dependency graph for xvaluedisplay_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XVALUEDISPLAY_PRIVATE_H_
 

Functions

void _draw_valuedisplay (void *w_, void *user_data)
 _draw_valuedisplay - draw a valuedisplay on expose call More...
 

Macro Definition Documentation

◆ XVALUEDISPLAY_PRIVATE_H_

#define XVALUEDISPLAY_PRIVATE_H_

Definition at line 24 of file xvaluedisplay_private.h.

Function Documentation

◆ _draw_valuedisplay()

void _draw_valuedisplay ( void *  w_,
void *  user_data 
)

_draw_valuedisplay - draw a valuedisplay on expose call

Parameters
*w_- The Widget_t contain the valuedisplay
*user_data- attached user_data
Returns
void

Definition at line 25 of file xvaluedisplay_private.c.

25  {
26  Widget_t *w = (Widget_t*)w_;
27  if (!w) return;
28  XWindowAttributes attrs;
29  XGetWindowAttributes(w->app->dpy, (Window)w->widget, &attrs);
30  int width = attrs.width-2;
31  int height = attrs.height-2;
32  if (attrs.map_state != IsViewable) return;
33 
34  cairo_rectangle(w->crb,2.0, 2.0, width, height);
35 
36  if(w->state==0) {
37  cairo_set_line_width(w->crb, 1.0);
39  cairo_fill_preserve(w->crb);
41  } else if(w->state==1) {
43  cairo_fill_preserve(w->crb);
44  cairo_set_line_width(w->crb, 1.5);
46  } else if(w->state==2) {
48  cairo_fill_preserve(w->crb);
49  cairo_set_line_width(w->crb, 1.0);
51  } else if(w->state==3) {
53  cairo_fill_preserve(w->crb);
54  cairo_set_line_width(w->crb, 1.0);
56  } else if(w->state==4) {
58  cairo_fill_preserve(w->crb);
59  cairo_set_line_width(w->crb, 1.0);
61  }
62  cairo_stroke(w->crb);
63 
64  cairo_rectangle(w->crb,4.0, 4.0, width, height);
65  cairo_stroke(w->crb);
66  cairo_rectangle(w->crb,3.0, 3.0, width, height);
67  cairo_stroke(w->crb);
68 
69  cairo_text_extents_t extents;
70 
71  char s[64];
72  const char* format[] = {"%.1f ", "%.2f ", "%. Hz"};
73  float value = adj_get_value(w->adj);
74  snprintf(s, 63, format[2-1], value);
75 
76 
78  float font_size = w->app->normal_font/w->scale.ascale;
79  cairo_set_font_size (w->crb, font_size);
80  cairo_text_extents(w->crb,s , &extents);
81  cairo_move_to (w->crb, (width-extents.width)*0.5, (height+extents.height)*0.55);
82  cairo_show_text(w->crb, s);
83  cairo_new_path (w->crb);
84 
85 }

References ACTIVE_, Widget_t::adj, adj_get_value(), Widget_t::app, Resize_t::ascale, Widget_t::crb, Xputty::dpy, get_color_state(), INSENSITIVE_, NORMAL_, Xputty::normal_font, PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, use_frame_color_scheme(), use_shadow_color_scheme(), use_text_color_scheme(), and Widget_t::widget.

use_text_color_scheme
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:199
INSENSITIVE_
@ INSENSITIVE_
Definition: xcolor.h:43
get_color_state
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:155
use_shadow_color_scheme
void use_shadow_color_scheme(Widget_t *w, Color_state st)
use_shadow_color_scheme - use shadow Colors to paint on Widget_t
Definition: xcolor.c:206
Xputty::normal_font
int normal_font
Definition: xputty.h:191
adj_get_value
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
Definition: xadjustment.c:154
Widget_t::crb
cairo_t * crb
Definition: xwidget.h:318
Widget_t::adj
Adjustment_t * adj
Definition: xwidget.h:334
Widget_t::scale
Resize_t scale
Definition: xwidget.h:356
Widget_t::app
Xputty * app
Definition: xwidget.h:300
Xputty::dpy
Display * dpy
Definition: xputty.h:181
use_frame_color_scheme
void use_frame_color_scheme(Widget_t *w, Color_state st)
use_frame_color_scheme - use frame Colors to paint on Widget_t
Definition: xcolor.c:213
Widget_t::state
int state
Definition: xwidget.h:342
Resize_t::ascale
float ascale
Definition: xwidget.h:214
ACTIVE_
@ ACTIVE_
Definition: xcolor.h:42
Widget_t::widget
Window widget
Definition: xwidget.h:302
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
NORMAL_
@ NORMAL_
Definition: xcolor.h:39
PRELIGHT_
@ PRELIGHT_
Definition: xcolor.h:40
SELECTED_
@ SELECTED_
Definition: xcolor.h:41