From: Tilman Sauerbeck Date: Sun, 22 Aug 2004 23:06:05 +0000 (+0000) Subject: Implemented the MOUSE_BUTTON_{UP,DOWN} events. X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=commitdiff_plain;h=eb5e1150186236a48b183da22b2b173add857eef Implemented the MOUSE_BUTTON_{UP,DOWN} events. --- diff --git a/src/ecore_x/rb_ecore_x.c b/src/ecore_x/rb_ecore_x.c index c30eef2..cce61d2 100644 --- a/src/ecore_x/rb_ecore_x.c +++ b/src/ecore_x/rb_ecore_x.c @@ -1,5 +1,5 @@ /* - * $Id: rb_ecore_x.c 90 2004-08-22 16:23:19Z tilman $ + * $Id: rb_ecore_x.c 91 2004-08-22 23:06:05Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -73,6 +73,68 @@ static VALUE c_ev_key_down_init (VALUE self, VALUE event) return self; } +static VALUE c_ev_mouse_button_down_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_X_Event_Mouse_Button_Down *e = (void *) event; + + rb_define_attr (c, "button", 1, 0); + rb_define_attr (c, "modifiers", 1, 0); + rb_define_attr (c, "x", 1, 0); + rb_define_attr (c, "y", 1, 0); + rb_define_attr (c, "root", 1, 0); + rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "event_window", 1, 0); + rb_define_attr (c, "time", 1, 0); + rb_define_attr (c, "double_click", 1, 0); + rb_define_attr (c, "triple_click", 1, 0); + + rb_iv_set (self, "@button", INT2FIX (e->button)); + rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers)); + rb_iv_set (self, "@x", INT2FIX (e->x)); + rb_iv_set (self, "@y", INT2FIX (e->x)); + rb_iv_set (self, "@root", rb_ary_new3 (2, INT2FIX (e->root.x), + INT2FIX (e->root.y))); + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@event_window", + TO_ECORE_X_WINDOW (Qnil, e->event_win)); + rb_iv_set (self, "@time", UINT2NUM (e->time)); + rb_iv_set (self, "@double_click", + e->double_click ? Qtrue : Qfalse); + rb_iv_set (self, "@triple_click", + e->triple_click ? Qtrue : Qfalse); + + return self; +} + +static VALUE c_ev_mouse_button_up_init (VALUE self, VALUE event) +{ + VALUE c = CLASS_OF (self); + Ecore_X_Event_Mouse_Button_Up *e = (void *) event; + + rb_define_attr (c, "button", 1, 0); + rb_define_attr (c, "modifiers", 1, 0); + rb_define_attr (c, "x", 1, 0); + rb_define_attr (c, "y", 1, 0); + rb_define_attr (c, "root", 1, 0); + rb_define_attr (c, "window", 1, 0); + rb_define_attr (c, "event_window", 1, 0); + rb_define_attr (c, "time", 1, 0); + + rb_iv_set (self, "@button", INT2FIX (e->button)); + rb_iv_set (self, "@modifiers", INT2FIX (e->modifiers)); + rb_iv_set (self, "@x", INT2FIX (e->x)); + rb_iv_set (self, "@y", INT2FIX (e->x)); + rb_iv_set (self, "@root", rb_ary_new3 (2, INT2FIX (e->root.x), + INT2FIX (e->root.y))); + rb_iv_set (self, "@window", TO_ECORE_X_WINDOW (Qnil, e->win)); + rb_iv_set (self, "@event_window", + TO_ECORE_X_WINDOW (Qnil, e->event_win)); + rb_iv_set (self, "@time", UINT2NUM (e->time)); + + return self; +} + static VALUE c_ev_mouse_move_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); @@ -331,6 +393,16 @@ void Init_ecore_x (void) rb_define_private_method (c, "initialize", c_ev_key_down_init, 1); + ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_BUTTON_DOWN, + "MouseButtonDown", c); + rb_define_private_method (c, "initialize", + c_ev_mouse_button_down_init, 1); + + ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_BUTTON_UP, + "MouseButtonUp", c); + rb_define_private_method (c, "initialize", + c_ev_mouse_button_up_init, 1); + ADD_EVENT (mX, ECORE_X_EVENT_, MOUSE_MOVE, "MouseMove", c); rb_define_private_method (c, "initialize", c_ev_mouse_move_init, 1);