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

A stock 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_stock_switch_new (gp_widget_stock_type on_stock, gp_widget_stock_type off_stock, gp_widget_size min_size, bool set)
 Allocate and initialize new stock switch widget.
 
static gp_widgetgp_widget_stock_switch_new_ev (gp_widget_stock_type on_stock, gp_widget_stock_type off_stock, gp_widget_size min_size, bool set, int(*on_event)(gp_widget_event *ev), void *priv)
 Allocate and initialize new stock switch widget.
 

Detailed Description

A stock switch widget.

Stock switch is a widget that cycles between two images to represent on and off state and is changed by clicking on the stock images. Consider for example shuffle_on and shuffle_off stock images as a canonical example of such widget.

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

Stock switch widget JSON attributes

Attribute Type Default Description
min_size string 2*pad + asc Minimal size parsed by gp_widget_size_units_parse().
on_stock string GP_WIDGET_STOCK_NONE Stock image when switch is on.
off_stock string GP_WIDGET_STOCK_NONE Stock image when switch is off.
set bool false Initial switch state.

Definition in file gp_widget_stock_switch.h.

Function Documentation

◆ gp_widget_stock_switch_new()

gp_widget * gp_widget_stock_switch_new ( gp_widget_stock_type  on_stock,
gp_widget_stock_type  off_stock,
gp_widget_size  min_size,
bool  set 
)

Allocate and initialize new stock switch widget.

Parameters
on_stockA stock image when switch is on, can be GP_WIDGET_STOCK_NONE if there is none.
off_stockA stock image when switch is off, can be GP_WIDGET_STOCK_NONE if there is none.
min_sizeA minimal widget size parsed by gp_widget_size_units_parse(). Pass GP_WIDGET_SIZE_DEFAULT for a default size.
setAn initial state for the switch.
Returns
A stock switch widget.

Referenced by gp_widget_stock_switch_new_ev().

◆ gp_widget_stock_switch_new_ev()

static gp_widget * gp_widget_stock_switch_new_ev ( gp_widget_stock_type  on_stock,
gp_widget_stock_type  off_stock,
gp_widget_size  min_size,
bool  set,
int(*)(gp_widget_event *ev)  on_event,
void *  priv 
)
inlinestatic

Allocate and initialize new stock switch widget.

Parameters
on_stockA stock image when switch is on, can be GP_WIDGET_STOCK_NONE 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 stock switch widget.

Definition at line 68 of file gp_widget_stock_switch.h.

References gp_widget_on_event_set(), and gp_widget_stock_switch_new().