GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Enumerations | Functions
gp_widget_grid.h File Reference

A grid to position widgets. More...

#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  gp_widget_grid_flags { GP_WIDGET_GRID_FRAME = 0x01 , GP_WIDGET_GRID_UNIFORM = 0x02 }
 A widget grid flags. More...
 

Functions

gp_widget * gp_widget_grid_new (unsigned int cols, unsigned int rows, int flags)
 Allocates and initializes a widget 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.
 
gp_widget * gp_widget_grid_rem (gp_widget *self, unsigned int col, unsigned int row)
 Removes child widget at col, row from a grid.
 
gp_widget * gp_widget_grid_get (gp_widget *self, unsigned int col, unsigned int row)
 Returns a pointer to a widget at col, row.
 
static void gp_widget_grid_del (gp_widget *self, unsigned col, unsigned int row)
 Deletes a child widget at col, row from a grid.
 
void gp_widget_grid_rows_ins (gp_widget *self, unsigned int row, unsigned int rows)
 Inserts new (empty) rows to the grid.
 
static void gp_widget_grid_row_ins (gp_widget *self, unsigned int row)
 Inserts new (empty) row 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 unsigned int gp_widget_grid_row_append (gp_widget *self)
 Appends a new (empty) row at the bottom of 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_row_prepend (gp_widget *self)
 Prepends a new (empty) row at the top of the grid.
 
void gp_widget_grid_rows_del (gp_widget *self, unsigned int row, unsigned int rows)
 Delete rows from the grid.
 
static void gp_widget_grid_row_del (gp_widget *self, unsigned int row)
 Removes row from the grid.
 
void gp_widget_grid_cols_ins (gp_widget *self, unsigned int col, unsigned int cols)
 Inserts new (empty) columns to the grid.
 
static void gp_widget_grid_col_ins (gp_widget *self, unsigned int col)
 Inserts new (empty) column to 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.
 
static unsigned int gp_widget_grid_col_append (gp_widget *self)
 Appends a new (empty) colum at the right side of 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.
 
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_cols_del (gp_widget *self, unsigned int col, unsigned int cols)
 Delete columns from the grid.
 
static void gp_widget_grid_col_del (gp_widget *self, unsigned int col)
 Delete column 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.
 
static void gp_widget_grid_no_border (gp_widget *self)
 Disables grid padd and fill.
 
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_row_fill_set (gp_widget *self, unsigned int row, uint8_t fill)
 Sets grid cell row fill coeficient.
 

Detailed Description

A grid to position widgets.

{
"info": {"version": 1, "license": "GPL-2.0-or-later"},
"layout": {
"cols": 2, "rows": 3,
"align": "fill",
"cfill": "2 * 1",
"rfill": "1, 2, 1",
"widgets": [
{
"align": "fill",
"widgets": [
{"type": "button", "label": "right-bottom", "halign": "right", "valign": "bottom"}
]
},
{"type": "button", "label": "left-bottom", "halign": "left", "valign": "bottom"},
{"type": "button", "label": "left-top", "halign": "left", "valign": "top"},
{"type": "button", "label": "right-top", "halign": "right", "valign": "top"},
{"type": "button", "label": "fill", "align": "fill"},
{"type": "button", "label": "vfill-right", "halign": "right", "valign": "fill"}
]
}
}

Definition in file gp_widget_grid.h.

Enumeration Type Documentation

◆ gp_widget_grid_flags

A widget grid flags.

Enumerator
GP_WIDGET_GRID_FRAME 

Draw a frame around the grid

GP_WIDGET_GRID_UNIFORM 

Make the cells uniform i.e. all cells have the same size

Definition at line 25 of file gp_widget_grid.h.

Function Documentation

◆ gp_widget_grid_border_set()

void gp_widget_grid_border_set ( gp_widget *  self,
enum gp_widget_border  border,
int  padd,
int  fill 
)

Sets border padd or fill coeficients.

Parameters
selfA grid widget.
borderWhich border(s) are set.
paddPadding coeficient no change on -1 clamped to 255.
fillA filling coeficient no change on -1 clamped to 255.

Referenced by gp_widget_grid_no_border().

◆ gp_widget_grid_col_append()

static unsigned int gp_widget_grid_col_append ( gp_widget *  self)
inlinestatic

Appends a new (empty) colum at the right side of the grid.

Parameters
selfA grid widget.
Returns
A column index to the appended column.

Definition at line 254 of file gp_widget_grid.h.

References gp_widget_grid_cols_append().

◆ gp_widget_grid_col_del()

static void gp_widget_grid_col_del ( gp_widget *  self,
unsigned int  col 
)
inlinestatic

Delete column from the grid.

If there are any widgets in the deleted rows they are freed with gp_widget_free().

Parameters
selfA grid widget.
colWhere to delete column.

Definition at line 298 of file gp_widget_grid.h.

References gp_widget_grid_cols_del().

◆ gp_widget_grid_col_fill_set()

void gp_widget_grid_col_fill_set ( gp_widget *  self,
unsigned int  col,
uint8_t  fill 
)

Sets grid cell column fill coeficient.

Parameters
selfA grid widget.
colA column.
fillA fill coeficient.

◆ gp_widget_grid_col_ins()

static void gp_widget_grid_col_ins ( gp_widget *  self,
unsigned int  col 
)
inlinestatic

Inserts new (empty) column to the grid.

Parameters
selfA grid widget.
colWhere to insert column.

Definition at line 232 of file gp_widget_grid.h.

References gp_widget_grid_cols_ins().

◆ gp_widget_grid_col_prepend()

static void gp_widget_grid_col_prepend ( gp_widget *  self)
inlinestatic

Prepends a new (empty) column at the left side of the grid.

Parameters
selfA grid widget.

Definition at line 272 of file gp_widget_grid.h.

References gp_widget_grid_cols_prepend().

◆ gp_widget_grid_cols_append()

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.

Parameters
selfA grid widget.
colsHow many columns to append.
Returns
A column index to the first appended column.

Referenced by gp_widget_grid_col_append().

◆ gp_widget_grid_cols_del()

void gp_widget_grid_cols_del ( gp_widget *  self,
unsigned int  col,
unsigned int  cols 
)

Delete columns from the grid.

If there are any widgets in the deleted columns they are freed with gp_widget_free().

Parameters
selfA grid widget.
colWhere to delete columns.
colsHow may columns to delete.

Referenced by gp_widget_grid_col_del().

◆ gp_widget_grid_cols_ins()

void gp_widget_grid_cols_ins ( gp_widget *  self,
unsigned int  col,
unsigned int  cols 
)

Inserts new (empty) columns to the grid.

Parameters
selfA grid widget.
colWhere to insert columns.
colsHow many columns to insert.

Referenced by gp_widget_grid_col_ins().

◆ gp_widget_grid_cols_prepend()

void gp_widget_grid_cols_prepend ( gp_widget *  self,
unsigned int  cols 
)

Prepends a new (empty) columns at the left side of the grid.

Parameters
selfA grid widget.
colsHow many columns to append.

Referenced by gp_widget_grid_col_prepend().

◆ gp_widget_grid_del()

static void gp_widget_grid_del ( gp_widget *  self,
unsigned  col,
unsigned int  row 
)
inlinestatic

Deletes a child widget at col, row from a grid.

Parameters
selfA grid widget.
colGrid column.
rowGrid row.

Definition at line 124 of file gp_widget_grid.h.

References gp_widget_grid_rem().

◆ gp_widget_grid_get()

gp_widget * gp_widget_grid_get ( gp_widget *  self,
unsigned int  col,
unsigned int  row 
)

Returns a pointer to a widget at col, row.

Parameters
selfA grid widget.
colGrid column.
rowGrid row.
Returns
A child widget occupying the slot or NULL if it's empty.

◆ gp_widget_grid_new()

gp_widget * gp_widget_grid_new ( unsigned int  cols,
unsigned int  rows,
int  flags 
)

Allocates and initializes a widget grid.

Parameters
colsNumber of grid columns.
rowsNumber of grid rows.
flagsBitwise or of the enum gp_widget_grid_flags.
Returns
A widget grid.

◆ gp_widget_grid_no_border()

static void gp_widget_grid_no_border ( gp_widget *  self)
inlinestatic

Disables grid padd and fill.

Shortcut for gp_widget_grid_border_set(self, GP_WIDGET_BORDER_ALL, 0, 0)

Parameters
selfA grid widget.

Definition at line 322 of file gp_widget_grid.h.

References gp_widget_grid_border_set().

◆ gp_widget_grid_put()

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.

Parameters
selfA grid widget.
colGrid column.
rowGrid row.
childA child widget.
Returns
Previous child occupying the slot or NULL if it was empty.

◆ gp_widget_grid_rem()

gp_widget * gp_widget_grid_rem ( gp_widget *  self,
unsigned int  col,
unsigned int  row 
)

Removes child widget at col, row from a grid.

Parameters
selfA grid widget.
colGrid column.
rowGrid row.
Returns
A child widget removed from the slot or NULL if it was empty.

Referenced by gp_widget_grid_del().

◆ gp_widget_grid_row_append()

static unsigned int gp_widget_grid_row_append ( gp_widget *  self)
inlinestatic

Appends a new (empty) row at the bottom of the grid.

Parameters
selfA grid widget.
Returns
A row index to the appended row.

Definition at line 168 of file gp_widget_grid.h.

References gp_widget_grid_rows_append().

◆ gp_widget_grid_row_del()

static void gp_widget_grid_row_del ( gp_widget *  self,
unsigned int  row 
)
inlinestatic

Removes row from the grid.

If there are any widgets in the deleted rows they are freed with gp_widget_free().

Parameters
selfA grid widget.
rowWhere to delete row.

Definition at line 212 of file gp_widget_grid.h.

References gp_widget_grid_rows_del().

◆ gp_widget_grid_row_fill_set()

void gp_widget_grid_row_fill_set ( gp_widget *  self,
unsigned int  row,
uint8_t  fill 
)

Sets grid cell row fill coeficient.

Parameters
selfA grid widget.
rowA row.
fillA fill coeficient.

◆ gp_widget_grid_row_ins()

static void gp_widget_grid_row_ins ( gp_widget *  self,
unsigned int  row 
)
inlinestatic

Inserts new (empty) row to the grid.

Parameters
selfA grid widget.
rowWhere to insert row.

Definition at line 146 of file gp_widget_grid.h.

References gp_widget_grid_rows_ins().

◆ gp_widget_grid_row_prepend()

static void gp_widget_grid_row_prepend ( gp_widget *  self)
inlinestatic

Prepends a new (empty) row at the top of the grid.

Parameters
selfA grid widget.

Definition at line 186 of file gp_widget_grid.h.

References gp_widget_grid_rows_prepend().

◆ gp_widget_grid_rows_append()

unsigned int gp_widget_grid_rows_append ( gp_widget *  self,
unsigned int  rows 
)

Appends a new (empty) rows at the bottom of the grid.

Parameters
selfA grid widget.
rowsHow many rows to append.
Returns
A row index to the first appended row.

Referenced by gp_widget_grid_row_append().

◆ gp_widget_grid_rows_del()

void gp_widget_grid_rows_del ( gp_widget *  self,
unsigned int  row,
unsigned int  rows 
)

Delete rows from the grid.

If there are any widgets in the deleted rows they are freed with gp_widget_free().

Parameters
selfA grid widget.
rowWhere to delete rows.
rowsHow may rows to delete.

Referenced by gp_widget_grid_row_del().

◆ gp_widget_grid_rows_ins()

void gp_widget_grid_rows_ins ( gp_widget *  self,
unsigned int  row,
unsigned int  rows 
)

Inserts new (empty) rows to the grid.

Parameters
selfA grid widget.
rowWhere to insert rows.
rowsHow many rows to insert.

Referenced by gp_widget_grid_row_ins().

◆ gp_widget_grid_rows_prepend()

void gp_widget_grid_rows_prepend ( gp_widget *  self,
unsigned int  rows 
)

Prepends a new (empty) rows at the top of the grid.

Parameters
selfA grid widget.
rowsHow many rows to append.

Referenced by gp_widget_grid_row_prepend().