Data Structures | |
struct | app_calculator_t |
Calculator context. More... | |
struct | widget_context |
Widget application context. More... | |
Macros | |
#define | BT_H 40 |
Height (in pixels) of a normal sized button. More... | |
#define | BT_POS_X(col) (W_SP + (BT_W * (col))) |
Calculate button X coordinate. More... | |
#define | BT_POS_Y(row) (W_SP + T_H + T_SP + (BT_H * (row))) |
Calculate button Y coordinate. More... | |
#define | BT_W 40 |
Width (in pixels) of a normal sized button. More... | |
#define | BT_X 4 |
Number of buttons in one column. More... | |
#define | BT_Y 5 |
Number of buttons in one row. More... | |
#define | MAX_DIGITS 9 |
Maximum number of digits on display. More... | |
#define | MAX_VALUE 999999999L |
Maximum value we can show on display. More... | |
#define | MIN_VALUE -999999999L |
Minimum value we can show on display. More... | |
#define | T_H 16 |
Height of the static text field. More... | |
#define | T_SP 16 |
Spacing between static text and button pad. More... | |
#define | T_W (BT_W * BT_X) |
Width of the static text field. More... | |
#define | TOTAL_NUM_ICONS 3 |
#define | W_SP 16 |
Spacing between widget frame and components. More... | |
Enumerations | |
enum | command_id { DUMMY_ID, ICON_BUTTON_1_ID, ICON_BUTTON_2_ID, ICON_BUTTON_3_ID, BUTTON_PREV_ID, BUTTON_NEXT_ID, BUTTON_SELECT_ID, DUMMY_ID, SLIDER_ID, BUTTON_ID, DUMMY_ID, SLIDER_ID, CHECK_BOX_ID, RADIO_BUTTON_1_ID, RADIO_BUTTON_2_ID, BUTTON_ID } |
Command event IDs. More... | |
enum | command_id { DUMMY_ID, ICON_BUTTON_1_ID, ICON_BUTTON_2_ID, ICON_BUTTON_3_ID, BUTTON_PREV_ID, BUTTON_NEXT_ID, BUTTON_SELECT_ID, DUMMY_ID, SLIDER_ID, BUTTON_ID, DUMMY_ID, SLIDER_ID, CHECK_BOX_ID, RADIO_BUTTON_1_ID, RADIO_BUTTON_2_ID, BUTTON_ID } |
Command event IDs. More... | |
enum | command_id { DUMMY_ID, ICON_BUTTON_1_ID, ICON_BUTTON_2_ID, ICON_BUTTON_3_ID, BUTTON_PREV_ID, BUTTON_NEXT_ID, BUTTON_SELECT_ID, DUMMY_ID, SLIDER_ID, BUTTON_ID, DUMMY_ID, SLIDER_ID, CHECK_BOX_ID, RADIO_BUTTON_1_ID, RADIO_BUTTON_2_ID, BUTTON_ID } |
Command event IDs. More... | |
Functions | |
static bool | app_calc_handler (struct wtk_basic_frame *frame, win_command_t command_data) |
Frame handler for the application. More... | |
static void | app_calc_update_disp (struct app_calculator_t *calc) |
Update calculator display with new value. More... | |
bool | app_widget_launch (void) |
Setup widget demo. More... | |
static void | app_widget_update_colors (struct widget_context *widget) |
Update colors. More... | |
static void | calc_perform_operation (struct app_calculator_t *calc) |
Perform calculation. More... | |
static bool | widget_frame_command_handler (struct wtk_basic_frame *frame, win_command_t command_data) |
Frame handler for the application. More... | |
Variables | |
static const char | btn_string [] = "Reset Slider" |
Description for the button. More... | |
static const char | checkbox_string [] = "Invert colors" |
Description for the check box. More... | |
static const char | rb1_string [] = "Color scheme 1" |
Description for the first radio button. More... | |
static const char | rb2_string [] = "Color scheme 2" |
Description for the second radio button. More... | |
static struct widget_context * | widget_ctx |
Statically allocated context pointer. More... | |
static struct widget_context * | widget_ctx |
Statically allocated context pointer. More... | |
static struct widget_context * | widget_ctx |
Statically allocated context pointer. More... | |
Color scheme | |
#define | COLOR_SCHEME_0_FG GFX_COLOR(30, 30, 200) |
Color scheme 0 foreground color. More... | |
#define | COLOR_SCHEME_0_BG GFX_COLOR(255, 255, 255) |
Color scheme 0 background color. More... | |
#define | COLOR_SCHEME_1_FG GFX_COLOR(0, 255, 0) |
Color scheme 1 foreground color. More... | |
#define | COLOR_SCHEME_1_BG GFX_COLOR(0, 100, 100) |
Color scheme 1 background color. More... | |
#define | APP_BACKGROUND_COLOR GFX_COLOR(220, 220, 220) |
Background color of the application frame. More... | |
Widget positions and sizes | |
#define | WIDGET_POS_X 14 |
Leftmost X coordinate in frame for the widgets. More... | |
#define | WIDGET_POS_Y 5 |
Topmost Y coordinate in frame for the widgets. More... | |
#define | SLIDER_POS_Y 10 |
Slider X coordinate, inside frame. More... | |
#define | SLIDER_SIZE_X 120 |
Width of slider. More... | |
#define | SLIDER_SIZE_Y 40 |
Height of slider. More... | |
#define | SLIDER_PB_SPACING_X 10 |
Spacing between the slider and progress bars. More... | |
#define | PB_SIZE_X SLIDER_SIZE_X |
Width of progress bar. More... | |
#define | PB_SIZE_Y SLIDER_SIZE_Y |
Height of progress bar. More... | |
#define | CHECK_BOX_SPACING_Y 20 |
Spacing above check box to slider and progress bars. More... | |
#define | RADIO_BUTTON_SPACING_Y 10 |
Spacing above each radio button. More... | |
#define | BUTTON_SPACING_Y 20 |
Spacing above the button. More... | |
#define | BUTTON_SIZE_Y 30 |
Height of the button. More... | |
#define APP_BACKGROUND_COLOR GFX_COLOR(220, 220, 220) |
Background color of the application frame.
#define BT_H 40 |
Height (in pixels) of a normal sized button.
#define BT_W 40 |
Width (in pixels) of a normal sized button.
#define BT_X 4 |
Number of buttons in one column.
#define BT_Y 5 |
Number of buttons in one row.
#define BUTTON_SIZE_Y 30 |
Height of the button.
#define BUTTON_SPACING_Y 20 |
Spacing above the button.
#define CHECK_BOX_SPACING_Y 20 |
Spacing above check box to slider and progress bars.
#define COLOR_SCHEME_0_BG GFX_COLOR(255, 255, 255) |
Color scheme 0 background color.
Referenced by app_widget_update_colors().
#define COLOR_SCHEME_0_FG GFX_COLOR(30, 30, 200) |
Color scheme 0 foreground color.
Referenced by app_widget_update_colors().
#define COLOR_SCHEME_1_BG GFX_COLOR(0, 100, 100) |
Color scheme 1 background color.
Referenced by app_widget_update_colors().
#define COLOR_SCHEME_1_FG GFX_COLOR(0, 255, 0) |
Color scheme 1 foreground color.
Referenced by app_widget_update_colors().
#define MAX_DIGITS 9 |
Maximum number of digits on display.
Referenced by app_calc_update_disp().
#define MAX_VALUE 999999999L |
Maximum value we can show on display.
Referenced by app_calc_update_disp(), and calc_perform_operation().
#define MIN_VALUE -999999999L |
Minimum value we can show on display.
Referenced by app_calc_update_disp(), and calc_perform_operation().
#define PB_SIZE_X SLIDER_SIZE_X |
Width of progress bar.
#define PB_SIZE_Y SLIDER_SIZE_Y |
Height of progress bar.
#define RADIO_BUTTON_SPACING_Y 10 |
Spacing above each radio button.
#define SLIDER_PB_SPACING_X 10 |
Spacing between the slider and progress bars.
#define SLIDER_POS_Y 10 |
Slider X coordinate, inside frame.
#define SLIDER_SIZE_X 120 |
Width of slider.
#define SLIDER_SIZE_Y 40 |
Height of slider.
#define T_H 16 |
Height of the static text field.
#define T_SP 16 |
Spacing between static text and button pad.
#define TOTAL_NUM_ICONS 3 |
Referenced by app_widget_launch(), and widget_frame_command_handler().
#define W_SP 16 |
Spacing between widget frame and components.
#define WIDGET_POS_X 14 |
Leftmost X coordinate in frame for the widgets.
#define WIDGET_POS_Y 5 |
Topmost Y coordinate in frame for the widgets.
enum command_id |
Command event IDs.
enum command_id |
Command event IDs.
enum command_id |
Command event IDs.
|
static |
Frame handler for the application.
Handles all command events from the widgets in the application frame.
frame | Pointer to the application frame |
command_data | Command event ID |
References app_calc_update_disp(), calc_perform_operation(), app_calculator_t::calc_regs, app_calculator_t::CALC_STATE_ERROR, app_calculator_t::CALC_STATE_READY, app_calculator_t::CALC_STATE_WAIT_OP, app_calculator_t::CALC_STATE_WAIT_VAL1, app_calculator_t::CALC_STATE_WAIT_VAL2, app_calculator_t::display, app_calculator_t::operand, app_calculator_t::operation, app_calculator_t::result, app_calculator_t::state, and wtk_basic_frame_get_custom_data().
|
static |
Update calculator display with new value.
calc | Pointer to calculator struct |
References app_calculator_t::calc_regs, app_calculator_t::display, MAX_DIGITS, MAX_VALUE, MIN_VALUE, app_calculator_t::state, app_calculator_t::text, and wtk_label_change().
Referenced by app_calc_handler().
bool app_widget_launch | ( | void | ) |
Setup widget demo.
Allocates memory for the application context, and creates all widgets that make up its interface. If memory allocation or widget creation fails, the application exits immediately.
Referenced by main().
|
static |
Update colors.
Updates the colors for the progress bar and issues redrawing of the widgets.
widget | Context for widget application |
References widget_context::color_invert, widget_context::color_scheme, COLOR_SCHEME_0_BG, COLOR_SCHEME_0_FG, COLOR_SCHEME_1_BG, COLOR_SCHEME_1_FG, widget_context::pb, temp, win_redraw(), wtk_progress_bar_as_child(), and wtk_progress_bar_set_colors().
Referenced by widget_frame_command_handler().
|
static |
Perform calculation.
calc | Pointer to calculator struct |
References app_calculator_t::calc_regs, MAX_VALUE, MIN_VALUE, app_calculator_t::operand, app_calculator_t::operation, app_calculator_t::result, and app_calculator_t::state.
Referenced by app_calc_handler().
|
static |
Frame handler for the application.
Handles all command events from the widgets in the application frame.
frame | Pointer to the application frame |
command_data | Command event ID |
References BUTTON_NEXT_ID, BUTTON_PREV_ID, BUTTON_SELECT_ID, win_command_event::data, ICON_BUTTON_1_ID, ICON_BUTTON_2_ID, ICON_BUTTON_3_ID, widget_context::icon_group, widget_context::icons, widget_context::lbl_selected, win_command_event::recipient, win_command_event::sender, TOTAL_NUM_ICONS, win_queue_command_event(), wtk_basic_frame_get_custom_data(), wtk_icon_button_as_child(), wtk_icon_button_get_command(), wtk_icon_button_select(), wtk_icon_group_get_selected(), and wtk_label_change().
Referenced by app_widget_launch().
|
static |
Description for the button.
|
static |
Description for the check box.
|
static |
Description for the first radio button.
|
static |
Description for the second radio button.
|
static |
Statically allocated context pointer.
|
static |
Statically allocated context pointer.
|
static |
Statically allocated context pointer.