GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_table.h
Go to the documentation of this file.
1//SPDX-License-Identifier: LGPL-2.0-or-later
2
3/*
4
5 Copyright (c) 2014-2024 Cyril Hrubis <metan@ucw.cz>
6
7 */
8
43#ifndef GP_WIDGET_TABLE_H
44#define GP_WIDGET_TABLE_H
45
67
77
88 const char *id;
90 unsigned long idx;
92 int sortable:1;
94
111 int (*seek_row)(gp_widget *self, int op, unsigned int pos);
123 int (*get_cell)(gp_widget *self, gp_widget_table_cell *cell, unsigned int col_idx);
134 void (*sort)(gp_widget *self, int desc, unsigned int col_idx);
135
144
154
181
185 unsigned int size;
187 unsigned int min_size;
189
193typedef struct gp_widget_table_priv {
197 void *priv;
201 union {
203 void *row_priv;
205 unsigned long row_idx;
206 };
208
209typedef struct gp_widget_table {
210 unsigned int cols;
211 unsigned int min_rows;
212
214 const gp_widget_table_header *header;
217
218 unsigned int selected_row;
219 unsigned int sorted_by_col;
220 int row_selected:1;
221 int sorted_desc:1;
222 int needs_header:1;
223
224 uint64_t last_click;
225 gp_coord click_y;
226 int in_drag_scroll:1;
227 int did_drag_scroll:1;
228
229 unsigned int start_row;
230 unsigned int last_rows;
231
233
235
236 void *free;
237
238 char buf[];
239} gp_widget_table;
240
248
260gp_widget *gp_widget_table_new(unsigned int cols, unsigned int min_rows,
261 const gp_widget_table_col_ops *col_ops,
262 const gp_widget_table_header *header);
263
274void gp_widget_table_sort_by(gp_widget *self, int desc, unsigned int col);
275
285
292void gp_widget_table_off_set(gp_widget *self, unsigned int off);
293
300void gp_widget_table_sel_set(gp_widget *self, unsigned int row);
301
312
320
328
329#endif /* GP_WIDGET_TABLE_H */
int gp_coord
Integer type for coordinates i.e. x, y, ...
Definition gp_types.h:19
void gp_widget_table_refresh(gp_widget *self)
Request table widget refres.
void gp_widget_table_off_set(gp_widget *self, unsigned int off)
Sets first row that should be shown by the table.
bool gp_widget_table_sel_has(gp_widget *self)
Returns if table has a fow selected.
gp_widget_table_event_type
A gp_widget_event::sub_type for a table widget.
@ GP_WIDGET_TABLE_TRIGGER
@ GP_WIDGET_TABLE_SELECT
void gp_widget_table_sel_set(gp_widget *self, unsigned int row)
Sets selected row.
unsigned int gp_widget_table_sel_get(gp_widget *self)
Gets a selected row.
gp_widget_table_row_op
Table row operation.
@ GP_TABLE_ROW_RESET
Sets current row to 0, i.e. the first row in the table.
@ GP_TABLE_ROW_MAX
Returns the number of table rows.
@ GP_TABLE_ROW_ADVANCE
Moves the current row forward.
gp_widget * gp_widget_table_new(unsigned int cols, unsigned int min_rows, const gp_widget_table_col_ops *col_ops, const gp_widget_table_header *header)
Creates a new table widget.
void gp_widget_table_sort_by(gp_widget *self, int desc, unsigned int col)
Sorts a table widget by a column.
gp_widget_table_priv * gp_widget_table_priv_get(gp_widget *self)
Returns a pointer to user data.
gp_widget_tattr
Text attribute flags.
Event structure passed to widget event handler.
A table cell content.
const char * text
An utf8 string.
gp_widget_tattr tattr
A text attribute, font and alignment.
A table column description.
unsigned long idx
An index to map the human readable ID to.
int sortable
If sort is not set this describes if column is sortable.
const char * id
Column human readable ID.
Table operations, defined by the application.
int(* seek_row)(gp_widget *self, int op, unsigned int pos)
Seek function for the table rows.
gp_widget_table_col_desc col_map[]
NULL id terminated column map array.
int(* get_cell)(gp_widget *self, gp_widget_table_cell *cell, unsigned int col_idx)
Returns a cell content.
int(* on_event)(gp_widget_event *ev)
Optional on_event handler.
void * on_event_priv
Optional on_event handler private pointer.
void(* sort)(gp_widget *self, int desc, unsigned int col_idx)
Sorts table by a column.
Cached column size and minimal size, used internally by the widget.
unsigned int min_size
Minimal column width in pixels.
unsigned int size
Current column width in pixels.
A table column header.
gp_widget_tattr tattr
Column header label text attributes.
unsigned int col_min_size
Column minimal size in text letters.
char * label
Column header label, may be NULL.
gp_widget_table_col_desc * col_desc
Pointer to a table column descriptor.
unsigned int col_fill
Column fill coeficient.
A structure to store data for the users of this widget.
unsigned long row_idx
A current row index.
void * priv
A pointer to a data structure with the table data.
void * row_priv
A current row pointer.
A widget base.
Definition gp_widget.h:28