summaryrefslogtreecommitdiffstats
path: root/include/widgets/listview.h
blob: ba104e60a80e52105530019971000659c40f31cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#ifndef ROFI_LISTVIEW_H
#define ROFI_LISTVIEW_H

/**
 * @defgroup listview listview
 * @ingroup widget
 *
 * @{
 */

/**
 * Handle to the listview.
 * No internal fields should be accessed directly.
 */
typedef struct _listview   listview;

/**
 * The scrolling type used in the list view
 */
typedef enum
{
    /** Flip through the pages. */
    LISTVIEW_SCROLL_PER_PAGE,
    /** keep selected item centered */
    LISTVIEW_SCROLL_CONTINIOUS
} ScrollType;

/**
 * @param tb The textbox to set
 * @param entry The position of the textbox
 * @param udata User data
 * @param type The textbox font style to apply to this entry (normal, selected, alternative row)
 * @param full If true Set both text and style.
 *
 * Update callback, this is called to set the value of each (visible) element.
 */
typedef void ( *listview_update_callback )( textbox *tb, unsigned int entry, void *udata, TextBoxFontType type, gboolean full );

/**
 * Callback when a element is activated.
 */
typedef void ( *listview_mouse_activated_cb )( listview *, xcb_button_press_event_t *, void * );

/**
 * @param cb The update callback.
 * @param udata The user data to pass to the callback
 * @param eh The height of one element
 *
 * @returns a new listview
 */
listview *listview_create ( listview_update_callback cb, void *udata, unsigned int eh );

/**
 * @param lv The listview handle
 * @param rows Number of elements
 *
 * Set the maximum number of elements to display.
 */
void listview_set_num_elements ( listview *lv, unsigned int rows );

/**
 * @param lv The listview handle
 * @param selected The row index to select
 *
 * Select the row, if selected > the number of rows, it selects the last one.
 */
void listview_set_selected ( listview *lv, unsigned int selected );

/**
 * @param lv The listview handle
 *
 * Returns the selected row.
 *
 * @returns the selected row.
 */
unsigned int listview_get_selected ( listview *lv );

/**
 * @param lv The listview handle
 *
 * Get the desired height of the listview widget.
 *
 * @returns the desired height.
 */
unsigned int listview_get_desired_height ( listview *lv );

/**
 * @param lv The listview handle
 *
 * Move the selection one row up.
 * - Wrap around.
 */
void listview_nav_up ( listview *lv );
/**
 * @param lv listview handle.
 *
 * Move the selection one row down.
 * - Wrap around.
 */
void listview_nav_down ( listview *lv );
/**
 * @param lv The listview handle
 *
 * Move the selection one column to the right.
 * - No wrap around.
 * - Do not move to top row when at start.
 */
void listview_nav_right ( listview *lv );
/**
 * @param lv The listview handle 
 *
 * Move the selection one column to the left.
 * - No wrap around.
 */
void listview_nav_left ( listview *lv );
/**
 * @param lv The listview handle 
 *
 * Move the selection one page down.
 * - No wrap around.
 * - Clip at top/bottom
 */
void listview_nav_page_next ( listview *lv );

/**
 * @param lv The listview handle 
 *
 * Move the selection one page up.
 * - No wrap around.
 * - Clip at top/bottom
 */
void listview_nav_page_prev ( listview *lv );

/**
 * @param lv Handler to the listview object
 * @param padding The padding
 *
 * Padding on between the widgets.
 */
void listview_set_padding (  listview *lv, unsigned int padding );

/**
 * @param lv Handler to the listview object
 * @param lines The maximum number of lines
 *
 * Set the maximum number of lines to show.
 */
void listview_set_max_lines ( listview *lv, unsigned int lines );

/**
 * @param lv Handler to the listview object
 * @param columns The maximum number of columns
 *
 * Set the maximum number of columns to show.
 */
void listview_set_max_columns ( listview *lv, unsigned int columns );

/**
 * @param lv Handler to the listview object
 * @param enabled enable
 *
 * Set fixed num lines mode.
 */
void listview_set_fixed_num_lines ( listview *lv, gboolean enabled );
/**
 * @param lv Handler to the listview object
 * @param enabled enable
 *
 * Hide the scrollbar.
 */
void listview_set_show_scrollbar ( listview *lv, gboolean enabled );
/**
 * @param lv Handler to the listview object
 * @param width Width in pixels
 *
 * Set the width of the scrollbar
 */
void listview_set_scrollbar_width ( listview *lv, unsigned int width );

/**
 * @param lv Handler to the listview object
 * @param cycle True for cycle mode
 *
 * Set cycle mode. On last entry go to first.
 */
void listview_set_cycle ( listview *lv, gboolean cycle );
/**
 * @param lv Handler to the listview object
 * @param type ScrollType
 *
 * Set the scroll type ScrollType::LISTVIEW_SCROLL_CONTINIOUS or ScrollType::LISTVIEW_SCROLL_PER_PAGE
 */
void listview_set_scroll_type ( listview *lv, ScrollType type );

/**
 * @param lv Handler to the listview object
 * @param cb The callback
 * @param udata User data
 *
 * Set the mouse activated callback.
 */
void listview_set_mouse_activated_cb ( listview *lv, listview_mouse_activated_cb cb, void *udata );
/**
 * @param lv Handler to the listview object
 * @param enable boolean to enable/disable multi-select
 *
 * Enable,disable multi-select.
 */
void listview_set_multi_select ( listview *lv, gboolean enable );
/* @} */

#endif // ROFI_LISTVIEW_H