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

Go to the source code of this file.

Macros

#define XLISTBOX_H_
 

Functions

void listbox_set_active_entry (Widget_t *w, int active)
 listbox_set_active_entry - set the active listbox entry More...
 
Widget_tcreate_listbox_viewport (Widget_t *parent, int elem, int width, int height)
 create_listbox_viewport - create a viewport on a listbox to a Widget_t More...
 
Widget_tadd_listbox (Widget_t *parent, const char *label, int x, int y, int width, int height)
 add_label - add a listbox to a Widget_t More...
 
Widget_tlistbox_add_entry (Widget_t *listbox, const char *label)
 listbox_add_entry - add a item to listbox More...
 

Macro Definition Documentation

◆ XLISTBOX_H_

#define XLISTBOX_H_

Definition at line 24 of file xlistbox.h.

Function Documentation

◆ add_listbox()

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

add_label - add a listbox to a Widget_t

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

Definition at line 46 of file xlistbox.c.

47  {
48 
49  Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
50  wid->label = label;
51  wid->scale.gravity = CENTER;
53  int elem = height/25;
54  wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, -1.0,1.0, CL_NONE);
55  wid->adj = wid->adj_y;
56  create_listbox_viewport(wid, elem, width, height);
57  return wid;
58 }

References _draw_listbox(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, CENTER, CL_NONE, create_listbox_viewport(), create_widget(), Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Widget_t::label, and Widget_t::scale.

◆ create_listbox_viewport()

Widget_t* create_listbox_viewport ( Widget_t parent,
int  elem,
int  width,
int  height 
)

create_listbox_viewport - create a viewport on a listbox to a Widget_t

Parameters
*parent- pointer to the Widget_t the listbox should pop over
width- define the width of the viewport
height- define the height of the viewport
Returns
Widget_t* - pointer to the Widget_t viewport

Definition at line 33 of file xlistbox.c.

33  {
34  Widget_t *wid = create_widget(parent->app, parent, 0, 0, width, height);
35  wid->scale.gravity = NORTHEAST;
36  float max_value = -elem ;
37  wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, max_value,1.0, CL_VIEWPORT);
38  wid->adj = wid->adj_y;
43  return wid;
44 }

References _configure_listbox(), _draw_listbox_viewslider(), _reconfigure_listbox_viewport(), _set_listbox_viewpoint(), add_adjustment(), Widget_t::adj, Func_t::adj_callback, Widget_t::adj_y, Widget_t::app, CL_VIEWPORT, Func_t::configure_notify_callback, create_widget(), Func_t::expose_callback, Widget_t::func, Resize_t::gravity, Func_t::map_notify_callback, NORTHEAST, and Widget_t::scale.

◆ listbox_add_entry()

Widget_t* listbox_add_entry ( Widget_t listbox,
const char *  label 
)

listbox_add_entry - add a item to listbox

Parameters
*listbox- pointer to the Widget_t listbox
*label- Label to show on the listbox
Returns
Widget_t* - pointer to the Widget_t listbox_item struct

Definition at line 60 of file xlistbox.c.

60  {
61  Widget_t* view_port = listbox->childlist->childs[0];
62  int width = listbox->scale.init_width;
63  int si = childlist_has_child(view_port->childlist);
64  Widget_t *wid = create_widget(listbox->app, view_port, 0, 25*si, width, 25);
65  float max_value = view_port->adj->max_value+1.0;
66  set_adjustment(view_port->adj,0.0, 0.0, 0.0, max_value,1.0, CL_VIEWPORT);
67  max_value = listbox->adj->max_value+1.0;
68  set_adjustment(listbox->adj,0.0, 0.0, 0.0, max_value,1.0, CL_NONE);
70  wid->scale.gravity = MENUITEM;
71  wid->label = label;
76  return wid;
77 }

References _draw_listbox_item(), _listbox_entry_released(), Widget_t::adj, Widget_t::app, Func_t::button_release_callback, Widget_t::childlist, childlist_has_child(), Childlist_t::childs, CL_NONE, CL_VIEWPORT, create_widget(), Func_t::enter_callback, Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, HAS_TOOLTIP, Resize_t::init_width, Widget_t::label, Func_t::leave_callback, Adjustment_t::max_value, MENUITEM, Widget_t::scale, set_adjustment(), transparent_draw(), and USE_TRANSPARENCY.

◆ listbox_set_active_entry()

void listbox_set_active_entry ( Widget_t w,
int  active 
)

listbox_set_active_entry - set the active listbox entry

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

Definition at line 26 of file xlistbox.c.

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

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
HAS_TOOLTIP
@ HAS_TOOLTIP
Definition: xwidget.h:249
Func_t::enter_callback
xevfunc enter_callback
Definition: xwidget.h:82
Resize_t::gravity
Gravity gravity
Definition: xwidget.h:192
MENUITEM
@ MENUITEM
Definition: xwidget.h:171
Childlist_t::childs
Widget_t ** childs
Definition: xchildlist.h:51
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
_draw_listbox
void _draw_listbox(void *w_, void *user_data)
_draw_listbox - draw listbox on expose call
Definition: xlistbox_private.c:26
Widget_t::flags
long long flags
Definition: xwidget.h:324
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
CL_VIEWPORT
@ CL_VIEWPORT
Definition: xadjustment.h:57
Widget_t::app
Xputty * app
Definition: xwidget.h:300
USE_TRANSPARENCY
@ USE_TRANSPARENCY
Definition: xwidget.h:243
_draw_listbox_viewslider
void _draw_listbox_viewslider(void *w_, void *user_data)
_draw_listbox_viewslider - draw a slider on the viewport to indicate the view point
Definition: xlistbox_private.c:100
Func_t::map_notify_callback
xevfunc map_notify_callback
Definition: xwidget.h:89
_reconfigure_listbox_viewport
void _reconfigure_listbox_viewport(void *w_, void *user_data)
_reconfigure_listbox_viewport - reconfigure the viewport adjustment on size changes
Definition: xlistbox_private.c:77
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
_listbox_entry_released
void _listbox_entry_released(void *w_, void *button_, void *user_data)
_listbox_entry_released - redraw the slider when buttob released
Definition: xlistbox_private.c:132
_configure_listbox
void _configure_listbox(void *w_, void *user_data)
_configure_listbox - configure the viewport on mapping
Definition: xlistbox_private.c:90
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
create_listbox_viewport
Widget_t * create_listbox_viewport(Widget_t *parent, int elem, int width, int height)
create_listbox_viewport - create a viewport on a listbox to a Widget_t
Definition: xlistbox.c:33
CL_NONE
@ CL_NONE
Definition: xadjustment.h:47
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
_set_listbox_viewpoint
void _set_listbox_viewpoint(void *w_, void *user_data)
_set_listbox_viewpoint - move the view_port to position
Definition: xlistbox_private.c:123
Func_t::configure_notify_callback
xevfunc configure_notify_callback
Definition: xwidget.h:88
childlist_has_child
int childlist_has_child(Childlist_t *childlist)
childlist_has_child - check if a Widget_t Childlist_t contain a child
Definition: xchildlist.c:91
Widget_t::label
const char * label
Definition: xwidget.h:326
Adjustment_t::min_value
float min_value
Definition: xadjustment.h:88
_draw_listbox_item
void _draw_listbox_item(void *w_, void *user_data)
_draw_listbox_item - draw item on expose call
Definition: xlistbox_private.c:33
Resize_t::init_width
int init_width
Definition: xwidget.h:198
NORTHEAST
@ NORTHEAST
Definition: xwidget.h:159