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

A switch widget. More...

#include <widgets/gp_widget_class_bool.h>
#include <widgets/gp_widget_stock.h>

Go to the source code of this file.

Functions

gp_widgetgp_widget_switch_new (const char *on_label, gp_widget_stock_type on_stock, const char *off_label, gp_widget_stock_type off_stock, bool set)
 Allocate and initialize new switch widget.
 
static gp_widgetgp_widget_switch_new_ev (const char *on_label, gp_widget_stock_type on_stock, const char *off_label, gp_widget_stock_type off_stock, bool set, int(*on_event)(gp_widget_event *ev), void *priv)
 Allocate and initialize new switch widget.
 

Detailed Description

A switch widget.

Switch is a bool class widget, after it's created it's acessed by the class functions such as gp_widget_bool_set().

Switch widget JSON attributes

| Attribute | Type | Default | Description | |------------—|-----—|-------------------—|------------—00---------------—| | label | string | NULL | Sets both off_label and on_label. | | on_label | string | NULL | A label when switch is on. | | on_stock | string | GP_WIDGET_STOCK_NONE | Stock image when switch is on. | | off_label | string | NULL | A label when switch is off. | | off_stock | string | GP_WIDGET_STOCK_NONE | Stock image when switch is off. | | set | bool | false | Initial switch state. |

Definition in file gp_widget_switch.h.

Function Documentation

◆ gp_widget_switch_new()

gp_widget * gp_widget_switch_new ( const char *  on_label,
gp_widget_stock_type  on_stock,
const char *  off_label,
gp_widget_stock_type  off_stock,
bool  set 
)

Allocate and initialize new switch widget.

Parameters
on_labelA label when switch is on, can be NULL if there is none.
on_stockA stock image when switch is on, can be GP_WIDGET_STOCK_NONE if there is none.
off_labelA label when switch is off, can be NULL if there is none.
off_stockA stock image when switch is off, can be GP_WIDGET_STOCK_NONE if there is none.
setAn initial state for the switch.
Returns
A switch widget.

Referenced by gp_widget_switch_new_ev().

◆ gp_widget_switch_new_ev()

static gp_widget * gp_widget_switch_new_ev ( const char *  on_label,
gp_widget_stock_type  on_stock,
const char *  off_label,
gp_widget_stock_type  off_stock,
bool  set,
int(*)(gp_widget_event *ev)  on_event,
void *  priv 
)
inlinestatic

Allocate and initialize new switch widget.

Parameters
on_labelA label when switch is on, can be NULL if there is none.
on_stockA stock image when switch is on, can be GP_WIDGET_STOCK_NONE if there is none.
off_labelA label when switch is off, can be NULL if there is none.
off_stockA stock image when switch is off, can be GP_WIDGET_STOCK_NONE if there is none.
setAn initial state for the switch.
on_eventAn widget event handler.
privUser private data.
Returns
A switch widget.

Definition at line 67 of file gp_widget_switch.h.

References gp_widget_on_event_set(), and gp_widget_switch_new().