![]() |
![]() |
![]() |
Pigment 0.3 Reference Manual | ![]() |
---|---|---|---|---|
#include <pgm/pgm.h> enum PgmEventType; enum PgmModifierType; enum PgmButtonType; enum PgmScrollDirection; enum PgmViewportState; PgmEventAny; PgmEventMotion; PgmEventButton; PgmEventScroll; PgmEventState; PgmEventWin32Message; PgmEventDnd; PgmEventKey; PgmEventExpose; PgmEventConfigure; 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_PRESSURE = 4, PGM_BUTTON_RELEASE = 5, PGM_KEY_PRESS = 6, PGM_KEY_RELEASE = 7, PGM_EXPOSE = 8, PGM_CONFIGURE = 9, PGM_DRAG_MOTION = 10, PGM_DRAG_DROP = 12, PGM_DRAG_LEAVE = 13, PGM_SCROLL = 14, PGM_STATE = 15, PGM_DELETE = 16, PGM_WIN32_MESSAGE = 17 } PgmEventType;
Specifies the type of the event.
a special code to indicate a null event. | |
the pointer has entered the window. | |
a mouse button has been pressed. | |
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.
|
|
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.
|
|
a mouse button pressure has changed. | |
a mouse button has been released. | |
a key has been pressed. | |
a key has been released. | |
the window has become visible and needs to be redrawn. | |
the size or the position of the viewport has changed. | |
the mouse has moved in the viewport while a drag is in progress. | |
the mouse has dropped data onto the viewport. | |
the mouse has left the viewport while a drag is in progress. | |
the scroll wheel was turned. | |
the state of a viewport has changed. | |
the window manager has requested that the toplevel window be destroyed, usually when the user clicks on a special icon in the title bar. | |
a Win32 message has been received (Only used on Windows). |
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.
typedef enum { PGM_VIEWPORT_ICONIFIED = (1 << 0) } PgmViewportState;
Specifies the state of a viewport.
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 |
the type of the event. |
guint8 |
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; guint32 pressure; } PgmEventMotion;
Generated when the pointer moves.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
gfloat |
the x coordinate of the pointer relative to the window. |
gfloat |
the y coordinate of the pointer relative to the window. |
guint32 |
the pressure force, set to 0 when not used with a touch screen. |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; PgmButtonType button; guint32 pressure; } PgmEventButton;
Used for button press and button release events.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
gfloat |
the x coordinate of the pointer relative to the window. |
gfloat |
the y coordinate of the pointer relative to the window. |
PgmButtonType |
the button which was pressed or released. |
guint32 |
the pressure force, set to 0 when not used with a touch screen. |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; PgmScrollDirection direction; } PgmEventScroll;
Generated when the mouse wheel is turned.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
gfloat |
the x coordinate of the pointer relative to the window. |
gfloat |
the y coordinate of the pointer relative to the window. |
PgmScrollDirection |
the scroll wheel direction. |
typedef struct { PgmEventType type; guint8 source; PgmViewportState changed_mask; PgmViewportState state_mask; } PgmEventState;
Generated when the state of a viewport changes.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
PgmViewportState |
mask specifying what viewport flags have changed. |
PgmViewportState |
mask specifying the new viewport flags. |
typedef struct { PgmEventType type; guint8 source; guint32 time; UINT message; WPARAM wparam; LPARAM lparam; }; #endif /* WIN32 */ /** * PgmEvent: * * <para> * The #PgmEvent struct contains a union of all of the event structs, * and allows access to the data fields in a number of ways. * </para> * <para> * 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: * <informalexample> * <programlisting language="c"> * PgmEvent *event; * PgmEventType type; * type = event->type; * </programlisting> * </informalexample> * </para> * <para> * 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: * <informalexample> * <programlisting language="c"> * PgmEvent *event; * gfloat x; * x = ((PgmEventButton*) event)->x; * </programlisting> * </informalexample> * or with: * <informalexample> * <programlisting language="c"> * PgmEvent *event; * gfloat x; * x = event->button.x; * </programlisting> * </informalexample> * </para> */ union _PgmEvent { PgmEventType type; PgmEventAny any; PgmEventMotion motion; PgmEventButton button; PgmEventScroll scroll; PgmEventKey key; PgmEventExpose expose; PgmEventConfigure configure; PgmEventDnd dnd; PgmEventState state; #ifdef WIN32 PgmEventWin32Message win32_message; #endif /* WIN32 */ } PgmEventWin32Message;
Describes a Win32 message.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
UINT |
the Win32 message value. |
WPARAM |
additional message information depending on the message value. |
LPARAM |
additional message information depending on the message value. |
typedef struct { PgmEventType type; guint8 source; guint32 time; gfloat x, y; gchar **uri; } PgmEventDnd;
Describes a drag motion, drop, or leave event.
PgmEventType |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
gfloat |
the new x coordinate of the window. |
gfloat |
the new y coordinate of the window. |
gchar ** |
the list of URI as a NULL-terminated array of strings. |
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 |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
guint32 |
the time of the event in milliseconds. |
guint |
A bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt), see PgmModifierType. |
guint |
the key that was pressed or released. See the pgm/pgmkeysyms.h header file for a complete list of Pigment key codes. |
guint16 |
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 |
the type of the event. |
guint8 |
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 |
the type of the event. |
guint8 |
the source field that can be filled by applications to indicate the source of the event (mouse, pen, remote control, etc). |
gint |
the new x coordinate of the window. |
gint |
the new y coordinate of the window. |
gint |
the new width of the viewport. |
gint |
the new height of the viewport. |
PgmEvent* pgm_event_new (PgmEventType type);
Creates a new PgmEvent of the specified type.
MT safe.
|
the type of event. |
Returns : |
a new PgmEvent instance. |
PgmEvent* pgm_event_copy (PgmEvent *event);
Copies event
.
MT safe.
|
a PgmEvent object. |
Returns : |
a newly allocated PgmEvent. |
void pgm_event_free (PgmEvent *event);
MT safe.
Frees all resources used by event
.
|
A PgmEvent object. |
guint32 pgm_keyval_to_unicode (guint keyval);
Converts from a Pigment key symbol to the corresponding ISO10646 (Unicode) character.
MT safe.
|
a Pigment key symbol. |
Returns : |
the corresponding unicode character, or 0 if there is no corresponding one. |