Microchip® Advanced Software Framework

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

Functions

struct win_windowwtk_button_as_child (struct wtk_button *button)
 This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. More...
 
struct wtk_buttonwtk_button_create (struct win_window *parent, struct win_area const *area, char const *caption, win_command_t command_data)
 This function creates a new button widget. More...
 
win_command_t wtk_button_get_command (struct wtk_button *button)
 This function returns the window command of the specified button, as set when the widget was created. More...
 
void wtk_button_size_hint (struct win_point *size, const char *caption)
 Get minimum widget size. More...
 
#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK
 Button border color. More...
 
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY
 Color of button background (text color when highlighted). More...
 
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE
 Color of button text (background color when highlighted). More...
 
#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK
 Button border color. More...
 
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY
 Color of button background (text color when highlighted). More...
 
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE
 Color of button text (background color when highlighted). More...
 
#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK
 Button border color. More...
 
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY
 Color of button background (text color when highlighted). More...
 
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE
 Color of button text (background color when highlighted). More...
 
#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK
 Button border color. More...
 
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY
 Color of button background (text color when highlighted). More...
 
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE
 Color of button text (background color when highlighted). More...
 
#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK
 Button border color. More...
 
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY
 Color of button background (text color when highlighted). More...
 
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE
 Color of button text (background color when highlighted). More...
 
enum  wtk_button_state {
  WTK_BUTTON_NORMAL,
  WTK_BUTTON_PRESSED
}
 Valid states for button, relevant to pointer and keyboard operations. More...
 
static bool wtk_button_handler (struct win_window *win, enum win_event_type type, void const *data)
 This function is the window event handler for button widgets. More...
 

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY

Color of button background (text color when highlighted).

Referenced by wtk_button_handler().

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY

Color of button background (text color when highlighted).

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY

Color of button background (text color when highlighted).

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY

Color of button background (text color when highlighted).

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR_GRAY

Color of button background (text color when highlighted).

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK

Button border color.

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK

Button border color.

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK

Button border color.

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK

Button border color.

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR_BLACK

Button border color.

Referenced by wtk_button_handler().

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE

Color of button text (background color when highlighted).

Referenced by wtk_button_handler().

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE

Color of button text (background color when highlighted).

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE

Color of button text (background color when highlighted).

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE

Color of button text (background color when highlighted).

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR_WHITE

Color of button text (background color when highlighted).

Valid states for button, relevant to pointer and keyboard operations.

Enumerator
WTK_BUTTON_NORMAL 

Normal state, no highlight or press.

WTK_BUTTON_PRESSED 

Widget pressed, action occurs when released.

struct win_window* wtk_button_as_child ( struct wtk_button button)

This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting.

Parameters
buttonButton widget to manage.
Returns
Window to be used for managing the button.

References Assert, and wtk_button::container.

Referenced by app_widget_launch().

struct wtk_button* wtk_button_create ( struct win_window parent,
struct win_area const *  area,
char const *  caption,
win_command_t  command_data 
)

This function creates a new button widget.

It allocates required memory and intializes necessary windows to create the widget. If there is not enough memory, the function returns NULL.

To destroy the widget and all its contents, and free its memory, call win_destroy() on the button's child reference, given by wtk_button_as_child(), like this: "win_destroy(wtk_button_as_child(myButtonPtr));". Usually it will be destroyed automatically when it's parent is destroyed.

Parameters
parentParent window, possibly wtk_frame_as_parent(myFramePtr).
areaArea of the internal contents.
captionPointer to caption string. Will be copied into widget.
command_dataCustom data to put into a command event when "clicked".
Returns
Pointer to button, or NULL if failed.

References win_attributes::area, Assert, win_attributes::background, win_attributes::behavior, wtk_button::caption, wtk_button::command, wtk_button::container, win_attributes::custom, win_attributes::event_handler, membag_alloc(), membag_free(), NULL, wtk_button::state, win_create(), wtk_button_handler(), WTK_BUTTON_NORMAL, and wtk_copy_string().

Referenced by app_widget_launch().

win_command_t wtk_button_get_command ( struct wtk_button button)

This function returns the window command of the specified button, as set when the widget was created.

Parameters
buttonButton widget to manage.
Returns
Associated window command of the button widget.

References Assert, and wtk_button::command.

static bool wtk_button_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
)
static
void wtk_button_size_hint ( struct win_point size,
const char *  caption 
)

Get minimum widget size.

This function returns the minimum size that is required for showing the full widget and the caption.

Return values
sizeSuggested size for the widget
Parameters
captionPointer to caption string to use for widget.

References Assert, gfx_get_string_bounding_box(), sysfont, win_point::x, and win_point::y.