24 static void _show_label(
Widget_t *w,
int width,
int height) {
26 cairo_text_extents_t extents;
29 cairo_text_extents(w->
crb,w->
label , &extents);
30 cairo_move_to (w->
crb, (width*0.5)-(extents.width/2), height-(extents.height/4));
32 cairo_new_path (w->
crb);
36 int width = cairo_xlib_surface_get_width(w->
image);
37 int height = cairo_xlib_surface_get_height(w->
image);
38 double x = (double)width_t/(
double)height;
39 double y = (double)height/(
double)width_t;
41 int findex = (int)(((width/height)-1) * knobstate);
42 cairo_scale(w->
crb, x,x);
44 cairo_set_source_surface (w->
crb, w->
image, -height*findex, 0);
45 cairo_rectangle(w->
crb,0, 0, height, height);
48 cairo_scale(w->
crb, y,y);
59 XWindowAttributes attrs;
60 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
61 int width = attrs.width-2;
62 int height = attrs.height-2;
64 const double scale_zero = 20 * (M_PI/180);
69 int grow = (width > height) ? height:width;
74 int knobx = (width - knob_x) * 0.5;
75 int knobx1 = width* 0.5;
77 int knoby = (height - knob_y) * 0.5;
78 int knoby1 = height * 0.5;
84 double angle = scale_zero + knobstate * 2 * (M_PI - scale_zero);
86 double pointer_off =knob_x/6;
87 double radius =
min(knob_x-pointer_off, knob_y-pointer_off) / 2;
88 double lengh_x = (knobx+radius+pointer_off/2) - radius * sin(angle);
89 double lengh_y = (knoby+radius+pointer_off/2) + radius * cos(angle);
90 double radius_x = (knobx+radius+pointer_off/2) - radius/ 1.18 * sin(angle);
91 double radius_y = (knoby+radius+pointer_off/2) + radius/ 1.18 * cos(angle);
93 cairo_arc(w->
crb,knobx1+arc_offset, knoby1+arc_offset, knob_x/2.1, 0, 2 * M_PI );
97 cairo_new_path (w->
crb);
100 cairo_arc(w->
crb,knobx1+arc_offset, knoby1+arc_offset, knob_x/3.1, 0, 2 * M_PI );
101 cairo_fill_preserve(w->
crb);
103 cairo_set_line_width(w->
crb, knobx1/15);
104 cairo_stroke(w->
crb);
105 cairo_new_path (w->
crb);
108 cairo_set_line_cap(w->
crb, CAIRO_LINE_CAP_ROUND);
109 cairo_set_line_join(w->
crb, CAIRO_LINE_JOIN_BEVEL);
110 cairo_move_to(w->
crb, radius_x, radius_y);
111 cairo_line_to(w->
crb,lengh_x,lengh_y);
112 cairo_set_line_width(w->
crb,knobx1/7);
114 cairo_stroke(w->
crb);
115 cairo_new_path (w->
crb);
118 cairo_text_extents_t extents;
122 const char* format[] = {
"%.1f",
"%.2f",
"%.3f"};
125 snprintf(s, 63,
"%d", (
int) value);
126 }
else if (fabs(w->
adj->
step)>0.09) {
127 snprintf(s, 63, format[1-1], value);
129 snprintf(s, 63, format[2-1], value);
132 cairo_text_extents(w->
crb, s, &extents);
133 cairo_move_to (w->
crb, knobx1-extents.width/2, knoby1+extents.height/2);
134 cairo_show_text(w->
crb, s);
135 cairo_new_path (w->
crb);
138 _show_label(w, width, height);