Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoEventCallback.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SOEVENTCALLBACK_H
00021 #define COIN_SOEVENTCALLBACK_H
00022 
00023 #include <Inventor/nodes/SoSubNode.h>
00024 #include <Inventor/lists/SbList.h>
00025 
00026 #ifndef COIN_INTERNAL
00027 // Added for Inventor compliance
00028 #include <Inventor/actions/SoHandleEventAction.h>
00029 #endif // !COIN_INTERNAL
00030 
00031 
00032 class SoEventCallback;
00033 class SoPath;
00034 class SoEvent;
00035 class SoPickedPoint;
00036 class SoHandleEventAction;
00037 
00038 typedef void SoEventCallbackCB(void * userdata, SoEventCallback * node);
00039 
00040 
00041 class COIN_DLL_API SoEventCallback : public SoNode {
00042   typedef SoNode inherited;
00043 
00044   SO_NODE_HEADER(SoEventCallback);
00045 
00046 public:
00047   static void initClass(void);
00048   SoEventCallback(void);
00049 
00050   void setPath(SoPath * path);
00051   const SoPath * getPath(void);
00052 
00053   void addEventCallback(SoType eventtype, SoEventCallbackCB * f,
00054                         void * userdata = NULL);
00055   void removeEventCallback(SoType eventtype, SoEventCallbackCB * f,
00056                            void * userdata = NULL);
00057 
00058   SoHandleEventAction * getAction(void) const;
00059   const SoEvent * getEvent(void) const;
00060   const SoPickedPoint * getPickedPoint(void) const;
00061 
00062   void setHandled(void);
00063   SbBool isHandled(void) const;
00064 
00065   void grabEvents(void);
00066   void releaseEvents(void);
00067 
00068 protected:
00069   virtual ~SoEventCallback();
00070 
00071   virtual void handleEvent(SoHandleEventAction * action);
00072 
00073 private:
00074   struct CallbackInfo {
00075     SoEventCallbackCB * func;
00076     SoType eventtype;
00077     void * userdata;
00078 
00079     // AIX native compiler xlC needs equality and inequality operators
00080     // to compile templates where these operators are referenced (even
00081     // if they are actually never used).
00082 
00083     SbBool operator==(const CallbackInfo & cbi) {
00084       return this->func == cbi.func && this->eventtype == cbi.eventtype && this->userdata == cbi.userdata;
00085     }
00086     SbBool operator!=(const CallbackInfo & cbi) {
00087       return !(*this == cbi);
00088     }
00089   };
00090 
00091   SbList<CallbackInfo> callbacks;
00092   SoHandleEventAction * heaction;
00093   SoPath * path;
00094 
00095 };
00096 
00097 #endif // !COIN_SOEVENTCALLBACK_H

Generated at Tue Mar 5 03:31:13 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001