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

A tabs widget. More...

Go to the source code of this file.

Enumerations

enum  gp_widget_tabs_event_type { GP_WIDGET_TABS_DEACTIVATED , GP_WIDGET_TABS_ACTIVATED }
 A gp_widget_event::sub_type for a tabs widget. More...
 

Functions

gp_widgetgp_widget_tabs_new (unsigned int tabs_cnt, unsigned int active_tab, const char *tab_labels[], int flags)
 Allocates and initializes a new tabs widget.
 
unsigned int gp_widget_tabs_cnt (gp_widget *self)
 Returns number of tabs.
 
gp_widgetgp_widget_tabs_put (gp_widget *self, unsigned int tab, gp_widget *child)
 Puts a child into a tab.
 
static gp_widgetgp_widget_tabs_rem (gp_widget *self, unsigned int tab)
 Removes child from a tab and returns pointer to it.
 
gp_widgetgp_widget_tabs_child_get (gp_widget *self, unsigned int tab)
 Returns a pointer to a child in a tab.
 
void gp_widget_tabs_tab_ins (gp_widget *self, unsigned int tab, const char *label, gp_widget *child)
 Adds a tab at an offset.
 
unsigned int gp_widget_tabs_tab_append (gp_widget *self, const char *label, gp_widget *child)
 Appends a tab at the end.
 
static void gp_widget_tabs_tab_prepend (gp_widget *self, const char *label, gp_widget *child)
 Appends a tab at the begining.
 
gp_widgetgp_widget_tabs_tab_rem (gp_widget *self, unsigned int tab)
 Remove a tab at position.
 
int gp_widget_tabs_tab_rem_by_child (gp_widget *self, gp_widget *child)
 Remove a tab identified by a child widget.
 
static int gp_widget_tabs_tab_del_by_child (gp_widget *self, gp_widget *child)
 Delete a tab identified by a child widget.
 
static void gp_widget_tabs_tab_del (gp_widget *self, unsigned int tab)
 Delete a tab at position.
 
unsigned int gp_widget_tabs_active_get (gp_widget *self)
 Returns active tab index.
 
gp_widgetgp_widget_tabs_active_child_get (gp_widget *self)
 Returns active tab child widget.
 
void gp_widget_tabs_active_set (gp_widget *self, unsigned int tab)
 Set active tab.
 
void gp_widget_tabs_active_set_rel (gp_widget *self, int dir, int wrap_around)
 Set active tab position relative to the currently active tab.
 
int gp_widget_tabs_tab_by_child (gp_widget *self, gp_widget *child)
 Returns tab idx by child pointer.
 
const char * gp_widget_tabs_label_get (gp_widget *self, unsigned int tab)
 Returns a tab label.
 
const char * gp_widget_tabs_active_label_get (gp_widget *self)
 Returns active tab label.
 

Detailed Description

A tabs widget.

Tabs widget JSON attributes

Attribute Type Default Description
labels array Array of string labels.
widgets array Array of child widgets.
active uint 0 Active tab, index into the labels and widgets array.

Definition in file gp_widget_tabs.h.

Enumeration Type Documentation

◆ gp_widget_tabs_event_type

A gp_widget_event::sub_type for a tabs widget.

Enumerator
GP_WIDGET_TABS_DEACTIVATED 

A tab is deactivated.

GP_WIDGET_TABS_ACTIVATED 

A tab activated.

Definition at line 43 of file gp_widget_tabs.h.

Function Documentation

◆ gp_widget_tabs_active_child_get()

gp_widget * gp_widget_tabs_active_child_get ( gp_widget self)

Returns active tab child widget.

Parameters
selfA tabs widget.
Returns
An active tab child widget.

◆ gp_widget_tabs_active_get()

unsigned int gp_widget_tabs_active_get ( gp_widget self)

Returns active tab index.

Parameters
selfA tabs widget.
Returns
An active tab index.

◆ gp_widget_tabs_active_label_get()

const char * gp_widget_tabs_active_label_get ( gp_widget self)

Returns active tab label.

Parameters
selfA tabs widget.
Returns
An active tab label.

◆ gp_widget_tabs_active_set()

void gp_widget_tabs_active_set ( gp_widget self,
unsigned int  tab 
)

Set active tab.

Parameters
selfA tabs widget.
tabA tab index.

◆ gp_widget_tabs_active_set_rel()

void gp_widget_tabs_active_set_rel ( gp_widget self,
int  dir,
int  wrap_around 
)

Set active tab position relative to the currently active tab.

Parameters
selfA tabs widget
dirA direction to go to
wrap_aroundContinue to beginning if we reach end and the other way around.

◆ gp_widget_tabs_child_get()

gp_widget * gp_widget_tabs_child_get ( gp_widget self,
unsigned int  tab 
)

Returns a pointer to a child in a tab.

Parameters
selfA tabs widget.
tabIndex of tab to put the child into.
Returns
A child widget ocupying the slot or NULL if it's empty.

◆ gp_widget_tabs_cnt()

unsigned int gp_widget_tabs_cnt ( gp_widget self)

Returns number of tabs.

Parameters
selfA tabs widget.
Returns
A number of tabs.

◆ gp_widget_tabs_label_get()

const char * gp_widget_tabs_label_get ( gp_widget self,
unsigned int  tab 
)

Returns a tab label.

Parameters
selfA tabs widget.
tabA tab index.
Returns
A tab label or NULL if tab is out of range.

◆ gp_widget_tabs_new()

gp_widget * gp_widget_tabs_new ( unsigned int  tabs_cnt,
unsigned int  active_tab,
const char *  tab_labels[],
int  flags 
)

Allocates and initializes a new tabs widget.

Parameters
tabs_cntNumber of tabs.
active_tabInitially active tab.
tab_labelsArray of tab labels.
flagsCurrently unused, must be 0.
Returns
A tabs widget.

◆ gp_widget_tabs_put()

gp_widget * gp_widget_tabs_put ( gp_widget self,
unsigned int  tab,
gp_widget child 
)

Puts a child into a tab.

Parameters
selfA tabs widget.
tabIndex of tab to put the child into.
childA tab child widget.
Returns
Previous child occupying the slot or NULL if it was empty.

Referenced by gp_widget_tabs_rem().

◆ gp_widget_tabs_rem()

static gp_widget * gp_widget_tabs_rem ( gp_widget self,
unsigned int  tab 
)
inlinestatic

Removes child from a tab and returns pointer to it.

Parameters
selfA tabs widget.
tabTab position.
Returns
A child widget ocupying the slot or NULL if it's empty.

Definition at line 92 of file gp_widget_tabs.h.

References gp_widget_tabs_put().

◆ gp_widget_tabs_tab_append()

unsigned int gp_widget_tabs_tab_append ( gp_widget self,
const char *  label,
gp_widget child 
)

Appends a tab at the end.

Parameters
selfA tabs widget.
labelTabs label.
childA tab child, may be NULL.
Returns
Index of the appended tab.

◆ gp_widget_tabs_tab_by_child()

int gp_widget_tabs_tab_by_child ( gp_widget self,
gp_widget child 
)

Returns tab idx by child pointer.

Parameters
selfA tabs widget.
childA tabs child.
Returns
Tab index, if found, -1 otherwise.

◆ gp_widget_tabs_tab_del()

static void gp_widget_tabs_tab_del ( gp_widget self,
unsigned int  tab 
)
inlinestatic

Delete a tab at position.

Removes a tab and frees the child widget.

Parameters
selfA tabs widget.
tabA tab index.

Definition at line 199 of file gp_widget_tabs.h.

References gp_widget_free(), and gp_widget_tabs_tab_rem().

◆ gp_widget_tabs_tab_del_by_child()

static int gp_widget_tabs_tab_del_by_child ( gp_widget self,
gp_widget child 
)
inlinestatic

Delete a tab identified by a child widget.

Parameters
selfA tabs widget.
childA tab child widget.

On successful deletion child is freed as well.

Returns
Zero on success non-zero if child was not found.

Definition at line 181 of file gp_widget_tabs.h.

References gp_widget_free(), and gp_widget_tabs_tab_rem_by_child().

◆ gp_widget_tabs_tab_ins()

void gp_widget_tabs_tab_ins ( gp_widget self,
unsigned int  tab,
const char *  label,
gp_widget child 
)

Adds a tab at an offset.

Parameters
selfA tabs widget.
tabAn offset.
labelTabs label.
childA tab child, may be NULL.

Referenced by gp_widget_tabs_tab_prepend().

◆ gp_widget_tabs_tab_prepend()

static void gp_widget_tabs_tab_prepend ( gp_widget self,
const char *  label,
gp_widget child 
)
inlinestatic

Appends a tab at the begining.

Parameters
selfA tabs widget.
labelTabs label.
childA tab child, may be NULL.

Definition at line 144 of file gp_widget_tabs.h.

References gp_widget_tabs_tab_ins().

◆ gp_widget_tabs_tab_rem()

gp_widget * gp_widget_tabs_tab_rem ( gp_widget self,
unsigned int  tab 
)

Remove a tab at position.

Parameters
selfA tabs widget.
tabA tab index.
Returns
A tab child.

Referenced by gp_widget_tabs_tab_del().

◆ gp_widget_tabs_tab_rem_by_child()

int gp_widget_tabs_tab_rem_by_child ( gp_widget self,
gp_widget child 
)

Remove a tab identified by a child widget.

Parameters
selfA tabs widget.
childA tab child widget.
Returns
Zero on success non-zero if child was not found.

Referenced by gp_widget_tabs_tab_del_by_child().