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

Go to the source code of this file.

Functions

void childlist_init (Childlist_t *childlist)
 childlist_init - internal use to allocate the array to min size
You usually didn't need to call this
 
void childlist_destroy (Childlist_t *childlist)
 childlist_destroy - internal use to free the Childlist_t
You usually didn't need to call this
 
void childlist_add_child (Childlist_t *childlist, Widget_t *child)
 childlist_add_child - internal use to add a child to the Childlist_t
You usually didn't need to call this
 
void childlist_remove_child (Childlist_t *childlist, Widget_t *child)
 childlist_remove_child - internal use to remove a child from the childlist
You usually didn't need to call this
 
int childlist_find_child (Childlist_t *childlist, Widget_t *child)
 childlist_find_child - find a child in a the Childlist_t this could be sued to check if a Widget_t is a child of a other Widget_t
 
int childlist_find_widget (Childlist_t *childlist, Window child_window)
 childlist_find_widget - find a child Widget_t in a the childlist by given the Window id
 
int childlist_has_child (Childlist_t *childlist)
 childlist_has_child - check if a Widget_t Childlist_t contain a child
 

Function Documentation

◆ childlist_add_child()

void childlist_add_child ( Childlist_t childlist,
Widget_t child 
)

childlist_add_child - internal use to add a child to the Childlist_t
You usually didn't need to call this

Parameters
*childlist- pointer to the Childlist_t
*child- pointer to the child to add

Definition at line 42 of file xchildlist.c.

42 {
43 if(!childlist) childlist_init(childlist);
44 if (childlist->cap < childlist->elem+2) {
45 _childlist_add_elem(childlist);
46 }
47 childlist->childs[childlist->elem] = child;
48 debug_print("Childlist_t add_child\n");
49 if (child->flags & IS_WINDOW) {
51 }
52 childlist->elem +=1;
53}
Widget_t ** childs
Definition xchildlist.h:51
long long flags
Definition xwidget.h:461
void childlist_init(Childlist_t *childlist)
childlist_init - internal use to allocate the array to min size You usually didn't need to call thi...
Definition xchildlist.c:25
void _childlist_add_elem(Childlist_t *childlist)
_childlist_add_elem - internal use to reallocate the childlist array to new size You didn't need to...
Atom os_register_wm_delete_window(Widget_t *wid)
os_register_wm_delete_window - Get the needed Atom to send a widget delete message
@ IS_WINDOW
Definition xwidget.h:390

References _childlist_add_elem(), Childlist_t::cap, childlist_init(), Childlist_t::childs, Childlist_t::elem, Widget_t::flags, IS_WINDOW, and os_register_wm_delete_window().

Referenced by add_popup_spinbox(), create_combobox_menu(), create_menu(), create_tooltip(), create_widget(), create_window(), os_create_main_window_and_surface(), and os_create_widget_window_and_surface().

◆ childlist_destroy()

void childlist_destroy ( Childlist_t childlist)

childlist_destroy - internal use to free the Childlist_t
You usually didn't need to call this

Parameters
*childlist- pointer to the Childlist_t

Definition at line 38 of file xchildlist.c.

38 {
39 if(childlist) free(childlist->childs);
40}

References Childlist_t::childs.

Referenced by destroy_widget(), and main_quit().

◆ childlist_find_child()

int childlist_find_child ( Childlist_t childlist,
Widget_t child 
)

childlist_find_child - find a child in a the Childlist_t this could be sued to check if a Widget_t is a child of a other Widget_t

Parameters
*childlist- pointer to the Childlist_t
*child- pointer to the child to find
Returns
int - return position in childlist or -1 when not found

Definition at line 69 of file xchildlist.c.

69 {
70 int i = 0;
71 for(;i<childlist->elem;i++) {
72 if(childlist->childs[i] == child) {
73 return i;
74 }
75 }
76 return -1;
77}

References Childlist_t::childs, and Childlist_t::elem.

Referenced by childlist_remove_child(), and destroy_widget().

◆ childlist_find_widget()

int childlist_find_widget ( Childlist_t childlist,
Window  child_window 
)

childlist_find_widget - find a child Widget_t in a the childlist by given the Window id

Parameters
*childlist- pointer to the Childlist_t
child_window- the Window to find the Widget_t for
Returns
int - return position in childlist or -1 when not found

Definition at line 79 of file xchildlist.c.

79 {
80 int i = childlist->elem-1;
81 for(;i>-1;i--) {
82 if(childlist->childs[i]->widget == child_window) {
83 return i;
84 }
85 }
86 return -1;
87}
Window widget
Definition xwidget.h:469

References Childlist_t::childs, Childlist_t::elem, and Widget_t::widget.

Referenced by os_main_run(), os_run_embedded(), and WndProc().

◆ childlist_has_child()

int childlist_has_child ( Childlist_t childlist)

◆ childlist_init()

void childlist_init ( Childlist_t childlist)

childlist_init - internal use to allocate the array to min size
You usually didn't need to call this

Parameters
*childlist- pointer to the Childlist_t

Definition at line 25 of file xchildlist.c.

25 {
26 childlist->childs = (Widget_t**)malloc(sizeof(Widget_t*) * 4);
27 assert(childlist->childs != NULL);
28 memset(childlist->childs, 0, 4 * sizeof(Widget_t*));
29 childlist->cap =4;
30 childlist->size = sizeof(childlist);
31 childlist->elem = 0;
32 int i = 0;
33 for(;i<childlist->cap;i++) {
34 childlist->childs[i] = NULL;
35 }
36}
size_t size
Definition xchildlist.h:53
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457

References Childlist_t::cap, Childlist_t::childs, Childlist_t::elem, and Childlist_t::size.

Referenced by childlist_add_child(), create_widget(), create_window(), and main_init().

◆ childlist_remove_child()

void childlist_remove_child ( Childlist_t childlist,
Widget_t child 
)

childlist_remove_child - internal use to remove a child from the childlist
You usually didn't need to call this

Parameters
*childlist- pointer to the Childlist_t
*child- pointer to the child to remove

Definition at line 55 of file xchildlist.c.

55 {
56 if (!childlist) return;
57 int it = childlist_find_child(childlist, child);
58 if(it >= 0){
59 childlist->childs[it] = NULL;
60 childlist->elem--;
61 int i = it;
62 for(;i<childlist->elem;i++) {
63 childlist->childs[i] = childlist->childs[i+1];
64 }
65 childlist->childs[childlist->elem+1] = NULL;
66 }
67}
int childlist_find_child(Childlist_t *childlist, Widget_t *child)
childlist_find_child - find a child in a the Childlist_t this could be sued to check if a Widget_t is...
Definition xchildlist.c:69

References childlist_find_child(), Childlist_t::childs, and Childlist_t::elem.

Referenced by destroy_widget().