![]() |
![]() |
![]() |
Pigment 0.3 Reference Manual | ![]() |
---|---|---|---|---|
#include <pgm/pgm.h> enum PgmEventType; enum PgmModifierType; enum PgmButtonType; enum PgmScrollDirection; union PgmEvent; PgmEventAny; PgmEventMotion; PgmEventButton; PgmEventScroll; PgmEventKey; PgmEventExpose; PgmEventConfigure; PgmEventDelete; PgmEvent* pgm_event_new (PgmEventType type); PgmEvent* pgm_event_copy (PgmEvent *event); void pgm_event_free (PgmEvent *event); guint32 pgm_keyval_to_unicode (guint keyval);
Various structs and functions used by Pigment for events handling.
Last reviewed on 2007-04-12 (0.1.5)
typedef enum { PGM_NOTHING = -1, PGM_MOTION_NOTIFY = 0, PGM_BUTTON_PRESS = 1, PGM_DOUBLE_BUTTON_PRESS = 2, PGM_TRIPLE_BUTTON_PRESS = 3, PGM_BUTTON_RELEASE = 4, PGM_KEY_PRESS = 5, PGM_KEY_RELEASE = 6, PGM_EXPOSE = 7, PGM_CONFIGURE = 8, PGM_SCROLL = 9, PGM_DELETE = 10 } PgmEventType;
Specifies the type of the event.
PGM_NOTHING |
a special code to indicate a null event. |
PGM_MOTION_NOTIFY |
the pointer has entered the window. |
PGM_BUTTON_PRESS |
a mouse button has been pressed. |
PGM_DOUBLE_BUTTON_PRESS |
a mouse button has been clicked 2 times in a short
period of time. Note that each click also generates a PGM_BUTTON_PRESS
event.
|
PGM_TRIPLE_BUTTON_PRESS |
a mouse button has been clicked 3 times in a short
period of time. Note that each click also generates a PGM_BUTTON_PRESS
event.
|
PGM_BUTTON_RELEASE |
a mouse button has been released. |
PGM_KEY_PRESS |
a key has been pressed. |
PGM_KEY_RELEASE |
a key has been released. |
PGM_EXPOSE |
the window has become visible and needs to be redrawn. |
PGM_CONFIGURE |
the size or the position of the viewport has changed. |
PGM_SCROLL |
the scroll wheel was turned. |
PGM_DELETE |
the window manager has requested that the toplevel window be destroyed, usually when the user clicks on a special icon in the title bar. |
typedef enum { PGM_SHIFT_MASK = (1 << 0), PGM_CAPSLOCK_MASK = (1 << 1), PGM_CONTROL_MASK = (1 << 2), PGM_ALT_MASK = (1 << 3), PGM_NUMLOCK_MASK = (1 << 4) } PgmModifierType;
A set of bit-flags to indicate the state of modifier keys. Typical modifier keys are Shift, Control, Alt and CapsLock.
typedef enum { PGM_BUTTON_LEFT = (1 << 0), PGM_BUTTON_MIDDLE = (1 << 1), PGM_BUTTON_RIGHT = (1 << 2) } PgmButtonType;
The mouse button type.
typedef enum { PGM_SCROLL_UP, PGM_SCROLL_DOWN } PgmScrollDirection;
The mouse wheel scrolling directions.
union PgmEvent { PgmEventType type; PgmEventAny any; PgmEventMotion motion; PgmEventButton button; PgmEventScroll scroll; PgmEventKey key; PgmEventExpose expose; PgmEventConfigure configure; PgmEventDelete delete; };
The PgmEvent struct contains a union of all of the event structs, and allows access to the data fields in a number of ways.
The event type is always the first field in all of the event structs, and can always be accessed with the following code, no matter what type of event it is:
PgmEvent *event; PgmEventType type; type = event->type;
To access other fields of the event structs, the pointer to the event can be
cast to the appropriate event struct pointer, or the union member name can be
used. For example if the event type is PGM_BUTTON_PRESS
then the x coordinate
of the button press can be accessed with:
PgmEvent *event; gfloat x; x = ((PgmEventButton*) event)->x;
or with:
PgmEvent *event; gfloat x; x = event->button.x;
typedef struct { PgmEventType type; guint8 source; } PgmEventAny;
Contains the fields which are common to all event structs. Any event pointer can safely be cast to a pointer to a PgmEventAny to access these fields.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; } PgmEventMotion;
Generated when the pointer moves.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 time ; |
the time of the event in milliseconds. |
gfloat x ; |
the x coordinate of the pointer relative to the window in canvas coordinate. |
gfloat y ; |
the y coordinate of the pointer relative to the window in canvas coordinate. |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; PgmButtonType button; } PgmEventButton;
Used for button press and button release events.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 time ; |
the time of the event in milliseconds. |
gfloat x ; |
the x coordinate of the pointer relative to the window in canvas coordinate. |
gfloat y ; |
the y coordinate of the pointer relative to the window in canvas coordinate. |
PgmButtonType button ; |
the button which was pressed or released. |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; PgmScrollDirection direction; } PgmEventScroll;
Generated when the mouse wheel is turned.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 time ; |
the time of the event in milliseconds. |
gfloat x ; |
the x coordinate of the pointer relative to the window in canvas coordinate. |
gfloat y ; |
the y coordinate of the pointer relative to the window in canvas coordinate. |
PgmScrollDirection direction ; |
the scroll wheel direction. |
typedef struct { PgmEventType type; guint8 source; guint32 time; guint modifier; guint keyval; guint16 hardware_keycode; } PgmEventKey;
Describes a key press or key release event.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 time ; |
the time of the event in milliseconds. |
guint modifier ; |
A bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt), see PgmModifierType. |
guint keyval ; |
the key that was pressed or released. See the pgm/pgmkeysyms.h header file for a complete list of Pigment key codes. |
guint16 hardware_keycode ; |
the raw code of the key that was pressed or released. |
typedef struct { PgmEventType type; guint8 source; } PgmEventExpose;
Generated when a window becomes visible and needs to be redrawn.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
typedef struct { PgmEventType type; guint8 source; gint x, y; gint width, height; } PgmEventConfigure;
Generated when a viewport size or position has changed.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
gint x ; |
the new x coordinate of the window. |
gint y ; |
the new y coordinate of the window. |
gint width ; |
the new width of the viewport. |
gint height ; |
the new height of the viewport. |
typedef struct { PgmEventType type; guint8 source; guint32 time; } PgmEventDelete;
Generated when the user requested that the viewport be destroyed.
PgmEventType type ; |
the type of the event. |
guint8 source ; |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 time ; |
the time of the event in milliseconds. |
PgmEvent* pgm_event_new (PgmEventType type);
Creates a new PgmEvent of the specified type.
MT safe.
type : |
the type of event. |
Returns : | a new PgmEvent instance. |
void pgm_event_free (PgmEvent *event);
MT safe.
Frees all resources used by event
.
event : |
A PgmEvent object. |