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

Go to the source code of this file.

Functions

void _draw_combobox_button (void *w_, void *user_data)
 _draw_combobox_button - internal draw the combobox button to the buffer
 
void _draw_combobox (void *w_, void *user_data)
 _draw_combobox - internal draw the combobox to the buffer
 
void _draw_combobox_menu (void *w_, void *user_data)
 _draw_combobox_menu - internal draw the combobox menu to the buffer
 
void _draw_combobox_entrys (void *w_, void *user_data)
 _draw_combobox_entrys - internal draw the combobox entrys to the buffer
 
void _combobox_motion (void *w_, void *xmotion_, void *user_data)
 _combobox_motion - mouse pointer move in viewport
 
void _combobox_key_pressed (void *w_, void *xkey_, void *user_data)
 _combobox_key_released - viewport entry released key
 
void _combobox_entry_released (void *w_, void *button_, void *user_data)
 _combobox_entry_released - viewport entry released mouse button
 
void _leave_combobox (void *w_, void *user_data)
 _leave_combobox - mouse pointer leave the combobox
 
void _reconfigure_combobox_viewport (void *w_, void *user_data)
 _reconfigure_combobox_viewport - set slider scale and step to match viewport entrys
 
void _set_combobox_viewpoint (void *w_, void *user_data)
 _set_combobox_viewpoint - set the slider state from viewport position
 
void _draw_combobox_menu_slider (void *w_, void *user_data)
 _draw_combobox_menu_slider - internal draw the combobox menu slider
 
void _set_combobox_menu_viewport (void *w_, void *user_data)
 _set_combobox_menu_viewport - set the viewport position from slider state
 
void _combobox_button_released (void *w_, void *button_, void *user_data)
 _combobox_button_released - popup menu on right click
 
void _button_combobox_released (void *w_, void *button_, void *user_data)
 _button_combobox_released - popup the combobox menu
 
void _entry_released (void *w_, void *item_, void *user_data)
 _entry_released - the combobox menu release func
 
void _set_entry (void *w_, void *user_data)
 _set_entry - set the active combobox entry on adjustment change
 
void _configure_combobox_menu (Widget_t *parent, Widget_t *menu, int elem, bool above)
 _configure_combobox_menu - set final size and position of menu to a Widget_t
 

Function Documentation

◆ _button_combobox_released()

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

_button_combobox_released - popup the combobox menu

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 382 of file xcombobox_private.c.

382 {
383 Widget_t *w = (Widget_t*)w_;
384 XButtonEvent *xbutton = (XButtonEvent*)button_;
385 if (w->flags & HAS_POINTER && xbutton->button == Button1) {
386 Widget_t *parent = (Widget_t*)w->parent;
387 w->state=1;
388 pop_combobox_menu_show(parent, parent->childlist->childs[1], true);
389 }
390 adj_set_value(w->adj, 0.0);
391}
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Adjustment_t * adj
Definition xwidget.h:497
void * parent
Definition xwidget.h:471
int state
Definition xwidget.h:511
long long flags
Definition xwidget.h:461
int button
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
void pop_combobox_menu_show(Widget_t *parent, Widget_t *menu, bool above)
Definition xcombobox.c:82
@ HAS_POINTER
Definition xwidget.h:402

References Widget_t::adj, adj_set_value(), XEvent::button, Widget_t::childlist, Childlist_t::childs, Widget_t::flags, HAS_POINTER, Widget_t::parent, pop_combobox_menu_show(), and Widget_t::state.

Referenced by add_combobox().

◆ _combobox_button_released()

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

_combobox_button_released - popup menu on right 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 371 of file xcombobox_private.c.

371 {
372 Widget_t *w = (Widget_t*)w_;
373 if (w->flags & HAS_POINTER){
374 XButtonEvent *xbutton = (XButtonEvent*)button_;
375 if (xbutton->button == Button3) {
376 w->state=1;
377 pop_combobox_menu_show(w, w->childlist->childs[1], true);
378 }
379 }
380}
Widget_t ** childs
Definition xchildlist.h:51
Childlist_t * childlist
Definition xwidget.h:499

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

Referenced by add_combobox().

◆ _combobox_entry_released()

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

_combobox_entry_released - viewport entry released mouse button

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

Definition at line 278 of file xcombobox_private.c.

278 {
279 Widget_t *w = (Widget_t*)w_;
280 if (w->flags & HAS_POINTER) {
281 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
282 XButtonEvent *xbutton = (XButtonEvent*)button_;
283 Metrics_t metrics;
284 os_get_window_metrics(w, &metrics);
285 int height = metrics.height-2;
286 int _items = height/(height/25);
287 int prelight_item = xbutton->y/_items + (int)max(0,adj_get_value(w->adj));
288 if(xbutton->button == Button4) {
289 if(prelight_item != comboboxlist->prelight_item) {
290 comboboxlist->prelight_item = prelight_item;
291 }
292 } else if (xbutton->button == Button5) {
293 if(prelight_item != comboboxlist->prelight_item) {
294 comboboxlist->prelight_item = prelight_item;
295 }
296 } else if(xbutton->button == Button1) {
297 Widget_t* combobox = (Widget_t*) w->parent;
298 comboboxlist->active_item = comboboxlist->prelight_item;
299 adj_set_value(combobox->adj,comboboxlist->active_item);
300 adj_set_value(comboboxlist->combobox->adj,comboboxlist->active_item +
301 comboboxlist->combobox->adj->min_value);
302 combobox->func.button_release_callback(combobox,NULL,NULL);
303 }
304 }
305}
ComboBox_t - struct to hold information for the combobox.
Definition xcombobox.h:45
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
void * parent_struct
Definition xwidget.h:473
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
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 ComboBox_t::active_item, Widget_t::adj, adj_get_value(), adj_set_value(), XEvent::button, Func_t::button_release_callback, ComboBox_t::combobox, Widget_t::flags, Widget_t::func, HAS_POINTER, Metrics_t::height, Adjustment_t::min_value, os_get_window_metrics(), Widget_t::parent, Widget_t::parent_struct, ComboBox_t::prelight_item, and XEvent::y.

Referenced by create_combobox_viewport().

◆ _combobox_key_pressed()

void _combobox_key_pressed ( void *  w_,
void *  xkey_,
void *  user_data 
)

_combobox_key_released - viewport entry released key

Parameters
*w_- void pointer to the Widget_t viewport
*xkey_- void pointer to XEvent.xkey struct
*user_data- void pointer to attached user_data

Definition at line 255 of file xcombobox_private.c.

255 {
256 Widget_t *w = (Widget_t*)w_;
257 XKeyEvent *xkey = (XKeyEvent*)xkey_;
258 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
259 Metrics_t metrics;
260 os_get_window_metrics(w, &metrics);
261 int height = metrics.height-2;
262 int _items = height/(height/25);
263 comboboxlist->prelight_item = xkey->y/_items + (int)max(0,adj_get_value(w->adj));
264 int nk = key_mapping(w->app->dpy, xkey);
265 if (nk) {
266 switch (nk) {
267 case 3:
268 case 4:
269 case 5:
270 case 6: comboboxlist->prelight_item = xkey->y/_items + (int)max(0,adj_get_value(w->adj));
271 break;
272 default:
273 break;
274 }
275 }
276}
int key_mapping(Display *dpy, XKeyEvent *xkey)
_key_mapping - modifier key's mapped to a integer value
Definition xwidget.c:37

References Widget_t::adj, adj_get_value(), Widget_t::app, Xputty::dpy, Metrics_t::height, key_mapping(), os_get_window_metrics(), Widget_t::parent_struct, ComboBox_t::prelight_item, and XEvent::y.

Referenced by create_combobox_viewport().

◆ _combobox_motion()

void _combobox_motion ( void *  w_,
void *  xmotion_,
void *  user_data 
)

_combobox_motion - mouse pointer move in viewport

Parameters
*w_- void pointer to the Widget_t viewport
*xmotion_- void pointer to XEvent.xmotion struct
*user_data- void pointer to attached user_data

Definition at line 240 of file xcombobox_private.c.

240 {
241 Widget_t *w = (Widget_t*)w_;
242 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
243 XMotionEvent *xmotion = (XMotionEvent*)xmotion_;
244 Metrics_t metrics;
245 os_get_window_metrics(w, &metrics);
246 int height = metrics.height-2;
247 int _items = height/(height/25);
248 int prelight_item = (xmotion->y/_items) + (int)max(0,adj_get_value(w->adj));
249 if(prelight_item != comboboxlist->prelight_item) {
250 comboboxlist->prelight_item = prelight_item;
251 }
252 expose_widget(w);
253}
void expose_widget(Widget_t *w)
expose_widgets - send a expose event (EXPOSE) to a Widget_t
Definition xwidget.c:445

References Widget_t::adj, adj_get_value(), expose_widget(), Metrics_t::height, os_get_window_metrics(), Widget_t::parent_struct, ComboBox_t::prelight_item, and XEvent::y.

Referenced by create_combobox_viewport().

◆ _configure_combobox_menu()

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

_configure_combobox_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 entrys to show
above- show menu below (0) or beside (1) the combobox

Definition at line 415 of file xcombobox_private.c.

415 {
416 Widget_t* view_port = menu->childlist->childs[0];
417 ComboBox_t *comboboxlist = (ComboBox_t*)view_port->parent_struct;
418 Widget_t *slider = menu->childlist->childs[1];
419 if (!comboboxlist->list_size) return;
420 int height = 25;
421 int x1, y1;
422 int posy = (above) ? parent->height : 0;
423 os_translate_coords(parent, parent->widget, os_get_root_window(parent->app, IS_WIDGET), 0, posy, &x1, &y1);
424 int item_width = 1.0;
425 cairo_text_extents_t extents;
426 int i = comboboxlist->list_size-1;
427 float m = view_port->adj->min_value;
428 set_adjustment(view_port->adj,0.0, view_port->adj->value, m, i-(elem-1)+m,1.0, CL_VIEWPORT);
429 bool is_not_scrolable = false;
430 if(comboboxlist->list_size <= elem) {
431 elem = comboboxlist->list_size;
432 is_not_scrolable = true;
433 }
434 cairo_set_font_size (view_port->crb, height/2);
435 for(;i>-1;i--) {
436 cairo_text_extents(view_port->crb,comboboxlist->list_names[i] , &extents);
437
438 item_width = max(item_width, (int)extents.width+40);
439 if(is_not_scrolable) view_port->scale.gravity = NORTHEAST;
440 }
441 if(above) {
442 if(item_width<parent->width)item_width = parent->width;
443 }
444
445 int screen_height = os_get_screen_height(parent);
446 if (y1+(height*elem) > screen_height) y1 = y1-((height*elem)+parent->height);
447 os_resize_window (menu->app->dpy, menu, item_width, height*elem);
448 os_resize_window (view_port->app->dpy, view_port, item_width, height*elem);
449 os_move_window(menu->app->dpy,slider,item_width-15, 0);
450 os_resize_window(menu->app->dpy,slider,15,height*elem);
451 os_move_window(menu->app->dpy,menu,x1, y1);
452}
int width
Definition xwidget.h:521
Window widget
Definition xwidget.h:469
int height
Definition xwidget.h:523
Xputty * app
Definition xwidget.h:465
Display * dpy
Definition xputty.h:232
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 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, Widget_t::app, Widget_t::childlist, Childlist_t::childs, CL_VIEWPORT, Widget_t::crb, Xputty::dpy, Resize_t::gravity, Widget_t::height, IS_WIDGET, ComboBox_t::list_names, ComboBox_t::list_size, Adjustment_t::min_value, NORTHEAST, os_get_root_window(), os_get_screen_height(), os_move_window(), os_resize_window(), os_translate_coords(), Widget_t::parent_struct, Widget_t::scale, set_adjustment(), Adjustment_t::value, Widget_t::widget, and Widget_t::width.

Referenced by combobox_set_menu_size(), and pop_combobox_menu_show().

◆ _draw_combobox()

void _draw_combobox ( void *  w_,
void *  user_data 
)

_draw_combobox - internal draw the combobox to the buffer

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

Definition at line 100 of file xcombobox_private.c.

100 {
101 Widget_t *w = (Widget_t*)w_;
102 if (!w) return;
103 Metrics_t metrics;
104 os_get_window_metrics(w, &metrics);
105 int width = metrics.width-2;
106 int height = metrics.height-2;
107 if (!metrics.visible) return;
108 int v = (int)adj_get_value(w->adj);
109 int vl = v - (int) w->adj->min_value;
110 // if (v<0) return;
111 Widget_t * menu = w->childlist->childs[1];
112 Widget_t* view_port = menu->childlist->childs[0];
113 ComboBox_t *comboboxlist = (ComboBox_t*)view_port->parent_struct;
114
115 cairo_rectangle(w->crb,2.0, 2.0, width, height);
116
117 if(w->state==0) {
118 cairo_set_line_width(w->crb, 1.0);
120 cairo_fill_preserve(w->crb);
122 } else if(w->state==1) {
124 cairo_fill_preserve(w->crb);
125 cairo_set_line_width(w->crb, 1.5);
127 } else if(w->state==2) {
129 cairo_fill_preserve(w->crb);
130 cairo_set_line_width(w->crb, 1.0);
132 } else if(w->state==3) {
134 cairo_fill_preserve(w->crb);
135 cairo_set_line_width(w->crb, 1.0);
137 } else if(w->state==4) {
139 cairo_fill_preserve(w->crb);
140 cairo_set_line_width(w->crb, 1.0);
142 }
143 cairo_stroke(w->crb);
144
145 cairo_rectangle(w->crb,4.0, 4.0, width, height);
146 cairo_stroke(w->crb);
147 cairo_rectangle(w->crb,3.0, 3.0, width, height);
148 cairo_stroke(w->crb);
149 if (comboboxlist->list_size<1) return;
150 if (vl<0) return;
151
152 cairo_text_extents_t extents;
153
155 float font_size = w->app->normal_font/w->scale.ascale;
156 cairo_set_font_size (w->crb, font_size);
157 cairo_text_extents(w->crb,"Ay", &extents);
158 double h = extents.height;
159
160 cairo_move_to (w->crb, 15, (height+h)*0.55);
161 cairo_show_text(w->crb, comboboxlist->list_names[vl]);
162 cairo_new_path (w->crb);
163 if (extents.width > (float)width-20) {
164 tooltip_set_text(w,comboboxlist->list_names[vl]);
165 w->flags |= HAS_TOOLTIP;
166 } else {
167 w->flags &= ~HAS_TOOLTIP;
168 }
169}
float min_value
Definition xadjustment.h:90
float ascale
Definition xwidget.h:369
Resize_t scale
Definition xwidget.h:525
cairo_t * crb
Definition xwidget.h:489
int normal_font
Definition xputty.h:248
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
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 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
@ NORMAL_
Definition xcolor.h:44
@ INSENSITIVE_
Definition xcolor.h:48
@ SELECTED_
Definition xcolor.h:46
@ PRELIGHT_
Definition xcolor.h:45
@ ACTIVE_
Definition xcolor.h:47
void tooltip_set_text(Widget_t *w, const char *label)
tooltip_set_text - set a (new) text to a tooltip for Widget_t
Definition xtooltip.c:25
@ HAS_TOOLTIP
Definition xwidget.h:404

References ACTIVE_, Widget_t::adj, adj_get_value(), Widget_t::app, Resize_t::ascale, Widget_t::childlist, Childlist_t::childs, Widget_t::crb, Widget_t::flags, get_color_state(), HAS_TOOLTIP, Metrics_t::height, INSENSITIVE_, ComboBox_t::list_names, ComboBox_t::list_size, Adjustment_t::min_value, NORMAL_, Xputty::normal_font, os_get_window_metrics(), Widget_t::parent_struct, PRELIGHT_, Widget_t::scale, SELECTED_, Widget_t::state, tooltip_set_text(), use_frame_color_scheme(), use_shadow_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by add_combobox().

◆ _draw_combobox_button()

void _draw_combobox_button ( void *  w_,
void *  user_data 
)

_draw_combobox_button - internal draw the combobox button to the buffer

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

Definition at line 26 of file xcombobox_private.c.

26 {
27 Widget_t *w = (Widget_t*)w_;
28 if (!w) return;
29 Metrics_t metrics;
30 os_get_window_metrics(w, &metrics);
31 int width = metrics.width-2;
32 int height = metrics.height-2;
33 if (!metrics.visible) return;
34 if (!w->state && (int)w->adj_y->value)
35 w->state = 3;
36
37 cairo_rectangle(w->crb,2.0, 4.0, width, height);
38
39 if(w->state==0) {
40 cairo_set_line_width(w->crb, 1.0);
41 _pattern_out(w, NORMAL_, height);
42 cairo_fill_preserve(w->crb);
44 } else if(w->state==1) {
45 _pattern_out(w, PRELIGHT_, height);
46 cairo_fill_preserve(w->crb);
47 cairo_set_line_width(w->crb, 1.5);
49 } else if(w->state==2) {
50 _pattern_in(w, SELECTED_, height);
51 cairo_fill_preserve(w->crb);
52 cairo_set_line_width(w->crb, 1.0);
54 } else if(w->state==3) {
55 _pattern_in(w, ACTIVE_, height);
56 cairo_fill_preserve(w->crb);
57 cairo_set_line_width(w->crb, 1.0);
59 }
60 cairo_stroke(w->crb);
61
62 if(w->state==2) {
63 cairo_rectangle(w->crb,4.0, 6.0, width, height);
64 cairo_stroke(w->crb);
65 cairo_rectangle(w->crb,3.0, 4.0, width, height);
66 cairo_stroke(w->crb);
67 } else if (w->state==3) {
68 cairo_rectangle(w->crb,3.0, 4.0, width, height);
69 cairo_stroke(w->crb);
70 }
71
72 float offset = 0.0;
73 if(w->state==0) {
75 } else if(w->state==1) {
77 offset = 1.0;
78 } else if(w->state==2) {
80 offset = 2.0;
81 } else if(w->state==3) {
83 offset = 1.0;
84 }
86 int wa = width/1.1;
87 int h = height/2.2;
88 int wa1 = width/1.55;
89 int h1 = height/1.3;
90 int wa2 = width/2.8;
91
92 cairo_move_to(w->crb, wa+offset, h+offset);
93 cairo_line_to(w->crb, wa1+offset, h1+offset);
94 cairo_line_to(w->crb, wa2+offset, h+offset);
95 cairo_line_to(w->crb, wa+offset, h+offset);
96 cairo_fill(w->crb);
97
98}
Adjustment_t * adj_y
Definition xwidget.h:495
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 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 _pattern_in(), _pattern_out(), ACTIVE_, Widget_t::adj_y, Widget_t::crb, get_color_state(), Metrics_t::height, NORMAL_, os_get_window_metrics(), PRELIGHT_, SELECTED_, Widget_t::state, use_fg_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Adjustment_t::value, Metrics_t::visible, and Metrics_t::width.

Referenced by add_combobox().

◆ _draw_combobox_entrys()

void _draw_combobox_entrys ( void *  w_,
void *  user_data 
)

_draw_combobox_entrys - internal draw the combobox entrys to the buffer

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

show label

Definition at line 178 of file xcombobox_private.c.

178 {
179 Widget_t *w = (Widget_t*)w_;
180 Metrics_t metrics;
181 os_get_window_metrics(w, &metrics);
182 int width = metrics.width-2;
183 int height = metrics.height-2;
184 if (!metrics.visible) return;
185 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
186
188 cairo_rectangle(w->crb, 0, 0, width, height);
189 cairo_fill (w->crb);
190
191 int i = (int)max(0,adj_get_value(w->adj));
192 int a = 0;
193 int j = comboboxlist->list_size<comboboxlist->show_items+i+1 ?
194 comboboxlist->list_size : comboboxlist->show_items+i+1;
195 for(;i<j;i++) {
196 if(i == comboboxlist->prelight_item && i == comboboxlist->active_item)
198 else if(i == comboboxlist->prelight_item)
200 else if (i == comboboxlist->active_item)
202 else
204 cairo_rectangle(w->crb, 0, a*25, width, 25);
205 cairo_fill_preserve(w->crb);
206 cairo_set_line_width(w->crb, 1.0);
208 cairo_stroke(w->crb);
209 cairo_text_extents_t extents;
211 if(i == comboboxlist->prelight_item && i == comboboxlist->active_item)
213 else if(i == comboboxlist->prelight_item)
215 else if (i == comboboxlist->active_item)
217 else
219
220 cairo_set_font_size (w->crb, 12);
221 cairo_text_extents(w->crb,"Ay", &extents);
222 double h = extents.height;
223 cairo_text_extents(w->crb,comboboxlist->list_names[i] , &extents);
224
225 cairo_move_to (w->crb, 15, (25*(a+1)) - h +2);
226 cairo_show_text(w->crb, comboboxlist->list_names[i]);
227 cairo_new_path (w->crb);
228 if (i == comboboxlist->prelight_item && extents.width > (float)width-20) {
229 tooltip_set_text(w,comboboxlist->list_names[i]);
230 w->flags |= HAS_TOOLTIP;
231 show_tooltip(w);
232 } else if (i == comboboxlist->prelight_item && extents.width < (float)width-20) {
233 w->flags &= ~HAS_TOOLTIP;
234 hide_tooltip(w);
235 }
236 a++;
237 }
238}
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 show_tooltip(Widget_t *wid)
show_tooltip - check if a Widget_t have a tooltip, and show it, if a tooltip is available.
Definition xwidget.c:419
void hide_tooltip(Widget_t *wid)
hide_tooltip - check if a Widget_t have a tooltip, and hide it, if a tooltip is mapped.
Definition xwidget.c:430

References ACTIVE_, ComboBox_t::active_item, Widget_t::adj, adj_get_value(), Widget_t::crb, Widget_t::flags, HAS_TOOLTIP, Metrics_t::height, hide_tooltip(), ComboBox_t::list_names, ComboBox_t::list_size, NORMAL_, os_get_window_metrics(), Widget_t::parent_struct, PRELIGHT_, ComboBox_t::prelight_item, SELECTED_, ComboBox_t::show_items, show_tooltip(), tooltip_set_text(), use_base_color_scheme(), use_frame_color_scheme(), use_text_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by create_combobox_viewport().

◆ _draw_combobox_menu()

void _draw_combobox_menu ( void *  w_,
void *  user_data 
)

_draw_combobox_menu - internal draw the combobox menu to the buffer

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

Definition at line 171 of file xcombobox_private.c.

171 {
172 Widget_t *w = (Widget_t*)w_;
173 if (!w) return;
175 cairo_paint (w->cr);
176}
XColor_t * color_scheme
Definition xwidget.h:467
cairo_t * cr
Definition xwidget.h:485
Colors normal
Definition xcolor.h:106
Colors active
Definition xcolor.h:109
@ BACKGROUND_
Definition xcolor.h:65
void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod)
set_pattern - set pattern for the selected Colors
Definition xcolor.c:308

References XColor_t::active, BACKGROUND_, Widget_t::color_scheme, Widget_t::cr, XColor_t::normal, and set_pattern().

Referenced by create_combobox_menu().

◆ _draw_combobox_menu_slider()

void _draw_combobox_menu_slider ( void *  w_,
void *  user_data 
)

_draw_combobox_menu_slider - internal draw the combobox menu slider

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

Definition at line 337 of file xcombobox_private.c.

337 {
338 Widget_t *w = (Widget_t*)w_;
339 Widget_t* view_port = (Widget_t*)w->parent_struct;
340 ComboBox_t *comboboxlist = (ComboBox_t*)view_port->parent_struct;
341 int v = (int)w->adj->max_value;
342 if (!v) return;
343 Metrics_t metrics;
344 os_get_window_metrics(w, &metrics);
345 int width = metrics.width-2;
346 int height = metrics.height-2;
347 if (!metrics.visible) return;
348 int show_items = height/25;
349 float slidersize = 1.0;
350 if (comboboxlist->list_size > show_items)
351 slidersize = (float)((float)show_items/(float)comboboxlist->list_size);
352 float sliderstate = adj_get_state(w->adj);
354 cairo_rectangle(w->crb, 0,0,width,height);
355 cairo_fill_preserve(w->crb);
357 cairo_fill(w->crb);
359 cairo_rectangle(w->crb, 0,((float)height-
360 ((float)height*slidersize))*sliderstate,width,((float)height*slidersize));
361 cairo_fill(w->crb);
362}
unsigned int list_size
Definition xcombobox.h:51
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_t
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::adj, adj_get_state(), Widget_t::crb, get_color_state(), Metrics_t::height, ComboBox_t::list_size, Adjustment_t::max_value, NORMAL_, os_get_window_metrics(), Widget_t::parent_struct, PRELIGHT_, use_bg_color_scheme(), use_frame_color_scheme(), use_shadow_color_scheme(), Metrics_t::visible, and Metrics_t::width.

Referenced by create_combobox_menu().

◆ _entry_released()

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

_entry_released - the combobox 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 393 of file xcombobox_private.c.

393 {
394 Widget_t *w = (Widget_t*)w_;
395 Widget_t* view_port = w->childlist->childs[0];
396 ComboBox_t *comboboxlist = (ComboBox_t*)view_port->parent_struct;
397 _set_entry(comboboxlist->combobox, NULL);
398}
void _set_entry(void *w_, void *user_data)
_set_entry - set the active combobox entry on adjustment change

References _set_entry(), Widget_t::childlist, Childlist_t::childs, ComboBox_t::combobox, and Widget_t::parent_struct.

Referenced by add_combobox().

◆ _leave_combobox()

void _leave_combobox ( void *  w_,
void *  user_data 
)

_leave_combobox - mouse pointer leave the combobox

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

Definition at line 307 of file xcombobox_private.c.

307 {
308 Widget_t *w = (Widget_t*)w_;
309 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
310 comboboxlist->prelight_item = -1;
311 expose_widget(w);
312}

References expose_widget(), Widget_t::parent_struct, and ComboBox_t::prelight_item.

Referenced by create_combobox_viewport().

◆ _reconfigure_combobox_viewport()

void _reconfigure_combobox_viewport ( void *  w_,
void *  user_data 
)

_reconfigure_combobox_viewport - set slider scale and step to match viewport entrys

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

Definition at line 314 of file xcombobox_private.c.

314 {
315 Widget_t *w = (Widget_t*)w_;
316 float st = adj_get_state(w->adj);
317 Widget_t* combobox = (Widget_t*) w->parent;
318 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
319 Metrics_t metrics;
320 os_get_window_metrics(combobox, &metrics);
321 int height = metrics.height;
322 comboboxlist->show_items = height/25;
323 set_adjustment(comboboxlist->slider->adj,0.0, 0.0, 0.0,
324 (float)(comboboxlist->list_size-(comboboxlist->show_items-1)),1.0, CL_VIEWPORTSLIDER);
325 adj_set_scale(comboboxlist->slider->adj,
326 ((float)(comboboxlist->list_size)/(float)comboboxlist->show_items)/25.0);
327 adj_set_state(w->adj,st);
328}
Widget_t * slider
Definition xcombobox.h:46
int show_items
Definition xcombobox.h:50
void adj_set_state(Adjustment_t *adj, float state)
adj_set_state - set the current state of the Adjustment_t
@ CL_VIEWPORTSLIDER
Definition xadjustment.h:65
void adj_set_scale(Adjustment_t *adj, float value)
adj_set_scale - internal use to scale the pointer movement (0.1 -1.0)

References Widget_t::adj, adj_get_state(), adj_set_scale(), adj_set_state(), CL_VIEWPORTSLIDER, Metrics_t::height, ComboBox_t::list_size, os_get_window_metrics(), Widget_t::parent, Widget_t::parent_struct, set_adjustment(), ComboBox_t::show_items, and ComboBox_t::slider.

Referenced by create_combobox_viewport().

◆ _set_combobox_menu_viewport()

void _set_combobox_menu_viewport ( void *  w_,
void *  user_data 
)

_set_combobox_menu_viewport - set the viewport position from slider state

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

Definition at line 364 of file xcombobox_private.c.

364 {
365 Widget_t *w = (Widget_t*)w_;
366 Widget_t *viewport = (Widget_t*)w->parent_struct;
367 adj_set_state(viewport->adj, adj_get_state(w->adj));
368 expose_widget(w);
369}

References Widget_t::adj, adj_get_state(), adj_set_state(), expose_widget(), and Widget_t::parent_struct.

Referenced by create_combobox_menu().

◆ _set_combobox_viewpoint()

void _set_combobox_viewpoint ( void *  w_,
void *  user_data 
)

_set_combobox_viewpoint - set the slider state from viewport position

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

Definition at line 330 of file xcombobox_private.c.

330 {
331 Widget_t *w = (Widget_t*)w_;
332 ComboBox_t *comboboxlist = (ComboBox_t*)w->parent_struct;
333 adj_set_state(comboboxlist->slider->adj,adj_get_state(w->adj));
334 expose_widget(w);
335}

References Widget_t::adj, adj_get_state(), adj_set_state(), expose_widget(), Widget_t::parent_struct, and ComboBox_t::slider.

Referenced by create_combobox_viewport().

◆ _set_entry()

void _set_entry ( void *  w_,
void *  user_data 
)

_set_entry - set the active combobox entry on adjustment change

Parameters
*w_- void pointer to the Widget_t combobox
*user_data- void pointer to the item label *(const char**)

Definition at line 400 of file xcombobox_private.c.

400 {
401 Widget_t *w = (Widget_t*)w_;
402 int v = (int)adj_get_value(w->adj)-w->adj->min_value;
403 Widget_t * menu = w->childlist->childs[1];
404 Widget_t* view_port = menu->childlist->childs[0];
405 ComboBox_t *comboboxlist = (ComboBox_t*)view_port->parent_struct;
406 if(v>=0 && comboboxlist->list_size) {
407 w->label = comboboxlist->list_names[v];
408 comboboxlist->active_item = v;
409 adj_set_value(w->adj,comboboxlist->active_item + w->adj->min_value);
410 adj_set_state(comboboxlist->slider->adj,adj_get_state(w->adj));
411 os_transparent_draw(w, user_data);
412 }
413}
const char * label
Definition xwidget.h:463
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer

References ComboBox_t::active_item, Widget_t::adj, adj_get_state(), adj_get_value(), adj_set_state(), adj_set_value(), Widget_t::childlist, Childlist_t::childs, Widget_t::label, ComboBox_t::list_names, ComboBox_t::list_size, Adjustment_t::min_value, os_transparent_draw(), Widget_t::parent_struct, and ComboBox_t::slider.

Referenced by _entry_released(), and add_combobox().