首頁 / LinuxDev / GTK+ 2.0 教學-GDK事件型別

GTK+ 2.0 教學-GDK事件型別

下列的資料型態被 GTK+ 傳遞給事件處理函式。列出每種資料型態同時也列出了使用該類型的信號。

  • GdkEvent
    • drag_end_event
  • GdkEventType<
  • GdkEventAny
    • delete_event
    • destroy_event
    • map_event
    • unmap_event
    • no_expose_event
  • GdkEventExpose
    • expose_event
  • GdkEventNoExpose
  • GdkEventVisibility
  • GdkEventMotion
    • motion_notify_event
  • GdkEventButton
    • button_press_event
    • button_release_event
  • GdkEventKey
    • key_press_event
    • key_release_event
  • GdkEventCrossing
    • enter_notify_event
    • leave_notify_event
  • GdkEventFocus
    • focus_in_event
    • focus_out_event
  • GdkEventConfigure
    • configure_event
  • GdkEventProperty
    • property_notify_event
  • GdkEventSelection
    • selection_clear_event
    • selection_request_event
    • selection_notify_event
  • GdkEventProximity
    • proximity_in_event
    • proximity_out_event
  • GdkEventDragBegin
    • drag_begin_event
  • GdkEventDragRequest
    • drag_request_event
  • GdkEventDropEnter
    • drop_enter_event
  • GdkEventDropLeave
    • drop_leave_event
  • GdkEventDropDataAvailable
    • drop_data_available_event
  • GdkEventClient
    • client_event
  • GdkEventOther
    • other_event

資料型態GdkEventType是一個特殊的資料型態,它被其餘的資料型態使用,作為一個傳遞給信號處理函式的資料型別指示器。在下面你會看到,每個事件資料結構有一個該型別的成員。它是如下的列舉值:

typedef enum{

GDK_NOTHING           = -1,

GDK_DELETE            = 0,

GDK_DESTROY           = 1,

GDK_EXPOSE            = 2,

GDK_MOTION_NOTIFY     = 3,

GDK_BUTTON_PRESS      = 4,

GDK_2BUTTON_PRESS     = 5,

GDK_3BUTTON_PRESS     = 6,

GDK_BUTTON_RELEASE    = 7,

GDK_KEY_PRESS         = 8,

GDK_KEY_RELEASE       = 9,

GDK_ENTER_NOTIFY      = 10,

GDK_LEAVE_NOTIFY      = 11,

GDK_FOCUS_CHANGE      = 12,

GDK_CONFIGURE         = 13,

GDK_MAP               = 14,

GDK_UNMAP             = 15,

GDK_PROPERTY_NOTIFY   = 16,

GDK_SELECTION_CLEAR   = 17,

GDK_SELECTION_REQUEST = 18,

GDK_SELECTION_NOTIFY  = 19,

GDK_PROXIMITY_IN      = 20,

GDK_PROXIMITY_OUT     = 21,

GDK_DRAG_BEGIN        = 22,

GDK_DRAG_REQUEST      = 23,

GDK_DROP_ENTER        = 24,

GDK_DROP_LEAVE        = 25,

GDK_DROP_DATA_AVAIL   = 26,

GDK_CLIENT_EVENT      = 27,

GDK_VISIBILITY_NOTIFY = 28,

GDK_NO_EXPOSE         = 29,

GDK_OTHER_EVENT       = 9999  /* 不贊成使用,用過濾器代替 */

} GdkEventType;

剩下的,與其餘事件型別不同的是GdkEvent。它是所有其餘資料型態的統一,允許在一個信號處理函式中轉換為指定的事件資料型別。

因此,事件型別有如下定義:

struct _GdkEventAny{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

};struct _GdkEventExpose

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkRectangle area;

gint count; /* 如果非零,它是跟隨事件的數目。*/

};

struct _GdkEventNoExpose

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

/* XXX: 有人需要X major_code或minor_code欄位嗎?*/

};

struct _GdkEventVisibility

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkVisibilityState state;

};

struct _GdkEventMotion

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 time;

gdouble x;

gdouble y;

gdouble pressure;

gdouble xtilt;

gdouble ytilt;

guint state;

gint16 is_hint;

GdkInputSource source;

guint32 deviceid;

gdouble x_root, y_root;

};

struct _GdkEventButton

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 time;

gdouble x;

gdouble y;

gdouble pressure;

gdouble xtilt;

gdouble ytilt;

guint state;

guint button;

GdkInputSource source;

guint32 deviceid;

gdouble x_root, y_root;

};

struct _GdkEventKey

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 time;

guint state;

guint keyval;

gint length;

gchar *string;

};

struct _GdkEventCrossing

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkWindow *subwindow;

GdkNotifyType detail;

};

struct _GdkEventFocus

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

gint16 in;

};

struct _GdkEventConfigure

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

gint16 x, y;

gint16 width;

gint16 height;

};

struct _GdkEventProperty

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkAtom atom;

guint32 time;

guint state;

};

struct _GdkEventSelection

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkAtom selection;

GdkAtom target;

GdkAtom property;

guint32 requestor;

guint32 time;

};

/* 這個事件資料型別很少用。它在支持XInput的程式中,用於繪製自己的游標 */

struct _GdkEventProximity

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 time;

GdkInputSource source;

guint32 deviceid;

};

struct _GdkEventDragRequest

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 requestor;

union {

struct {

guint protocol_version:4;

guint sendreply:1;

guint willaccept:1;

guint delete_data:1; /* Do *not* delete if link is sent, only

if data is sent */

guint senddata:1;

guint reserved:22;

} flags;

glong allflags;

} u;

guint8 isdrop;/* 幾個 X 事件能產生這個gdk事件---這讓應用程式知道拖放是否真的發生
                    或我們僅僅設置資料 */

GdkPoint drop_coords;

gchar *data_type;

guint32 timestamp;

};

struct _GdkEventDragBegin

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

union {

struct {

guint protocol_version:4;

guint reserved:28;

} flags;

glong allflags;

} u;

};

struct _GdkEventDropEnter

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 requestor;

union {

struct {

guint protocol_version:4;

guint sendreply:1;

guint extended_typelist:1;

guint reserved:26;

} flags;

glong allflags;

} u;

};

struct _GdkEventDropLeave

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 requestor;

union {

struct {

guint protocol_version:4;

guint reserved:28;

} flags;

glong allflags;

} u;

};

struct _GdkEventDropDataAvailable

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

guint32 requestor;

union {

struct {

guint protocol_version:4;

guint isdrop:1;

guint reserved:25;

} flags;

glong allflags;

} u;

gchar *data_type; /* MIME type */

gulong data_numbytes;

gpointer data;

guint32 timestamp;

GdkPoint coords;

};

struct _GdkEventClient

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkAtom message_type;

gushort data_format;

union {

char b[20];

short s[10];

long l[5];

} data;

};

struct _GdkEventOther

{

GdkEventType type;

GdkWindow *window;

gint8 send_event;

GdkXEvent *xevent;

};
Print Friendly, PDF & Email
馬上成為工作達人的Fans

About ㄚ琪

工作達人Fun Taiwan的創辦者及總編,可以在這裡更認識他。

One comment

發表迴響

你的電子郵件位址並不會被公開。 Required fields are marked *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料

Scroll To Top