/* ClanRuby, A set of Ruby bindings for ClanLib Copyright (C) 2002 Russell Olsen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * Input slots for mouse stuff. */ static CL_Slot mouseButtonPressSlot; static CL_Slot mouseButtonReleaseSlot; static CL_Slot mouseMoveSlot; /* * ID of the ruby method we call when an event occurs */ static ID onMouseButtonPressID; static ID onMouseButtonReleaseID; static ID onMouseMoveID; /* * Ruby method to call when a button is pressed. */ static VALUE pressHandler = Qnil; static VALUE releaseHandler = Qnil; static VALUE moveHandler = Qnil; /* * Clanlib function which is called when a button is pressed, * in turn calls the associated ruby button press method if there * is one. */ static void onButtonPress(CL_InputDevice *device, const CL_Key &key) { VALUE handler = rb_cvar_get( classMouse, onMouseButtonPressID ); if ( handler != Qnil ) { VALUE vAscii = INT2NUM(key.ascii); VALUE vID = INT2NUM(key.id); VALUE vX = rb_float_new(key.x); VALUE vY = rb_float_new(key.y); rb_funcall( handler, onButtonPressID, 4, vID, vAscii, vX, vY ); } } /* * Initialize the button press class. */ /* * Connect the clanlib button handler to the ruby handler. */ onButtonPressID = rb_intern("onButtonPress"); buttonSlot = CL_Mouse::sig_button_press.connect( onButtonPress);