libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xlistview.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 XLISTVIEW_H_
24 #define XLISTVIEW_H_
25 
26 #include "xputty.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /**
33  * @brief ViewList_t - struct to hold information for the listview
34  * @param prelight_item - the list item which has the focus
35  * @param active_item - the list item which is selected(active)
36  * @param show_items - the viewable amount of list items
37  * @param list_size - total amount of list items in list
38  * @param **list_names - the list entrys
39  */
40 
41 typedef struct {
45  int list_size;
46  char **list_names;
47 } ViewList_t;
48 
49 /**
50  * @brief listview_set_active_entry - set the active listview entry
51  * @param *w_ - void pointer to the Widget_t listview
52  * @param active - the active entry (int)
53  * @return void
54  */
55 
56 void listview_set_active_entry(Widget_t *w, int active);
57 
58 /**
59  * @brief create_listview_viewport - create a viewport on a listview to a Widget_t
60  * @param *parent - pointer to the Widget_t the listview should pop over
61  * @param width - define the width of the viewport
62  * @param height - define the height of the viewport
63  * @return Widget_t* - pointer to the Widget_t viewport
64  */
65 
66 Widget_t* create_listview_viewport(Widget_t *parent, int elem, int width, int height);
67 
68 /**
69  * @brief add_label - add a listview to a Widget_t
70  * @param *parent - pointer to the Widget_t request the label
71  * @param *label - Label to show on the button
72  * @param x,y,width,height - the position/geometry to create the label
73  * @return Widget_t* - pointer to the Widget_t label struct
74  */
75 
76 Widget_t* add_listview(Widget_t *parent, const char * label,
77  int x, int y, int width, int height);
78 
79 /**
80  * @brief listview_mem_free - release additional used memory when destroy the Widget_t
81  * @param *w_ - void pointer to the Widget_t
82  * @param *user_data - void pointer to attached user_data
83  * @return void
84  */
85 
86 void listview_mem_free(void *w_, void* user_data);
87 
88 /**
89  * @brief listview_set_list - set a list to a listview Widget_t
90  * @param *listview - pointer to the Widget_t listview which should show the list
91  * @param **list - pointer to the list
92  * @param list_size - how many items contain the list
93  * @return void
94  */
95 
96 void listview_set_list(Widget_t *listview, char **list, int list_size);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif //XLISTVIEW_H_
ViewList_t::prelight_item
int prelight_item
Definition: xlistview.h:42
listview_set_active_entry
void listview_set_active_entry(Widget_t *w, int active)
listview_set_active_entry - set the active listview entry
Definition: xlistview.c:27
xputty.h
ViewList_t::show_items
int show_items
Definition: xlistview.h:44
create_listview_viewport
Widget_t * create_listview_viewport(Widget_t *parent, int elem, int width, int height)
create_listview_viewport - create a viewport on a listview to a Widget_t
Definition: xlistview.c:38
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
ViewList_t::list_size
int list_size
Definition: xlistview.h:45
listview_mem_free
void listview_mem_free(void *w_, void *user_data)
listview_mem_free - release additional used memory when destroy the Widget_t
Definition: xlistview.c:79
listview_set_list
void listview_set_list(Widget_t *listview, char **list, int list_size)
listview_set_list - set a list to a listview Widget_t
Definition: xlistview.c:85
ViewList_t::list_names
char ** list_names
Definition: xlistview.h:46
add_listview
Widget_t * add_listview(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_label - add a listview to a Widget_t
Definition: xlistview.c:64
ViewList_t
ViewList_t - struct to hold information for the listview.
Definition: xlistview.h:41
ViewList_t::active_item
int active_item
Definition: xlistview.h:43