00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef SO_WX_DEVICE
00025 #define SO_WX_DEVICE
00026 
00028 
00029 
00030 
00032 
00033 #include <Inventor/SbLinear.h>
00034 #include <Inventor/events/SoEvent.h>
00035 #include <Inventor/Wx/SoWxDef.h>
00036 
00037 #include <wx/event.h>
00038 #include <wx/object.h>
00039 
00040 
00041 #define   EventMask int
00042 #ifdef _WIN32
00043 #define   ButtonPressMask   0x01
00044 #define   ButtonReleaseMask 0x02
00045 #define   PointerMotionMask 0x04
00046 #define   ButtonMotionMask  0x08
00047 #define   KeyPressMask      0x10
00048 #define   KeyReleaseMask    0x20
00049 #define   EnterWindowMask   0x40
00050 #define   LeaveWindowMask   0x80
00051 #else
00052 #define NoEventMask               0L
00053 #define KeyPressMask                (1L<<0)  
00054 #define KeyReleaseMask            (1L<<1)  
00055 #define ButtonPressMask           (1L<<2)  
00056 #define ButtonReleaseMask         (1L<<3)  
00057 #define EnterWindowMask           (1L<<4)  
00058 #define LeaveWindowMask           (1L<<5)  
00059 #define PointerMotionMask         (1L<<6)  
00060 #define PointerMotionHintMask   (1L<<7)  
00061 #define Button1MotionMask         (1L<<8)  
00062 #define Button2MotionMask         (1L<<9)  
00063 #define Button3MotionMask         (1L<<10) 
00064 #define Button4MotionMask         (1L<<11) 
00065 #define Button5MotionMask         (1L<<12) 
00066 #define ButtonMotionMask          (1L<<13)
00067 #endif
00068 
00069 class wxEvent;
00070 
00093 class  SoWxDevice : public wxObject
00094 {
00095 public:
00101   virtual void enable( wxWindow* w, XtEventHandler f, void* data, void* unused = NULL ) = 0;
00102 
00106   virtual void disable( wxWindow* w, XtEventHandler f, void* data ) = 0;
00107     
00114   virtual const SoEvent* translateEvent( wxEvent& anEvent ) = 0;
00115 
00125   void setWindowSize( const SbVec2s& s ) { m_winSize = s; }
00126 
00130   const SbVec2s& getWindowSize() const { return m_winSize; }
00131 
00132  private:
00140   inline void         setEventPosition(SoEvent *event, float x, float y) const;
00141     
00142   
00143   
00144   wxWindow* deviceWidget;
00145 
00146  private:
00147   SbVec2s m_winSize;    
00148 };
00149 
00150 
00151 void
00152 SoWxDevice::setEventPosition( SoEvent* event, float x, float y ) const
00153 {
00154   event->setPosition(SbVec2f(x, (((float)m_winSize[1]) - 1.f) - y));
00155 }
00156 
00157 #endif // SO_WX_DEVICE
00158 
00159 
00160