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
190typedef struct gp_widget_table {
191 unsigned int cols;
192 unsigned int min_rows;
193
195 const gp_widget_table_header *header;
198
199 unsigned int selected_row;
200 unsigned int sorted_by_col;
201 int row_selected:1;
202 int sorted_desc:1;
203 int needs_header:1;
204
205 uint64_t last_click;
206
207 unsigned int start_row;
208 unsigned int last_rows;
209
211
212 void *priv;
213
214 /* iterator based API */
215 union {
216 void *row_priv;
217 unsigned long row_idx;
218 };
219
220 void *free;
221
222 char buf[];
223} gp_widget_table;
224
232
244gp_widget *gp_widget_table_new(unsigned int cols, unsigned int min_rows,
245 const gp_widget_table_col_ops *col_ops,
246 const gp_widget_table_header *header);
247
258void gp_widget_table_sort_by(gp_widget *self, int desc, unsigned int col);
259
269
276void gp_widget_table_off_set(gp_widget *self, unsigned int off);
277
284void gp_widget_table_sel_set(gp_widget *self, unsigned int row);
285
286#endif /* GP_WIDGET_TABLE_H */
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.
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.
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_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 widget base.
Definition gp_widget.h:28