/* Copyright (C) 1997, 1998, 1999, 2000 by Alex Pfaffe (Digital Dawn Graphics Inc) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _ddgEvent_Class_ #define _ddgEvent_Class_ #include "util/ddgutil.h" class WEXP ddgEventHandler { public: typedef bool (*MouseHandlerFn)(void*, int button, int state, int x, int y); typedef bool (*MouseMotionHandlerFn)(void*, int x, int y); typedef bool (*SpecialKeyHandlerFn)(void*, int key, int x, int y); typedef bool (*KeyHandlerFn)(void*, unsigned char key, int x, int y); private: MouseHandlerFn _mhfn; MouseMotionHandlerFn _mmhfn; SpecialKeyHandlerFn _skhfn; KeyHandlerFn _khfn; ddgEventHandler* _defaultHandler; void* _hobj; public: ddgEventHandler(void); void mouseHandler( MouseHandlerFn h ) { _mhfn = h; } MouseHandlerFn mouseHandler( void ) { return _mhfn; } void mouseMotionHandler( MouseMotionHandlerFn h ) { _mmhfn = h; } void keyHandler( KeyHandlerFn h ) { _khfn = h; } void specialKeyHandler( SpecialKeyHandlerFn h ) { _skhfn = h; } MouseMotionHandlerFn mouseMotionHandler( void ) { return _mmhfn; } KeyHandlerFn keyHandler( void ) { return _khfn; } SpecialKeyHandlerFn specialKeyHandler( void ) { return _skhfn; } void handlerObject( void *obj ) { _hobj = obj; } void* handlerObject( void ) { return _hobj; } void defaultHandler( ddgEventHandler *handler ) { _defaultHandler = handler; } ddgEventHandler* defaultHandler( void ) { return _defaultHandler; } void set( void *obj, KeyHandlerFn skey, SpecialKeyHandlerFn sspecialKey, MouseHandlerFn smouse, MouseMotionHandlerFn smouseMotion ); void overrideEventHandler( ddgEventHandler *handler ); static bool smouse(void *obj, int button, int state, int x, int y); static bool smouseMotion(void *obj, int x, int y); static bool sspecialKey(void *obj, int k, int x, int y); static bool skey(void *obj, unsigned char k, int x, int y); }; #endif