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

Go to the source code of this file.

Functions

void _rounded_rectangle (cairo_t *cr, float x, float y, float width, float height)
 _rounded_rectangle - internal draw a rounded button
 
void _pattern_out (Widget_t *w, Color_state st, int height)
 _pattern_in - a little pattern to make press state more visible
 
void _pattern_in (Widget_t *w, Color_state st, int height)
 _pattern_in - a little pattern to make press state more visible
 
void _draw_image_button (Widget_t *w, int width_t, int height_t, float offset)
 
void _draw_image_button_with_label (Widget_t *w, int width_t, int height_t)
 
void _draw_switch_image_button (void *w_, void *user_data)
 draw switch_image_button - internal draw the button to the buffer
 
void _draw_button_base (Widget_t *w, int width, int height)
 
int _remove_low_dash (char *str)
 
void _draw_button (void *w_, void *user_data)
 _draw_button - internal draw the button to the buffer
 
void _draw_base_button (void *w_, void *user_data)
 _draw_base_button - internal draw the button with base to the buffer
 
void _draw_on_off_button (void *w_, void *user_data)
 _draw_on_off_button - internal draw the on/off button to the buffer
 
void _draw_ti_button (void *w_, void *user_data)
 _draw_ti_button - internal draw the button to the buffer
 
void _draw_check_button (void *w_, void *user_data)
 _draw_check_button - internal draw the button to the buffer
 
void _draw_check_box (void *w_, void *user_data)
 _draw_check_box - internal draw the check box to the buffer
 
void _button_pressed (void *w_, void *button, void *user_data)
 _button_pressed - redraw the button and send state via user_callback
 
void _button_released (void *w_, void *button_, void *user_data)
 _button_released - redraw the button and send state via user_callback
 
void _toggle_button_pressed (void *w_, void *button, void *user_data)
 _toggle_button_pressed - redraw the button and send state via user_callback
 
void _toggle_button_released (void *w_, void *button_, void *user_data)
 _toggle_button_released - redraw the button and send state via user_callback
 

Function Documentation

◆ _button_pressed()

void _button_pressed ( void *  w_,
void *  button_,
void *  user_data 
)

_button_pressed - redraw the button and send state via user_callback

Parameters
*w_- void pointer to the Widget_t button
*button_- void pointer to XEvent.xbutton struct
*user_data- void pointer to attached user_data

Definition at line 420 of file xbutton_private.c.

420 {
421 Widget_t *w = (Widget_t*)w_;
422 adj_set_value(w->adj_y, 1.0);
423}
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Adjustment_t * adj_y
Definition xwidget.h:495
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t

References adj_set_value(), and Widget_t::adj_y.

Referenced by add_button(), and add_image_button().

◆ _button_released()

void _button_released ( void *  w_,
void *  button_,
void *  user_data 
)

_button_released - redraw the button and send state via user_callback

Parameters
*w_- void pointer to the Widget_t button
*button_- void pointer to XEvent.xbutton struct
*user_data- void pointer to attached user_data

Definition at line 425 of file xbutton_private.c.

425 {
426 Widget_t *w = (Widget_t*)w_;
427 if (w->flags & HAS_POINTER) w->state=1;
428 adj_set_value(w->adj_y, 0.0);
429}
int state
Definition xwidget.h:511
long long flags
Definition xwidget.h:461
@ HAS_POINTER
Definition xwidget.h:402

References adj_set_value(), Widget_t::adj_y, Widget_t::flags, HAS_POINTER, and Widget_t::state.

Referenced by add_button(), and add_image_button().

◆ _draw_base_button()

void _draw_base_button ( void *  w_,
void *  user_data 
)

_draw_base_button - internal draw the button with base to the buffer

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

Definition at line 220 of file xbutton_private.c.

220 {
221 Widget_t *w = (Widget_t*)w_;
222 if (!w) return;
223 Metrics_t metrics;
224 os_get_window_metrics(w, &metrics);
225 int width = metrics.width-2;
226 int height = metrics.height-2;
227 if (!metrics.visible) return;
228 _draw_button_base(w, width, height);
229
230 float offset = 0.0;
231 if(w->state==1 && ! (int)w->adj_y->value) {
232 offset = 1.0;
233 } else if(w->state==1) {
234 offset = 2.0;
235 } else if(w->state==2) {
236 offset = 2.0;
237 } else if(w->state==3) {
238 offset = 1.0;
239 }
240 if (w->image) {
241 if(strlen(w->label)) {
242 _draw_image_button_with_label(w, width, height);
243 } else {
244 _draw_image_button(w, width, height,offset);
245 }
246 } else {
247
248 cairo_text_extents_t extents;
250 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
251
252 if (strstr(w->label, "_")) {
253 cairo_text_extents(w->crb, "--", &extents);
254 double underline = extents.width;
255 strncpy(w->input_label,w->label, sizeof(w->input_label)-1);
256 int pos = _remove_low_dash(w->input_label);
257 int len = strlen(w->input_label);
258 cairo_text_extents(w->crb,w->input_label , &extents);
259 int set_line = (extents.width/len) * pos;
260 cairo_move_to (w->crb, (width-extents.width)*0.5 +offset, (height+extents.height)*0.5 +offset);
261 cairo_show_text(w->crb, w->input_label);
262 cairo_set_line_width(w->crb, 1.0);
263 cairo_move_to (w->crb, (width-extents.width)*0.5 +offset + set_line, (height+extents.height)*0.55 +offset);
264 cairo_line_to(w->crb,(width-extents.width)*0.5 +offset + set_line + underline, (height+extents.height)*0.55 +offset);
265 cairo_stroke(w->crb);
266 } else {
267 cairo_text_extents(w->crb,w->label , &extents);
268 cairo_move_to (w->crb, (width-extents.width)*0.5 +offset, (height+extents.height)*0.5 +offset);
269 cairo_show_text(w->crb, w->label);
270 }
271 }
272}
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
float ascale
Definition xwidget.h:369
Resize_t scale
Definition xwidget.h:525
cairo_surface_t * image
Definition xwidget.h:491
cairo_t * crb
Definition xwidget.h:489
char input_label[32]
Definition xwidget.h:459
const char * label
Definition xwidget.h:463
Xputty * app
Definition xwidget.h:465
int normal_font
Definition xputty.h:248
int _remove_low_dash(char *str)
void _draw_button_base(Widget_t *w, int width, int height)
void _draw_image_button(Widget_t *w, int width_t, int height_t, float offset)
void _draw_image_button_with_label(Widget_t *w, int width_t, int height_t)
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 _draw_button_base(), _draw_image_button(), _draw_image_button_with_label(), _remove_low_dash(), Widget_t::adj_y, Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::image, Widget_t::input_label, Widget_t::label, Xputty::normal_font, os_get_window_metrics(), Widget_t::scale, Widget_t::state, use_text_color_scheme(), Adjustment_t::value, Metrics_t::visible, and Metrics_t::width.

Referenced by add_button(), and add_toggle_button().

◆ _draw_button()

void _draw_button ( void *  w_,
void *  user_data 
)

_draw_button - internal draw the button to the buffer

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

Definition at line 191 of file xbutton_private.c.

191 {
192 Widget_t *w = (Widget_t*)w_;
193 if (!w) return;
194 Metrics_t metrics;
195 os_get_window_metrics(w, &metrics);
196 int width = metrics.width-2;
197 int height = metrics.height-2;
198 if (!metrics.visible) return;
199
200 float offset = 0.0;
201 if(w->state==1 && ! (int)w->adj_y->value) {
202 offset = 1.0;
203 } else if(w->state==1) {
204 offset = 2.0;
205 } else if(w->state==2) {
206 offset = 2.0;
207 } else if(w->state==3) {
208 offset = 1.0;
209 }
210
211 if (w->image) {
212 if(strlen(w->label)) {
213 _draw_image_button_with_label(w, width, height);
214 } else {
215 _draw_image_button(w, width, height,offset);
216 }
217 }
218}

References _draw_image_button(), _draw_image_button_with_label(), Widget_t::adj_y, Metrics_t::height, Widget_t::image, Widget_t::label, os_get_window_metrics(), Widget_t::state, Adjustment_t::value, Metrics_t::visible, and Metrics_t::width.

Referenced by add_image_button().

◆ _draw_button_base()

void _draw_button_base ( Widget_t w,
int  width,
int  height 
)

Definition at line 129 of file xbutton_private.c.

129 {
130 if (!w->state && (int)w->adj_y->value) {
131 w->state = 3;
132 } else if (w->state == 3 && !(int)w->adj_y->value) {
133 w->state = 0;
134 }
135
136 _rounded_rectangle(w->crb,2.0, 2.0, width, height);
137
138 if(w->state==0) {
139 cairo_set_line_width(w->crb, 1.0);
140 _pattern_out(w, NORMAL_, height);
141 cairo_fill_preserve(w->crb);
143 } else if(w->state==1) {
144 _pattern_out(w, PRELIGHT_, height);
145 cairo_fill_preserve(w->crb);
146 cairo_set_line_width(w->crb, 1.5);
148 } else if(w->state==2) {
149 _pattern_in(w, SELECTED_, height);
150 cairo_fill_preserve(w->crb);
151 cairo_set_line_width(w->crb, 1.0);
153 } else if(w->state==3) {
154 _pattern_in(w, ACTIVE_, height);
155 cairo_fill_preserve(w->crb);
156 cairo_set_line_width(w->crb, 1.0);
158 }
159 cairo_stroke(w->crb);
160
161 if(w->state==2) {
162 _rounded_rectangle(w->crb,4.0, 4.0, width, height);
163 cairo_stroke(w->crb);
164 _rounded_rectangle(w->crb,3.0, 3.0, width, height);
165 cairo_stroke(w->crb);
166 } else if (w->state==3) {
167 _rounded_rectangle(w->crb,3.0, 3.0, width, height);
168 cairo_stroke(w->crb);
169 }
170}
void _pattern_out(Widget_t *w, Color_state st, int height)
_pattern_in - a little pattern to make press state more visible
void _pattern_in(Widget_t *w, Color_state st, int height)
_pattern_in - a little pattern to make press state more visible
void _rounded_rectangle(cairo_t *cr, float x, float y, float width, float height)
_rounded_rectangle - internal draw a rounded button
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:280
@ NORMAL_
Definition xcolor.h:44
@ SELECTED_
Definition xcolor.h:46
@ PRELIGHT_
Definition xcolor.h:45
@ ACTIVE_
Definition xcolor.h:47

References _pattern_in(), _pattern_out(), _rounded_rectangle(), ACTIVE_, Widget_t::adj_y, Widget_t::crb, NORMAL_, PRELIGHT_, SELECTED_, Widget_t::state, use_frame_color_scheme(), and Adjustment_t::value.

Referenced by _draw_base_button(), _draw_check_box(), _draw_check_button(), _draw_on_off_button(), and _draw_ti_button().

◆ _draw_check_box()

void _draw_check_box ( void *  w_,
void *  user_data 
)

_draw_check_box - internal draw the check box to the buffer

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

Definition at line 374 of file xbutton_private.c.

374 {
375 Widget_t *w = (Widget_t*)w_;
376 if (!w) return;
377 Metrics_t metrics;
378 os_get_window_metrics(w, &metrics);
379 int height = metrics.height-2;
380 if (!metrics.visible) return;
381 if (w->image) {
382 _draw_image_button(w, height, height,0.0);
383 } else {
384 _draw_button_base(w, height, height);
385
386 if(adj_get_value(w->adj)) {
388 float offset = 1.0;
389 int wa = height/1.3;
390 int h = height/2.2;
391 int wa1 = height/2.2;
392 int h1 = height/1.3;
393 int wa2 = height/2.8;
394
395 cairo_set_line_width(w->crb, 2.5);
396 cairo_move_to(w->crb, wa+offset, h+offset);
397 cairo_line_to(w->crb, wa1+offset, h1+offset);
398 cairo_line_to(w->crb, wa2+offset, h+offset);
399 cairo_stroke(w->crb);
400 }
401
402 cairo_new_path (w->crb);
403
404 cairo_text_extents_t extents;
406 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
407 cairo_text_extents(w->crb,w->label , &extents);
408 cairo_move_to (w->crb, height+5 , (height+extents.height)*0.5 );
409 cairo_show_text(w->crb, w->label);
410 cairo_new_path (w->crb);
411 }
412}
Adjustment_t * adj
Definition xwidget.h:497
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
Definition xcolor.c:245

References _draw_button_base(), _draw_image_button(), Widget_t::adj, adj_get_value(), Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::image, Widget_t::label, Xputty::normal_font, os_get_window_metrics(), Widget_t::scale, use_fg_color_scheme(), use_text_color_scheme(), and Metrics_t::visible.

Referenced by add_check_box().

◆ _draw_check_button()

void _draw_check_button ( void *  w_,
void *  user_data 
)

_draw_check_button - internal draw the button to the buffer

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

Definition at line 341 of file xbutton_private.c.

341 {
342 Widget_t *w = (Widget_t*)w_;
343 if (!w) return;
344 Metrics_t metrics;
345 os_get_window_metrics(w, &metrics);
346 int width = metrics.width-2;
347 int height = metrics.height-2;
348 if (!metrics.visible) return;
349 if (w->image) {
350 _draw_image_button(w, width, height,0.0);
351 } else {
352 _draw_button_base(w, width, height);
353
354 if(w->state==3) {
356 float offset = 1.0;
357 int wa = width/1.3;
358 int h = height/2.2;
359 int wa1 = width/2.2;
360 int h1 = height/1.3;
361 int wa2 = width/2.8;
362
363 cairo_set_line_width(w->crb, 2.5);
364 cairo_move_to(w->crb, wa+offset, h+offset);
365 cairo_line_to(w->crb, wa1+offset, h1+offset);
366 cairo_line_to(w->crb, wa2+offset, h+offset);
367 cairo_stroke(w->crb);
368 }
369
370 cairo_new_path (w->crb);
371 }
372}

References _draw_button_base(), _draw_image_button(), Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::image, os_get_window_metrics(), Widget_t::state, use_fg_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by add_check_button().

◆ _draw_image_button()

void _draw_image_button ( Widget_t w,
int  width_t,
int  height_t,
float  offset 
)

Definition at line 57 of file xbutton_private.c.

57 {
58 int width, height;
59 os_get_surface_size(w->image, &width, &height);
60 double half_width = (width/height >=2) ? width*0.5 : width;
61 double x = (double)width_t/(double)(half_width);
62 double y = (double)height_t/(double)height;
63 double x1 = (double)height/(double)height_t;
64 double y1 = (double)(half_width)/(double)width_t;
65 double off_set = offset*x1;
66 double buttonstate = adj_get_state(w->adj);
67 int findex = (int)(((width/height)-1) * buttonstate) * (width/height >=2);
68 cairo_scale(w->crb, x,y);
69 cairo_set_source_surface (w->crb, w->image, -height*findex+off_set, off_set);
70 cairo_rectangle(w->crb,0, 0, height, height);
71 cairo_fill(w->crb);
72 cairo_scale(w->crb, x1,y1);
73}
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_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 Widget_t::adj, adj_get_state(), Widget_t::crb, Widget_t::image, and os_get_surface_size().

Referenced by _draw_base_button(), _draw_button(), _draw_check_box(), _draw_check_button(), _draw_switch_image_button(), and _draw_ti_button().

◆ _draw_image_button_with_label()

void _draw_image_button_with_label ( Widget_t w,
int  width_t,
int  height_t 
)

Definition at line 75 of file xbutton_private.c.

75 {
76 int width, height;
77 os_get_surface_size(w->image, &width, &height);
78 double x = (double)width_t/(double)height;
79 double y = (double)height/(double)width_t;
80 double buttonstate = adj_get_state(w->adj);
81 int findex = (int)(((width/height)-1) * buttonstate);
82 cairo_scale(w->crb, x,x);
83 cairo_set_source_surface (w->crb, w->image, -height*findex, 0);
84 cairo_rectangle(w->crb,0, 0, height, height);
85 cairo_fill(w->crb);
86 cairo_scale(w->crb, y,y);
87 cairo_text_extents_t extents;
88 if(w->state==0) {
90 } else if(w->state==1 && ! (int)w->adj_y->value) {
92 } else if(w->state==1) {
94 } else if(w->state==2) {
96 } else if(w->state==3) {
98 }
99
101 cairo_set_font_size (w->crb,w->app->normal_font/w->scale.ascale);
102 if ((int)adj_get_value(w->adj) && strlen(w->input_label)) {
103 cairo_text_extents(w->crb,w->input_label , &extents);
104 cairo_move_to (w->crb, (width_t*0.5)-(extents.width/2), height_t-(extents.height/4));
105 cairo_show_text(w->crb, w->input_label);
106 } else {
107 cairo_text_extents(w->crb,w->label , &extents);
108 cairo_move_to (w->crb, (width_t*0.5)-(extents.width/2), height_t-(extents.height/4));
109 cairo_show_text(w->crb, w->label);
110 }
111 cairo_new_path (w->crb);
112}

References ACTIVE_, Widget_t::adj, adj_get_state(), adj_get_value(), Widget_t::adj_y, Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Widget_t::image, Widget_t::input_label, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_surface_size(), PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, use_fg_color_scheme(), use_text_color_scheme(), and Adjustment_t::value.

Referenced by _draw_base_button(), _draw_button(), and _draw_switch_image_button().

◆ _draw_on_off_button()

void _draw_on_off_button ( void *  w_,
void *  user_data 
)

_draw_on_off_button - internal draw the on/off button to the buffer

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

Definition at line 274 of file xbutton_private.c.

274 {
275 Widget_t *w = (Widget_t*)w_;
276 if (!w) return;
277 Metrics_t metrics;
278 os_get_window_metrics(w, &metrics);
279 int width = metrics.width-2;
280 int height = metrics.height-2;
281 if (!metrics.visible) return;
282
283 _draw_button_base(w, width, height);
284
285 float offset = 0.0;
286 cairo_text_extents_t extents;
287 if(w->state==1 && ! (int)w->adj_y->value) {
288 offset = 1.0;
289 } else if(w->state==1) {
290 offset = 2.0;
291 } else if(w->state==2) {
292 offset = 2.0;
293 } else if(w->state==3) {
294 offset = 1.0;
295 }
296 if((int)w->adj_y->value) {
297 w->label = "On";
298 } else {
299 w->label = "Off";
300 }
301
303 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
304 cairo_text_extents(w->crb,w->label , &extents);
305 if(IS_UTF8(w->label[0])) {
306 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
307 cairo_text_extents(w->crb,w->label , &extents);
308 }
309
310 cairo_move_to (w->crb, (width-extents.width)*0.5 +offset, (height+extents.height)*0.5 +offset);
311 cairo_show_text(w->crb, w->label);
312 cairo_new_path (w->crb);
313
314}

References _draw_button_base(), Widget_t::adj_y, 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, Widget_t::state, use_text_color_scheme(), Adjustment_t::value, Metrics_t::visible, and Metrics_t::width.

Referenced by add_on_off_button().

◆ _draw_switch_image_button()

void _draw_switch_image_button ( void *  w_,
void *  user_data 
)

draw switch_image_button - internal draw the button to the buffer

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

Definition at line 114 of file xbutton_private.c.

114 {
115 Widget_t *w = (Widget_t*)w_;
116 if (!w) return;
117 Metrics_t metrics;
118 os_get_window_metrics(w, &metrics);
119 int width = metrics.width-2;
120 int height = metrics.height-2;
121 if (!metrics.visible) return;
122 if(strlen(w->label)) {
123 _draw_image_button_with_label(w, width, height);
124 } else {
125 _draw_image_button(w, width, height,0.0);
126 }
127}

References _draw_image_button(), _draw_image_button_with_label(), Metrics_t::height, Widget_t::label, os_get_window_metrics(), Metrics_t::visible, and Metrics_t::width.

Referenced by add_switch_image_button().

◆ _draw_ti_button()

void _draw_ti_button ( void *  w_,
void *  user_data 
)

_draw_ti_button - internal draw the button to the buffer

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

Definition at line 316 of file xbutton_private.c.

316 {
317 Widget_t *w = (Widget_t*)w_;
318 if (!w) return;
319 Metrics_t metrics;
320 os_get_window_metrics(w, &metrics);
321 int width = metrics.width-2;
322 int height = metrics.height-2;
323 if (!metrics.visible) return;
324 _draw_button_base(w, width, height);
325 if (w->image) {
326 float offset = 0.0;
327 if(w->state==1 && ! (int)w->adj_y->value) {
328 offset = 1.0;
329 } else if(w->state==1) {
330 offset = 2.0;
331 } else if(w->state==2) {
332 offset = 2.0;
333 } else if(w->state==3) {
334 offset = 1.0;
335 }
336
337 _draw_image_button(w, width, height,offset);
338 }
339}

References _draw_button_base(), _draw_image_button(), Widget_t::adj_y, Metrics_t::height, Widget_t::image, os_get_window_metrics(), Widget_t::state, Adjustment_t::value, Metrics_t::visible, and Metrics_t::width.

Referenced by add_image_toggle_button().

◆ _pattern_in()

void _pattern_in ( Widget_t w,
Color_state  st,
int  height 
)

_pattern_in - a little pattern to make press state more visible

Parameters
*w- void pointer to the Widget_t button
st- the color state to use
height- the button height

Definition at line 46 of file xbutton_private.c.

46 {
47 Colors *c = get_color_scheme(w,st);
48 if (!c) return;
49 cairo_pattern_t *pat = cairo_pattern_create_linear (2, 2, 2, height);
50 cairo_pattern_add_color_stop_rgba(pat, 0.0, 0.0, 0.0, 0.0, 0.0);
51 cairo_pattern_add_color_stop_rgba(pat, 0.5, c->light[0], c->light[1], c->light[2], c->light[3]);
52 cairo_pattern_add_color_stop_rgba(pat, 1.0, 0.0, 0.0, 0.0, 0.0);
53 cairo_set_source(w->crb, pat);
54 cairo_pattern_destroy (pat);
55}
Color_t - struct used to set cairo color for Widget_t.
Definition xcolor.h:85
double light[4]
Definition xcolor.h:92
Colors * get_color_scheme(Widget_t *wid, Color_state st)
get_color_scheme - get pointer to the Colors struct to use in relation to the Color_state
Definition xcolor.c:197

References Widget_t::crb, get_color_scheme(), and Colors::light.

Referenced by _draw_button_base(), and _draw_combobox_button().

◆ _pattern_out()

void _pattern_out ( Widget_t w,
Color_state  st,
int  height 
)

_pattern_in - a little pattern to make press state more visible

Parameters
*w- void pointer to the Widget_t button
st- the color state to use
height- the button height

Definition at line 35 of file xbutton_private.c.

35 {
36 Colors *c = get_color_scheme(w,st);
37 if (!c) return;
38 cairo_pattern_t *pat = cairo_pattern_create_linear (2, 2, 2, height);
39 cairo_pattern_add_color_stop_rgba(pat, 0.0, c->light[0], c->light[1], c->light[2], c->light[3]);
40 cairo_pattern_add_color_stop_rgba(pat, 0.5, 0.0, 0.0, 0.0, 0.0);
41 cairo_pattern_add_color_stop_rgba(pat, 1.0, c->light[0], c->light[1], c->light[2], c->light[3]);
42 cairo_set_source(w->crb, pat);
43 cairo_pattern_destroy (pat);
44}

References Widget_t::crb, get_color_scheme(), and Colors::light.

Referenced by _draw_button_base(), and _draw_combobox_button().

◆ _remove_low_dash()

int _remove_low_dash ( char *  str)

Definition at line 172 of file xbutton_private.c.

172 {
173
174 char *src;
175 char *dst;
176 int i = 0;
177 int r = 0;
178 for (src = dst = str; *src != '\0'; src++) {
179 *dst = *src;
180 if (*dst != '_') {
181 dst++;
182 } else {
183 r = i;
184 }
185 i++;
186 }
187 *dst = '\0';
188 return r;
189}

Referenced by _draw_base_button().

◆ _rounded_rectangle()

void _rounded_rectangle ( cairo_t *  cr,
float  x,
float  y,
float  width,
float  height 
)

_rounded_rectangle - internal draw a rounded button

Parameters
*cr- the cairo_t context to draw to
x- point on x axis
y- point on y axis
width- the button width
height- the button height

Definition at line 25 of file xbutton_private.c.

25 {
26 cairo_new_path (cr);
27 cairo_move_to (cr, x, (y + height)/2);
28 cairo_curve_to (cr, x ,y, x, y, (x + width)/2, y);
29 cairo_curve_to (cr, width, y, width, y, width, (y + height)/2);
30 cairo_curve_to (cr, width, height, width, height, (width + x)/2, height);
31 cairo_curve_to (cr, x, height, x, height, x, (y + height)/2);
32 cairo_close_path (cr);
33}

Referenced by _draw_button_base().

◆ _toggle_button_pressed()

void _toggle_button_pressed ( void *  w_,
void *  button_,
void *  user_data 
)

_toggle_button_pressed - redraw the button and send state via user_callback

Parameters
*w_- void pointer to the Widget_t button
*button_- void pointer to XEvent.xbutton struct
*user_data- void pointer to attached user_data

Definition at line 437 of file xbutton_private.c.

437 {
438 Widget_t *w = (Widget_t*)w_;
439 expose_widget(w);
440}
void expose_widget(Widget_t *w)
expose_widgets - send a expose event (EXPOSE) to a Widget_t
Definition xwidget.c:445

References expose_widget().

Referenced by add_check_box(), add_check_button(), add_image_toggle_button(), add_on_off_button(), add_switch_image_button(), and add_toggle_button().

◆ _toggle_button_released()

void _toggle_button_released ( void *  w_,
void *  button_,
void *  user_data 
)

_toggle_button_released - redraw the button and send state via user_callback

Parameters
*w_- void pointer to the Widget_t button
*button_- void pointer to XEvent.xbutton struct
*user_data- void pointer to attached user_data

Definition at line 442 of file xbutton_private.c.

442 {
443 Widget_t *w = (Widget_t*)w_;
444 XButtonEvent *xbutton = (XButtonEvent*)button_;
445 if (w->flags & HAS_POINTER) {
446 float value = w->adj->value;
447 if (xbutton->button == Button1) value = value ?
448 w->adj->min_value : w->adj->max_value;
449 if (xbutton->button == Button4) value = w->adj->max_value;
450 if (xbutton->button == Button5) value = w->adj->min_value;
451 adj_set_value(w->adj, value);
452 w->state = (int) w->adj->value ? 3 : 1;
453 } else {
454 w->state = (int) w->adj->value ? 3 : 0;
455 }
456 expose_widget(w);
457}
float min_value
Definition xadjustment.h:90
float max_value
Definition xadjustment.h:92
int button

References Widget_t::adj, adj_set_value(), XEvent::button, expose_widget(), Widget_t::flags, HAS_POINTER, Adjustment_t::max_value, Adjustment_t::min_value, Widget_t::state, and Adjustment_t::value.

Referenced by add_check_box(), add_check_button(), add_image_toggle_button(), add_on_off_button(), add_switch_image_button(), and add_toggle_button().