Index: /trunk/SophyaPI/PI/pi3ddrw.cc
===================================================================
--- /trunk/SophyaPI/PI/pi3ddrw.cc	(revision 169)
+++ /trunk/SophyaPI/PI/pi3ddrw.cc	(revision 170)
@@ -26,4 +26,6 @@
   lCO = 10.;  dlCO = 3.;  
   v3D_obs = false;
+  xMin = yMin = zMin = -1.;  
+  xMax = yMax = zMax = 1.;
 }
 
@@ -85,5 +87,5 @@
 
 // ......................................................................
-// ........................  Classe PIDrawer3D ..........................
+// .......................  Classe PIDraw3DWdg ..........................
 // ......................................................................
 
Index: /trunk/SophyaPI/PI/pi3ddrw.h
===================================================================
--- /trunk/SophyaPI/PI/pi3ddrw.h	(revision 169)
+++ /trunk/SophyaPI/PI/pi3ddrw.h	(revision 170)
@@ -31,4 +31,7 @@
   virtual PIGraphicUC*	SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
 
+  float ZMin() const {return zMin;}
+  float ZMax() const {return zMax;}
+
 protected :
   float xO, yO, zO;  // Position observateur = camera
@@ -38,4 +41,5 @@
   float lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ 
   bool v3D_obs;      // Si defini par Set3DView_Obs 
+  float zMin, zMax;  // Pour delimiter le cube 3D (avec x/yMin-Max)
 };
 
Index: /trunk/SophyaPI/PI/pibwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.h	(revision 169)
+++ /trunk/SophyaPI/PI/pibwdggen.h	(revision 170)
@@ -1,2 +1,9 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdgGen
+// Classe de base pour la creation de nouvelles composantes
+// graphiques interactives       
+//                        R.Ansari -  E.Aubourg 96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
 #ifndef PIBWDGGEN_H_SEEN
 #define PIBWDGGEN_H_SEEN
@@ -8,4 +15,5 @@
 #include PIGRAPHIC_H
 #include "pigraphuc.h"
+#include "pievthandler.h"
 #include "psfile.h"
 
@@ -15,13 +23,4 @@
 #include <vector.h>
 #endif
-
-enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 
-
-enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D , 
-                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
-                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B, 
-                   PIK_Up = 0xFF52, PIK_Down = 0xFF54, 
-                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
-                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ; 
 
 
Index: /trunk/SophyaPI/PI/picmapx.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapx.cc	(revision 169)
+++ /trunk/SophyaPI/PI/picmapx.cc	(revision 170)
@@ -61,4 +61,6 @@
 static int NTotAllocCol = 0;
 
+static int nerrallocol = 0;
+
 /* --Methode-- */
 bool PIColorMapX::AllocColor(PIColor const& col, int index)
@@ -106,6 +108,8 @@
   }
 else {
-  printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
+  nerrallocol++;
+  if (nerrallocol < 21) printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
          (int) col.red, (int) col.blue, (int) col.green);
+  if (nerrallocol == 20) printf("No more  PIColorMapX::AllocColor() Errors will be reported \n");
   return(false);
   }
Index: /trunk/SophyaPI/PI/pievthandler.cc
===================================================================
--- /trunk/SophyaPI/PI/pievthandler.cc	(revision 169)
+++ /trunk/SophyaPI/PI/pievthandler.cc	(revision 170)
@@ -1,4 +1,56 @@
 // Module PI : Peida Interactive      PIEventHandler
 // Classe Gestionnaire d'evenements (Ecran/Clavier/Souris)
-//                                    Reza 11/98
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
 
+#include "pievthandler.h"
+
+
+/* --Methode-- */
+PIEventHandler::PIEventHandler(PIMsgHandler* par, PIMessage msg)
+	: PIMsgHandler(par)
+{
+SetMsg(msg);
+curwdg = NULL;
+event = PIEvent_None;
+posx = posy = 0;
+key = 0;
+keymod = PIKM_Blank;
+evttime = 0;
+}
+
+/* --Methode-- */
+PIEventHandler::~PIEventHandler()
+{
+}
+
+/* --Methode-- */
+void PIEventHandler::Draw(PIGraphic*, int, int, int, int)
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::ProcessEvent()
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::SetCurrentWdg(PIWdg* wdg)
+{
+curwdg = wdg;
+}
+
+
+/* --Methode-- */
+void PIEventHandler::SetEventInfo(PIEventMask evt, int px, int py, 
+                                  int k, PIKeyModifier km, unsigned long tm)
+{
+event = evt;
+posx = px; posy = py;
+key = k;
+keymod = km;
+evttime = tm;
+}
+
Index: /trunk/SophyaPI/PI/pievthandler.h
===================================================================
--- /trunk/SophyaPI/PI/pievthandler.h	(revision 169)
+++ /trunk/SophyaPI/PI/pievthandler.h	(revision 170)
@@ -2,14 +2,81 @@
 // Module PI : Peida Interactive      PIEventHandler
 // Classe Gestionnaire d'evenements (Ecran/Clavier/Souris) 
-//                                    Reza 11/98 
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
 
 #ifndef PIEVTHANDLER_H_SEEN
 #define PIEVTHANDLER_H_SEEN
 
+#include "pisysdep.h"
 #include "pimsghandler.h"
+#include PIWDG_H
+#include PIGRAPHIC_H
 
+
+// ....  KeyModifier (<Shift>, <Control> , <Alt>) and special key values ....
+enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 
+
+enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D , 
+                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
+                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B, 
+                   PIK_Up = 0xFF52, PIK_Down = 0xFF54, 
+                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
+                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ; 
+
+// .......... Event Mask values ..........
+enum PIEventMask {
+     PIEvent_None	  =  0,                  //
+     PIEvent_Draw         =  1 << 0,             // ReDraw window
+     PIEvent_Resize       =  1 << 1,             // window resized
+     PIEvent_Enter        =  1 << 2,             // Pointer entered window
+     PIEvent_Leave        =  1 << 3,             // Pointer leaved window
+     PIEvent_But1Press    =  1 << 4,             // Button-1 Press
+     PIEvent_But1Release  =  1 << 5,             // Button-1 Release
+     PIEvent_But2Press    =  1 << 6,             // Button-2 Press
+     PIEvent_But2Release  =  1 << 7,             // Button-2 Release
+     PIEvent_But3Press    =  1 << 8,             // Button-3 Press
+     PIEvent_But3Release  =  1 << 9,             // Button-3 Release
+     PIEvent_PtrMove      =  1 << 14,            // Pointer moved
+     PIEvent_Ptr1Move     =  1 << 15,            // Pointer moved with button-1
+     PIEvent_Ptr2Move     =  1 << 16,            // Pointer moved with button-2
+     PIEvent_Ptr3Move     =  1 << 17,            // Pointer moved with button-3
+     PIEvent_Keyboard     =  1 << 20             // key-pressed Keyboard
+} ;
+
+
+// -----------------  Class PIEventHandler  -----------------------
 class PIEventHandler : public PIMsgHandler
 {
 public:
+			PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0);
+			~PIEventHandler();
+
+  inline  void		SetMsg(PIMessage msg = 0) { myMsg=msg; }
+  inline  PIMessage	Msg() { return (myMsg); }
+
+  virtual void		Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void		ProcessEvent();
+
+  virtual  void		SetCurrentWdg(PIWdg* wdg);
+  inline  PIWdg*	CurrentWdg() { return(curwdg); }
+
+  virtual void		SetEventInfo(PIEventMask evt, int px, int py, 
+                                     int k, PIKeyModifier km, unsigned long tm);
+  inline  PIEventMask	EventType() { return(event); }
+  inline  int		GetPosX() { return(posx); }  
+  inline  int		GetPosY() { return(posy); }  
+  inline  int		GetKey() { return(key); }
+  inline  PIKeyModifier GetKeyMod() { return(keymod); }
+  inline  unsigned long GetEventTime() { return(evttime); }
+
+protected:
+  PIMessage	myMsg;	       // associated user message
+
+  PIWdg*	curwdg;        // Current PIWdg, where event originated
+  PIEventMask	event;	       // event type
+  int		posx, posy;    // Pointer Position  
+  int		key;	       // Pressed key-code 
+  PIKeyModifier keymod;	       // Pressed key-modifier (shift, Cntl, ...)
+  unsigned long evttime;       // Event-time in ms  
 };
 
Index: /trunk/SophyaPI/PI/piperiodx.cc
===================================================================
--- /trunk/SophyaPI/PI/piperiodx.cc	(revision 169)
+++ /trunk/SophyaPI/PI/piperiodx.cc	(revision 170)
@@ -11,5 +11,5 @@
 int szx, szy, szf;
 XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
-id = XtAppAddTimeOut(*appctx, pip->Interval()*1000, xttimer_action, pip);
+id = XtAppAddTimeOut(*appctx, pip->Intervalms(), xttimer_action, pip);
 pip->SetTimerId(id);
 return;
@@ -33,5 +33,5 @@
 {
 if (mFgact) return;
-if (dt > 0)  mDt = dt;
+if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
 
 int szx,szy,szf;
Index: /trunk/SophyaPI/PI/pisurfdr.cc
===================================================================
--- /trunk/SophyaPI/PI/pisurfdr.cc	(revision 169)
+++ /trunk/SophyaPI/PI/pisurfdr.cc	(revision 170)
@@ -56,4 +56,12 @@
   Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 
             (xmin+xmax)/2.+D , (ymin+ymax)/2.+2*D , zmin+(zmax-zmin)*0.60, 0.25, 0.25);  
+  
+  xMin = xmin - 0.05*(xmax-xmin);
+  xMax = xmax + 0.05*(xmax-xmin);
+  yMin = ymin - 0.05*(ymax-ymin);
+  yMax = ymax + 0.05*(ymax-ymin);
+  zMin = zmin - 0.05*(zmax-zmin);
+  zMax = zmax + 0.05*(zmax-zmin);
+
 //  printf("PISurfaceDrawer::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
 //  printf("PISurfaceDrawer::UpdateLimits() :  %g %g %g <<- %g %g %g \n", 
Index: /trunk/SophyaPI/PI/piwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.cc	(revision 169)
+++ /trunk/SophyaPI/PI/piwdggen.cc	(revision 170)
@@ -10,5 +10,5 @@
 #include "piwdggen.h"
 #include "picontainergen.h"
-
+#include "pievthandler.h"
 #include "psfile.h"
 
@@ -181,4 +181,9 @@
 //  ChildDel() doit etre appele par la classe qui implemente le widget
 // if (parent)  parent->ChildDel(this);   //  On previent le container parent 
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
 }
 
@@ -220,4 +225,53 @@
 }
 
+//++
+// Titre	Gestion des Draw/Event Handler
+//	Des Draw ou des Event Handler peuvent etre ajoute a un Widget 
+//--
+
+//++
+// void AddDrawHandler(PIEventHandler* drwh, bool ad=false)
+//	Ajout de 
+// void RemoveDrawHandler(PIEventHandler* drwh)
+//	Suppression de 
+// void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false)
+//	Ajout de 
+// void RemoveEventHandler(PIEventHandler* evh)
+//	Suppression de 
+//--
+
+/* --Methode-- */
+void PIWdgGen::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+EvHand eh;
+eh.evh = drwh; eh.mask = PIEvent_Draw;  eh.ad = ad;
+mDHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveDrawHandler(PIEventHandler* drwh)
+{
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+  if ((*it).evh == drwh) { mDHlist.erase(it); break; }
+}
+
+/* --Methode-- */
+void PIWdgGen::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+EvHand eh;
+eh.evh = evh; eh.mask = evtmask;  eh.ad = ad;
+mEHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveEventHandler(PIEventHandler* evh)
+{
+list<EvHand>::iterator it;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+  if ((*it).evh == evh) { mEHlist.erase(it); break; }
+}
+
+
 /* --Methode-- 
 string PIWdgGen::kindstr()
Index: /trunk/SophyaPI/PI/piwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.h	(revision 169)
+++ /trunk/SophyaPI/PI/piwdggen.h	(revision 170)
@@ -7,10 +7,13 @@
 #define PIWDG_H_SEEN
 
+#include "pimsghandler.h"
+
 #include <string>
+#include <list>
 #if defined(__KCC__)
 using std::string ;
+#include <list.h>
 #endif
 
-#include "pimsghandler.h"
 
 void PIBeep();
@@ -30,4 +33,6 @@
 class PSFile;
 class PIContainerGen;
+class PIEventHandler;
+
 class PIWdgGen : public PIMsgHandler
 {
@@ -91,8 +96,17 @@
   virtual void           PasteSelection(unsigned int typ, void *pdata, unsigned int l)    = 0;
 
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// !! Devrait etre protected - mis ici a cause de cxx  Reza 12/98
+  struct EvHand { PIEventHandler* evh; unsigned long mask;  bool ad; };
 protected:
-  PIContainerGen        *parent;
+  PIContainerGen*        parent;
   PIMessage              myMsg;
-
+  list<EvHand>		 mDHlist;
+  list<EvHand>		 mEHlist;
 private:
   int flag;
Index: /trunk/SophyaPI/PI/piwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.cc	(revision 169)
+++ /trunk/SophyaPI/PI/piwdgx.cc	(revision 170)
@@ -9,4 +9,6 @@
 #include <X11/CoreP.h>
 
+#include <X11/keysym.h>
+
 #include <Xm/Xm.h>       // A cause des container XmForm 
 #include <Xm/Form.h>     // Idem 
@@ -14,4 +16,5 @@
 #include "piwdgx.h"
 #include "picontainerx.h"
+#include "pievthandler.h"
 
 
@@ -734,2 +737,239 @@
 return;
 }
+
+
+// Declaration de l' EventHandler Xt
+static void evthandler_piwdgx (Widget wdgp, XtPointer, XEvent* evt, Boolean* cont);
+
+
+/* --Methode-- */
+void PIWdgX::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+PIWdgGen::AddDrawHandler(drwh, ad);
+XtAddEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveDrawHandler(PIEventHandler* drwh)
+{
+PIWdgGen::RemoveDrawHandler(drwh);
+if (mEHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+PIWdgGen::AddEventHandler(evh, evtmask, ad);
+EventMask mask = 0;
+// if (evtmask & PIEvent_Resize)  pas traite pour le moment
+if (evtmask & PIEvent_Enter)  mask |= EnterNotify;
+if (evtmask & PIEvent_Leave)  mask |= LeaveNotify;
+if (evtmask & PIEvent_But1Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But1Release)  mask |= ButtonRelease;
+if (evtmask & PIEvent_But2Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But2Release)  mask |= ButtonRelease;
+if (evtmask & PIEvent_But3Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But3Release)  mask |= ButtonRelease;
+if (evtmask & PIEvent_PtrMove)  mask |= PointerMotionHintMask;
+if (evtmask & PIEvent_Ptr1Move)  mask |= (PointerMotionHintMask | Button1MotionMask);
+if (evtmask & PIEvent_Ptr2Move)  mask |= (PointerMotionHintMask | Button2MotionMask);
+if (evtmask & PIEvent_Ptr3Move)  mask |= (PointerMotionHintMask | Button3MotionMask);
+if (evtmask & PIEvent_Keyboard)  mask |= KeyPressMask;
+XtAddEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveEventHandler(PIEventHandler* evh)
+{
+PIWdgGen::RemoveEventHandler(evh);
+if (mEHlist.size() > 0) return; 
+unsigned mask = EnterNotify;
+mask |= LeaveNotify;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= PointerMotionHintMask;
+mask |= (PointerMotionHintMask | Button1MotionMask);
+mask |= (PointerMotionHintMask | Button2MotionMask);
+mask |= (PointerMotionHintMask | Button3MotionMask);
+mask |= KeyPressMask;
+XtRemoveEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::CallDrawHandlers(int x0, int y0, int dx, int dy)
+{
+PIGraphicWin* g = new PIGraphicWin(this);
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) { 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo(PIEvent_Draw, x0, y0, 0, PIKM_Blank, 0);
+  g->SaveGraphicAtt();
+  eh->Draw(g, x0, y0, dx, dy);
+  g->RestoreGraphicAtt();
+  }
+delete g;
+}
+
+/* --Methode-- */
+void PIWdgX::CallEventHandlers(unsigned long evt, int px, int py,
+                               int k, int km, unsigned long tm)
+{
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
+  if (!((*it).mask & evt))  continue; 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo((PIEventMask)evt, px, py, k, (PIKeyModifier)km, tm);
+  eh->ProcessEvent();
+  }
+}
+
+
+// -------   Event Handler Xt ----------
+/* Nouvelle-Fonction */
+void evthandler_piwdgx (Widget wdgp, XtPointer usd, 
+                             XEvent* evt, Boolean* cont)
+{
+
+*cont = FALSE ; 
+PIWdgX* wx = (PIWdgX*)usd;
+PIEventMask evm = PIEvent_None;
+PIKeyModifier kmod = PIKM_Blank;
+
+switch (evt->type) {
+  case Expose :
+    wx->CallDrawHandlers(evt->xexpose.x , evt->xexpose.y , evt->xexpose.width , evt->xexpose.height);
+    break;
+  case EnterNotify : 
+    wx->CallEventHandlers(PIEvent_Enter, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+    break;
+
+  case LeaveNotify : 
+    wx->CallEventHandlers(PIEvent_Leave, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+  break;
+
+  case ButtonPress :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Press;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Press;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Press;
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case ButtonRelease :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Release;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Release;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Release;
+
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case MotionNotify :
+    {
+    int xw, yw, xr, yr;
+    unsigned int key_but;
+    Window rw, cw;
+    if ( evt->xmotion.is_hint == NotifyHint ) { 
+      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
+                  &xr, &yr, &xw, &yw, &key_but) ) break ;
+      }
+    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
+    if  (key_but & Button1Mask ) evm = PIEvent_Ptr1Move;
+    else  if (key_but & Button2Mask ) evm = PIEvent_Ptr2Move;
+    else  if (key_but & Button3Mask ) evm = PIEvent_Ptr3Move;
+    else if ( !(key_but & (Button4Mask|Button5Mask)) )  evm = PIEvent_PtrMove;
+
+    if  (key_but & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (key_but & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (key_but & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+
+    wx->CallEventHandlers(evm, xw, yw, 0, kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xmotion.time, evt->xmotion.serial);    
+    }
+  break;
+
+  case KeyPress :
+    {
+    XComposeStatus cs;
+    KeySym key;
+    char buf[10];
+    int i,nc,rkey;
+
+  
+    kmod = PIKM_Blank;
+    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+
+    if  (evt->xkey.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xkey.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xkey.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    switch (key) {
+      case XK_Return :
+        rkey = PIK_Return;
+      break;
+      case XK_KP_Enter :
+        rkey = PIK_Enter;
+      break;
+      case XK_Up :
+        rkey = PIK_Up;
+      break;
+      case XK_Down :
+        rkey = PIK_Down;
+      break;
+      case XK_Left :
+        rkey = PIK_Left;
+      break;
+      case XK_Right :
+        rkey = PIK_Right;
+      break;
+      case XK_Prior :
+        rkey = PIK_Previous;
+      break;
+      case XK_Next :
+        rkey = PIK_Next;
+      break;
+      default :
+        rkey = 0;
+      break;
+    }
+    if (rkey > 0)  wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                         rkey, kmod, evt->xkey.time);
+    else for(i=0; i<nc; i++)  
+            wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                 (int)(buf[i]), kmod, evt->xkey.time);
+    PIXSetLastEventTimeSerial(evt->xkey.time, evt->xkey.serial);    
+
+  }
+  break;
+}
+
+return;
+}
Index: /trunk/SophyaPI/PI/piwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.h	(revision 169)
+++ /trunk/SophyaPI/PI/piwdgx.h	(revision 170)
@@ -1,4 +1,6 @@
-/* Classe pour enrobage generique des widgets Xt, Mac, etc  */
-/*                                    Reza 10/95            */
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIWdgX
+//                                    Reza 10/95            
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
 
 #ifndef PIWDG_X_SEEN
@@ -62,4 +64,15 @@
   virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
 
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// En public, pour permettre l'acces depuis call-back Xt
+  virtual void		 CallDrawHandlers(int x0, int y0, int dx, int dy); 
+  virtual void		 CallEventHandlers(unsigned long evt, int px, int py,
+                                           int k, int km, unsigned long tm);
+
 //  Usage limite a a la version X11
   inline SysDWdg XtWdg() const {return(sdw); }; 
