Add widget tag support (and fix a couple of doxygen problems)
This commit is contained in:
parent
679961a25e
commit
0587e35169
@ -166,6 +166,7 @@
|
||||
// #define GWIN_NEED_PROGRESSBAR FALSE
|
||||
// #define GWIN_PROGRESSBAR_AUTO FALSE
|
||||
// #define GWIN_FLAT_STYLING FALSE
|
||||
// #define GWIN_WIDGET_TAGS FALSE
|
||||
|
||||
//#define GWIN_NEED_CONTAINERS FALSE
|
||||
// #define GWIN_NEED_CONTAINER FALSE
|
||||
|
@ -39,6 +39,9 @@ static void SendButtonEvent(GWidgetObject *gw) {
|
||||
continue;
|
||||
pbe->type = GEVENT_GWIN_BUTTON;
|
||||
pbe->button = (GHandle)gw;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
pbe->tag = gw->tag;
|
||||
#endif
|
||||
geventSendEvent(psl);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@
|
||||
typedef struct GEventGWinButton {
|
||||
GEventType type; // The type of this event (GEVENT_GWIN_BUTTON)
|
||||
GHandle button; // The button that has been depressed (actually triggered on release)
|
||||
#if GWIN_WIDGET_TAGS
|
||||
WidgetTag tag; // The button tag
|
||||
#endif
|
||||
} GEventGWinButton;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,9 @@ static void SendCheckboxEvent(GWidgetObject *gw) {
|
||||
pce->type = GEVENT_GWIN_CHECKBOX;
|
||||
pce->checkbox = &gw->g;
|
||||
pce->isChecked = (gw->g.flags & GCHECKBOX_FLG_CHECKED) ? TRUE : FALSE;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
pce->tag = gw->tag;
|
||||
#endif
|
||||
geventSendEvent(psl);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@ typedef struct GEventGWinCheckbox {
|
||||
GEventType type; // The type of this event (GEVENT_GWIN_CHECKBOX)
|
||||
GHandle checkbox; // The checkbox that has been depressed (actually triggered on release)
|
||||
bool_t isChecked; // Is the checkbox currently checked or unchecked?
|
||||
#if GWIN_WIDGET_TAGS
|
||||
WidgetTag tag; // The checkbox tag
|
||||
#endif
|
||||
} GEventGWinCheckbox;
|
||||
|
||||
/* A Checkbox window */
|
||||
|
@ -242,6 +242,9 @@ GHandle _gwidgetCreate(GDisplay *g, GWidgetObject *pgw, const GWidgetInit *pInit
|
||||
pgw->fnDraw = pInit->customDraw ? pInit->customDraw : vmt->DefaultDraw;
|
||||
pgw->fnParam = pInit->customParam;
|
||||
pgw->pstyle = pInit->customStyle ? pInit->customStyle : defaultStyle;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
pgw->tag = pInit->tag;
|
||||
#endif
|
||||
|
||||
return &pgw->g;
|
||||
}
|
||||
@ -473,5 +476,16 @@ bool_t gwinAttachListener(GListener *pl) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GWIN_WIDGET_TAGS
|
||||
void gwinSetTag(GHandle gh, WidgetTag tag) {
|
||||
if ((gh->flags & GWIN_FLG_WIDGET))
|
||||
gw->tag = tag;
|
||||
}
|
||||
|
||||
WidgetTag gwinGetTag(GHandle gh) {
|
||||
return ((gh->flags & GWIN_FLG_WIDGET)) ? gw->tag : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GFX_USE_GWIN && GWIN_NEED_WIDGET */
|
||||
/** @} */
|
||||
|
@ -72,6 +72,11 @@ extern const GWidgetStyle WhiteWidgetStyle;
|
||||
*/
|
||||
typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);
|
||||
|
||||
/**
|
||||
* @brief Defines a the type of a tag on a widget
|
||||
*/
|
||||
typedef uint16_t WidgetTag;
|
||||
|
||||
/**
|
||||
* @brief The structure to initialise a widget.
|
||||
*
|
||||
@ -92,6 +97,9 @@ typedef struct GWidgetInit {
|
||||
CustomWidgetDrawFunction customDraw; // @< A custom draw function - use NULL for the standard
|
||||
void * customParam; // @< A parameter for the custom draw function (default = NULL)
|
||||
const GWidgetStyle * customStyle; // @< A custom style to use - use NULL for the default style
|
||||
#if GWIN_WIDGET_TAGS || defined(__DOXYGEN__)
|
||||
WidgetTag tag; // @< The tag to associate with the widget
|
||||
#endif
|
||||
} GWidgetInit;
|
||||
/** @} */
|
||||
|
||||
@ -110,6 +118,9 @@ typedef struct GWidgetObject {
|
||||
CustomWidgetDrawFunction fnDraw; // @< The current draw function
|
||||
void * fnParam; // @< A parameter for the current draw function
|
||||
const GWidgetStyle * pstyle; // @< The current widget style colors
|
||||
#if GWIN_WIDGET_TAGS || defined(__DOXYGEN__)
|
||||
WidgetTag tag; // @< The widget tag
|
||||
#endif
|
||||
} GWidgetObject;
|
||||
/** @} */
|
||||
|
||||
@ -187,6 +198,34 @@ void gwinSetText(GHandle gh, const char *text, bool_t useAlloc);
|
||||
*/
|
||||
const char *gwinGetText(GHandle gh);
|
||||
|
||||
#if GWIN_WIDGET_TAGS || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Set the tag of a widget.
|
||||
*
|
||||
* @param[in] gh The widget handle
|
||||
* @param[in] tag The tag to set.
|
||||
*
|
||||
* @note Non-widgets will ignore this call.
|
||||
*
|
||||
* @pre Requires GWIN_WIDGET_TAGS to be TRUE
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gwinSetTag(GHandle gh, WidgetTag tag);
|
||||
|
||||
/**
|
||||
* @brief Get the tag of a widget.
|
||||
* @return The widget tag value (or 0 if it is not a widget)
|
||||
*
|
||||
* @param[in] gh The widget handle
|
||||
*
|
||||
* @pre Requires GWIN_WIDGET_TAGS to be TRUE
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
WidgetTag gwinGetTag(GHandle gh);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set the style of a widget.
|
||||
*
|
||||
@ -235,7 +274,7 @@ void gwinSetCustomDraw(GHandle gh, CustomWidgetDrawFunction fn, void *param);
|
||||
*/
|
||||
bool_t gwinAttachListener(GListener *pl);
|
||||
|
||||
#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
|
||||
#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Set the mouse to be used to control the widgets
|
||||
* @return TRUE on success
|
||||
@ -249,7 +288,7 @@ bool_t gwinAttachListener(GListener *pl);
|
||||
bool_t gwinAttachMouse(uint16_t instance);
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
|
||||
#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Attach a toggle to a widget
|
||||
* @return TRUE on success
|
||||
@ -267,7 +306,7 @@ bool_t gwinAttachListener(GListener *pl);
|
||||
bool_t gwinAttachToggle(GHandle gh, uint16_t role, uint16_t instance);
|
||||
#endif
|
||||
|
||||
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
|
||||
#if (GFX_USE_GINPUT && GINPUT_NEED_DIAL) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Attach a toggle to a widget
|
||||
* @return TRUE on success
|
||||
|
@ -66,6 +66,9 @@ static void sendListEvent(GWidgetObject *gw, int item) {
|
||||
ple->type = GEVENT_GWIN_LIST;
|
||||
ple->list = (GHandle)gw;
|
||||
ple->item = item;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
ple->tag = gw->tag;
|
||||
#endif
|
||||
|
||||
geventSendEvent(psl);
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ typedef struct GEventGWinList {
|
||||
GEventType type; // The type of this event (GEVENT_GWIN_LIST)
|
||||
GHandle list; // The list
|
||||
int item; // The item that has been selected (or unselected in a multi-select listbox)
|
||||
#if GWIN_WIDGET_TAGS
|
||||
WidgetTag tag; // The list tag
|
||||
#endif
|
||||
} GEventGWinList;
|
||||
|
||||
// A list window
|
||||
|
@ -38,6 +38,9 @@ static void SendRadioEvent(GWidgetObject *gw) {
|
||||
pbe->type = GEVENT_GWIN_RADIO;
|
||||
pbe->radio = (GHandle)gw;
|
||||
pbe->group = ((GRadioObject *)gw)->group;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
pbe->tag = gw->tag;
|
||||
#endif
|
||||
geventSendEvent(psl);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,9 @@ typedef struct GEventGWinRadio {
|
||||
GEventType type; // The type of this event (GEVENT_GWIN_RADIO)
|
||||
GHandle radio; // The radio button that has been depressed
|
||||
uint16_t group; // The group for this radio button
|
||||
#if GWIN_WIDGET_TAGS
|
||||
WidgetTag tag; // The radio tag
|
||||
#endif
|
||||
} GEventGWinRadio;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,9 @@ static void SendSliderEvent(GWidgetObject *gw) {
|
||||
pse->type = GEVENT_GWIN_SLIDER;
|
||||
pse->slider = (GHandle)gw;
|
||||
pse->position = ((GSliderObject *)gw)->pos;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
pse->tag = gw->tag;
|
||||
#endif
|
||||
geventSendEvent(psl);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,9 @@ typedef struct GEventGWinSlider {
|
||||
GEventType type; // The type of this event (GEVENT_GWIN_BUTTON)
|
||||
GHandle slider; // The slider that is returning results
|
||||
int position;
|
||||
#if GWIN_WIDGET_TAGS
|
||||
WidgetTag tag; // The slider tag
|
||||
#endif
|
||||
} GEventGWinSlider;
|
||||
|
||||
// There are currently no GEventGWinSlider listening flags - use 0
|
||||
|
@ -127,6 +127,15 @@
|
||||
* @name GWIN Optional Parameters
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Add a tag to each widget
|
||||
* @details Defaults to FALSE
|
||||
* @note Adds a tag member to each widget. Any events created include this tag.
|
||||
* The enables switch based application logic to detect the event source.
|
||||
*/
|
||||
#ifndef GWIN_WIDGET_TAGS
|
||||
#define GWIN_WIDGET_TAGS FALSE
|
||||
#endif
|
||||
/**
|
||||
* @brief Use flat styling for controls rather than a 3D look
|
||||
* @details Defaults to FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user