2013-03-10 06:15:49 +00:00
|
|
|
/*
|
2013-06-15 11:09:02 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-05-03 14:36:17 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
2013-05-03 14:36:17 +00:00
|
|
|
* http://chibios-gfx.com/license.html
|
2013-03-10 06:15:49 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-06 04:44:47 +00:00
|
|
|
/**
|
|
|
|
* @file include/gwin/button.h
|
|
|
|
* @brief GWIN Graphic window subsystem header file.
|
|
|
|
*
|
|
|
|
* @defgroup Button Button
|
|
|
|
* @ingroup GWIN
|
|
|
|
*
|
|
|
|
* @details GWIN allows it to easily create buttons with different styles
|
|
|
|
* and check for different meta states such as: PRESSED, CLICKED,
|
|
|
|
* RELEASED etc.
|
|
|
|
*
|
|
|
|
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
|
|
|
* @pre GWIN_NEED_BUTTON must be set to TRUE in your gfxconf.h
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-03-10 06:15:49 +00:00
|
|
|
#ifndef _GWIN_BUTTON_H
|
|
|
|
#define _GWIN_BUTTON_H
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/* This file is included within "gwin/gwidget.h" */
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/**
|
|
|
|
* @brief The Event Type for a Button Event
|
|
|
|
*/
|
2013-03-10 06:15:49 +00:00
|
|
|
#define GEVENT_GWIN_BUTTON (GEVENT_GWIN_FIRST+0)
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/**
|
|
|
|
* @brief A Button Event
|
|
|
|
* @note There are currently no GEventGWinButton listening flags - use 0 as the flags to @p gwinAttachListener()
|
|
|
|
*/
|
|
|
|
typedef struct GEventGWinButton {
|
2013-03-10 06:15:49 +00:00
|
|
|
GEventType type; // The type of this event (GEVENT_GWIN_BUTTON)
|
|
|
|
GHandle button; // The button that has been depressed (actually triggered on release)
|
|
|
|
} GEventGWinButton;
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/**
|
|
|
|
* @brief The button widget structure
|
|
|
|
* @note Do not use the members directly - treat it as a black-box.
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
typedef struct GButtonObject {
|
2013-06-06 04:33:32 +00:00
|
|
|
GWidgetObject w;
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GINPUT_NEED_TOGGLE
|
2013-07-07 09:40:37 +00:00
|
|
|
uint16_t toggle;
|
2013-07-05 15:45:24 +00:00
|
|
|
#endif
|
2013-03-10 06:15:49 +00:00
|
|
|
} GButtonObject;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2013-06-06 04:33:32 +00:00
|
|
|
* @brief Create a button widget.
|
2013-03-10 06:15:49 +00:00
|
|
|
* @return NULL if there is no resultant drawing area, otherwise a window handle.
|
|
|
|
*
|
|
|
|
* @param[in] gb The GButtonObject structure to initialise. If this is NULL the structure is dynamically allocated.
|
2013-06-24 12:58:37 +00:00
|
|
|
* @param[in] pInit The initialisation parameters
|
2013-06-06 04:33:32 +00:00
|
|
|
*
|
2013-06-07 16:27:59 +00:00
|
|
|
* @note The drawing color and the background color get set to the current defaults. If you haven't called
|
|
|
|
* @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
|
|
|
|
* @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
|
|
|
|
* is no default font and text drawing operations will no nothing.
|
2013-06-10 07:18:01 +00:00
|
|
|
* @note A button remembers its normal drawing state. If there is a window manager then it is automatically
|
2013-06-07 16:27:59 +00:00
|
|
|
* redrawn if the window is moved or its visibility state is changed.
|
2013-06-10 07:18:01 +00:00
|
|
|
* @note A button supports mouse and a toggle input.
|
|
|
|
* @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will
|
|
|
|
* forget the previous toggle. When assigning a toggle the role parameter must be 0.
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
GHandle gwinButtonCreate(GButtonObject *gb, const GWidgetInit *pInit);
|
2013-03-10 06:15:49 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-06 04:33:32 +00:00
|
|
|
* @brief Is the button current pressed
|
|
|
|
* @return TRUE if the button is depressed
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
2013-06-06 04:33:32 +00:00
|
|
|
* @param[in] gh The window handle (must be a button widget)
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
bool_t gwinButtonIsPressed(GHandle gh);
|
2013-03-10 06:15:49 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-06 04:33:32 +00:00
|
|
|
* @brief Some custom button drawing routines
|
|
|
|
* @details These function may be passed to @p gwinSetCustomDraw() to get different button drawing styles
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
2013-06-06 04:33:32 +00:00
|
|
|
* @param[in] gw The widget object (in this case a button)
|
2013-03-10 06:15:49 +00:00
|
|
|
* @param[in] param A parameter passed in from the user
|
|
|
|
*
|
|
|
|
* @note In your custom button drawing function you may optionally call these
|
|
|
|
* standard functions and then draw your extra details on top.
|
2013-06-06 04:33:32 +00:00
|
|
|
* @note The standard functions below ignore the param parameter except for @p gwinButtonDraw_Image().
|
|
|
|
* @note The image custom draw function @p gwinButtonDraw_Image() uses param to pass in the gdispImage pointer.
|
|
|
|
* The image must be already opened before calling @p gwinSetCustomDraw(). The image should be 3
|
|
|
|
* times the height of the button. The button image is repeated 3 times vertically, the first (top) for
|
|
|
|
* the "up" image, the 2nd for the "down" image, and the third (bottom) image for the disabled state. If
|
|
|
|
* the disabled state is never going to be used then the image can be just 2 times the button height.
|
|
|
|
* No checking is done to compare the size of the button to the size of the image.
|
|
|
|
* Note text is drawn on top of the image.
|
|
|
|
* @note These custom drawing routines don't have to worry about setting clipping as the framework
|
|
|
|
* sets clipping to the object window prior to calling these routines.
|
2013-03-10 06:15:49 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @{
|
|
|
|
*/
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_3D(GWidgetObject *gw, void *param); // @< A standard 3D button
|
2013-03-10 06:15:49 +00:00
|
|
|
#if GDISP_NEED_ARC || defined(__DOXYGEN__)
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param); // @< A rounded rectangle button
|
2013-03-10 06:15:49 +00:00
|
|
|
#endif
|
|
|
|
#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_Ellipse(GWidgetObject *gw, void *param); // @< A circular button
|
2013-03-10 06:15:49 +00:00
|
|
|
#endif
|
|
|
|
#if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_ArrowUp(GWidgetObject *gw, void *param); // @< An up arrow button
|
|
|
|
void gwinButtonDraw_ArrowDown(GWidgetObject *gw, void *param); // @< A down arrow button
|
|
|
|
void gwinButtonDraw_ArrowLeft(GWidgetObject *gw, void *param); // @< A left arrow button
|
|
|
|
void gwinButtonDraw_ArrowRight(GWidgetObject *gw, void *param); // @< A right arrow button
|
|
|
|
#endif
|
|
|
|
#if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
|
|
|
|
void gwinButtonDraw_Image(GWidgetObject *gw, void *param); // @< An image button - see the notes above on the param.
|
2013-03-10 06:15:49 +00:00
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _GWIN_BUTTON_H */
|
|
|
|
/** @} */
|
2013-03-30 23:52:33 +00:00
|
|
|
|