Progress bar widget
[Widget toolkit]

Collaboration diagram for Progress bar widget:

Data Structures

struct  wtk_progress_bar
 Progress bar control struct. More...

Modules

 Progress bar widget options

Functions

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.
struct win_windowwtk_progress_bar_as_child (struct wtk_progress_bar *bar)
 Get pointer to progress bar window.
uint8_t wtk_progress_bar_get_value (struct wtk_progress_bar *bar)
 Get progress bar value.
bool wtk_progress_bar_set_value (struct wtk_progress_bar *bar, uint8_t value)
 Set new progress bar value.
void wtk_progress_bar_set_colors (struct wtk_progress_bar *bar, gfx_color_t color1, gfx_color_t color2)
 Set new progress bar colors.



static bool wtk_progress_bar_handler (struct win_window *win, enum win_event_type type, void const *data)
 Progress bar event handler.



#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR(0, 0, 0)
 Color of the progress bar's frame border.

Define Documentation

#define WTK_PROGRESS_BAR_BORDER_COLOR   GFX_COLOR(0, 0, 0)

Color of the progress bar's frame border.

Definition at line 363 of file wtk.h.

Referenced by wtk_progress_bar_handler().


Function Documentation

struct win_window* wtk_progress_bar_as_child ( struct wtk_progress_bar bar  )  [read]

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:
bar Pointer to wtk_progress_bar struct to manage.
Returns:
Pointer to window to be used for managing the progress bar.

Definition at line 88 of file wtk_progress_bar.c.

References assert, and wtk_progress_bar::container.

Referenced by app_fonts_load(), app_tank_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 
) [read]

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.

Todo:
Revisit, support larger progress bars and values given a config symbol.
Parameters:
parent Pointer to parent win_window struct.
area Pointer to win_area struct with position and size of the progress bar. Minimum size in both x and y direction is 3 pixels.
maximum Maximum value of the progress bar.
value Initial value of the progress bar.
fill_color Color for filled area.
background_color Color for background area.
option Configuration options for progress bar.
Returns:
Pointer to new progress bar, if memory allocation was successful.

Definition at line 308 of file wtk_progress_bar.c.

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(), 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, and wtk_rescale_value().

Referenced by app_tank_launch().

uint8_t wtk_progress_bar_get_value ( struct wtk_progress_bar bar  ) 

Get progress bar value.

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

Definition at line 152 of file wtk_progress_bar.c.

References assert, and wtk_progress_bar::value.

Referenced by tank_worker().

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:
win Window receiving the event.
type The event type.
data Custom data, depending on event type.
Returns:
True if the event was recognized and accepted.

Definition at line 195 of file wtk_progress_bar.c.

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, and WTK_PROGRESS_BAR_VERTICAL.

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:
bar Pointer to wtk_progress_bar struct to set colors for.
fill_color Fill color to set for progress bar.
background_color Background color to set for progress bar.

Definition at line 168 of file wtk_progress_bar.c.

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(), and tank_worker().

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:
bar Pointer to wtk_progress_bar struct to set new value for.
value New value for the progress bar.
Returns:
True if progress bar's value was changed.

Definition at line 106 of file wtk_progress_bar.c.

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, and wtk_rescale_value().

Referenced by app_fonts_load(), tank_worker(), and widget_frame_command_handler().

Generated on Thu Apr 29 14:09:59 2010 for display-demo by  doxygen 1.6.3