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
46#include <core/gp_compiler.h>
47
69
79
90 const char *id;
92 unsigned long idx;
94 int sortable:1;
96
113 int (*seek_row)(gp_widget *self, int op, unsigned int pos);
125 int (*get_cell)(gp_widget *self, gp_widget_table_cell *cell, unsigned int col_idx);
136 void (*sort)(gp_widget *self, int desc, unsigned int col_idx);
137
146
156
183
187 unsigned int size;
189 unsigned int min_size;
191
195typedef struct gp_widget_table_priv {
199 void *priv;
203 union {
205 void *row_priv;
207 unsigned long row_idx;
208 };
210
211typedef struct gp_widget_table {
212 unsigned int cols;
213 unsigned int min_rows;
214
216 const gp_widget_table_header *header;
219
220 unsigned int selected_row;
221 unsigned int sorted_by_col;
222 int row_selected:1;
223 int sorted_desc:1;
224 int needs_header:1;
225
226 uint64_t last_click;
227 gp_coord click_y;
228 int in_drag_scroll:1;
229 int did_drag_scroll:1;
230
231 unsigned int start_row;
232 unsigned int last_rows;
233
235
237
238 void *free;
239
240 char buf[] GP_ALIGNED;
241} gp_widget_table;
242
250
262gp_widget *gp_widget_table_new(unsigned int cols, unsigned int min_rows,
263 const gp_widget_table_col_ops *col_ops,
264 const gp_widget_table_header *header);
265
276void gp_widget_table_sort_by(gp_widget *self, int desc, unsigned int col);
277
287
294void gp_widget_table_off_set(gp_widget *self, unsigned int off);
295
302void gp_widget_table_sel_set(gp_widget *self, unsigned int row);
303
314
322
330
331#endif /* GP_WIDGET_TABLE_H */
int gp_coord
Integer type for coordinates i.e. x, y, ...
Definition gp_types.h:19
A compiler dependent macros.
void gp_widget_table_refresh(gp_widget *self)
Request table widget refres.
struct gp_widget_table_header gp_widget_table_header
A table column header.
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.
struct gp_widget_table_priv gp_widget_table_priv
A structure to store data for the users of this widget.
struct gp_widget_table_cell gp_widget_table_cell
A table cell content.
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.
struct gp_widget_table_col_desc gp_widget_table_col_desc
A table column description.
struct gp_widget_table_col_size gp_widget_table_col_size
Cached column size and minimal size, used internally by the widget.
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.
struct gp_widget_table_col_ops gp_widget_table_col_ops
Table operations, defined by the application.
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:29