GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_grid.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
81#ifndef GP_WIDGET_GRID_H
82#define GP_WIDGET_GRID_H
83
84#include <stdint.h>
85
95
96/* row/column cell sizes, offsets and fill coefs */
97struct gp_widget_grid_cell {
98 unsigned int size;
99 unsigned int off;
100 uint8_t fill;
101};
102
104typedef struct gp_widget_grid_gap {
111 uint8_t padd;
120 uint8_t fill;
122
134gp_widget *gp_widget_grid_new(unsigned int cols, unsigned int rows,
135 enum gp_widget_grid_flags flags);
136
144
152
167
182
190
198
213gp_widget *gp_widget_grid_put(gp_widget *self, unsigned int col, unsigned int row,
214 gp_widget *child);
215
225gp_widget *gp_widget_grid_rem(gp_widget *self, unsigned int col, unsigned int row);
226
236gp_widget *gp_widget_grid_get(gp_widget *self, unsigned int col, unsigned int row);
237
245static inline void gp_widget_grid_del(gp_widget *self, unsigned col, unsigned int row)
246{
247 gp_widget *ret = gp_widget_grid_rem(self, col, row);
248
249 gp_widget_free(ret);
250}
251
259void gp_widget_grid_rows_ins(gp_widget *self, unsigned int row, unsigned int rows);
260
267static inline void gp_widget_grid_row_ins(gp_widget *self, unsigned int row)
268{
269 gp_widget_grid_rows_ins(self, row, 1);
270}
271
280unsigned int gp_widget_grid_rows_append(gp_widget *self, unsigned int rows);
281
289static inline unsigned int gp_widget_grid_row_append(gp_widget *self)
290{
291 return gp_widget_grid_rows_append(self, 1);
292}
293
300void gp_widget_grid_rows_prepend(gp_widget *self, unsigned int rows);
301
307static inline void gp_widget_grid_row_prepend(gp_widget *self)
308{
309 return gp_widget_grid_rows_prepend(self, 1);
310}
311
322void gp_widget_grid_rows_del(gp_widget *self, unsigned int row, unsigned int rows);
323
333static inline void gp_widget_grid_row_del(gp_widget *self, unsigned int row)
334{
335 gp_widget_grid_rows_del(self, row, 1);
336}
337
345void gp_widget_grid_cols_ins(gp_widget *self, unsigned int col, unsigned int cols);
346
353static inline void gp_widget_grid_col_ins(gp_widget *self, unsigned int col)
354{
355 gp_widget_grid_cols_ins(self, col, 1);
356}
357
366unsigned int gp_widget_grid_cols_append(gp_widget *self, unsigned int cols);
367
375static inline unsigned int gp_widget_grid_col_append(gp_widget *self)
376{
377 return gp_widget_grid_cols_append(self, 1);
378}
379
386void gp_widget_grid_cols_prepend(gp_widget *self, unsigned int cols);
387
393static inline void gp_widget_grid_col_prepend(gp_widget *self)
394{
395 return gp_widget_grid_cols_prepend(self, 1);
396}
397
408void gp_widget_grid_cols_del(gp_widget *self, unsigned int col, unsigned int cols);
409
419static inline void gp_widget_grid_col_del(gp_widget *self, unsigned int col)
420{
421 gp_widget_grid_cols_del(self, col, 1);
422}
423
424
434 int padd, int fill);
435
443static inline void gp_widget_grid_no_border(gp_widget *self)
444{
446}
447
461void gp_widget_grid_col_fill_set(gp_widget *self, unsigned int col, uint8_t fill);
462
476void gp_widget_grid_row_fill_set(gp_widget *self, unsigned int row, uint8_t fill);
477
478#endif /* GP_WIDGET_GRID_H */
void gp_widget_free(gp_widget *self)
Frees widget memory.
unsigned int gp_widget_grid_cols_get(gp_widget *self)
Returns number of grid columns.
static void gp_widget_grid_row_prepend(gp_widget *self)
Prepends a new (empty) row at the top of the grid.
gp_widget * gp_widget_grid_put(gp_widget *self, unsigned int col, unsigned int row, gp_widget *child)
Puts a child widget into a frame widget.
void gp_widget_grid_rows_ins(gp_widget *self, unsigned int row, unsigned int rows)
Inserts new (empty) rows to the grid.
void gp_widget_grid_cols_prepend(gp_widget *self, unsigned int cols)
Prepends a new (empty) columns at the left side of the grid.
gp_widget * gp_widget_grid_new(unsigned int cols, unsigned int rows, enum gp_widget_grid_flags flags)
Allocates and initializes a widget grid.
void gp_widget_grid_rows_del(gp_widget *self, unsigned int row, unsigned int rows)
Delete rows from the grid.
unsigned int gp_widget_grid_rows_get(gp_widget *self)
Returns number of grid rows.
void gp_widget_grid_cols_ins(gp_widget *self, unsigned int col, unsigned int cols)
Inserts new (empty) columns to the grid.
unsigned int gp_widget_grid_rows_append(gp_widget *self, unsigned int rows)
Appends a new (empty) rows at the bottom of the grid.
static void gp_widget_grid_col_del(gp_widget *self, unsigned int col)
Delete column from the grid.
enum gp_widget_grid_flags gp_widget_grid_flags_get(gp_widget *self)
static void gp_widget_grid_del(gp_widget *self, unsigned col, unsigned int row)
Deletes a child widget at col, row from a grid.
static void gp_widget_grid_row_ins(gp_widget *self, unsigned int row)
Inserts new (empty) row to the grid.
static unsigned int gp_widget_grid_col_append(gp_widget *self)
Appends a new (empty) colum at the right side of the grid.
gp_widget_grid_flags
A widget grid flags.
@ GP_WIDGET_GRID_FRAME
@ GP_WIDGET_GRID_UNIFORM
static void gp_widget_grid_col_ins(gp_widget *self, unsigned int col)
Inserts new (empty) column to the grid.
void gp_widget_grid_rows_prepend(gp_widget *self, unsigned int rows)
Prepends a new (empty) rows at the top of the grid.
static void gp_widget_grid_col_prepend(gp_widget *self)
Prepends a new (empty) column at the left side of the grid.
void gp_widget_grid_col_fill_set(gp_widget *self, unsigned int col, uint8_t fill)
Sets grid cell column fill coeficient.
void gp_widget_grid_flags_set(gp_widget *self, enum gp_widget_grid_flags flags)
static void gp_widget_grid_no_border(gp_widget *self)
Disables grid padd and fill.
static unsigned int gp_widget_grid_row_append(gp_widget *self)
Appends a new (empty) row at the bottom of the grid.
unsigned int gp_widget_grid_cols_append(gp_widget *self, unsigned int cols)
Appends a new (empty) colums at the right side of the grid.
gp_widget * gp_widget_grid_rem(gp_widget *self, unsigned int col, unsigned int row)
Removes child widget at col, row from a grid.
const gp_widget_grid_gap * gp_widget_grid_cols_gaps_get(gp_widget *self)
Returns a widget grid horizontal borders.
void gp_widget_grid_row_fill_set(gp_widget *self, unsigned int row, uint8_t fill)
Sets grid cell row fill coeficient.
gp_widget * gp_widget_grid_get(gp_widget *self, unsigned int col, unsigned int row)
Returns a pointer to a widget at col, row.
void gp_widget_grid_cols_del(gp_widget *self, unsigned int col, unsigned int cols)
Delete columns from the grid.
const gp_widget_grid_gap * gp_widget_grid_rows_gaps_get(gp_widget *self)
Returns a widget grid vertical borders.
static void gp_widget_grid_row_del(gp_widget *self, unsigned int row)
Removes row from the grid.
void gp_widget_grid_border_set(gp_widget *self, enum gp_widget_border border, int padd, int fill)
Sets border padd or fill coeficients.
gp_widget_border
Describes borders.
@ GP_WIDGET_BORDER_ALL
All borders selected.
Describes a row or a column border or a gap between cells.
uint8_t padd
A padding, static part of the border/gap.
uint8_t fill
A dynamic part of the border/gap.
A widget base.
Definition gp_widget.h:28