GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Widget event handling. More...
#include <stdarg.h>
#include <widgets/gp_widget_types.h>
Go to the source code of this file.
Data Structures | |
struct | gp_widget_event |
Event structure passed to widget event handler. More... | |
Macros | |
#define | GP_WIDGET_EVENT_DEFAULT_MASK |
Default widget event mask. | |
Enumerations | |
enum | gp_widget_event_type { GP_WIDGET_EVENT_NEW , GP_WIDGET_EVENT_FREE , GP_WIDGET_EVENT_WIDGET , GP_WIDGET_EVENT_INPUT , GP_WIDGET_EVENT_REDRAW , GP_WIDGET_EVENT_RESIZE , GP_WIDGET_EVENT_COLOR_SCHEME , GP_WIDGET_EVENT_MAX } |
Widget event type. More... | |
Functions | |
void | gp_widget_event_mask (gp_widget *self, enum gp_widget_event_type ev_type) |
Masks widget events. | |
void | gp_widget_event_unmask (gp_widget *self, enum gp_widget_event_type ev_type) |
Unmasks widget events. | |
const char * | gp_widget_event_type_name (enum gp_widget_event_type ev_type) |
Returns string name for a given event type. | |
void | gp_widget_event_dump (gp_widget_event *ev) |
Prints event details into stdout. | |
static int | gp_widget_send_event (gp_widget *self, enum gp_widget_event_type type,...) |
Helper function to send a widget library event to application. | |
static int | gp_widget_send_widget_event (gp_widget *self, unsigned int sub_type,...) |
Helper function to send a widget specific event to application. | |
int | gp_widget_input_inject (gp_widget *self, gp_widget_event *ev) |
A helper function to inject key and utf input events to a widget. | |
Widget event handling.
Widget events is an interface between the application and the widget toolkit, typical event is a button press or a text edit. Each widget usually has only one event callback and sends a subset of event types.
Definition in file gp_widget_event.h.
enum gp_widget_event_type |
Widget event type.
We have 32bit mask so the maximal number of possible events is 32.
Definition at line 29 of file gp_widget_event.h.
void gp_widget_event_dump | ( | gp_widget_event * | ev | ) |
Prints event details into stdout.
ev | Pointer to a widget event. |
void gp_widget_event_mask | ( | gp_widget * | self, |
enum gp_widget_event_type | ev_type | ||
) |
Masks widget events.
Disables widget events.
self | The widget |
ev_type | Event type to disable |
const char * gp_widget_event_type_name | ( | enum gp_widget_event_type | ev_type | ) |
Returns string name for a given event type.
ev_type | Widget event type. |
void gp_widget_event_unmask | ( | gp_widget * | self, |
enum gp_widget_event_type | ev_type | ||
) |
Unmasks widget events.
Enables widget events.
self | The widget |
ev_type | Event type to enable |
int gp_widget_input_inject | ( | gp_widget * | self, |
gp_widget_event * | ev | ||
) |
A helper function to inject key and utf input events to a widget.
Internal function used in widget tests.
This function takes a widget event and if the event type is GP_WIDGET_EVENT_INPUT the input event is injected to the widget input event handler, i.e. the widget will get the input as if it was focused.
This of course works only for key presses and unicode input events as relative or absolute coordinates are normalized as events pass down the widget tree, i.e. for any event widget receives the widget top level corner has coordinate [0,0]. Hence these kinds of events are not injected.
self | A widget to inject the input event to. |
ev | A widget event. |
|
inlinestatic |
Helper function to send a widget library event to application.
This is called by the widget library when event should be send to the widget.
self | Pointer to the widget sending this event. |
type | Event type see gp_widget_event_type enum. |
Definition at line 121 of file gp_widget_event.h.
References GP_WIDGET_EVENT_COLOR_SCHEME, GP_WIDGET_EVENT_INPUT, GP_WIDGET_EVENT_REDRAW, GP_WIDGET_EVENT_RESIZE, and gp_widget_event::self.
|
inlinestatic |
Helper function to send a widget specific event to application.
This is called by the widget library when event should be send to the widget.
self | Pointer to the widget sending this event. |
type | Event type as defined by a particular widget. |
Definition at line 163 of file gp_widget_event.h.
References GP_WIDGET_EVENT_WIDGET, and gp_widget_event::self.