![]() |
µGFX
2.9
version 2.9
|
The basic widget implementation (base class).
A widget is a Window that supports interacting with the user via an input device such as a mouse or toggle buttons. It is the base class for widgets such as buttons and sliders.
Data Structures | |
struct | GColorSet |
The GColorSet structure. More... | |
struct | GWidgetStyle |
The GWidgetStyle structure. More... | |
struct | GWidgetInit |
The structure to initialise a widget. More... | |
struct | GWidgetObject |
The GWIN Widget structure. More... | |
struct | GEventGWin |
A Generic GWIN Event. More... | |
Functions | |
void | gwinWidgetClearInit (GWidgetInit *pwi) |
Clear a GWidgetInit structure to all zero's. More... | |
void | gwinSetDefaultStyle (const GWidgetStyle *pstyle, gBool updateAll) |
Set the default style for widgets created hereafter. More... | |
const GWidgetStyle * | gwinGetDefaultStyle (void) |
Get the current default style. More... | |
void | gwinSetText (GHandle gh, const char *text, gBool useAlloc) |
Set the text of a widget. More... | |
const char * | gwinGetText (GHandle gh) |
Get the text of a widget. More... | |
void | gwinPrintg (GHandle gh, const char *fmt,...) |
Set the text of a widget using a printf style format. More... | |
gBool | gwinIsWidget (GHandle gh) |
Check whether a handles is a widget handle or not. More... | |
void | gwinSetTag (GHandle gh, WidgetTag tag) |
Set the tag of a widget. More... | |
WidgetTag | gwinGetTag (GHandle gh) |
Get the tag of a widget. More... | |
void | gwinSetStyle (GHandle gh, const GWidgetStyle *pstyle) |
Set the style of a widget. More... | |
const GWidgetStyle * | gwinGetStyle (GHandle gh) |
Get the style of a widget. More... | |
void | gwinSetCustomDraw (GHandle gh, CustomWidgetDrawFunction fn, void *param) |
Set the routine to perform a custom widget drawing. More... | |
gBool | gwinAttachListener (GListener *pl) |
Attach a Listener to listen for widget events. More... | |
gBool | gwinAttachToggle (GHandle gh, gU16 role, gU16 instance) |
Attach a toggle to a widget. More... | |
gBool | gwinDetachToggle (GHandle gh, gU16 role) |
Detach a toggle from a widget. More... | |
gBool | gwinAttachDial (GHandle gh, gU16 role, gU16 instance) |
Attach a toggle to a widget. More... | |
gBool | gwinSetFocus (GHandle gh) |
Set the keyboard focus to a specific window. More... | |
GHandle | gwinGetFocus (void) |
Get the widget that is currently in focus. More... | |
typedef struct GColorSet | GColorSet |
The GColorSet structure. More... | |
typedef struct GWidgetStyle | GWidgetStyle |
The GWidgetStyle structure. More... | |
typedef struct GWidgetInit | GWidgetInit |
The structure to initialise a widget. More... | |
typedef struct GWidgetObject | GWidgetObject |
The GWIN Widget structure. More... | |
typedef struct GEventGWin | GEventGWin |
A Generic GWIN Event. More... | |
const GWidgetStyle | BlackWidgetStyle |
We define a couple of GWidgetStyle's that you can use in your application. The Black style is the default style if you don't specify one. More... | |
#define | GEVENT_GWIN_OPEN (GEVENT_GWIN_FIRST+0x00) |
The list of predefined GWIN events. More... | |
Typedefs | |
typedef void(* | CustomWidgetDrawFunction) (struct GWidgetObject *gw, void *param) |
Defines a custom drawing function for a widget. More... | |
typedef gU16 | WidgetTag |
Defines a the type of a tag on a widget. More... | |
gBool gwinAttachDial | ( | GHandle | gh, |
gU16 | role, | ||
gU16 | instance | ||
) |
Attach a toggle to a widget.
[in] | gh | The widget handle |
[in] | role | The function the dial will perform for the widget |
[in] | instance | The dial instance |
gBool gwinAttachListener | ( | GListener * | pl | ) |
Attach a Listener to listen for widget events.
[in] | pl | The listener |
gBool gwinAttachToggle | ( | GHandle | gh, |
gU16 | role, | ||
gU16 | instance | ||
) |
Attach a toggle to a widget.
[in] | gh | The widget handle |
[in] | role | The function the toggle will perform for the widget |
[in] | instance | The toggle instance |
gBool gwinDetachToggle | ( | GHandle | gh, |
gU16 | role | ||
) |
Detach a toggle from a widget.
[in] | gh | The widget handle |
[in] | role | The function the toggle will perform for the widget |
const GWidgetStyle* gwinGetDefaultStyle | ( | void | ) |
Get the current default style.
GHandle gwinGetFocus | ( | void | ) |
Get the widget that is currently in focus.
The widget that is currently in focus is the widget that receives mouse and keyboard events.
const GWidgetStyle* gwinGetStyle | ( | GHandle | gh | ) |
Get the style of a widget.
[in] | gh | The widget handle |
Get the tag of a widget.
[in] | gh | The widget handle |
const char* gwinGetText | ( | GHandle | gh | ) |
Get the text of a widget.
[in] | gh | The widget handle |
gBool gwinIsWidget | ( | GHandle | gh | ) |
Check whether a handles is a widget handle or not.
[in] | gh | The handle to check. |
void gwinPrintg | ( | GHandle | gh, |
const char * | fmt, | ||
... | |||
) |
Set the text of a widget using a printf style format.
[in] | gh | The widget handle |
[in] | fmt | The format string using a printf/g syntax. See vsnprintg() |
[in] | ... | The printg paramters. |
void gwinSetCustomDraw | ( | GHandle | gh, |
CustomWidgetDrawFunction | fn, | ||
void * | param | ||
) |
Set the routine to perform a custom widget drawing.
[in] | gh | The widget handle |
[in] | fn | The function to use to draw the widget |
[in] | param | A parameter to pass to the widget drawing function |
gwinDraw()
to redraw the widget. void gwinSetDefaultStyle | ( | const GWidgetStyle * | pstyle, |
gBool | updateAll | ||
) |
Set the default style for widgets created hereafter.
[in] | pstyle | The default style. Passing NULL uses the system compiled style. |
[in] | updateAll | If gTrue then all existing widgets that are using the current default style will be updated to use this new style. Widgets that have custom styles different from the default style will not be updated. |
gBool gwinSetFocus | ( | GHandle | gh | ) |
Set the keyboard focus to a specific window.
[in] | gh | The window |
void gwinSetStyle | ( | GHandle | gh, |
const GWidgetStyle * | pstyle | ||
) |
Set the style of a widget.
[in] | gh | The widget handle |
[in] | pstyle | The style to set. This must be a static structure (not allocated on a transient stack). Use NULL to reset to the default style. |
Set the tag of a widget.
[in] | gh | The widget handle |
[in] | tag | The tag to set. |
void gwinSetText | ( | GHandle | gh, |
const char * | text, | ||
gBool | useAlloc | ||
) |
Set the text of a widget.
[in] | gh | The widget handle |
[in] | text | The text to set. This must be a constant string unless useAlloc is set. |
[in] | useAlloc | If gTrue the string specified will be copied into dynamically allocated memory. |
void gwinWidgetClearInit | ( | GWidgetInit * | pwi | ) |
Clear a GWidgetInit structure to all zero's.
[in] | pwi | The GWidgetInit structure to clear |
|
extern |
We define a couple of GWidgetStyle's that you can use in your application. The Black style is the default style if you don't specify one.
#define GEVENT_GWIN_OPEN (GEVENT_GWIN_FIRST+0x00) |
The list of predefined GWIN events.
Definition at line 165 of file gwin_widget.h.
typedef void(* CustomWidgetDrawFunction) (struct GWidgetObject *gw, void *param) |
Defines a custom drawing function for a widget.
Definition at line 76 of file gwin_widget.h.
typedef struct GEventGWin GEventGWin |
A Generic GWIN Event.
A comment/rant on the above structure: We would really like the GWindowObject member to be anonymous. While this is allowed under the C11, C99, GNU and various other standards which have been around forever - compiler support often requires special flags e.g gcc requires the -fms-extensions flag (no wonder the language and compilers have not really progressed in 30 years). As portability is a key requirement we unfortunately won't use this useful feature in case we get a compiler that won't support it even with special flags.
gwinAttachListener()
typedef struct GWidgetInit GWidgetInit |
The structure to initialise a widget.
gwinWidgetClearInit()
to clear it. gwinSetText()
with useAlloc set to gTrue. typedef struct GWidgetObject GWidgetObject |
The GWIN Widget structure.
typedef struct GWidgetStyle GWidgetStyle |
The GWidgetStyle structure.
A GWidgetStyle is a set of colors that together form a "style". These colors should not be confused with the GWindow foreground and background colors which are used for drawing operations.
typedef gU16 WidgetTag |
Defines a the type of a tag on a widget.
Definition at line 81 of file gwin_widget.h.