Data Structures | |
struct | app_calculator_t |
Calculator 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 | W_SP 16 |
Spacing between widget frame and components. 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 | calc_perform_operation (struct app_calculator_t *calc) |
Perform calculation. More... | |
#define BT_H 40 |
Height (in pixels) of a normal sized button.
Referenced by app_widget_launch().
Calculate button X coordinate.
Referenced by app_widget_launch().
Calculate button Y coordinate.
Referenced by app_widget_launch().
#define BT_W 40 |
Width (in pixels) of a normal sized button.
Referenced by app_widget_launch().
#define BT_X 4 |
Number of buttons in one column.
Referenced by app_widget_launch().
#define BT_Y 5 |
Number of buttons in one row.
Referenced by app_widget_launch().
#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 T_H 16 |
Height of the static text field.
Referenced by app_widget_launch().
#define T_SP 16 |
Spacing between static text and button pad.
Referenced by app_widget_launch().
Width of the static text field.
Referenced by app_widget_launch().
#define W_SP 16 |
Spacing between widget frame and components.
Referenced by app_widget_launch().
|
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().
Referenced by app_widget_launch().
|
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.
References app_calc_handler(), BT_H, BT_POS_X, BT_POS_Y, BT_W, BT_X, BT_Y, app_calculator_t::calc_regs, app_calculator_t::CALC_STATE_WAIT_VAL1, gfx_bitmap::color, gfx_bitmap::data, app_calculator_t::display, app_calculator_t::frame, app_calculator_t::frame_bg, GFX_BITMAP_SOLID, GFX_COLOR, GFX_COLOR_WHITE, gfx_get_height(), gfx_get_width(), font::height, membag_alloc(), membag_free(), app_calculator_t::operand, app_calculator_t::operation, win_area::pos, app_calculator_t::result, win_area::size, app_calculator_t::state, sysfont, T_H, T_SP, T_W, app_calculator_t::text, app_calculator_t::text_frame, app_calculator_t::text_frame_bg, gfx_bitmap::type, W_SP, win_destroy(), win_get_root(), win_show(), wtk_basic_frame_as_child(), wtk_basic_frame_create(), wtk_button_as_child(), wtk_button_create(), wtk_label_as_child(), wtk_label_create(), win_point::x, and win_point::y.
Referenced by main().
|
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().