/** * \brief Frame handler for the application * * Handles all command events from the widgets in the application frame. * * \sa wtk_basic_frame_command_handler_t * * \param frame Pointer to the application frame * \param command_data Command event ID * * \return True if exiting, to destroy the window */ static bool widget_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data) { struct widget_context *widget; char command; widget = (struct widget_context *)wtk_basic_frame_get_custom_data(frame); command = (uintptr_t)command_data; switch (command) { case SLIDER_ID: /* Update the progress bar when slider value changes. */ wtk_progress_bar_set_value(widget->pb, wtk_slider_get_value(widget->slider)); break; case CHECK_BOX_ID: /* Invert the colors for the progress bar. */ widget->color_invert = !widget->color_invert; app_widget_update_colors(widget); break; case RADIO_BUTTON_1_ID: /* Set first color scheme for the progress bar. */ widget->color_scheme = 0; app_widget_update_colors(widget); break; case RADIO_BUTTON_2_ID: /* Set second color scheme for the progress bar. */ widget->color_scheme = 1; app_widget_update_colors(widget); break; case BUTTON_ID: /* Reset the slider and progress bar values and update */ wtk_slider_set_value(widget->slider, 0); wtk_progress_bar_set_value(widget->pb, 0); } return false; }
/** * \brief Frame handler for the application * * Handles all command events from the widgets in the application frame. * * \sa wtk_basic_frame_command_handler_t * * \param frame Pointer to the application frame * \param command_data Command event ID * * \return True if exiting, to destroy the window */ static bool widget_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data) { struct widget_context *widget; char command; widget = (struct widget_context *)wtk_basic_frame_get_custom_data(frame); command = (uintptr_t)command_data; switch (command) { case BUTTON_ID: /* Update the plot with the new value as set by the slider */ wtk_plot_add_value(widget->plot, wtk_slider_get_value(widget->slider)); /* Redraw the plot with the new value */ win_redraw(wtk_plot_as_child(widget->plot)); break; } return false; }