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

Go to the source code of this file.

Functions

Widget_tadd_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 actions
 
Widget_tadd_image_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_image_button - add a image button to a Widget_t connect to func.value_changed_callback to implement your actions
 
Widget_tadd_on_off_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_on_off_button - add a button with default on/off label to a Widget_t connect to func.value_changed_callback to implement your actions
 
Widget_tadd_toggle_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_toggle_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions
 
Widget_tadd_image_toggle_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_image_toggle_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions
 
Widget_tadd_switch_image_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_switch_image_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions
 
Widget_tadd_check_button (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_check_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions
 
int get_width (const char *label)
 
Widget_tadd_check_box (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_check_box - add a check box to a Widget_t connect to func.value_changed_callback to implement your actions
 

Function Documentation

◆ 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 actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 26 of file xbutton.c.

27 {
28
29 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
30 wid->label = label;
31 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
32 wid->adj = wid->adj_y;
33 wid->scale.gravity = CENTER;
39 return wid;
40}
evfunc button_release_callback
Definition xwidget.h:101
xevfunc expose_callback
Definition xwidget.h:85
xevfunc leave_callback
Definition xwidget.h:88
xevfunc enter_callback
Definition xwidget.h:87
evfunc button_press_callback
Definition xwidget.h:100
Gravity gravity
Definition xwidget.h:347
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
Adjustment_t * adj_y
Definition xwidget.h:495
Adjustment_t * adj
Definition xwidget.h:497
const char * label
Definition xwidget.h:463
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
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
@ CL_TOGGLE
Definition xadjustment.h:51
void _button_released(void *w_, void *button_, void *user_data)
_button_released - redraw the button and send state via user_callback
void _draw_base_button(void *w_, void *user_data)
_draw_base_button - internal draw the button with base 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 os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
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:265
@ CENTER
Definition xwidget.h:320

References _button_pressed(), _button_released(), _draw_base_button(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

Referenced by add_combobox(), open_directory_dialog(), open_file_dialog(), open_message_dialog(), and save_file_dialog().

◆ add_check_box()

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

add_check_box - add a check box to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 141 of file xbutton.c.

142 {
143
144 Widget_t *wid = create_widget(parent->app, parent, x, y, get_width(label), height);
145 wid->label = label;
146 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
147 wid->adj = wid->adj_y;
148 wid->scale.gravity = CENTER;
154 return wid;
155}
int get_width(const char *label)
Definition xbutton.c:137
void _toggle_button_released(void *w_, void *button_, void *user_data)
_toggle_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 _draw_check_box(void *w_, void *user_data)
_draw_check_box - internal draw the check box to the buffer

References _draw_check_box(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, get_width(), Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

◆ add_check_button()

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

add_check_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 121 of file xbutton.c.

122 {
123
124 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
125 wid->label = label;
126 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
127 wid->adj = wid->adj_y;
128 wid->scale.gravity = CENTER;
134 return wid;
135}
void _draw_check_button(void *w_, void *user_data)
_draw_check_button - internal draw the button to the buffer

References _draw_check_button(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

Referenced by open_directory_dialog(), open_file_dialog(), and save_file_dialog().

◆ add_image_button()

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

add_image_button - add a image button to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 42 of file xbutton.c.

43 {
44
45 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
46 wid->label = label;
47 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
48 wid->adj = wid->adj_y;
49 wid->scale.gravity = CENTER;
55 return wid;
56}
void _draw_button(void *w_, void *user_data)
_draw_button - internal draw the button to the buffer

References _button_pressed(), _button_released(), _draw_button(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

◆ add_image_toggle_button()

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

add_image_toggle_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 89 of file xbutton.c.

90 {
91
92 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
93 wid->label = label;
94 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
95 wid->adj = wid->adj_y;
96 wid->scale.gravity = CENTER;
102 return wid;
103}
void _draw_ti_button(void *w_, void *user_data)
_draw_ti_button - internal draw the button to the buffer

References _draw_ti_button(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

Referenced by add_directory_button(), add_file_button(), and add_save_file_button().

◆ add_on_off_button()

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

add_on_off_button - add a button with default on/off label to a Widget_t connect to func.value_changed_callback to implement your actions

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

Definition at line 58 of file xbutton.c.

59 {
60
61 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
62 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
63 wid->adj = wid->adj_y;
64 wid->scale.gravity = CENTER;
70 return wid;
71}
void _draw_on_off_button(void *w_, void *user_data)
_draw_on_off_button - internal draw the on/off button to the buffer

References _draw_on_off_button(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

◆ add_switch_image_button()

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

add_switch_image_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 105 of file xbutton.c.

106 {
107
108 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
109 wid->label = label;
110 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
111 wid->adj = wid->adj_y;
112 wid->scale.gravity = ASPECT;
118 return wid;
119}
void _draw_switch_image_button(void *w_, void *user_data)
draw switch_image_button - internal draw the button to the buffer
@ ASPECT
Definition xwidget.h:322

References _draw_switch_image_button(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, ASPECT, Func_t::button_press_callback, Func_t::button_release_callback, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

Referenced by add_my_switch_image().

◆ add_toggle_button()

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

add_toggle_button - add a button to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the button
*label- Label to show on 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 73 of file xbutton.c.

74 {
75
76 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
77 wid->label = label;
78 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,1.0, CL_TOGGLE);
79 wid->adj = wid->adj_y;
80 wid->scale.gravity = CENTER;
86 return wid;
87}

References _draw_base_button(), _toggle_button_pressed(), _toggle_button_released(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, Func_t::button_press_callback, Func_t::button_release_callback, CENTER, CL_TOGGLE, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, Func_t::leave_callback, os_transparent_draw(), and Widget_t::scale.

◆ get_width()

int get_width ( const char *  label)

Definition at line 137 of file xbutton.c.

137 {
138 return max(1, strlen(label)*12);
139}

Referenced by add_check_box().