EasyGUI
gui_widget_list.h
1 
6 /*
7  * Copyright (c) 2019 Tilen MAJERLE
8  *
9  * Permission is hereby granted, free of charge, to any person
10  * obtaining a copy of this software and associated documentation
11  * files (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * This file is part of EasyGUI library.
30  *
31  * Author: Tilen Majerle <tilen@majerle.eu>
32  */
33 #ifndef GUI_HDR_WIDGET_LIST_H
34 #define GUI_HDR_WIDGET_LIST_H
35 
36 /* C++ detection */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include "gui_widget.h"
42 
58 typedef struct {
62  int16_t count;
65  uint8_t (*check_values_cb)(gui_handle_p h);
66  int16_t (*entries_per_page_cb)(gui_handle_p h);
67  uint8_t (*remove_item_cb)(gui_handle_p h, void* item); /* Remove item callback */
69 
70 uint8_t gui_widget_list_init(gui_handle_p h, gui_widget_listdata_t* const ld);
71 uint8_t gui_widget_list_slide(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t dir);
72 uint8_t gui_widget_list_add_item(gui_handle_p h, gui_widget_listdata_t* const ld, void* element);
73 void * gui_widget_list_get_item_byindex(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t index);
74 uint8_t gui_widget_list_remove_item_byindex(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t index);
75 uint8_t gui_widget_list_remove_items(gui_handle_p h, gui_widget_listdata_t* const ld);
76 uint8_t gui_widget_list_check_values(gui_handle_p h, gui_widget_listdata_t* const ld);
77 
78 uint8_t gui_widget_list_inc_selection(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t* const curr_selected, int16_t dir);
79 uint8_t gui_widget_list_set_selection(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t* const curr_selected, int16_t new_selection);
80 
88 #define gui_widget_list_get_count_pp(h, ld) GUI_I16(((ld)->entries_per_page_cb != NULL) ? (ld)->entries_per_page_cb(h) : 0)
89 
96 #define gui_widget_list_get_visible_start_index(h, ld) GUI_I16((ld)->visiblestartindex)
97 uint8_t gui_widget_list_set_visible_start_index(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t start);
98 
106 #define gui_widget_list_get_count(h, ld) GUI_I16((ld)->count)
107 
108 void * gui_widget_list_get_first_visible_item(gui_handle_p h, gui_widget_listdata_t* const ld, int16_t* const index_out);
109 void * gui_widget_list_get_next_item(gui_handle_p h, gui_widget_listdata_t* const ld, void* const curr_item);
110 
115 /* C++ detection */
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* GUI_HDR_WIDGET_LIST_H */
uint8_t gui_widget_list_check_values(gui_handle_p h, gui_widget_listdata_t *const ld)
Check all the values if ok represented and correct problematic.
Definition: gui_widget_list.c:216
int16_t count
Definition: gui_widget_list.h:62
void * gui_widget_list_get_item_byindex(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t index)
Get item by index number.
Definition: gui_widget_list.c:152
Linked list root structure for start and end widget in structure.
Definition: gui_defs.h:196
uint8_t gui_widget_list_slide(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t dir)
Get number of elements on linked list.
Definition: gui_widget_list.c:107
uint8_t gui_widget_list_init(gui_handle_p h, gui_widget_listdata_t *const ld)
Initialize list helper module.
Definition: gui_widget_list.c:92
gui_linkedlistroot_t root
Definition: gui_widget_list.h:59
void * gui_widget_list_get_next_item(gui_handle_p h, gui_widget_listdata_t *const ld, void *const curr_item)
Get next visible item handle of current.
Definition: gui_widget_list.c:305
List data structure.
Definition: gui_widget_list.h:58
uint8_t gui_widget_list_remove_item_byindex(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t index)
Remove item from list by index value.
Definition: gui_widget_list.c:169
uint8_t gui_widget_list_inc_selection(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t *const curr_selected, int16_t dir)
Set new active selected item from a list.
Definition: gui_widget_list.c:229
int16_t max_visible_items
Definition: gui_widget_list.h:61
uint8_t gui_widget_list_add_item(gui_handle_p h, gui_widget_listdata_t *const ld, void *element)
Add new item to list.
Definition: gui_widget_list.c:135
uint8_t gui_widget_list_set_selection(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t *const curr_selected, int16_t new_selection)
Set new active selected item from a list.
Definition: gui_widget_list.c:257
uint8_t gui_widget_list_remove_items(gui_handle_p h, gui_widget_listdata_t *const ld)
Remove all items from list.
Definition: gui_widget_list.c:191
void * gui_widget_list_get_first_visible_item(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t *const index_out)
Get first visible item handle.
Definition: gui_widget_list.c:289
int16_t visiblestartindex
Definition: gui_widget_list.h:63
uint8_t gui_widget_list_set_visible_start_index(gui_handle_p h, gui_widget_listdata_t *const ld, int16_t start)
Set top visible start list index.
Definition: gui_widget_list.c:270