libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xchildlist.h
Go to the documentation of this file.
1 /*
2  * 0BSD
3  *
4  * BSD Zero Clause License
5  *
6  * Copyright (c) 2019 Hermann Meyer
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted.
10 
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  *
19  */
20 
21 #pragma once
22 
23 #ifndef XCHILDLIST_H_
24 #define XCHILDLIST_H_
25 
26 #include "xputty.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
33 /**
34  *
35  * @brief Childlist_t - struct to hold a Widget_t child list
36  * \n Xputty main holds a list of any Widget_t created in relation to main
37  * \n Any Event is only propagate to Widget_t's found in this list
38  * \n Every Widget_t holds a list of Child Widget_t's they contain
39  * \n When a Widget_t get destroy_widget() call, all of it's childs
40  * receive a destroy_widget() call before the Widget_t itself get destroyed
41  * \n the expose_callback() (EXPOSE) and the configure_callback() (CONFIGURE)
42  * will be propagate to all childs in a Childlist_t
43  * @param **childs - dynamic array to hold pointers to the childs
44  * @param size - current size of array
45  * @param cap - current capacity of the array
46  * @param elem - current elements in the array
47  */
48 
49 struct Childlist_t {
50 /** dynamic array to hold pointers to the childs */
52 /** current size of array */
53  size_t size;
54 /** current capacity of the array */
55  int cap;
56 /** current elements in the array */
57  int elem;
58 };
59 
60 /**
61  * @brief childlist_init - internal use to allocate the array to min size
62  * \n You usually didn't need to call this
63  * @param *childlist - pointer to the Childlist_t
64  * @return void
65  */
66 
67 void childlist_init(Childlist_t *childlist);
68 
69 /**
70  * @brief childlist_destroy - internal use to free the Childlist_t
71  * \n You usually didn't need to call this
72  * @param *childlist - pointer to the Childlist_t
73  * @return void
74  */
75 
76 void childlist_destroy(Childlist_t *childlist);
77 
78 /**
79  * @brief childlist_add_child - internal use to add a child to the Childlist_t
80  * \n You usually didn't need to call this
81  * @param *childlist - pointer to the Childlist_t
82  * @param *child - pointer to the child to add
83  * @return void
84  */
85 
86 void childlist_add_child(Childlist_t *childlist, Widget_t *child);
87 
88 /**
89  * @brief childlist_remove_child - internal use to remove a child from the childlist
90  * \n You usually didn't need to call this
91  * @param *childlist - pointer to the Childlist_t
92  * @param *child - pointer to the child to remove
93  * @return void
94  */
95 
96 void childlist_remove_child(Childlist_t *childlist, Widget_t *child);
97 
98 /**
99  * @brief childlist_find_child - find a child in a the Childlist_t
100  * this could be sued to check if a Widget_t is a child of a other Widget_t
101  * @param *childlist - pointer to the Childlist_t
102  * @param *child - pointer to the child to find
103  * @return int - return position in childlist or -1
104  * when not found
105  */
106 
107 int childlist_find_child(Childlist_t *childlist, Widget_t *child);
108 
109 /**
110  * @brief childlist_find_widget - find a child Widget_t in a the childlist
111  * by given the Window id
112  * @param *childlist - pointer to the Childlist_t
113  * @param child_window - the Window to find the Widget_t for
114  * @return int - return position in childlist or -1
115  * when not found
116  */
117 
118 int childlist_find_widget(Childlist_t *childlist, Window child_window);
119 
120 /**
121  * @brief childlist_has_child - check if a Widget_t Childlist_t contain a child
122  * @param *childlist - pointer to the Childlist_t
123  * @return int - return element counter value
124  * 0 when Widget_t Childlist_t didn't contain a child
125  */
126 
127 int childlist_has_child(Childlist_t *childlist);
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif //XCHILDLISTT_H_
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 thi...
Definition: xchildlist.c:25
Childlist_t::childs
Widget_t ** childs
Definition: xchildlist.h:51
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 cal...
Definition: xchildlist.c:42
xputty.h
Childlist_t::cap
int cap
Definition: xchildlist.h:55
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
Childlist_t
Childlist_t - struct to hold a Widget_t child list Xputty main holds a list of any Widget_t created...
Definition: xchildlist.h:49
Childlist_t::size
size_t size
Definition: xchildlist.h:53
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
Definition: xchildlist.c:38
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...
Definition: xchildlist.c:71
Childlist_t::elem
int elem
Definition: xchildlist.h:57
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 ...
Definition: xchildlist.c:57
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
Definition: xchildlist.c:81
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