2013-06-02 04:13:28 +00:00
|
|
|
/*
|
2013-06-15 11:37:22 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-06-02 04:13:28 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
|
|
|
* http://chibios-gfx.com/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file include/gwin/checkbox.h
|
|
|
|
* @brief GWIN Graphic window subsystem header file.
|
|
|
|
*
|
|
|
|
* @defgroup Checkbox Checkbox
|
|
|
|
* @ingroup GWIN
|
|
|
|
*
|
2013-06-04 08:23:55 +00:00
|
|
|
* @details GWIN allows it to easily create checkboxes.
|
2013-06-02 04:13:28 +00:00
|
|
|
*
|
|
|
|
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
|
|
|
* @pre GWIN_NEED_CHECKBOX must be set to TRUE in your gfxconf.h
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GWIN_CHECKBOX_H
|
|
|
|
#define _GWIN_CHECKBOX_H
|
|
|
|
|
|
|
|
#if GWIN_NEED_CHECKBOX || defined(__DOXYGEN__)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver constants. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
#define GW_CHECKBOX 0x0005
|
|
|
|
#define GEVENT_GWIN_CHECKBOX (GEVENT_GWIN_FIRST+2)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Type definitions */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
typedef struct GEventGWinCheckbox_t {
|
2013-06-02 16:52:42 +00:00
|
|
|
GEventType type; // The type of this event (GEVENT_GWIN_CHECKBOX)
|
|
|
|
GHandle checkbox; // The checkbox that has been depressed (actually triggered on release)
|
2013-06-02 16:59:51 +00:00
|
|
|
bool_t isChecked; // Is the checkbox currently checked or unchecked?
|
2013-06-02 04:13:28 +00:00
|
|
|
} GEventGWinCheckbox;
|
|
|
|
|
|
|
|
typedef enum GCheckboxState_e {
|
2013-06-02 14:15:46 +00:00
|
|
|
GCHBX_UNCHECKED, GCHBX_CHECKED
|
2013-06-02 04:13:28 +00:00
|
|
|
} GCheckboxState;
|
|
|
|
|
2013-06-02 14:15:46 +00:00
|
|
|
typedef struct GCheckboxColor_t {
|
|
|
|
color_t border;
|
|
|
|
color_t checked;
|
|
|
|
color_t bg;
|
|
|
|
} GCheckboxColor;
|
2013-06-02 04:13:28 +00:00
|
|
|
|
|
|
|
/* custom rendering interface */
|
|
|
|
typedef void (*GCheckboxDrawFunction)(GHandle gh, bool_t enabled, bool_t state, void* param);
|
|
|
|
|
|
|
|
/* A Checkbox window */
|
|
|
|
typedef struct GCheckboxObject_t {
|
|
|
|
GWindowObject gwin;
|
|
|
|
GListener listener;
|
|
|
|
|
|
|
|
GCheckboxDrawFunction fn;
|
2013-06-02 14:15:46 +00:00
|
|
|
GCheckboxColor *colors;
|
2013-06-02 16:59:51 +00:00
|
|
|
bool_t isChecked;
|
2013-06-02 04:13:28 +00:00
|
|
|
void *param;
|
|
|
|
} GCheckboxObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create a checkbox window.
|
|
|
|
*
|
|
|
|
* @param[in] gb The GCheckboxObject structure to initialise. If this is NULL, the structure is dynamically allocated.
|
|
|
|
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
|
|
|
|
* @param[in] width The width of the window
|
|
|
|
* @param[in] height The height of the window
|
|
|
|
*
|
|
|
|
* @note The checkbox is not automatically drawn. Call gwinCheckboxDraw() after changing the checkbox style.
|
|
|
|
*
|
|
|
|
* @return NULL if there is no resultant drawing area, otherwise a window handle.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
GHandle gwinCheckboxCreate(GCheckboxObject *gb, coord_t x, coord_t y, coord_t width, coord_t height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Redraw a checkbox
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a checkbox window)
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
void gwinCheckboxDraw(GHandle gh);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable or disable a button
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a checkbox window)
|
|
|
|
* @param[in] enabled Enable or disable the button
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
void gwinCheckboxSetEnabled(GHandle gh, bool_t enabled);
|
|
|
|
|
2013-06-03 15:36:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Set the callback routine to perform a custom drawing.
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a checkbox window)
|
|
|
|
* @param[in] fn The function to use to draw the checkbox
|
|
|
|
* @param[in] param A parameter to pass to the checkbox drawing function
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
void gwinCheckboxSetCustom(GHandle gh, GCheckboxDrawFunction fn, void *param);
|
|
|
|
|
2013-06-02 04:13:28 +00:00
|
|
|
/**
|
|
|
|
* @brief Enable a checkbox
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
#define gwinCheckboxEnable(gh) gwinCheckboxSetEnabled( ((GCheckboxObject *)(gh)), TRUE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable a checkbox
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
#define gwinCheckboxDisable(gh) gwinCheckboxSetEnabled( ((GCheckboxObject *)(gh)), FALSE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the state of a checkbox
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a checkbox window)
|
|
|
|
*
|
2013-06-02 14:15:46 +00:00
|
|
|
* @return The state of the checkbox (GCHBX_CHECKED or GCHBX_UNCHECKED)
|
2013-06-02 04:13:28 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-06-02 16:59:51 +00:00
|
|
|
#define gwinCheckboxGetState(gh) (((GCheckboxObject *)(gh))->isChecked)
|
2013-06-02 04:13:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the source handle of a checkbox
|
|
|
|
* @details Get the source handle of a checkbox so the application can listen for events
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a checkbox window)
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
#define gwinCheckboxGetSource(gh) ((GSourceHandle)(gh))
|
|
|
|
|
|
|
|
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
|
|
|
|
/**
|
|
|
|
* @brief Attach a mouse to a checkbox
|
|
|
|
*
|
|
|
|
* @param[in] gh The checkbox handle
|
|
|
|
* @param[in] instance The mouse instance
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
|
|
|
bool_t gwinCheckboxAttachMouse(GHandle gh, uint16_t instance);
|
2013-06-02 14:15:46 +00:00
|
|
|
#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
|
2013-06-02 04:13:28 +00:00
|
|
|
|
|
|
|
#endif /* _GWIN_NEED_CHECKBOX */
|
|
|
|
|
|
|
|
#endif /* _GWIN_CHECKBOX_H */
|
|
|
|
/** @} */
|
|
|
|
|