BSB Developer Docs
Loading...
Searching...
No Matches
countdown.h File Reference

A widget that displays time until or from the specified timestamp. More...

#include <gui/widget.h>
#include <gui/gui.h>
#include <toolbox/color.h>
#include <time.h>

Go to the source code of this file.

Typedefs

typedef struct Countdown Countdown
 Countdown opaque structure.
 
typedef void(* CountdownCallback) (void *context)
 Countdown callback function type.
 

Enumerations

enum  CountdownDirection { CountdownDirectionTimeLeft , CountdownDirectionTimeSince , CountdownDirectionMAX }
 
enum  CountdownShowHour { CountdownShowHourAlways , CountdownShowHourWhenNonZero , CountdownShowHourMAX }
 

Functions

Countdown * countdown_alloc (Widget *parent)
 Create a new Countdown instance.
 
void countdown_free (Countdown *instance)
 Delete a Countdown instance.
 
Widget * countdown_get_base (Countdown *instance)
 Get a pointer to the base class instance.
 
void countdown_set_callback (Countdown *instance, CountdownCallback callback, void *context)
 Set a countdown callback.
 
void countdown_set_text_color (Countdown *instance, Color color)
 Set the countdown text color.
 
void countdown_set_text_font (Countdown *instance, const char *font_path)
 Set the countdown font from a font file.
 
void countdown_begin (Countdown *instance, time_t time, CountdownDirection direction, CountdownShowHour hours)
 Starts counting down (or up)
 
void countdown_stop (Countdown *instance)
 Stop counting.
 

Detailed Description

A widget that displays time until or from the specified timestamp.

Typedef Documentation

◆ CountdownCallback

typedef void(* CountdownCallback) (void *context)

Countdown callback function type.

Parameters
[in,out]contextpointer to a user-specific object

Function Documentation

◆ countdown_alloc()

Countdown * countdown_alloc ( Widget * parent)

Create a new Countdown instance.

Parameters
[in,out]parentpointer to the parent Widget instance
Returns
pointer to the newly created Countdown instance

◆ countdown_begin()

void countdown_begin ( Countdown * instance,
time_t time,
CountdownDirection direction,
CountdownShowHour hours )

Starts counting down (or up)

Parameters
[in]instancepointer to the Countdown instance to be modified
[in]timeseconds-based Unix timestamp to count down to or up from
[in]directionexplicit counting direction - see CountdownDirection enum
[in]hourswhen to show the hours position - see CountdownShowHour enum

◆ countdown_free()

void countdown_free ( Countdown * instance)

Delete a Countdown instance.

Parameters
[in,out]instancepointer to the Countdown instance to be deleted

◆ countdown_get_base()

Widget * countdown_get_base ( Countdown * instance)

Get a pointer to the base class instance.

The return value can be used in all Widget methods.

Parameters
[in,out]instancepointer to the Countdown instance to be queried
Returns
pointer to the base class instance

◆ countdown_set_callback()

void countdown_set_callback ( Countdown * instance,
CountdownCallback callback,
void * context )

Set a countdown callback.

The callback function is called when the timer reaches zero. Works only when CountdownDirectionTimeLeft is set.

Parameters
[in,out]instancepointer to the Countdown instance to be queried
[in]callbackcallback function pointer
[in]contextcallback context data

◆ countdown_set_text_color()

void countdown_set_text_color ( Countdown * instance,
Color color )

Set the countdown text color.

Parameters
[in,out]instancepointer to the Countdown instance to be modified
[in]colortext color

◆ countdown_set_text_font()

void countdown_set_text_font ( Countdown * instance,
const char * font_path )

Set the countdown font from a font file.

Parameters
[in,out]instancepointer to the Countdown instance to be modified
[in]font_pathpath to font file

◆ countdown_stop()

void countdown_stop ( Countdown * instance)

Stop counting.

Parameters
[in]instancepointer to the Countdown instance to be modified