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

Go to the source code of this file.

Macros

#define XCOMBOBOX_H_
 

Functions

Widget_tadd_combobox (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_combobox - add a combobox More...
 
Widget_tcombobox_add_entry (Widget_t *wid, const char *label)
 combobox_add_entry - add a entry to the combobox More...
 
void combobox_add_numeric_entrys (Widget_t *wid, int imin, int imax)
 combobox_add_numeric_items - add numeric items from imin to imax to wid More...
 
void combobox_set_active_entry (Widget_t *w, int active)
 combobox_set_active_entry - set the active combobox entry More...
 

Macro Definition Documentation

◆ XCOMBOBOX_H_

#define XCOMBOBOX_H_

Definition at line 24 of file xcombobox.h.

Function Documentation

◆ add_combobox()

Widget_t* add_combobox ( Widget_t parent,
const char *  label,
int  x,
int  y,
int  width,
int  height 
)

add_combobox - add a combobox

Parameters
*parent- pointer to the Widget_t request the button
x,y,width,height- the position/geometry to create the button
Returns
Widget_t* - pointer to the Widget_t button struct

Definition at line 32 of file xcombobox.c.

32  {
33 
34  Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
35  wid->label = label;
36  wid->scale.gravity = CENTER;
37  wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, -1.0,1.0, CL_ENUM);
38  wid->adj = wid->adj_y;
44 
45  Widget_t* button = add_button(wid, "", width-20, 0, 20, height);
48 
49  Widget_t* menu = create_menu(wid, 25);
51 
52 
53  return wid;
54 }

References _button_combobox_released(), _combobox_button_released(), _draw_combobox(), _draw_combobox_button(), _entry_released(), _set_entry(), add_adjustment(), add_button(), Widget_t::adj, Func_t::adj_callback, Widget_t::adj_y, Widget_t::app, Func_t::button_release_callback, CENTER, CL_ENUM, create_menu(), create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, Widget_t::scale, and transparent_draw().

◆ combobox_add_entry()

Widget_t* combobox_add_entry ( Widget_t wid,
const char *  label 
)

combobox_add_entry - add a entry to the combobox

Parameters
*wid- pointer to the Widget_t combobox
*label- Label to show on the menu
Returns
Widget_t* - pointer to the Widget_t menu_item struct

Definition at line 56 of file xcombobox.c.

56  {
57  Widget_t *menu = wid->childlist->childs[1];
58  Widget_t *item = menu_add_item(menu,label);
59  wid->label = label;
60  float max_value = wid->adj->max_value+1.0;
61  set_adjustment(wid->adj,0.0, max_value, 0.0, max_value,1.0, CL_ENUM);
62 
63  return item;
64 }

References Widget_t::adj, Widget_t::childlist, Childlist_t::childs, CL_ENUM, Widget_t::label, Adjustment_t::max_value, menu_add_item(), and set_adjustment().

◆ combobox_add_numeric_entrys()

void combobox_add_numeric_entrys ( Widget_t wid,
int  imin,
int  imax 
)

combobox_add_numeric_items - add numeric items from imin to imax to wid

Parameters
*wid- pointer to the Widget_t combobox
*imin- the low number of the numeric items
*imax- the high number of the numeric items
Returns
void

Definition at line 66 of file xcombobox.c.

66  {
67  Widget_t *menu = wid->childlist->childs[1];
68  menu_add_numeric_items(menu, &imin, &imax);
69  float max_value = wid->adj->max_value+(imax-imin)+1;
70  set_adjustment(wid->adj,0.0, max_value, 0.0, max_value,1.0, CL_ENUM);
71 }

References Widget_t::adj, Widget_t::childlist, Childlist_t::childs, CL_ENUM, Adjustment_t::max_value, menu_add_numeric_items(), and set_adjustment().

◆ combobox_set_active_entry()

void combobox_set_active_entry ( Widget_t w,
int  active 
)

combobox_set_active_entry - set the active combobox entry

Parameters
*w_- void pointer to the Widget_t combobox
active- the active entry (int)
Returns
void

Definition at line 25 of file xcombobox.c.

25  {
26  float value = (float)active;
27  if (value>w->adj->max_value) value = w->adj->max_value;
28  else if (value<w->adj->min_value) value = w->adj->min_value;
29  adj_set_value(w->adj, value);
30 }

References Widget_t::adj, adj_set_value(), Adjustment_t::max_value, and Adjustment_t::min_value.

Func_t::leave_callback
xevfunc leave_callback
Definition: xwidget.h:83
Func_t::enter_callback
xevfunc enter_callback
Definition: xwidget.h:82
_button_combobox_released
void _button_combobox_released(void *w_, void *button_, void *user_data)
_button_combobox_released - popup the combobox menu
Definition: xcombobox_private.c:173
Resize_t::gravity
Gravity gravity
Definition: xwidget.h:192
Childlist_t::childs
Widget_t ** childs
Definition: xchildlist.h:51
CL_ENUM
@ CL_ENUM
Definition: xadjustment.h:55
menu_add_item
Widget_t * menu_add_item(Widget_t *menu, const char *label)
menu_add_item - add a item to menu
Definition: xmenu.c:137
create_widget
Widget_t * create_widget(Xputty *app, Widget_t *win, int x, int y, int width, int height)
*create_widget - create a widget A Widget_t could only be created as child of a other Widget_t To...
Definition: xwidget.c:268
transparent_draw
void transparent_draw(void *wid, void *user_data)
transparent_draw - copy parent surface to child surface you usaualy didn't need to call this,...
Definition: xwidget.c:469
Func_t::expose_callback
xevfunc expose_callback
Definition: xwidget.h:80
CENTER
@ CENTER
Definition: xwidget.h:165
adj_set_value
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
Definition: xadjustment.c:163
Widget_t::adj
Adjustment_t * adj
Definition: xwidget.h:334
Widget_t::scale
Resize_t scale
Definition: xwidget.h:356
_set_entry
void _set_entry(void *w_, void *user_data)
_set_entry - set the active combobox entry on adjustment change
Definition: xcombobox_private.c:198
Widget_t::app
Xputty * app
Definition: xwidget.h:300
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
Func_t::button_release_callback
evfunc button_release_callback
Definition: xwidget.h:94
Widget_t::childlist
Childlist_t * childlist
Definition: xwidget.h:336
Adjustment_t::max_value
float max_value
Definition: xadjustment.h:90
set_adjustment
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 it will be created if it not exsits yet
Definition: xadjustment.c:80
Func_t::adj_callback
xevfunc adj_callback
Definition: xwidget.h:84
Widget_t::adj_y
Adjustment_t * adj_y
Definition: xwidget.h:332
Widget_t::func
Func_t func
Definition: xwidget.h:310
menu_add_numeric_items
void menu_add_numeric_items(Widget_t *menu, int *imin, int *imax)
menu_add_numeric_items - add numeric items from imin to imax to menu
Definition: xmenu.c:193
_combobox_button_released
void _combobox_button_released(void *w_, void *button_, void *user_data)
_combobox_button_released - popup menu on right click
Definition: xcombobox_private.c:162
add_adjustment
Adjustment_t * add_adjustment(Widget_t *w, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*add_adjustment - adding a adjustment to a Widget_t
Definition: xadjustment.c:25
_entry_released
void _entry_released(void *w_, void *item_, void *user_data)
_entry_released - the combobox menu release func
Definition: xcombobox_private.c:184
create_menu
Widget_t * create_menu(Widget_t *parent, int height)
create_menu - create a menu to a Widget_t
Definition: xmenu.c:107
_draw_combobox_button
void _draw_combobox_button(void *w_, void *user_data)
_draw_combobox_button - internal draw the combobox button to the buffer
Definition: xcombobox_private.c:26
Widget_t::label
const char * label
Definition: xwidget.h:326
Adjustment_t::min_value
float min_value
Definition: xadjustment.h:88
add_button
Widget_t * add_button(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_button - add a button to a Widget_t connect to func.value_changed_callback to implement your acti...
Definition: xbutton.c:26
_draw_combobox
void _draw_combobox(void *w_, void *user_data)
_draw_combobox - internal draw the combobox to the buffer
Definition: xcombobox_private.c:100