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

Go to the source code of this file.

Functions

int _menu_remove_low_dash (char *str)
 
void _draw_menu_label (void *w_, void *user_data)
 _draw_menu_label - draw the menu label on expose call
 
void _check_menu_state (void *w_, void *user_data)
 _check_menu_state - follow the mouse pointer when a menu is active
 
void _menu_released (void *w_, void *button_, void *user_data)
 _menu_released - popup the menu on click
 
void _menu_entry_released (void *w_, void *item_, void *user_data)
 _menu_entry_released - the menu release func
 
void _draw_menu_slider (void *w_, void *user_data)
 _draw_menu_slider - draw the menu slider on expose call
 
void _draw_menu (void *w_, void *user_data)
 _draw_menu - draw menu on expose call
 
void _draw_submenu (void *w_, void *user_data)
 _draw_submenu - draw submenu on expose call
 
void _enter_submenu (void *w_, void *user_data)
 _enter_submenu - enter submenu
 
void _leave_submenu (void *w_, void *user_data)
 _leave_submenu - leave submenu
 
void _draw_item (void *w_, void *user_data)
 _draw_item - draw item on expose call
 
void _draw_value_item (void *w_, void *user_data)
 _draw_value_item - draw item on expose call
 
void _draw_accel_item (void *w_, void *user_data)
 _draw_accel_item - draw accel item on expose call
 
void _draw_accel_check_item (void *w_, void *user_data)
 _accel_draw_check_item - draw item on expose call
 
void _draw_check_item (void *w_, void *user_data)
 _draw_check_item - draw item on expose call
 
void _set_viewpoint (void *w_, void *user_data)
 _set_viewpoint - move the view_port to position
 
void _set_menu_viewpoint (void *w_, void *user_data)
 _set_menu_viewpoint - move the view_port to position by slider
 
void _check_item_button_pressed (void *w_, void *button_, void *user_data)
 _check_item_button_pressed - redraw item on button press
 
void _radio_item_button_pressed (void *w_, void *button_, void *user_data)
 _radio_item_button_pressed - redraw item on button press
 
void _value_item_released (void *w_, void *button_, void *user_data)
 _value_item_released - redraw item on button released
 
void _configure_menu (Widget_t *parent, Widget_t *menu, int elem, bool above)
 _configure_menu - set final size and position of menu to a Widget_t
 

Function Documentation

◆ _check_item_button_pressed()

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

_check_item_button_pressed - redraw item on button press

Parameters
*w_- void pointer to view_port
*button_- the xbutton which is pressed
*user_data- attached user_data

Definition at line 458 of file xmenu_private.c.

458 {
459 Widget_t *w = (Widget_t*)w_;
460 if (w->flags & HAS_FOCUS) {
461 float value = w->adj_y->value ? 0.0 : 1.0;
462 adj_set_value(w->adj_y, value);
463 }
464}
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Adjustment_t * adj_y
Definition xwidget.h:495
long long flags
Definition xwidget.h:461
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
@ HAS_FOCUS
Definition xwidget.h:400

References adj_set_value(), Widget_t::adj_y, Widget_t::flags, HAS_FOCUS, and Adjustment_t::value.

Referenced by menu_add_check_item().

◆ _check_menu_state()

void _check_menu_state ( void *  w_,
void *  user_data 
)

_check_menu_state - follow the mouse pointer when a menu is active

Parameters
*w_- the menu to check
*user_data- attached user_data

Definition at line 79 of file xmenu_private.c.

79 {
80 Widget_t *w = (Widget_t*)w_;
81 Widget_t *parent = w->parent;
82 int i = parent->childlist->elem-1;
83 for(;i>-1;i--) {
84 Widget_t *wid = parent->childlist->childs[i];
86 if ((wid->childlist->childs[0] == w->app->hold_grab) && (wid !=w)) {
87#ifdef _WIN32 //SetCaptureDisabled//XUngrabPointer
88 //ReleaseCapture(); // SetCapture() is currently disabled in pop_menu_show()
89#else
90 XUngrabPointer(w->app->dpy,CurrentTime);
91#endif
93 w->app->hold_grab = NULL;
94 if (w->app->submenu) {
96 w->app->submenu = NULL;
97 }
98 pop_menu_show(w, w->childlist->childs[0], 6, true);
99 break;
100 }
101 }
102 }
103 os_transparent_draw(w_, user_data);
104}
Widget_t ** childs
Definition xchildlist.h:51
void * parent
Definition xwidget.h:471
Childlist_t * childlist
Definition xwidget.h:499
Xputty * app
Definition xwidget.h:465
Display * dpy
Definition xputty.h:232
Widget_t * hold_grab
Definition xputty.h:238
Widget_t * submenu
Definition xputty.h:242
int childlist_has_child(Childlist_t *childlist)
childlist_has_child - check if a Widget_t Childlist_t contain a child
Definition xchildlist.c:89
void pop_menu_show(Widget_t *parent, Widget_t *menu, int elem, bool above)
pop_menu_show - pop up a menu to a Widget_t
Definition xmenu.c:27
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
void widget_hide(Widget_t *w)
widget_hide - unmap/hide a Widget_t
Definition xwidget.c:368

References Widget_t::app, Widget_t::childlist, childlist_has_child(), Childlist_t::childs, Xputty::dpy, Childlist_t::elem, Xputty::hold_grab, os_transparent_draw(), Widget_t::parent, pop_menu_show(), Xputty::submenu, and widget_hide().

Referenced by add_menu().

◆ _configure_menu()

void _configure_menu ( Widget_t parent,
Widget_t menu,
int  elem,
bool  above 
)

_configure_menu - set final size and position of menu to a Widget_t

Parameters
*parent- pointer to the Widget_t the menu should pop over
*menu- the menu to show
elem- how many entries to show (max value)
above- show menu above or below the parent Widget_t

Definition at line 478 of file xmenu_private.c.

478 {
479 Widget_t* view_port = menu->childlist->childs[0];
480 Widget_t *slider = menu->childlist->childs[1];
481 if (!view_port->childlist->elem) return;
482 Metrics_t metrics;
483 os_get_window_metrics(view_port->childlist->childs[0], &metrics);
484 int height = metrics.height;
485 int x1, y1;
486 int posy = (above) ? parent->height : 0;
487 int posx = (above) ? 0 : parent->width ;
488 os_translate_coords(parent, parent->widget, os_get_root_window(parent->app, IS_WIDGET), posx, posy, &x1, &y1);
489 int item_width = 1.0;
490 cairo_text_extents_t extents;
491 int i = view_port->childlist->elem-1;
492 set_adjustment(view_port->adj,0.0, view_port->adj->value, 0.0, i-(elem-1),1.0, CL_VIEWPORT);
493 bool is_not_scrolable = false;
494 if(view_port->childlist->elem <= elem) {
495 elem = view_port->childlist->elem;
496 is_not_scrolable = true;
497 }
498 for(;i>-1;i--) {
499 Widget_t *w = view_port->childlist->childs[i];
500 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
501 cairo_text_extents(w->crb,w->label , &extents);
502
503 item_width = max(item_width, (int)extents.width+40);
504 if(is_not_scrolable) w->scale.gravity = NORTHEAST;
505 }
506 if(above) {
507 if(item_width<parent->width)item_width = parent->width;
508 }
509 slider->adj->step = max(0.0,1.0/(view_port->childlist->elem-elem));
510 adj_set_scale(slider->adj, ((float)view_port->childlist->elem/(float)elem)/25.0);
511
512 int screen_height = os_get_screen_height(parent);
513 if (y1+(height*elem) > screen_height) y1 = y1-((height*elem)+parent->height);
514 os_resize_window (menu->app->dpy, menu, item_width, height*elem);
515 os_resize_window (view_port->app->dpy, view_port, item_width, height*view_port->childlist->elem);
516 os_move_window(menu->app->dpy,slider,item_width-10, 0);
517 os_resize_window(menu->app->dpy,slider,10,height*elem);
518 os_move_window(menu->app->dpy,menu,x1, y1);
519}
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
float ascale
Definition xwidget.h:369
Gravity gravity
Definition xwidget.h:347
Resize_t scale
Definition xwidget.h:525
int width
Definition xwidget.h:521
Adjustment_t * adj
Definition xwidget.h:497
Window widget
Definition xwidget.h:469
cairo_t * crb
Definition xwidget.h:489
const char * label
Definition xwidget.h:463
int height
Definition xwidget.h:523
int normal_font
Definition xputty.h:248
void set_adjustment(Adjustment_t *adj, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*set_adjustment - set a new range to a existing Adjustment_t or create if it not exists yet
Definition xadjustment.c:80
@ CL_VIEWPORT
Definition xadjustment.h:57
void adj_set_scale(Adjustment_t *adj, float value)
adj_set_scale - internal use to scale the pointer movement (0.1 -1.0)
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_resize_window(Display *dpy, Widget_t *w, int x, int y)
os_resize_window - Resize a Widget_t
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void os_translate_coords(Widget_t *w, Window from_window, Window to_window, int from_x, int from_y, int *to_x, int *to_y)
os_translate_coords - get x,y related to destination Window
void os_move_window(Display *dpy, Widget_t *w, int x, int y)
os_move_window - Move a Widget_t
int os_get_screen_height(Widget_t *w)
os_get_screen_height - Get the height of the used Display
@ NORTHEAST
Definition xwidget.h:302
@ IS_WIDGET
Definition xwidget.h:388

References Widget_t::adj, adj_set_scale(), Widget_t::app, Resize_t::ascale, Widget_t::childlist, Childlist_t::childs, CL_VIEWPORT, Widget_t::crb, Xputty::dpy, Childlist_t::elem, Resize_t::gravity, Metrics_t::height, Widget_t::height, IS_WIDGET, Widget_t::label, Xputty::normal_font, NORTHEAST, os_get_root_window(), os_get_screen_height(), os_get_window_metrics(), os_move_window(), os_resize_window(), os_translate_coords(), Widget_t::scale, set_adjustment(), Adjustment_t::step, Adjustment_t::value, Widget_t::widget, and Widget_t::width.

Referenced by pop_menu_show(), and pop_submenu_show().

◆ _draw_accel_check_item()

void _draw_accel_check_item ( void *  w_,
void *  user_data 
)

_accel_draw_check_item - draw item on expose call

Parameters
*w_- the item to draw
*user_data- attached user_data

Definition at line 391 of file xmenu_private.c.

391 {
392 _draw_accel_item(w_, user_data);
393 Widget_t *w = (Widget_t*)w_;
394 Metrics_t metrics;
395 os_get_window_metrics(w, &metrics);
396 int height = metrics.height;
397 if (w->flags & IS_RADIO) {
398 cairo_arc(w->crb, height/3, height/2, height/6, 0, 2 * M_PI );
399 } else {
400 cairo_rectangle(w->crb, height/6, height/3, height/3 , height/3);
401 }
403 cairo_fill(w->crb);
404 if ((int) w->adj_y->value) {
405 if (w->flags & IS_RADIO) {
406 cairo_arc(w->crb, height/3, height/2, height/6-2, 0, 2 * M_PI );
407 } else {
408 cairo_rectangle(w->crb, height/6+1, height/3+1, height/3-2 , height/3-2);
409 }
411 cairo_fill(w->crb);
412 }
413}
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_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
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:273
@ ACTIVE_
Definition xcolor.h:47
void _draw_accel_item(void *w_, void *user_data)
_draw_accel_item - draw accel item on expose call
@ IS_RADIO
Definition xwidget.h:394

References _draw_accel_item(), ACTIVE_, Widget_t::adj_y, Widget_t::crb, Widget_t::flags, get_color_state(), Metrics_t::height, IS_RADIO, os_get_window_metrics(), use_fg_color_scheme(), use_shadow_color_scheme(), and Adjustment_t::value.

Referenced by menu_add_accel_check_entry().

◆ _draw_accel_item()

void _draw_accel_item ( void *  w_,
void *  user_data 
)

_draw_accel_item - draw accel item on expose call

Parameters
*w_- the item to draw
*user_data- attached user_data

show label

Definition at line 341 of file xmenu_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;
347 int height = metrics.height;
348 if (!metrics.visible) return;
349
351 cairo_rectangle(w->crb, 0, 0, width , height);
352 if(w->state==1) {
354 } else if(w->state==2) {
356 } else if(w->state==3) {
358 }
359 cairo_fill_preserve(w->crb);
360 cairo_set_line_width(w->crb, 1.0);
362 cairo_stroke(w->crb);
363
364 cairo_text_extents_t extents;
367 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
368
369 if (strstr(w->label, "_")) {
370 cairo_text_extents(w->crb, "--", &extents);
371 double underline = extents.width;
372 strncpy(w->input_label,w->label, sizeof(w->input_label)-1);
374 int len = strlen(w->input_label);
375 cairo_text_extents(w->crb,w->input_label , &extents);
376 int set_line = (extents.width/len) * pos;
377 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
378 cairo_show_text(w->crb, w->input_label);
379 cairo_set_line_width(w->crb, 1.0);
380 cairo_move_to (w->crb, 20 + set_line, (height+extents.height)*0.55);
381 cairo_line_to(w->crb,20 + set_line + underline, (height+extents.height)*0.55);
382 cairo_stroke(w->crb);
383 } else {
384 cairo_text_extents(w->crb,w->label , &extents);
385 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
386 cairo_show_text(w->crb, w->label);
387 }
388 cairo_new_path (w->crb);
389}
int state
Definition xwidget.h:511
char input_label[32]
Definition xwidget.h:459
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
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 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
@ NORMAL_
Definition xcolor.h:44
@ SELECTED_
Definition xcolor.h:46
@ PRELIGHT_
Definition xcolor.h:45
int _menu_remove_low_dash(char *str)

References _menu_remove_low_dash(), ACTIVE_, Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::input_label, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_window_metrics(), PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, use_base_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by _draw_accel_check_item(), and menu_add_accel_item().

◆ _draw_check_item()

void _draw_check_item ( void *  w_,
void *  user_data 
)

_draw_check_item - draw item on expose call

Parameters
*w_- the item to draw
*user_data- attached user_data

Definition at line 415 of file xmenu_private.c.

415 {
416 _draw_item(w_, user_data);
417 Widget_t *w = (Widget_t*)w_;
418 Metrics_t metrics;
419 os_get_window_metrics(w, &metrics);
420 int height = metrics.height;
421 if (w->flags & IS_RADIO) {
422 cairo_arc(w->crb, height/3, height/2, height/6, 0, 2 * M_PI );
423 } else {
424 cairo_rectangle(w->crb, height/6, height/3, height/3 , height/3);
425 }
427 cairo_fill(w->crb);
428 if ((int) w->adj_y->value) {
429 if (w->flags & IS_RADIO) {
430 cairo_arc(w->crb, height/3, height/2, height/6-2, 0, 2 * M_PI );
431 } else {
432 cairo_rectangle(w->crb, height/6+1, height/3+1, height/3-2 , height/3-2);
433 }
435 cairo_fill(w->crb);
436 }
437}
void _draw_item(void *w_, void *user_data)
_draw_item - draw item on expose call

References _draw_item(), ACTIVE_, Widget_t::adj_y, Widget_t::crb, Widget_t::flags, get_color_state(), Metrics_t::height, IS_RADIO, os_get_window_metrics(), use_fg_color_scheme(), use_shadow_color_scheme(), and Adjustment_t::value.

Referenced by menu_add_check_item(), and menu_add_radio_item().

◆ _draw_item()

void _draw_item ( void *  w_,
void *  user_data 
)

_draw_item - draw item on expose call

Parameters
*w_- the item to draw
*user_data- attached user_data

show label

Definition at line 266 of file xmenu_private.c.

266 {
267 Widget_t *w = (Widget_t*)w_;
268 if (!w) return;
269 Metrics_t metrics;
270 os_get_window_metrics(w, &metrics);
271 int width = metrics.width;
272 int height = metrics.height;
273 if (!metrics.visible) return;
274
276 cairo_rectangle(w->crb, 0, 0, width , height);
277 if(w->state==1) {
279 } else if(w->state==2) {
281 } else if(w->state==3) {
283 }
284 cairo_fill_preserve(w->crb);
285 cairo_set_line_width(w->crb, 1.0);
287 cairo_stroke(w->crb);
288
289 cairo_text_extents_t extents;
292 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
293 cairo_text_extents(w->crb,w->label , &extents);
294 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
295 cairo_show_text(w->crb, w->label);
296 cairo_new_path (w->crb);
297}

References ACTIVE_, Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_window_metrics(), PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, use_base_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by _draw_check_item(), menu_add_item(), menu_add_numeric_items(), and menu_add_value_entry().

◆ _draw_menu()

void _draw_menu ( void *  w_,
void *  user_data 
)

_draw_menu - draw menu on expose call

Parameters
*w_- the menu to draw
*user_data- attached user_data

Definition at line 152 of file xmenu_private.c.

152 {
153 Widget_t *w = (Widget_t*)w_;
154 if (!w) return;
156 cairo_paint (w->crb);
157}
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Definition xcolor.c:252

References Widget_t::crb, get_color_state(), and use_bg_color_scheme().

Referenced by create_menu().

◆ _draw_menu_label()

void _draw_menu_label ( void *  w_,
void *  user_data 
)

_draw_menu_label - draw the menu label on expose call

Parameters
*w_- the menu to draw
*user_data- attached user_data

Definition at line 44 of file xmenu_private.c.

44 {
45 Widget_t *w = (Widget_t*)w_;
46 Metrics_t metrics;
47 os_get_window_metrics(w, &metrics);
48 int height = metrics.height;
49
50 cairo_text_extents_t extents;
52 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
53 cairo_text_extents(w->crb, "A", &extents);
54 double lh = extents.height;
55
56 if (strstr(w->label, "_")) {
57 cairo_text_extents(w->crb, "--", &extents);
58 double underline = extents.width;
59 strncpy(w->input_label,w->label, sizeof(w->input_label)-1);
61 int len = strlen(w->input_label);
62 cairo_text_extents(w->crb,w->input_label , &extents);
63 int set_line = (extents.width/len) * pos;
64 cairo_move_to (w->crb, 10, (height+lh)*0.5);
65 cairo_show_text(w->crb, w->input_label);
66 cairo_set_line_width(w->crb, 1.0);
67 cairo_move_to (w->crb, 10 + set_line, (height+lh)*0.55);
68 cairo_line_to(w->crb,10 + set_line + underline, (height+lh)*0.55);
69 cairo_stroke(w->crb);
70 } else {
71 cairo_text_extents(w->crb,w->label , &extents);
72 cairo_move_to (w->crb, 10, (height+lh)*0.5);
73 cairo_show_text(w->crb, w->label);
74 }
75
76 cairo_new_path (w->crb);
77}

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

Referenced by add_menu().

◆ _draw_menu_slider()

void _draw_menu_slider ( void *  w_,
void *  user_data 
)

_draw_menu_slider - draw the menu slider on expose call

Parameters
*w_- the menu to draw
*user_data- attached user_data

Definition at line 132 of file xmenu_private.c.

132 {
133 Widget_t *w = (Widget_t*)w_;
134 int v = (int)w->adj->max_value;
135 if (!v) return;
136 Metrics_t metrics;
137 os_get_window_metrics(w, &metrics);
138 int width = metrics.width;
139 int height = metrics.height;
140 if (!metrics.visible) return;
141 float sliderstate = adj_get_state(w->adj);
143 cairo_rectangle(w->crb, 0,0,width,height);
144 cairo_fill_preserve(w->crb);
146 cairo_fill(w->crb);
148 cairo_rectangle(w->crb, 0,(height-10)*sliderstate,width,10);
149 cairo_fill(w->crb);
150}
float max_value
Definition xadjustment.h:92
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_t

References Widget_t::adj, adj_get_state(), Widget_t::crb, get_color_state(), Metrics_t::height, Adjustment_t::max_value, NORMAL_, os_get_window_metrics(), use_bg_color_scheme(), use_shadow_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by create_menu().

◆ _draw_submenu()

void _draw_submenu ( void *  w_,
void *  user_data 
)

_draw_submenu - draw submenu on expose call

Parameters
*w_- the menu to draw
*user_data- attached user_data

show label

Definition at line 159 of file xmenu_private.c.

159 {
160 Widget_t *w = (Widget_t*)w_;
161 if (!w) return;
162 Metrics_t metrics;
163 os_get_window_metrics(w, &metrics);
164 int width = metrics.width;
165 int height = metrics.height;
166 if (!metrics.visible) return;
167
169 cairo_rectangle(w->crb, 0, 0, width , height);
170 if(w->state==1) {
172 } else if(w->state==2) {
174 } else if(w->state==3) {
176 }
177 cairo_fill_preserve(w->crb);
178 cairo_set_line_width(w->crb, 1.0);
180 cairo_stroke(w->crb);
181
182 cairo_text_extents_t extents;
185 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
186
187 if (strstr(w->label, "_")) {
188 cairo_text_extents(w->crb, "--", &extents);
189 double underline = extents.width;
190 strncpy(w->input_label,w->label, sizeof(w->input_label)-1);
192 int len = strlen(w->input_label);
193 cairo_text_extents(w->crb,w->input_label , &extents);
194 int set_line = (extents.width/len) * pos;
195 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
196 cairo_show_text(w->crb, w->input_label);
197 cairo_set_line_width(w->crb, 1.0);
198 cairo_move_to (w->crb, 20 + set_line, (height+extents.height)*0.55);
199 cairo_line_to(w->crb,20 + set_line + underline, (height+extents.height)*0.55);
200 cairo_stroke(w->crb);
201 } else {
202 cairo_text_extents(w->crb,w->label , &extents);
203 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
204 cairo_show_text(w->crb, w->label);
205 }
206 cairo_move_to (w->crb, (width-15), (height+extents.height)*0.5);
207 cairo_show_text(w->crb, ">");
208 cairo_new_path (w->crb);
209}

References _menu_remove_low_dash(), ACTIVE_, Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::input_label, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_window_metrics(), PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, use_base_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by cmenu_add_submenu(), and menu_add_submenu().

◆ _draw_value_item()

void _draw_value_item ( void *  w_,
void *  user_data 
)

_draw_value_item - draw item on expose call

Parameters
*w_- the item to draw
*user_data- attached user_data

show value on the item

Definition at line 299 of file xmenu_private.c.

299 {
300 Widget_t *w = (Widget_t*)w_;
301 if (!w) return;
302 Metrics_t metrics;
303 os_get_window_metrics(w, &metrics);
304 int width = metrics.width-2;
305 int height = metrics.height-2;
306 if (!metrics.visible) return;
307
309 cairo_rectangle(w->crb, 0, 0, width , height);
310 if(w->state==1) {
312 } else if(w->state==2) {
314 } else if(w->state==3) {
316 }
317 cairo_fill_preserve(w->crb);
318 cairo_set_line_width(w->crb, 1.0);
320 cairo_stroke(w->crb);
322 cairo_text_extents_t extents;
324 char s[64];
325 const char* format[] = {"%.1f", "%.2f", "%.3f"};
326 float value = adj_get_value(w->adj);
327 if (fabs(w->adj->step)>0.99) {
328 snprintf(s, 63,"%d", (int) value);
329 } else if (fabs(w->adj->step)>0.09) {
330 snprintf(s, 63, format[1-1], value);
331 } else {
332 snprintf(s, 63, format[2-1], value);
333 }
334 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
335 cairo_text_extents(w->crb, s, &extents);
336 cairo_move_to (w->crb, 20, (height+extents.height)*0.5);
337 cairo_show_text(w->crb, s);
338 cairo_new_path (w->crb);
339}
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t

References ACTIVE_, Widget_t::adj, adj_get_value(), Widget_t::app, Resize_t::ascale, Widget_t::crb, get_color_state(), Metrics_t::height, NORMAL_, Xputty::normal_font, os_get_window_metrics(), PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, Adjustment_t::step, use_base_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by menu_add_value_entry(), and menu_add_value_item().

◆ _enter_submenu()

void _enter_submenu ( void *  w_,
void *  user_data 
)

_enter_submenu - enter submenu

Parameters
*w_- the submenu entered
*user_data- attached user_data

Definition at line 211 of file xmenu_private.c.

211 {
212 Widget_t *w = (Widget_t*)w_;
213 Metrics_t metrics;
214 os_get_window_metrics(w, &metrics);
215 if (!metrics.visible) return;
217 if (w->app->submenu) {
218 if (w->app->submenu != w->childlist->childs[0]) {
220 w->app->submenu = NULL;
221 }
222 }
223 pop_submenu_show(w, w->childlist->childs[0], 6, false);
224 }
225 os_transparent_draw(w_, user_data);
226}
void pop_submenu_show(Widget_t *parent, Widget_t *menu, int elem, bool above)
pop_submenu_show - pop up a submenu to a Widget_t
Definition xmenu.c:41

References Widget_t::app, Widget_t::childlist, childlist_has_child(), Childlist_t::childs, os_get_window_metrics(), os_transparent_draw(), pop_submenu_show(), Xputty::submenu, Metrics_t::visible, and widget_hide().

Referenced by cmenu_add_submenu(), and menu_add_submenu().

◆ _leave_submenu()

void _leave_submenu ( void *  w_,
void *  user_data 
)

_leave_submenu - leave submenu

Parameters
*w_- the submenu leaved
*user_data- attached user_data

Definition at line 228 of file xmenu_private.c.

228 {
229 Widget_t *w = (Widget_t*)w_;
230
231 if (!w->data) {
232#ifdef __linux__
233 XCrossingEvent notify;
234 memset(&notify, 0, sizeof(notify));
235 notify.type = LeaveNotify;
236 notify.display = w->app->dpy;
237 notify.send_event = True;
238 notify.subwindow = w->widget;
239 notify.window = w->widget;
240 notify.x = 1;
241 notify.y = 1;
242 notify.same_screen = True;
243 notify.focus = False;
244 XSendEvent(w->app->dpy, w->widget,True,LeaveWindowMask, (XEvent*)&notify);
245#endif
246 w->data = 1;
247 return;
248 }
249 w->data = 0;
251 Widget_t *parent = (Widget_t*) w->parent;
252 int i=0;
253 for(;i<parent->childlist->elem;i++) {
254 if (parent->childlist->childs[i]->flags & HAS_FOCUS) {
256 if (w->app->submenu == w->childlist->childs[0])
257 w->app->submenu = NULL;
258 break;
259 }
260 }
261
262 }
263 os_transparent_draw(w_, user_data);
264}
int data
Definition xwidget.h:509

References Widget_t::app, Widget_t::childlist, childlist_has_child(), Childlist_t::childs, Widget_t::data, Xputty::dpy, Childlist_t::elem, Widget_t::flags, HAS_FOCUS, os_transparent_draw(), Widget_t::parent, Xputty::submenu, Widget_t::widget, and widget_hide().

Referenced by cmenu_add_submenu(), and menu_add_submenu().

◆ _menu_entry_released()

void _menu_entry_released ( void *  w_,
void *  item_,
void *  user_data 
)

_menu_entry_released - the menu release func

Parameters
*w_- void pointer to the Widget_t menu
*item_- void pointer to the selected item *(int*)
*user_data- void pointer to the item label *(const char**)

Definition at line 114 of file xmenu_private.c.

114 {
115 Widget_t *w = (Widget_t*)w_;
116 Widget_t * bar = NULL;
117 int i = w->app->childlist->elem-1;
118 for(;i>-1;i--) {
119 Widget_t *wid = w->app->childlist->childs[i];
120 if (wid == w) {
121 bar = w->app->childlist->childs[i-1];
122 int old_value = (int)adj_get_value(bar->adj);
123 adj_set_value(bar->adj, (float)*(int*)item_);
124 if (old_value == *(int*)item_) {
125 bar->func.value_changed_callback(bar, NULL);
126 }
127 break;
128 }
129 }
130}
xevfunc value_changed_callback
Definition xwidget.h:90
Func_t func
Definition xwidget.h:481
Childlist_t * childlist
Definition xputty.h:230

References Widget_t::adj, adj_get_value(), adj_set_value(), Widget_t::app, Xputty::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::func, and Func_t::value_changed_callback.

Referenced by add_menu(), cmenu_add_submenu(), and menu_add_submenu().

◆ _menu_released()

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

_menu_released - popup the menu on click

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 106 of file xmenu_private.c.

106 {
107 Widget_t *w = (Widget_t*)w_;
108 XButtonEvent *xbutton = (XButtonEvent*)button_;
109 if (w->flags & HAS_POINTER && xbutton->button == Button1) {
110 pop_menu_show(w, w->childlist->childs[0], 6, true);
111 }
112}
int button
@ HAS_POINTER
Definition xwidget.h:402

References XEvent::button, Widget_t::childlist, Childlist_t::childs, Widget_t::flags, HAS_POINTER, and pop_menu_show().

Referenced by add_menu().

◆ _menu_remove_low_dash()

int _menu_remove_low_dash ( char *  str)

Definition at line 25 of file xmenu_private.c.

25 {
26
27 char *src;
28 char *dst;
29 int i = 0;
30 int r = 0;
31 for (src = dst = str; *src != '\0'; src++) {
32 *dst = *src;
33 if (*dst != '_') {
34 dst++;
35 } else {
36 r = i;
37 }
38 i++;
39 }
40 *dst = '\0';
41 return r;
42}

Referenced by _draw_accel_item(), _draw_menu_label(), and _draw_submenu().

◆ _radio_item_button_pressed()

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

_radio_item_button_pressed - redraw item on button press

Parameters
*w_- void pointer to view_port
*button_- the xbutton which is pressed
*user_data- attached user_data

Definition at line 466 of file xmenu_private.c.

466 {
467 Widget_t *w = (Widget_t*)w_;
468 if (w->flags & HAS_FOCUS) {
470 }
471}
void radio_item_set_active(Widget_t *w)
radio_item_set_active - activate selected radio item
Definition xmenu.c:326

References Widget_t::flags, HAS_FOCUS, and radio_item_set_active().

Referenced by menu_add_radio_item().

◆ _set_menu_viewpoint()

void _set_menu_viewpoint ( void *  w_,
void *  user_data 
)

_set_menu_viewpoint - move the view_port to position by slider

Parameters
*w_- void pointer to view_port
*user_data- attached user_data

Definition at line 451 of file xmenu_private.c.

451 {
452 Widget_t *w = (Widget_t*)w_;
453 Widget_t *menu = (Widget_t*)w->parent;
454 Widget_t*view_port = menu->childlist->childs[0];
455 adj_set_state(view_port->adj,adj_get_state(w->adj));
456}
void adj_set_state(Adjustment_t *adj, float state)
adj_set_state - set the current state of the Adjustment_t

References Widget_t::adj, adj_get_state(), adj_set_state(), Widget_t::childlist, Childlist_t::childs, and Widget_t::parent.

Referenced by create_menu().

◆ _set_viewpoint()

void _set_viewpoint ( void *  w_,
void *  user_data 
)

_set_viewpoint - move the view_port to position

Parameters
*w_- void pointer to view_port
*user_data- attached user_data

Definition at line 439 of file xmenu_private.c.

439 {
440 Widget_t *w = (Widget_t*)w_;
441 Widget_t *menu = (Widget_t*)w->parent;
442 Widget_t* slider = menu->childlist->childs[1];
443 int v = (int)max(0,adj_get_value(w->adj));
444 Metrics_t metrics;
445 os_get_window_metrics(w->childlist->childs[0], &metrics);
446 int height = metrics.height;
447 os_move_window(w->app->dpy,w,0, -height*v);
448 adj_set_state(slider->adj,adj_get_state(w->adj));
449}

References Widget_t::adj, adj_get_state(), adj_get_value(), adj_set_state(), Widget_t::app, Widget_t::childlist, Childlist_t::childs, Xputty::dpy, Metrics_t::height, os_get_window_metrics(), os_move_window(), and Widget_t::parent.

Referenced by create_viewport().

◆ _value_item_released()

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

_value_item_released - redraw item on button released

Parameters
*w_- void pointer to view_port
*button_- the xbutton which is pressed
*user_data- attached user_data

Definition at line 473 of file xmenu_private.c.

473 {
474 Widget_t *w = (Widget_t*)w_;
475 expose_widget(w);
476}
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 menu_add_value_entry(), and menu_add_value_item().