Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Progress bar widget

Modules

 Progress bar widget options
 These options can be ORed together to specify the behaviour of a progress bar widget when creating it with wtk_progress_bar_create.
 

Data Structures

struct  wtk_progress_bar
 Progress bar control struct. More...
 

Functions

struct win_windowwtk_progress_bar_as_child (struct wtk_progress_bar *bar)
 Get pointer to progress bar window. More...
 
struct wtk_progress_barwtk_progress_bar_create (struct win_window *parent, struct win_area const *area, uint8_t maximum, uint8_t value, gfx_color_t fill_color, gfx_color_t background_color, uint8_t option)
 Create a new progress bar widget. More...
 
uint8_t wtk_progress_bar_get_value (struct wtk_progress_bar *bar)
 Get progress bar value. More...
 
void wtk_progress_bar_set_colors (struct wtk_progress_bar *bar, gfx_color_t color1, gfx_color_t color2)
 Set new progress bar colors. More...
 
bool wtk_progress_bar_set_value (struct wtk_progress_bar *bar, uint8_t value)
 Set new progress bar value. More...
 
#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK
 Color of the progress bar's frame border. More...
 
#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK
 Color of the progress bar's frame border. More...
 
#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK
 Color of the progress bar's frame border. More...
 
#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK
 Color of the progress bar's frame border. More...
 
#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK
 Color of the progress bar's frame border. More...
 
static bool wtk_progress_bar_handler (struct win_window *win, enum win_event_type type, void const *data)
 Progress bar event handler. More...
 

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK

Color of the progress bar's frame border.

Referenced by wtk_progress_bar_handler().

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK

Color of the progress bar's frame border.

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK

Color of the progress bar's frame border.

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK

Color of the progress bar's frame border.

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR_BLACK

Color of the progress bar's frame border.

struct win_window* wtk_progress_bar_as_child ( struct wtk_progress_bar bar)

Get pointer to progress bar window.

Returns a reference to the window that should be used when managing the widget, such as destroying, moving or reparenting it.

Parameters
barPointer to wtk_progress_bar struct to manage.
Returns
Pointer to window to be used for managing the progress bar.

References Assert, and wtk_progress_bar::container.

Referenced by app_widget_launch(), and app_widget_update_colors().

struct wtk_progress_bar* wtk_progress_bar_create ( struct win_window parent,
struct win_area const *  area,
uint8_t  maximum,
uint8_t  value,
gfx_color_t  fill_color,
gfx_color_t  background_color,
uint8_t  option 
)

Create a new progress bar widget.

Allocates the necessary memory and intializes the window and data for progress bar widgets. If there is not enough memory, the function returns NULL.
To destroy a progress bar widget and all its contents, and free its memory, call win_destroy() on the progress bar's child reference, given by wtk_progress_bar_as_child(), like this: "win_destroy(wtk_progress_bar_as_child(my_progress_bar_ptr));".

Progress bar widgets divide their window area in two non-overlapping rectangles: one with a fill color, and one with a background color. The ratio between the two rectangles' sizes is given by the progress bar's value relative to its maximum: a higher value gives a larger fill.

By default, a vertically oriented progress bar fills from the top, while a horizontal one fills from the left. The progress bar's orientation and fill direction can both be configured at the time of creation. The fill and background colors can be changed at runtime.

Refer to <gfx/wtk.h> for available configuration options.

Parameters
parentPointer to parent win_window struct.
areaPointer to win_area struct with position and size of the progress bar. Minimum size in both x and y direction is 3 pixels.
maximumMaximum value of the progress bar.
valueInitial value of the progress bar.
fill_colorColor for filled area.
background_colorColor for background area.
optionConfiguration options for progress bar.
Returns
Pointer to new progress bar, if memory allocation was successful.

References win_attributes::area, Assert, win_attributes::background, wtk_progress_bar::background_color, win_attributes::behavior, wtk_progress_bar::container, win_attributes::custom, win_attributes::event_handler, wtk_progress_bar::fill_color, wtk_progress_bar::maximum, membag_alloc(), membag_free(), NULL, wtk_progress_bar::option, wtk_progress_bar::position, win_area::size, wtk_progress_bar::value, win_create(), wtk_progress_bar_handler(), WTK_PROGRESS_BAR_INVERT, WTK_PROGRESS_BAR_VERTICAL, wtk_rescale_value(), win_point::x, and win_point::y.

Referenced by app_widget_launch().

uint8_t wtk_progress_bar_get_value ( struct wtk_progress_bar bar)

Get progress bar value.

Parameters
barPointer to wtk_progress_bar struct to get value from.
Returns
Value of progress bar.

References Assert, and wtk_progress_bar::value.

static bool wtk_progress_bar_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
)
static

Progress bar event handler.

This is the window event handler for progress bar widgets. It handles the two relevant event types sent to a progress bar's container window, i.e., drawing, and destroy events.

Parameters
winWindow receiving the event.
typeThe event type.
dataCustom data, depending on event type.
Returns
True if the event was recognized and accepted.

References Assert, wtk_progress_bar::background_color, wtk_progress_bar::container, wtk_progress_bar::fill_color, gfx_draw_filled_rect, gfx_draw_rect, membag_free(), wtk_progress_bar::option, win_clip_region::origin, wtk_progress_bar::position, win_area::size, WIN_EVENT_DESTROY, WIN_EVENT_DRAW, win_get_area(), win_get_custom_data(), WTK_PROGRESS_BAR_BORDER_COLOR, WTK_PROGRESS_BAR_VERTICAL, win_point::x, and win_point::y.

Referenced by wtk_progress_bar_create().

void wtk_progress_bar_set_colors ( struct wtk_progress_bar bar,
gfx_color_t  fill_color,
gfx_color_t  background_color 
)

Set new progress bar colors.

This sets new fill and background colors for the progress bar. If the bar is inverted, the two colors are switched.

Parameters
barPointer to wtk_progress_bar struct to set colors for.
fill_colorFill color to set for progress bar.
background_colorBackground color to set for progress bar.

References Assert, wtk_progress_bar::background_color, wtk_progress_bar::fill_color, wtk_progress_bar::option, and WTK_PROGRESS_BAR_INVERT.

Referenced by app_widget_update_colors().

bool wtk_progress_bar_set_value ( struct wtk_progress_bar bar,
uint8_t  value 
)

Set new progress bar value.

Updates the current value and issues a redrawing of the progress bar if its value was indeed changed. In this case, a new end position for the progress bar's fill area is also computed.

Parameters
barPointer to wtk_progress_bar struct to set new value for.
valueNew value for the progress bar.
Returns
True if progress bar's value was changed.

References Assert, wtk_progress_bar::container, wtk_progress_bar::maximum, wtk_progress_bar::option, wtk_progress_bar::position, win_area::size, wtk_progress_bar::value, win_get_area(), win_redraw(), WTK_PROGRESS_BAR_INVERT, WTK_PROGRESS_BAR_VERTICAL, wtk_rescale_value(), win_point::x, and win_point::y.

Referenced by widget_frame_command_handler().