Index: /trunk/SophyaPI/PI/piapplx.cc
===================================================================
--- /trunk/SophyaPI/PI/piapplx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piapplx.cc	(revision 23)
@@ -25,5 +25,5 @@
                             10, 10, 0, 0);
 menubar = new PIMenubar(this, "DefMenubar");
-Menubar()->SetBinding(true, true, true, false);
+Menubar()->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
 sxt = ( sx > Menubar()->XSize() ) ? sx : Menubar()->XSize();
 syt = ( sy > 0 ) ? sy : 0;
@@ -35,5 +35,5 @@
   topcont = new PIContainerX(MBCont(), "TopLevelCont", 
                              sx, sy, 0, 40);
-  topcont->SetBinding(true, true, true, true);
+  topcont->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
   topcont->Show();
   }
Index: /trunk/SophyaPI/PI/pibwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pibwdggen.cc	(revision 23)
@@ -43,5 +43,5 @@
 void PIBaseWdgGen::But1Press(int /*x*/, int /*y*/)
 {
-Send(PIMsg_ActiveWdg);
+Send(Msg(), PIMsg_Active);
 #ifdef DEBUG_RZXB
 printf ("PIBaseWdgGen::But1Press PosX,Y= %d %d \n", x, y);
Index: /trunk/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pibwdgx.cc	(revision 23)
@@ -398,13 +398,4 @@
 
 
-/* --Methode-- */
-void PIBaseWdgX::SelectFont(int isz, int jat)
-{
-mFAtt = fntatt[jat];
-mFSize = fntsz[isz];
-mFSt = fntst[isz][jat];
-XSetFont(XtDisplay(XtWdg()), DefGC(), fntst[isz][jat]->fid);
-return;
-}
 
 /* --Methode-- */
@@ -584,5 +575,5 @@
 void PIBaseWdgX::But1Release(int x, int y)
 {
-Send(PIMsg_ActiveWdg);
+Send(Msg(), PIMsg_Active);
 #ifdef DEBUG_PIBWDGX
 printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y);
@@ -667,4 +658,8 @@
                           "medium-o-normal", "medium-i-normal" };
 
+static XFontStruct * defnt = NULL;
+static char * fnbi[3];
+
+
 /* --Methode-- */
 void PIBaseWdgX::Init()
@@ -673,6 +668,4 @@
 int i,j,k, count;
 char **list;
-XFontStruct * defnt;
-char * fnbi[3];
 
 if (fgbwdg)  return;
@@ -740,26 +733,6 @@
 else defnt = XLoadQueryFont(mdsp, buff);
 
-/* Allocation des fonts */
 for (i=0; i<NMAXFONTSZ; i++)
-  for (j=0; j<3; j++)
-  {
-  for (k=0; k<5; k++)
-    {
-    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[j], fntsz[i]+k);
-    list = XListFonts(mdsp, buff, 10, &count);
-    XFreeFontNames(list);
-    if (count > 0)  break;
-    }
-  if (count > 0)
-    {  
-    fntst[i][j] = XLoadQueryFont(mdsp, buff);
-//    printf("PIBaseWdgX::Init:  font %s loaded \n", buff);
-    }
-  else
-    {   
-    printf("PIBaseWdgX::Init: Pb font %s \n", buff);    
-    fntst[i][j] = defnt;
-    }
-  }
+  for (j=0; j<3; j++)  fntst[i][j] = NULL;
 
  
@@ -793,2 +766,35 @@
 return;
 }
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelectFont(int isz, int jat)
+{
+
+if (!fntst[isz][jat])  // Il faut charger la fonte
+  {
+  char buff[256];
+  int count,k;
+  Display * mdsp = PIXDisplay();
+  char **list;
+
+  for (k=0; k<5; k++)    // Recherche de la fonte pour tailles croissantes
+    {
+    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[jat], fntsz[isz]+k);
+    list = XListFonts(mdsp, buff, 10, &count);
+    XFreeFontNames(list);
+    if (count > 0)  break;
+    }
+  if (count > 0)
+    fntst[isz][jat] = XLoadQueryFont(mdsp, buff);
+  else
+    { printf("PIBaseWdgX::SelectFont/ Pb font %s - Using default \n", buff);    
+    fntst[isz][jat] = defnt; }
+  }
+
+mFAtt = fntatt[jat];
+mFSize = fntsz[isz];
+mFSt = fntst[isz][jat];
+XSetFont(XtDisplay(XtWdg()), DefGC(), fntst[isz][jat]->fid);
+return;
+}
Index: /trunk/SophyaPI/PI/pidemo.cc
===================================================================
--- /trunk/SophyaPI/PI/pidemo.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pidemo.cc	(revision 23)
@@ -202,7 +202,12 @@
 
 /* --Methode-- */
-void PIDemoApp::Process(long msg, PIMsgHandler* sender, void* data)
+void PIDemoApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
 PIWdg *sndw;
+PIMessage tmsg, smm;
+
+tmsg = msg;
+msg = UserMsg(msg);
+smm = ModMsg(tmsg);
 
 if  ((GetState()) && (msg > 9999)) { PIBeep(); return; }
@@ -213,5 +218,5 @@
 else if ( (msg >= 10300) && (msg < 10400) )  MBProcess3(msg, sender, data);
 else if ( (msg >= 10400) && (msg < 10500) )  MBProcess4(msg, sender, data);
-else if (msg == PIMsg_ActiveWdg)
+else if (smm == PIMsg_Active)
   {
   sndw = (PIWdg *)sender;
@@ -226,5 +231,19 @@
     }
   }
-else printf("PIDemoApp::Process() BUG?? Msg %d  \n", (int)msg);
+else if (smm == PIMsg_Close)
+  {
+  sndw = (PIWdg *)sender;
+  if(sndw->kind() == PIWindow::ClassId)
+    {
+    mCurWin = (PIWindow *)sender;
+    CloseCurrent();
+    }
+  else  
+    printf("PIDemoApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n",
+           (int)tmsg,  (int)sndw->kind(), (long)sender);       
+  }
+
+else printf("PIDemoApp::Process() BUG?? Msg %d (%d-%d) \n", 
+            (int)tmsg,(int)msg,(int)smm);
 
 /*   Changement palette outil  */
@@ -239,5 +258,5 @@
 
 /* --Methode-- */
-void PIDemoApp::MBProcess1(long msg, PIMsgHandler* /*sender*/, void* data)
+void PIDemoApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
 {
 
@@ -293,5 +312,5 @@
 
 /* --Methode-- */
-void PIDemoApp::MBProcess2(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void PIDemoApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 int snx,sny,sx,sy,zm,wt;
@@ -359,5 +378,5 @@
 
 /* --Methode-- */
-void PIDemoApp::MBProcess3(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void PIDemoApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 ImageR4 * pim;
@@ -415,5 +434,5 @@
 
 /* --Methode-- */
-void PIDemoApp::MBProcess4(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void PIDemoApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 ImageR4 * pim;
@@ -584,5 +603,5 @@
   {
   pii[i] = new PIImage(win, "Pave", 160, 160, 5+170*i, 65);
-  pii[i]->SetBinding(true, true, true, true);
+  pii[i]->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
   pii[i]->SetZoomWin(zoom);
   pii[i]->SetTextWin(labimg);
@@ -677,5 +696,5 @@
                           sx, sy, 200, 200);
 pii = new PIImage(awp[mNwin], (char *)name.c_str(), sx, sy, 0, 0);
-pii->SetBinding(true, true, true, true);
+pii->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
 pii->SetZoomWin(zoom);
 pii->SetTextWin(labimg);
@@ -909,5 +928,5 @@
 
 /* --Methode-- */
-void VisuTools::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void VisuTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 CMapId cmap[5] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 
@@ -916,4 +935,5 @@
 if (dap->CurrentPIImage() == NULL)  return;
 dap->SetBusy();
+msg = UserMsg(msg);
 if ((msg < 110) && (msg > 90))  // Zoom
   dap->CurrentPIImage()->SetZoom((int)(msg-100));
@@ -1016,5 +1036,5 @@
 
 /* --Methode-- */
-void CutTools::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void CutTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 if ((fgpb) || (dap->CurrentPIImage() == NULL))
@@ -1022,5 +1042,5 @@
   return; }
 
-
+msg = UserMsg(msg);
 switch(msg)
   {
@@ -1238,5 +1258,5 @@
 
 /* --Methode-- */
-void LutWind::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void LutWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 float min, max;
@@ -1244,4 +1264,5 @@
 int typlut[2] = {kLutType_Lin, kLutType_Log} ; 
 
+msg = UserMsg(msg);
 switch (msg)
   {
@@ -1319,9 +1340,10 @@
 
 /* --Methode-- */
-void UserProcWind::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/)
+void UserProcWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
 {
 ImageR4 *mimg, *oimg;
 int xp, yp, dx, dy;
 
+msg = UserMsg(msg);
 switch (msg)
   {
@@ -1497,7 +1519,8 @@
 
 /* --Methode-- */
-void OptionWind::Process(long msg, PIMsgHandler* /*sender*/, void* data)
-{
-
+void OptionWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+msg = UserMsg(msg);
 switch (msg)
   {
Index: /trunk/SophyaPI/PI/pidemo.h
===================================================================
--- /trunk/SophyaPI/PI/pidemo.h	(revision 22)
+++ /trunk/SophyaPI/PI/pidemo.h	(revision 23)
@@ -29,5 +29,5 @@
      ~PIDemoApp();
 
-     virtual void   Process(long msg, PIMsgHandler* sender, void* data=NULL);
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
      void AddImage(ImageR4 * nouv, string const & name, int zm=0, int typ=3);
@@ -51,8 +51,8 @@
 
 private:
-    void MBProcess1(long msg, PIMsgHandler* sender, void* data=NULL);
-    void MBProcess2(long msg, PIMsgHandler* sender, void* data=NULL);
-    void MBProcess3(long msg, PIMsgHandler* sender, void* data=NULL);
-    void MBProcess4(long msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess1(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess2(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess3(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess4(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     bool FitPSF_Res(ImageR4 *pim);
 
@@ -86,5 +86,5 @@
   VisuTools(PIDemoApp *par, PIContainer *pw);
   ~VisuTools();
-  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
   PIPUMenu * ZoomOptMenu() { return mPum[1]; }
@@ -108,5 +108,5 @@
   ~CutTools();
   virtual void  Show();
-  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
 private:
@@ -139,5 +139,5 @@
   ~LutWind();
   virtual void  Show();
-  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
 private:
@@ -159,5 +159,5 @@
                 ~UserProcWind();
   virtual void  Show();
-  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
   void          SelectUP(int n) { mUpr = n; };
 
@@ -179,5 +179,5 @@
   ~OptionWind();
   virtual void  Show();
-  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
 private:
Index: /trunk/SophyaPI/PI/pidrawwin.cc
===================================================================
--- /trunk/SophyaPI/PI/pidrawwin.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pidrawwin.cc	(revision 23)
@@ -6,5 +6,5 @@
 {
    mDrawWdg = new PIScDrawWdg(this, nom, sx-20, sy-20, 10, 10);
-   mDrawWdg->SetBinding(true, true, true, true);   
+   mDrawWdg->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);   
 }
 
Index: /trunk/SophyaPI/PI/pierrdisp.cc
===================================================================
--- /trunk/SophyaPI/PI/pierrdisp.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pierrdisp.cc	(revision 23)
@@ -67,6 +67,7 @@
 
 void
-PIErrorDisplay::Process(long msg, PIMsgHandler *sender, void *data)
+PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
 {
+msg = UserMsg(msg);
   switch(msg) {
   case 5000:
Index: /trunk/SophyaPI/PI/pierrdisp.h
===================================================================
--- /trunk/SophyaPI/PI/pierrdisp.h	(revision 22)
+++ /trunk/SophyaPI/PI/pierrdisp.h	(revision 23)
@@ -36,5 +36,5 @@
   
   void          UpdData();
-  void          Process(long msg, PIMsgHandler *sender, void *data);
+  void          Process(PIMessage msg, PIMsgHandler *sender, void *data);
   void          DoPeriodic() {UpdData();}
 protected:
Index: /trunk/SophyaPI/PI/pifilechogen.cc
===================================================================
--- /trunk/SophyaPI/PI/pifilechogen.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechogen.cc	(revision 23)
@@ -4,5 +4,5 @@
 /************* PIFileChooserGen ************/
 
-PIFileChooserGen::PIFileChooserGen(PIMsgHandler* par, char* nom, long msg)
+PIFileChooserGen::PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg)
 : PIWdg(NULL, nom)
 {
Index: /trunk/SophyaPI/PI/pifilechogen.h
===================================================================
--- /trunk/SophyaPI/PI/pifilechogen.h	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechogen.h	(revision 23)
@@ -10,5 +10,5 @@
   enum {ClassId = 2100};
 
-                     PIFileChooserGen(PIMsgHandler* par, char* nom, long msg);
+                     PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg);
   virtual            ~PIFileChooserGen();
 
Index: /trunk/SophyaPI/PI/pifilechomac.cc
===================================================================
--- /trunk/SophyaPI/PI/pifilechomac.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechomac.cc	(revision 23)
@@ -72,5 +72,5 @@
 
 
-PIFileChooserMac::PIFileChooserMac(PIMsgHandler* par, char* nom, long msg)
+PIFileChooserMac::PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg)
 : PIFileChooserGen(par, nom, msg)
 {
@@ -92,7 +92,7 @@
 // Envoyer un message....
   if (mFileName == "")
-    Send(Msg(), NULL);
+    Send(Msg(), PIMsg_Cancel, NULL);
   else
-    Send(Msg(), (void *) (GetFileName().c_str()));
+    Send(Msg(), PIMsg_OK, (void *) (GetFileName().c_str()));
 }
 
Index: /trunk/SophyaPI/PI/pifilechomac.h
===================================================================
--- /trunk/SophyaPI/PI/pifilechomac.h	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechomac.h	(revision 23)
@@ -9,5 +9,5 @@
 public:
 
-                   PIFileChooserMac(PIMsgHandler* par, char* nom, long msg);
+                   PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg);
   virtual          ~PIFileChooserMac();
 
Index: /trunk/SophyaPI/PI/pifilechox.cc
===================================================================
--- /trunk/SophyaPI/PI/pifilechox.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechox.cc	(revision 23)
@@ -11,10 +11,11 @@
 #include <Xm/FileSB.h>
 
-// Fonction prive (CallBack)
-static void filesel_okact(Widget w, XtPointer *usd, XtPointer *calld);
+// Fonctions privees (CallBack)
+//static void filesel_okact(Widget w, XtPointer *usd, XtPointer *calld);
 static void filesel_cancelact(Widget w, XtPointer *usd, XtPointer *calld);
 
 /* Nouvelle-Fonction */
-void  filesel_okact(Widget w, XtPointer *usd, XtPointer *calld)
+void  filesel_okact(Widget /*w*/, XtPointer *usd, 
+                    XmFileSelectionBoxCallbackStruct *calld)
 {
 PIFileChooserX *pif;
@@ -22,16 +23,21 @@
 pif->mSt = 1;
 pif->MWin()->Unmanage();
-pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
+//pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
+char *flnm;
+XmStringGetLtoR(calld->value, XmSTRING_DEFAULT_CHARSET, &flnm); 
+strncpy(pif->mFName, flnm, 511); 
+pif->Send( pif->Msg(), PIMsg_OK, (void *) pif->mFName);
 return;
 }
 
 /* Nouvelle-Fonction */
-void  filesel_cancelact(Widget w, XtPointer *usd, XtPointer *calld)
+void  filesel_cancelact(Widget /*w*/, XtPointer *usd, XtPointer */*calld*/)
 {
 PIFileChooserX *pif;
 pif = (PIFileChooserX *) usd ;
 pif->mSt = 0;
+pif->mFName[0] = '\0';
 pif->MWin()->Unmanage();
-pif->Send(pif->Msg(), NULL);
+pif->Send(pif->Msg(), PIMsg_Cancel, NULL);
 return;
 }
@@ -41,5 +47,5 @@
 
 /* --Methode-- */
-PIFileChooserX::PIFileChooserX(PIMsgHandler* par, char* nom, long msg)
+PIFileChooserX::PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg)
 : PIFileChooserGen(par, nom, msg)
 {
@@ -51,4 +57,5 @@
 
 mSt = 0;
+mFName[0] = mFName[511] = '\0';
 
 CreateXtWdg(nom, xmFileSelectionBoxWidgetClass, mWin->XtWdg(), PIFC_SzX, PIFC_SzY, 0, 0);
Index: /trunk/SophyaPI/PI/pifilechox.h
===================================================================
--- /trunk/SophyaPI/PI/pifilechox.h	(revision 22)
+++ /trunk/SophyaPI/PI/pifilechox.h	(revision 23)
@@ -11,5 +11,5 @@
 public:
 
-                   PIFileChooserX(PIMsgHandler* par, char* nom, long msg);
+                   PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg);
   virtual          ~PIFileChooserX();
 
@@ -25,5 +25,7 @@
   inline PIWdg *   MWin() { return mWin; }
 
+//  Je les declare ici, en public, a cause des callback
   int mSt;
+  char mFName[512];     
 
 protected:
Index: /trunk/SophyaPI/PI/piimage.cc
===================================================================
--- /trunk/SophyaPI/PI/piimage.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piimage.cc	(revision 23)
@@ -25,5 +25,7 @@
 winovis = true;     // $CHECK$ Reza A enlever si possible 17/6/96
 zow = NULL; 
-txw = NULL;
+trtw = NULL;
+trtlb = txw = NULL;
+SetTextWin(NULL);
 zpixm = pixm = NULL;
 xszpxm = xspxm = 0;
@@ -32,4 +34,5 @@
 offx = offy = 0;
 xpav = ypav = 0;
+xpv0 = ypv0 = 0;
 xszpav = yszpav = 1;
 xmv0 = ymv0 = -1;
@@ -59,4 +62,5 @@
 if (lut) delete lut;
 if (aisup)  delete img;   // Suppression automatique d'image
+if (trtw)  delete trtw;
 }
 
@@ -91,4 +95,26 @@
 return;
 }
+
+/* --Methode-- */
+void PIImage::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+txw = tw;
+if (trw)
+  {
+  if (trtw)  trtw->SetSize(tx, ty);
+  else
+    {
+    trtw = new PIWindow(this, "PixVal", PIWK_transient, tx, ty, 0, 0);
+    trtw->SetAutoDelChilds(true);
+    trtlb = new PILabel(trtw, "PixVal", tx, ty, 0, 0);
+    trtlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (trtw) { delete trtw; trtw = NULL;  trtlb = NULL; }
+
+return;
+}
+
 
 /* --Methode-- */
@@ -161,10 +187,10 @@
 
 /* --Methode-- */
-void PIImage::SetZoom(float fzm, bool refr)
+void PIImage::SetZoomF(float fzm, bool refr)
 {
 int zm;
 
 if (fzm < 0.01) return;
-if (fzm < 1.)  zm = -(1./fzm);
+if (fzm < 1.)  zm = (int)(-(1./fzm));
 else zm = (int)(fzm+0.25);
 SetZoom(zm, refr);
@@ -186,5 +212,5 @@
 
 /* --Methode-- */
-float PIImage::GetZoom()
+float PIImage::GetZoomF()
 {
 if (zoom >= 1)  return((float)zoom);
@@ -248,5 +274,5 @@
   { 
   ComputePixmap();
-  Send(PIMsg_ActiveWdg);
+  Send(Msg(), PIMsg_Active);
   }
 if (zow != NULL) 
@@ -255,10 +281,11 @@
   ComputeZoomPixmap();
   }
-if (txw)
+if (txw || trtlb)
   {
   char buff[256];
-  sprintf(buff,"%s : X= %d , Y= %d  PixVal= %g ", 
-          (char *)Nom().c_str(), xpav, ypav, img->FValue(xpav, ypav));
-  txw->SetLabel((string)buff);
+  sprintf(buff,"X= %d , Y= %d  PixVal= %g ",  /*(char *)Nom().c_str(),*/
+          xpav, ypav, img->FValue(xpav, ypav));
+  if (txw)  txw->SetLabel((string)buff);
+  if (trtlb)  trtlb->SetLabel((string)buff);
   }
 
@@ -296,9 +323,10 @@
 int xp, yp;
 
-Send(PIMsg_ActiveWdg);
+Send(Msg(), PIMsg_Active);
 if (img == NULL)  return;
 if ( PosW2Img(x, y, &xp, &yp) )  return;
 SelPointerShape(PI_CrossPointer);
 xpav = xp;  ypav = yp;
+ShowTrTxW();
 Apply(false);
 if (curshow)  DrawCursor(-1,-1);
@@ -324,4 +352,5 @@
 SelPointerShape(PI_ArrowPointer);
 if (curshow)  DrawCursor();
+if (trtw)  trtw->Hide();
 return;
 }
@@ -333,7 +362,7 @@
 int xp, yp;
 
-Send(PIMsg_ActiveWdg);
-if (img == NULL)  return;
-if ( PosW2Img(x, y, &xp, &yp) )  { xmv0 = -1;  return; }
+Send(Msg(), PIMsg_Active);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xpv0, &ypv0) )  {  xmv0 = -1;  return; }
 xmv0 = x;  ymv0 = y;  dxmv = dymv = 0;
 if (curshow)  DrawCursor(-1,-1);
@@ -343,4 +372,5 @@
 else SelForeground(PI_Magenta);
 SelLine(PI_NormalLine);
+ShowTrTxW();
 return;
 }
@@ -356,4 +386,12 @@
 dxmv = x-xmv0;  dymv = y-ymv0;
 DrawBox(xmv0, ymv0, dxmv, dymv);
+if (txw || trtlb)
+  {
+  char buff[256];
+  sprintf(buff,"X,Y= %d,%d  PixVal= %g (X,Yc= %d,%d)",  
+          xp, yp, img->FValue(x, yp), (xp+xpv0)/2, (yp+ypv0)/2);
+  if (txw)  txw->SetLabel((string)buff);
+  if (trtlb)  trtlb->SetLabel((string)buff);
+  }
 return;
 }
@@ -362,5 +400,5 @@
 void PIImage::But2Release(int x, int y)
 {
-int xp, yp, xp2, yp2;
+int xp2, yp2;
 
 if (img == NULL)  return;
@@ -369,14 +407,14 @@
 SelGOMode(PI_GOCopy);
 SelForeground(PI_White);
-PosW2Img(xmv0, ymv0, &xp, &yp);
 if ( PosW2Img(x, y, &xp2, &yp2) )  
   PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2);
-xpav = (xp+xp2)/2;
-ypav = (yp+yp2)/2;
-xszpav = ((xp2-xp) > 0) ? (xp2-xp) : 1;
-yszpav = ((yp2-yp) > 0) ? (yp2-yp) : 1;
+xpav = (xpv0+xp2)/2;
+ypav = (ypv0+yp2)/2;
+xszpav = ((xp2-xpv0) > 0) ? (xp2-xpv0) : 1;
+yszpav = ((yp2-ypv0) > 0) ? (yp2-ypv0) : 1;
 
 Apply(false);
 if (curshow)  DrawCursor();
+if (trtw)  trtw->Hide();
 return;
 }
@@ -388,8 +426,9 @@
 int xp, yp;
 
-Send(PIMsg_ActiveWdg);
+Send(Msg(), PIMsg_Active);
 if (img == NULL)  return;
 if ( PosW2Img(x, y, &xp, &yp) )  { xmv0 = -1;  return; }
 if (curshow)  DrawCursor(-1,-1);
+ShowTrTxW();
 SelPointerShape(PI_TDLRArrowPointer);
 xmv0 = xp;
@@ -406,9 +445,10 @@
 if (xmv0 < 0)  return;
 if ( PosW2Img(x, y, &xp, &yp) )  return;
-if (txw)
+if (txw || trtlb)
   {
   char buff[256];
-  sprintf(buff,"%s : DelX= %d , DelY= %d ", (char *)Nom().c_str(), xp-xmv0, yp-ymv0);
-  txw->SetLabel((string)buff);
+  sprintf(buff,"DelX= %d , DelY= %d ", xp-xmv0, yp-ymv0);
+  if (txw) txw->SetLabel((string)buff);
+  if (trtlb) trtlb->SetLabel((string)buff);
   }
 }
@@ -420,4 +460,5 @@
 
 SelPointerShape(PI_ArrowPointer);
+if (trtw)  trtw->Hide();
 if (img == NULL)  return;
 if (xmv0 < 0)  return;
@@ -611,4 +652,20 @@
   }
 else { xcurs = ycurs = -1; }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::ShowTrTxW()
+{
+if (trtw) 
+  {
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  tpy -= (trtw->YSize()+5);
+  if (tpy < 0)  tpy = 0;
+  trtw->SetPos(tpx, tpy);
+  trtw->Show();  
+  }
 
 return;
Index: /trunk/SophyaPI/PI/piimage.h
===================================================================
--- /trunk/SophyaPI/PI/piimage.h	(revision 22)
+++ /trunk/SophyaPI/PI/piimage.h	(revision 23)
@@ -13,4 +13,5 @@
 #include PIPIXMAP_H
 #include PISTDWDG_H
+#include PIWIN_H
 
 class PIImage : public PIPixmap
@@ -28,5 +29,5 @@
 
   void SetZoomWin(PIPixmap * zw, bool refr=true);
-  inline void SetTextWin(PILabel * tw) { txw = tw; };
+  void SetTextWin(PILabel * tw, bool trw=true, int tx=350, int ty=30);
   void ShowCursor(bool sc=true); 
 
@@ -36,6 +37,6 @@
 
   void SetZoom(int zm, bool refr=true);
-  void SetZoom(float fzm, bool refr=true);
-  float GetZoom();
+  void SetZoomF(float fzm, bool refr=true);
+  float GetZoomF();
 
   void SetOffset(int ox, int oy, bool refr=true);
@@ -78,4 +79,6 @@
   void DrawCursor(int xc, int yc);
 
+  void ShowTrTxW();
+
   int PosW2Img(int xiw, int yiw, int * xp, int * yp);
   int PosImg2W(int xp, int yp, int * xiw, int * yiw);
@@ -103,5 +106,9 @@
 
   PILabel * txw;
+  PILabel * trtlb;
+  PIWindow * trtw;
+
   int xpav, ypav;
+  int xpv0, ypv0;
   int xmv0, ymv0;
   int dxmv, dymv;
Index: /trunk/SophyaPI/PI/pimenubarx.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenubarx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pimenubarx.cc	(revision 23)
@@ -28,5 +28,5 @@
 
 SetPos(0,0);
-SetBinding(true, true, true, false);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
 
 Manage();
Index: /trunk/SophyaPI/PI/pimenugen.h
===================================================================
--- /trunk/SophyaPI/PI/pimenugen.h	(revision 22)
+++ /trunk/SophyaPI/PI/pimenugen.h	(revision 23)
@@ -14,12 +14,12 @@
 	          ~PIMenuGen();
 				   
-  virtual void	  AppendItem(char* nom, long msg)=0;
+  virtual void	  AppendItem(char* nom, PIMessage msg)=0;
 
   virtual void    DeleteItem(char *nom)=0;
-  virtual void    DeleteItemMsg(long msg)=0;
+  virtual void    DeleteItemMsg(PIMessage msg)=0;
   virtual void    DeleteItemNum(int n)=0;
 
   virtual void    CheckItem(char *nom, bool st=false)=0; 
-  virtual void    CheckItemMsg(long msg, bool st=false)=0; 
+  virtual void    CheckItemMsg(PIMessage msg, bool st=false)=0; 
   virtual void    CheckItemNum(int n, bool st=false)=0; 
 
Index: /trunk/SophyaPI/PI/pimenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pimenumac.cc	(revision 23)
@@ -24,5 +24,5 @@
 
 int
-PIMenuMac::FindItemByMsg(long msg)
+PIMenuMac::FindItemByMsg(PIMessage msg)
 {
   if (mMsgs.size() == 0) return -1;
@@ -43,5 +43,5 @@
 
 void
-PIMenuMac::AppendItem(char* nom, long msg)
+PIMenuMac::AppendItem(char* nom, PIMessage msg)
 {
   LStr255 titre(nom);
@@ -59,5 +59,5 @@
 
 void
-PIMenuMac::CheckItemMsg(long msg, bool st)
+PIMenuMac::CheckItemMsg(PIMessage msg, bool st)
 {
   int i = FindItemByMsg(msg);
@@ -83,5 +83,5 @@
 
 void
-PIMenuMac::DeleteItemMsg(long msg)
+PIMenuMac::DeleteItemMsg(PIMessage msg)
 {
   int i = FindItemByMsg(msg);
@@ -104,5 +104,5 @@
 {
   if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ?
-  Send(mMsgs[item], (void*) GetMenuItemText(item).c_str());
+  Send(mMsgs[item], PIMsg_Click, (void*) GetMenuItemText(item).c_str());
 }
 
Index: /trunk/SophyaPI/PI/pimenumac.h
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.h	(revision 22)
+++ /trunk/SophyaPI/PI/pimenumac.h	(revision 23)
@@ -13,12 +13,12 @@
 				   ~PIMenuMac();
 				   
-	virtual void	AppendItem(char* nom, long msg);
+	virtual void	AppendItem(char* nom, PIMessage msg);
 
     virtual void    DeleteItem(char *nom);
-    virtual void    DeleteItemMsg(long msg);
+    virtual void    DeleteItemMsg(PIMessage msg);
     virtual void    DeleteItemNum(int n);
 
     virtual void    CheckItem(char *nom, bool st=false); 
-    virtual void    CheckItemMsg(long msg, bool st=false); 
+    virtual void    CheckItemMsg(PIMessage msg, bool st=false); 
     virtual void    CheckItemNum(int n, bool st=false); 
 	
@@ -33,5 +33,5 @@
 	string          GetMenuItemText(int item);
 	int             GetMenuItemMsg(int item);
-	int             FindItemByMsg(long msg);
+	int             FindItemByMsg(PIMessage msg);
 	int             FindItemByName(string const& nom);
 	
@@ -40,5 +40,5 @@
 	LMenu*          macMenu;
 	int             mMenuId;
-	vector<long>    mMsgs;
+	vector<PIMessage>    mMsgs;
 	static int      lastId;
 	static list<PIMenuMac*> sMenus;
Index: /trunk/SophyaPI/PI/pimenux.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenux.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pimenux.cc	(revision 23)
@@ -25,5 +25,5 @@
 
 // pim->Hide();
-pim->Send(cusd->msg, (void *)pim->ItemNameWdg(cusd->itb).c_str());
+pim->Send(cusd->msg, PIMsg_Click, (void *)pim->ItemNameWdg(cusd->itb).c_str());
 #ifdef DEBUG_PIMenuX
 printf("%%%Debug_menub_action: Msg= %d  %lx\n", (int)cusd->msg, (long)pim);
@@ -60,5 +60,5 @@
 
 /* --Methode-- */
-void PIMenuX::AppendItem(char* nom, long msg)
+void PIMenuX::AppendItem(char* nom, PIMessage msg)
 {
 AddItem(nom, msg, false);
@@ -78,5 +78,5 @@
 
 /* --Methode-- */
-void PIMenuX::DeleteItemMsg(long msg)
+void PIMenuX::DeleteItemMsg(PIMessage msg)
 {
 for(int i=0; i<mNItem; i++)
@@ -121,5 +121,5 @@
 
 /* --Methode-- */
-void PIMenuX::CheckItemMsg(long msg, bool st)
+void PIMenuX::CheckItemMsg(PIMessage msg, bool st)
 {
 for(int i=0; i<mNItem; i++)
@@ -189,5 +189,5 @@
 
 /* --Methode-- */
-long PIMenuX::ItemMsg(int n)
+PIMessage PIMenuX::ItemMsg(int n)
 {
 if ( (n < 0) || (n >= mNItem))  return(0);
@@ -208,5 +208,5 @@
 
 /* --Methode-- */
-int PIMenuX::GetNumItemMsg(long msg)
+int PIMenuX::GetNumItemMsg(PIMessage msg)
 {
 for(int i=0; i<mNItem; i++)
@@ -224,5 +224,5 @@
 
 /* --Methode-- */
-void PIMenuX::AddItem(char* nom, long msg, bool tog)
+void PIMenuX::AddItem(char* nom, PIMessage msg, bool tog)
 {
 _pimxit_ *buto;
@@ -288,5 +288,5 @@
 
 /* --Methode-- A virer 
-void PIMenuX::AppendCheckItem(char* nom, long msg)
+void PIMenuX::AppendCheckItem(char* nom, PIMessage msg)
 {
 AddItem(nom, msg, true);
Index: /trunk/SophyaPI/PI/pimenux.h
===================================================================
--- /trunk/SophyaPI/PI/pimenux.h	(revision 22)
+++ /trunk/SophyaPI/PI/pimenux.h	(revision 23)
@@ -11,5 +11,5 @@
 SysDWdg itb;
 PIMenuX *pmen;
-long msg;
+PIMessage msg;
 bool togg;
 };
@@ -22,22 +22,22 @@
 	          ~PIMenuX();
 				   
-  virtual void	  AppendItem(char* nom, long msg);
+  virtual void	  AppendItem(char* nom, PIMessage msg);
 
   virtual void    DeleteItem(char *nom);
-  virtual void    DeleteItemMsg(long msg);
+  virtual void    DeleteItemMsg(PIMessage msg);
   virtual void    DeleteItemNum(int n);
 
   virtual void    CheckItem(char *nom, bool st=false); 
-  virtual void    CheckItemMsg(long msg, bool st=false); 
+  virtual void    CheckItemMsg(PIMessage msg, bool st=false); 
   virtual void    CheckItemNum(int n, bool st=false); 
 
   virtual void    Show();
-  virtual void   Show(PIWdg *w, int px, int py);
+  virtual void    Show(PIWdg *w, int px, int py);
   virtual void    Hide();
 
 // Pour usage prive et par OptionMenu, ...
-  long            ItemMsg(int n);
+  PIMessage       ItemMsg(int n);
   int             GetNumItem(char *nom);
-  int             GetNumItemMsg(long msg);
+  int             GetNumItemMsg(PIMessage msg);
   SysDWdg         GetItemWdg(int n);
   string          ItemName(int n);
@@ -45,5 +45,5 @@
 
 protected:
-        void      AddItem(char* nom, long msg, bool tog);
+        void      AddItem(char* nom, PIMessage msg, bool tog);
         void      Check();
 
Index: /trunk/SophyaPI/PI/pimsghandler.cc
===================================================================
--- /trunk/SophyaPI/PI/pimsghandler.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pimsghandler.cc	(revision 23)
@@ -10,5 +10,5 @@
 
 void
-PIMsgHandler::Process(long msg, PIMsgHandler* sender, void* data)
+PIMsgHandler::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
 	ReSend(msg, sender, data);
@@ -16,17 +16,20 @@
 
 void
-PIMsgHandler::Send(long msg, void* data)
+PIMsgHandler::Send(PIMessage msg, PIMsgMod mm,  void* data)
 {
 //	Process(msg, this, data);  $CHECK$  Reza 12/06/96
 // Send par defaut appelle le process du parent $CHECK$
 if (msgParent)
-  msgParent->Process(msg, this, data);
+  msgParent->Process(BuildMsg(msg, mm), this, data);
 
 }
 
 void
-PIMsgHandler::ReSend(long msg, PIMsgHandler* sender, void* data)
+PIMsgHandler::ReSend(PIMessage msg, PIMsgHandler* sender, void* data)
 {
   if (msgParent)
     msgParent->Process(msg, sender, data);
 }
+
+
+
Index: /trunk/SophyaPI/PI/pimsghandler.h
===================================================================
--- /trunk/SophyaPI/PI/pimsghandler.h	(revision 22)
+++ /trunk/SophyaPI/PI/pimsghandler.h	(revision 23)
@@ -7,27 +7,41 @@
 
 enum {
- // Les messages
-	PIMsg_ActiveWdg     = 1,
-	PIMsg_OK            = 2,
-	PIMsg_Cancel        = 3,
-	PIMsg_Help          = 4,
-	PIMsg_DataChanged   = 5,
-	PIMsg_Click         = 6,
-        PIMsg_Press         = 7
+ // Les messages reserves systeme (PI)   les 8 premiers bits
+ // Messages user, les bits restants
+	PIMsg_Active        = 1,
+        PIMsg_Close         = 2,
+
+	PIMsg_OK            = 11,
+	PIMsg_Cancel        = 12,
+	PIMsg_Help          = 13,
+
+	PIMsg_DataChanged   = 21,
+	PIMsg_Click         = 22,
+        PIMsg_Press         = 23
 };
+
+
+// Definition de type pour les messages - Il est peu probable que le typedef change ...
+//                                      Reza 17/10/96
+typedef unsigned long PIMessage;
+typedef unsigned char PIMsgMod;
 
 class PIMsgHandler {
 public:
-					PIMsgHandler(PIMsgHandler* par=NULL);
-	virtual 	   ~PIMsgHandler();
+			     PIMsgHandler(PIMsgHandler* par=NULL);
+	virtual 	     ~PIMsgHandler();
 	
-	virtual void	SetMsgParent(PIMsgHandler* par) {msgParent = par;}
+	virtual void	     SetMsgParent(PIMsgHandler* par) {msgParent = par;}
 
-	virtual void    Send(long msg, void* data=NULL);
-	
-	
+	virtual void         Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL);
+
+        inline  PIMessage    UserMsg(PIMessage msg) { return (msg >> 8); }
+        inline  PIMessage    ModMsg(PIMessage msg) { return (msg & 0xFF); }
+	inline  PIMessage    BuildMsg(PIMessage um, PIMsgMod mm) 
+                        	  { return ((um << 8) | mm); }
+
 protected:
-	virtual void	ReSend(long msg, PIMsgHandler* sender, void* data=NULL);
-	virtual void	Process(long msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	ReSend(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
 private:
Index: /trunk/SophyaPI/PI/pioptmenugen.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenugen.h	(revision 22)
+++ /trunk/SophyaPI/PI/pioptmenugen.h	(revision 23)
@@ -18,7 +18,7 @@
 
   virtual string     GetValueStr() = 0;    // Option choisie
-  virtual long       GetValue() = 0;       // Message correspondant a l'option choisie
+  virtual PIMessage  GetValue() = 0;       // Message correspondant a l'option choisie
   virtual void       SetValueStr(string & s) = 0;
-  virtual void       SetValue(long msg) = 0;
+  virtual void       SetValue(PIMessage msg) = 0;
 
 protected:
Index: /trunk/SophyaPI/PI/pioptmenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 23)
@@ -34,7 +34,7 @@
 
 /* --Methode-- */
-void PIOptMenuMac::Process(long msg, PIMsgHandler* sender, void* data)
+void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
-Select((char *)data, msg);
+Select((char *)data, UserMsg(msg));  //  Reza 17/10/96 $CHECK$ ???
 ReSend(msg, sender, data);
 }
@@ -48,5 +48,5 @@
 
 void
-PIOptMenuMac::Select(char *txt, long msg)
+PIOptMenuMac::Select(char *txt, PIMessage msg)
 { // Ca doit faire quoi ????
 mStext = txt;  mSmsg = msg;
@@ -68,5 +68,5 @@
 
 /* --Methode-- */
-void PIOptMenuMac::SetValue(long msg)
+void PIOptMenuMac::SetValue(PIMessage msg)
 {
 int n;
Index: /trunk/SophyaPI/PI/pioptmenumac.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenumac.h	(revision 22)
+++ /trunk/SophyaPI/PI/pioptmenumac.h	(revision 23)
@@ -10,18 +10,18 @@
 	               ~PIOptMenuMac();
 
-  virtual void      Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 				   
   virtual void	    ListenToMessage(MessageT inMessage, void *ioParam);
   virtual string    GetValueStr() { return(mStext); }
-  virtual long      GetValue()    { return(mSmsg); } 
+  virtual PIMessage GetValue()    { return(mSmsg); } 
   virtual void      SetValueStr(string & s);
-  virtual void      SetValue(long msg);
+  virtual void      SetValue(PIMessage msg);
   
-  inline void       Select(char *txt, long msg); // public ou protege ???
+  inline void       Select(char *txt, PIMessage msg); // public ou protege ???
 
 
 protected:
   string    mStext;
-  long      mSmsg;
+  PIMessage mSmsg;
   //MenuHandle macMenu;
   PIPUMenu* mPUMenu;
Index: /trunk/SophyaPI/PI/pioptmenux.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenux.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pioptmenux.cc	(revision 23)
@@ -20,10 +20,9 @@
 sy -= 2;
 SetBorderWidth(1); 
-// SetBinding(true, true, true, true);
 mAB = new PIButton(this, "?", 0, sy-2, sy-2, 1, 1);
-mAB->SetBinding(true, true, false, true);
-mAB->SetPressMsg(PIMsg_Press);
+mAB->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_free, PIBK_fixed);
+mAB->ActivatePress(true);
 mLab = new PILabel(this, "OptLabel", sx-sy-1, sy, sy+1, 0);
-mLab->SetBinding(true, true, true, true);
+mLab->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
 mMen = pum;
 SetValue(mMen->ItemMsg(0));
@@ -40,13 +39,13 @@
 
 /* --Methode-- */
-void PIOptMenuX::Process(long msg, PIMsgHandler* sender, void* data)
+void PIOptMenuX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
 // printf("PIOptMenuX::Process Msg= %d Sender= %lx \n", (int)msg, (long)sender);
-if ((sender == mAB) && (msg == PIMsg_Press))  
+if ((sender == mAB) && (ModMsg(msg) == PIMsg_Press))  
   {  mMen->SetMsgParent(this);    mMen->Show(this, 0, YSize()); }
 else if (sender == mMen)
   {
   mAB->ReleaseButton();
-  SetValue(msg);
+  SetValue(UserMsg(msg));
   ReSend(msg, this, data);
   }
@@ -72,5 +71,5 @@
 
 /* --Methode-- */
-void PIOptMenuX::SetValue(long msg)
+void PIOptMenuX::SetValue(PIMessage msg)
 {
 int n;
Index: /trunk/SophyaPI/PI/pioptmenux.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenux.h	(revision 22)
+++ /trunk/SophyaPI/PI/pioptmenux.h	(revision 23)
@@ -12,10 +12,10 @@
 	            ~PIOptMenuX();
 
-  virtual void      Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 				   
   virtual string    GetValueStr() { return(mStext); }
-  virtual long      GetValue()    { return(mSmsg); } 
+  virtual PIMessage GetValue()    { return(mSmsg); } 
   virtual void      SetValueStr(string & s);
-  virtual void      SetValue(long msg);
+  virtual void      SetValue(PIMessage msg);
   
   
@@ -26,5 +26,5 @@
   PIPUMenu *mMen;
   string   mStext;
-  long     mSmsg;
+  PIMessage mSmsg;
 
 };
Index: /trunk/SophyaPI/PI/piqualmon.cc
===================================================================
--- /trunk/SophyaPI/PI/piqualmon.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piqualmon.cc	(revision 23)
@@ -88,6 +88,7 @@
 
 void 
-PIQualiteWin::Process(long msg, PIMsgHandler *sender, void *data)
-{
+PIQualiteWin::Process(PIMessage msg, PIMsgHandler *, void *)
+{
+  msg = UserMsg(msg);  // Reza 17/10/96 $CHECK$
   switch (msg) {
   case 80100:
Index: /trunk/SophyaPI/PI/piqualmon.h
===================================================================
--- /trunk/SophyaPI/PI/piqualmon.h	(revision 22)
+++ /trunk/SophyaPI/PI/piqualmon.h	(revision 23)
@@ -23,5 +23,5 @@
   virtual void        UpdateInfo(LImageInfo linfor, LImageInfo linfob, 
 				 string labflnmr, string labflnmb);
-  virtual void        Process(long msg, PIMsgHandler *sender, void *data);
+  virtual void        Process(PIMessage msg, PIMsgHandler *sender, void *data);
 
 protected:
Index: /trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 23)
@@ -14,5 +14,7 @@
   clip = true;
   padsup = false;
-  mTxw = NULL;
+  mTrlb = mTxw = NULL;
+  mTrW = NULL;
+  SetTextWin(NULL);
   ActivateButton(1);    // Pour pouvoir activer la fenetre et coordonnees 
   ActivateMove(1);      //    "         "         "        "
@@ -25,4 +27,5 @@
 {
   DeleteDrawers();
+  if (mTrW)  delete mTrW;
 }
 
@@ -531,4 +534,24 @@
     axesFlags |= kMajTicks;
 }
+void
+PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+mTxw = tw;
+if (trw)
+  {
+  if (mTrW)  mTrW->SetSize(tx, ty);
+  else
+    {
+    mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0);
+    mTrW->SetAutoDelChilds(true);
+    mTrlb = new PILabel(mTrW, "PixVal", tx, ty, 0, 0);
+    mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (mTrW) { delete mTrW; mTrW = NULL;  mTrlb = NULL; }
+
+return;
+}
 
 void
@@ -547,7 +570,18 @@
 PIScDrawWdg::But1Press(int x, int y)
 {
-  if (UpdateText(x, y)) 
+  if (UpdateText(x, y))
+     {
+     if (mTrW)
+       { 
+       int tpx, tpy;
+       GetScreenPos(tpx, tpy);       
+       tpy -= (mTrW->YSize()+5);
+       if (tpy < 0)  tpy = 0;
+       mTrW->SetPos(tpx, tpy);
+       mTrW->Show();
+       }
      SelPointerShape(PI_CrossPointer);
-  Send(PIMsg_ActiveWdg);
+     }
+  Send(Msg(), PIMsg_Active);
 
 }
@@ -564,5 +598,5 @@
   if (UpdateText(x, y)) 
     SelPointerShape(PI_ArrowPointer);
-
+  if (mTrW)  mTrW->Hide();
 }
 
@@ -570,5 +604,5 @@
 PIScDrawWdg::UpdateText(int xp, int yp)
 {
-  if (mTxw == NULL)  return(false);
+  if ((mTxw == NULL) && (mTrlb == NULL)) return(false);
 
   char buff[128];
@@ -576,5 +610,8 @@
   Local2Sc(xp, yp, dx, dy); 
   sprintf(buff, "X= %g  Y= %g",  dx, dy);
-  mTxw->SetLabel((string)buff);
+  if (mTxw)
+    mTxw->SetLabel((string)buff);
+  if (mTrlb)
+    mTrlb->SetLabel((string)buff);
   return(true);
 
@@ -595,5 +632,5 @@
   SelGOMode(PI_GOXOR);
   SelLine(PI_ThinLine);
-  Send(PIMsg_ActiveWdg);
+  Send(Msg(), PIMsg_Active);
 }
 
Index: /trunk/SophyaPI/PI/piscdrawwdg.h
===================================================================
--- /trunk/SophyaPI/PI/piscdrawwdg.h	(revision 22)
+++ /trunk/SophyaPI/PI/piscdrawwdg.h	(revision 23)
@@ -6,4 +6,5 @@
 #include PIBWDG_H
 #include PISTDWDG_H
+#include PIWIN_H
 
 #include <list.h>
@@ -68,5 +69,5 @@
   virtual void       SetAxesFlags(int flags=kAxesDflt);
   
-  void   SetTextWin(PILabel * tw) {mTxw = tw; }
+  void               SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30);
 
   double XMin() const {return xMin;}
@@ -111,4 +112,6 @@
   PILineAtt cLatt;
   PILabel * mTxw;  
+  PILabel * mTrlb;
+  PIWindow * mTrW;
   bool clip;
   bool padsup;
Index: /trunk/SophyaPI/PI/pistatmon.cc
===================================================================
--- /trunk/SophyaPI/PI/pistatmon.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pistatmon.cc	(revision 23)
@@ -69,6 +69,7 @@
 }
 
-void PIStatWin::Process(long msg, PIMsgHandler *, void *)
-{
+void PIStatWin::Process(PIMessage msg, PIMsgHandler *, void *)
+{
+  msg = UserMsg(msg);  // Reza 17/10/96 $CHECK$
   switch (msg) {
   case 1010:
Index: /trunk/SophyaPI/PI/pistatmon.h
===================================================================
--- /trunk/SophyaPI/PI/pistatmon.h	(revision 22)
+++ /trunk/SophyaPI/PI/pistatmon.h	(revision 23)
@@ -19,5 +19,5 @@
 			       int sx, int sy, int px, int py);
   virtual            ~PIStatWin();
-  virtual void       Process(long msg, PIMsgHandler *sender, void *data);
+  virtual void       Process(PIMessage msg, PIMsgHandler *sender, void *data);
   void               UpdateInfo(LImageInfo linfoR, LImageInfo linfoB, 
 				string var);
Index: /trunk/SophyaPI/PI/pistdwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/pistdwdggen.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdggen.cc	(revision 23)
@@ -14,10 +14,9 @@
 /************* PIButtonGen ************/
 
-PIButtonGen::PIButtonGen(PIContainerGen *par, char *nom, long msg,
+PIButtonGen::PIButtonGen(PIContainerGen *par, char *nom, PIMessage msg,
                          int sx, int sy, int px, int py, PIBtnSign bsgn)
 : PIWdg(par, nom, sx, sy, px, py)
 {
 SetMsg(msg);
-mPressMsg = 0;
 mSgn = bsgn;
 }
@@ -26,12 +25,8 @@
 {}
 
-void PIButtonGen::SetPressMsg(long prmsg)
-{
-mPressMsg = prmsg;
-}
 
 /************* PIScaleGen ************/
 
-PIScaleGen::PIScaleGen(PIContainerGen *par, char *nom, long msg, 
+PIScaleGen::PIScaleGen(PIContainerGen *par, char *nom, PIMessage msg, 
                        int /*min*/, int /*max*/, int sx, int sy, int px, int py)
 : PIWdg(par, nom, sx, sy, px, py) 
@@ -58,5 +53,5 @@
 /************* PICheckBoxGen ************/
 
-PICheckBoxGen::PICheckBoxGen(PIContainerGen *par, char *nom, long msg,
+PICheckBoxGen::PICheckBoxGen(PIContainerGen *par, char *nom, PIMessage msg,
                          int sx, int sy, int px, int py)
 : PIWdg(par, nom, sx, sy, px, py)
Index: /trunk/SophyaPI/PI/pistdwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/pistdwdggen.h	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdggen.h	(revision 23)
@@ -26,5 +26,6 @@
   enum {ClassId = 1010};
 
-                     PIButtonGen(PIContainerGen* par, char* nom, long msg = PIMsg_Click,
+                     PIButtonGen(PIContainerGen* par, char* nom, 
+                                 PIMessage msg = PIMsg_Click,
                                  int sx=10, int sy=10, int px=0, int py=0,
                                  PIBtnSign bsgn = PIBtn_Label);
@@ -33,9 +34,7 @@
   virtual long       kind() {return ClassId; }
 
-  virtual void       SetPressMsg(long prmsg);
-  inline long        PressMsg() { return(mPressMsg); }  
+  virtual void       ActivatePress(bool acp=false)=0;
 
 protected:
-  long mPressMsg;
   PIBtnSign mSgn;
 };
@@ -54,4 +53,7 @@
   virtual string     GetText() const = 0;
 
+  virtual void       SetMutiLineMode(bool mlm=false) = 0;
+  virtual void       SetTextEditable(bool te=true) = 0;
+
   virtual long       kind() {return ClassId; }
 };
@@ -63,5 +65,6 @@
   enum {ClassId = 1030};
 
-                     PIScaleGen(PIContainerGen* par, char* nom, long msg = PIMsg_Click,
+                     PIScaleGen(PIContainerGen* par, char* nom, 
+                     PIMessage msg = PIMsg_Click,
                      int min=0, int max=10, int sx=100, int sy=10, int px=0, int py=0);
   ~PIScaleGen();
@@ -85,5 +88,5 @@
 
                      PICheckBoxGen(PIContainerGen* par, char* nom, 
-                                   long msg = PIMsg_Click,
+                                   PIMessage msg = PIMsg_Click,
                                    int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PICheckBoxGen()=0;
Index: /trunk/SophyaPI/PI/pistdwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgmac.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdgmac.cc	(revision 23)
@@ -22,5 +22,5 @@
 #include <LStdControl.h>
 
-PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, long msg,
+PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg,
                          int sx, int sy, int px, int py, PIBtnSign bsgn)
 : PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
@@ -39,5 +39,5 @@
 {
   if (inMessage == msg_Click)
-    Send(myMsg);
+    Send(myMsg, PIMsg_Press);
 }
 
@@ -77,5 +77,5 @@
 
 
-PIScaleMac::PIScaleMac(PIContainerGen* par, char* nom, long msg,
+PIScaleMac::PIScaleMac(PIContainerGen* par, char* nom, PIMessage msg,
                        int min, int max, int sx, int sy, int px, int py)
 : PIScaleGen(par, nom, msg, min, max, sx, sy, px, py)
@@ -100,5 +100,5 @@
 {
   if (inMessage == msg_ThumbDragged)
-    Send(myMsg);
+    Send(myMsg, PIMsg_DataChanged);
 }
 
@@ -166,5 +166,5 @@
 #include <LStdControl.h>
 
-PICheckBoxMac::PICheckBoxMac(PIContainerGen *par, char *nom, long msg,
+PICheckBoxMac::PICheckBoxMac(PIContainerGen *par, char *nom, PIMessage msg,
                          int sx, int sy, int px, int py)
 : PICheckBoxGen(par, nom, msg, sx, sy, px, py)
@@ -183,5 +183,5 @@
 {
   if (inMessage == msg_Click)
-    Send(myMsg);
+    Send(myMsg, PIMsg_DataChanged);
 }
 
Index: /trunk/SophyaPI/PI/pistdwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgmac.h	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdgmac.h	(revision 23)
@@ -16,5 +16,5 @@
 {
 public:
-                     PIButtonMac(PIContainerGen *par, char *nom, long msg = PIMsg_Click,
+                     PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg = PIMsg_Click,
                                  int sx=10, int sy=10, int px=0, int py=0,
                                  PIBtnSign bsgn = PIBtn_Label);
@@ -36,5 +36,5 @@
 {
 public:
-                     PIScaleMac(PIContainerGen* par, char* nom, long msg=PIMsg_Click,
+                     PIScaleMac(PIContainerGen* par, char* nom, PIMessage msg=PIMsg_Click,
                                 int min=0, int max=10, int sx=100, int sy=10, int px=0, int py=0);
                     ~PIScaleMac();
@@ -55,5 +55,5 @@
 public:
                      PICheckBoxMac(PIContainerGen* par, char* nom, 
-                                   long msg = PIMsg_Click,
+                                   PIMessage msg = PIMsg_Click,
                                    int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PICheckBoxMac();
Index: /trunk/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdgx.cc	(revision 23)
@@ -37,18 +37,18 @@
 
 /* Nouvelle-Fonction */
-void  button_action(Widget w, XtPointer *usd, XtPointer *calld)
+void  button_action(Widget , XtPointer *usd, XtPointer *)
 {
 PIButtonX *pib;
 pib = (PIButtonX *) usd ;
-pib->Send(pib->Msg());
+pib->Send(pib->Msg(),PIMsg_Click,NULL);
 return;
 }
 
 /* Nouvelle-Fonction */
-void  button_press(Widget w, XtPointer *usd, XmAnyCallbackStruct *calld)
+void  button_press(Widget, XtPointer *usd, XmAnyCallbackStruct *calld)
 {
 PIButtonX *pib;
 pib = (PIButtonX *) usd ;
-pib->Send(pib->PressMsg());
+pib->Send(pib->Msg(),PIMsg_Press,NULL);
 pib->myevt = *(calld->event);
 pib->myevt.type = pib->myevt.xbutton.type = ButtonRelease;
@@ -60,5 +60,5 @@
 
 /* --Methode-- */
-PIButtonX::PIButtonX(PIContainerGen *par, char *nom, long msg, 
+PIButtonX::PIButtonX(PIContainerGen *par, char *nom, PIMessage msg, 
                      int sx, int sy, int px, int py, PIBtnSign bsgn)
 : PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
@@ -96,4 +96,6 @@
 XtAddCallback(XtWdg(), XmNactivateCallback, 
               button_action, (XtPointer)this);
+
+mAcP = false;
 SetBorderWidth(0);
 Manage();
@@ -105,17 +107,15 @@
 
 /* --Methode-- */
-void PIButtonX::SetPressMsg(long prmsg)
-{
-if (PressMsg() == prmsg)  return; 
+void PIButtonX::ActivatePress(bool acp)
+{
+if (mAcP == acp)  return; 
     
-if ((PressMsg() != 0)  && (prmsg == 0) )   
+if (mAcP)
   XtRemoveCallback(XtWdg(), XmNarmCallback, 
                    button_press, (XtPointer)this);
-else if (PressMsg() == 0)
+else 
   XtAddCallback(XtWdg(), XmNarmCallback, 
                 button_press, (XtPointer)this);
-
-PIButtonGen::SetPressMsg(prmsg);
-
+mAcP = acp;
 return;
 }       
@@ -138,4 +138,6 @@
 {
 CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
+SetMutiLineMode(false);
+SetTextEditable(true);
 Manage();
 }
@@ -162,4 +164,60 @@
 }
 
+/* --Methode-- */
+void PITextX::SetMutiLineMode(bool mlm)
+{
+Arg  warg[2];
+int n = 0;
+
+if (mlm)
+  { XtSetArg(warg[n],XmNeditMode, XmMULTI_LINE_EDIT);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditMode, XmSINGLE_LINE_EDIT);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+/* --Methode-- */
+void PITextX::SetTextEditable(bool te)
+{
+Arg  warg[2];
+int n = 0;
+
+if (te)
+  { XtSetArg(warg[n],XmNeditable, TRUE);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditable, FALSE);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+// Fonction privee (CallBack)
+static void text_action(Widget w, XtPointer *usd, XtPointer *calld);
+
+void  text_action(Widget, XtPointer *usd, XtPointer *)
+{
+PIText *pit;
+
+pit = (PIText *) usd ;
+pit->Send(pit->Msg(), PIMsg_DataChanged, NULL);
+}
+
+
+/* --Methode-- */
+void PITextX::SetMsg(PIMessage msg)
+{
+
+if (Msg() && !msg)
+  XtRemoveCallback(XtWdg(), XmNactivateCallback, 
+                   text_action, (XtPointer)this);
+if (!Msg() && msg)
+  XtAddCallback(XtWdg(), XmNactivateCallback, 
+                text_action, (XtPointer)this);
+
+PIWdg::SetMsg(msg);
+}
+
 
 /************* PIScaleX ************/
@@ -167,18 +225,20 @@
 
 // Fonction prive (CallBack)
-static void scale_action(Widget w, XtPointer *usd, XtPointer *calld);
-
-void  scale_action(Widget w, XtPointer *usd, XtPointer *calld)
+static void scale_action(Widget w, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld);
+
+void  scale_action(Widget, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld)
 {
 PIScale *pis;
 
 pis = (PIScale *) usd ;
-pis->Send(pis->Msg(), (void *)pis->GetValue());
-
-return;
-}
-
-/* --Methode-- */
-PIScaleX::PIScaleX(PIContainerGen *par, char *nom, long msg,
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)calld->value);
+return;
+}
+
+/* --Methode-- */
+PIScaleX::PIScaleX(PIContainerGen *par, char *nom, PIMessage msg,
                    int min, int max, int sx, int sy, int px, int py)
 : PIScaleGen(par, nom, msg, min, max, sx, sy, px, py)
@@ -188,11 +248,21 @@
 CreateXtWdg(nom, xmScaleWidgetClass, NULL, sx, sy, px, py);
 XtSetArg(warg[n], XmNshowValue, TRUE); n++;
-XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+if (sx > sy)
+  {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else
+  { 
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
 XtSetArg(warg[n], XmNscaleWidth, sx); n++;
 XtSetArg(warg[n], XmNscaleHeight, sy); n++;
 XtSetArg(warg[n], XmNstringDirection, XmSTRING_DIRECTION_R_TO_L); n++;
-XtSetArg(warg[n], XmRProcessingDirection, XmMAX_ON_RIGHT); n++;
+
 XtSetValues(XtWdg(), warg, n);
 SetMinMax(min, max);
+SetValue(min);
 XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
               scale_action, (XtPointer)this);
@@ -207,9 +277,14 @@
 void PIScaleX::SetMinMax(int min, int max)
 {
+if (min >= max)  max = min+10;
+if (mVal < min)  mVal = min;
+if (mVal > max)  mVal = max;
 int n=0;
-Arg warg[2];
+Arg warg[3];
 XtSetArg(warg[n], XmNminimum, min); n++;
 XtSetArg(warg[n], XmNmaximum, max); n++;
-XtSetValues(XtWdg(), warg, n);
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
 return;
 }
@@ -220,4 +295,6 @@
 {
 int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax)  val = mMax;
 Arg warg[2];
 XtSetArg(warg[n], XmNvalue, val); n++;
@@ -234,7 +311,14 @@
 XtSetArg(warg[n], XmNvalue, &val); n++;
 XtGetValues(this->sdw, warg, n);
+mVal = val;
 return(val);
 }
 
+/* --Methode-- */
+void  PIScaleX::CBSetVal(int val)
+{
+mVal = val;
+return;
+}
 
 /************* PICheckBoxX ************/
@@ -245,14 +329,14 @@
 
 /* Nouvelle-Fonction */
-void  toggb_action(Widget w, XtPointer *usd, XtPointer *calld)
+void  toggb_action(Widget , XtPointer *usd, XtPointer *)
 {
 PICheckBoxX *picb;
 picb = (PICheckBoxX *) usd ;
-picb->Send(picb->Msg(), (void *)picb->GetState());
-return;
-}
-
-/* --Methode-- */
-PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, long msg,
+picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)picb->GetState());
+return;
+}
+
+/* --Methode-- */
+PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, PIMessage msg,
                          int sx, int sy, int px, int py)
 : PICheckBoxGen(par, nom, msg, sx, sy, px, py)
Index: /trunk/SophyaPI/PI/pistdwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgx.h	(revision 22)
+++ /trunk/SophyaPI/PI/pistdwdgx.h	(revision 23)
@@ -17,15 +17,20 @@
 {
 public:
-                     PIButtonX(PIContainerGen *par, char *nom, long msg = PIMsg_Click,
+                     PIButtonX(PIContainerGen *par, char *nom, 
+                               PIMessage msg = PIMsg_Click,
                                int sx=10, int sy=10, int px=0, int py=0,
                                PIBtnSign bsgn = PIBtn_Label);
   virtual           ~PIButtonX();
 
-  virtual void       SetPressMsg(long prmsg);
+  virtual void       ActivatePress(bool acp=false);
 
   void               ReleaseButton();   // Fonction a utiliser avec attention
 
   XEvent myevt;   // Attention - Pour usage interne 
+
+protected :
+  bool mAcP;
 };
+
 
 class PITextX : public PITextGen
@@ -37,4 +42,9 @@
   virtual void       SetText(string const&);
   virtual string     GetText() const;
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetMsg(PIMessage msg=0);
 };
 
@@ -42,5 +52,5 @@
 {
 public:
-  PIScaleX(PIContainerGen* par, char* nom, long msg=PIMsg_Click,
+  PIScaleX(PIContainerGen* par, char* nom, PIMessage msg=PIMsg_Click,
          int min=0, int max=10, int sx=100, int sy=10, int px=0, int py=0);
   ~PIScaleX();
@@ -48,7 +58,9 @@
   virtual void SetMinMax(int min, int max);
   virtual void SetValue(int val);
-  virtual int GetValue(); 
+  virtual int  GetValue(); 
 
+  virtual void CBSetVal(int val);   // A ne pas utiliser pour Callback
 protected: 
+  int mVal, mMin, mMax;
 };
 
@@ -58,5 +70,5 @@
 public:
                      PICheckBoxX(PIContainerGen *par, char *nom, 
-                                 long msg=PIMsg_Click,
+                                 PIMessage msg=PIMsg_Click,
                                  int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PICheckBoxX();
Index: /trunk/SophyaPI/PI/pitestapp.cc
===================================================================
--- /trunk/SophyaPI/PI/pitestapp.cc	(revision 22)
+++ /trunk/SophyaPI/PI/pitestapp.cc	(revision 23)
@@ -20,5 +20,5 @@
 #include "piimage.h"
 
-RzImage * RzReadFits(char *flnm);
+#include "fitsimage.h"
 
 int SysBeep(int n)
@@ -48,5 +48,5 @@
 	~PITestApp();
 
-	virtual void	Process(long msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
 //    PIMenubar * menb;
@@ -116,4 +116,5 @@
   ckb = new PICheckBox(this->MainWin(), "CheckBox", 166, 60, 20, 10, 10);
   text = new PIText(this->MainWin(), "TEXTE", 100, 30, 20,40);
+  text->SetMsg(7440);
   label  = new PILabel(this->MainWin(), "Label", 140, 20, 20,80);
   label->SetBorderWidth(1);
@@ -186,5 +187,6 @@
 static PIWindow *imgw[5];
 static PIImage *cur=NULL;
-static ScSample *scs1, *scs2;
+static ScSample *scs1, *scs2, *scs3;
+static ExBWdg *exb1;
 
 static PIWindow * wp3, *wp2, *wp4, *wp5;
@@ -197,5 +199,5 @@
 
 void
-PITestApp::Process(long msg, PIMsgHandler* sender, void* data)
+PITestApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
   static int x = 0;
@@ -203,12 +205,22 @@
 
 //   SysBeep(1);
-  char truc[100];
+  char truc[256];
   sprintf(truc,"< %ld - %d (%d)>",msg,x++, (int)((PIWdgGen *)sender)->kind());
   this->label->SetLabel(truc);
-
-  if (msg == PIMsg_ActiveWdg) 
-    { /* printf("Process: Setting active ImageWindow (%lx) \n", (long)data); */
-    cur = (PIImage *)data; }
-
+  sprintf(truc,"[%d] Msg= %ld (%d-%d) Kind=(%d)",x, msg, (int)UserMsg(msg),
+         (int)ModMsg(msg), (int)((PIWdgGen *)sender)->kind());
+  puts(truc);
+
+  if (ModMsg(msg) == PIMsg_Active) 
+    {  printf("Process: Setting active ImageWindow (%lx) \n", (long)sender); 
+    cur = (PIImage *)data; return;}
+
+  if (ModMsg(msg) == PIMsg_Close)
+    {
+    printf("Close Message received (Sender= %lx)\n", (long)sender);
+    return;
+    }
+
+  msg = UserMsg(msg);
   if (msg == 33) ckb->SetState(true);
     
@@ -278,5 +290,5 @@
                                   PIWK_normal, 400, 400, 500, 500);
         pimg[nimg] = new PIImage(imgw[nimg], "MyImage", 400, 400, 0, 0);
-        pimg[nimg]->SetBinding(true, true, true, true);
+        pimg[nimg]->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed );
         pimg[nimg]->SetZoomWin(zoom);
         pimg[nimg]->SetTextWin(labimg);
@@ -301,28 +313,44 @@
   wp2 = new PIWindow(app, "Window-2", PIWK_normal,  150, 150, 250, 250);
   ExBWdg bw(wp2, "BWdg", 150, 150, 0, 0);
-//  bw.SetBinding(false, true, true, false);
 //  bw.ActivateButton(1);
 //  bw.ActivatePtrCross();
 //  bw.ActivateKeyboard();
 
-  wp4 = new PIWindow(app, "Window-4", PIWK_dialog,  120, 120, 350, 350);
-  PIButton bt1(wp4, "OK", 6001, 40, 20, 10, 80);
-  PIButton bt2(wp4, "Cancel", 6002, 40, 20, 60, 80);
-  PILabel  lb1(wp4, "Mat_00", 30, 20, 10, 10);
-  PIText  tx1(wp4, "A00", 50, 20, 50, 10);  
-  PILabel  lb2(wp4, "Mat_11", 30, 20, 10, 40);
-  PIText  tx2(wp4, "A11", 50, 20, 50, 40);  
+
+  wp4 = new PIWindow(app, "Window-4", PIWK_dialog,  200, 200, 350, 350);
+  PIButton bt1(wp4, "OK", 6001, 60, 30, 20, 160);
+  PIButton bt2(wp4, "Cancel", 6002, 60, 30, 100, 160);
+  bt1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  bt2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PILabel  lb1(wp4, "Editable", 40, 30, 10, 10);
+    lb1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PIText  tx1(wp4, "A00", 100, 30, 60, 10);  
+    tx1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  tx1.SetText("Hello");
+  tx1.SetTextEditable(false);
+  //  PILabel  lb2(wp4, "", 30, 20, 10, 40);
+  PIText  tx2(wp4, "A11", 180, 100, 15, 50);
+  tx2.SetMutiLineMode(true);
+  tx2.SetText(" Bonjour, \n Comment ca va ? \n A demain. ");
+    tx2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
 
   wp3 = new PIWindow(app, "Window-3", PIWK_normal, 200, 200, 350, 350);
   pxm = new PIPixmap(wp3, "myPixmap", 150, 150, 10, 10);
-  pxm->SetBinding(true, true, true, true);
+  pxm->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed );
   pxm->SetPixmap(pixels, 150, 150);
 
-  wp5 = new PIWindow(app, "Window-5", PIWK_normal,  400, 200, 200, 200);
+  wp5 = new PIWindow(app, "Window-5", PIWK_normal,  400, 450, 200, 200);
   scs1 = new ScSample(wp5, "ScSample", 200, 200, 0, 0);
-  scs1->SetBinding(true, true, true, true);
-  scs2 = new ScSample(wp5, "ScSample", 200, 200, 200, 0);
-  scs2->SetBinding(true, true, true, true);
-
+  scs1->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  scs2 = new ScSample(wp5, "ScSample", 160, 160, 220, 20);
+  scs2->SetBinding(PIBK_elastic,PIBK_fixed,PIBK_fixed,PIBK_elastic);
+
+  scs3 = new ScSample(wp5, "ScSample", 200, 200, 100, 220);
+
+  scs3->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  /*  
+  exb1 = new ExBWdg(wp5, "ExB1", 200, 200, 100, 220);
+  exb1->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  */
   //  wp4 = new PIWindow(app, "Open...", PIWK_dialog, 300, 300, 400, 400);
 
Index: /trunk/SophyaPI/PI/piwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piwdggen.cc	(revision 23)
@@ -23,4 +23,25 @@
 }
 
+/* --Methode-- */
+void PIWdgGen::SetMsg(PIMessage msg)
+{
+myMsg = msg;
+}
+
+/* --Methode-- */
+void PIWdgGen::GetScreenPos(int & spx, int & spy)
+/*  Renvoie la position de la fenetre par rapport a l'ecran */
+{
+PIWdgGen * wc;
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc) 
+  { spx += wc->XPos();  
+  spy += wc->YPos();  wc = wc->Parent();
+  }
+return;
+}
+
 
 /* --Methode-- 
Index: /trunk/SophyaPI/PI/piwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.h	(revision 22)
+++ /trunk/SophyaPI/PI/piwdggen.h	(revision 23)
@@ -12,4 +12,12 @@
 void PIBeep();
 
+// Les differents types d'accrochage aux containers  
+
+enum PIBindingKind {    
+  PIBK_free = 0,
+  PIBK_fixed = 1,
+  PIBK_elastic = 2
+};
+
 class PIContainerGen;
 class PIWdgGen : public PIMsgHandler
@@ -24,6 +32,7 @@
 
   virtual long           kind() {return ClassId; }
+//  string               kindstr();
 
-//  string               kindstr();
+  inline PIWdgGen*       Parent() { return( (PIWdgGen*)parent ); }
 
   inline void         	 SetUserData( void * p, int fg = 0) {pdata=p; flag=fg; }
@@ -32,6 +41,7 @@
   inline int         	 UserFlag() { return(flag); };
 
-  inline void            SetMsg(long msg = 0) { myMsg = msg; }
-  inline long            Msg() { return(myMsg); }
+
+  virtual void           SetMsg(PIMessage msg = 0);
+  inline  PIMessage      Msg() { return (myMsg); }
 
   virtual void           SetSize(int sx, int sy)=0;
@@ -39,5 +49,6 @@
   virtual void           SetBorderWidth(int bw)=0;
   virtual void           SetLabel(string const&) {}
-  virtual void           SetBinding(bool left, bool top, bool right, bool bottom)=0;
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom)=0;
 
   virtual int            XSize()=0;
@@ -47,8 +58,9 @@
 
   virtual string         Nom()=0;
+  virtual void           GetScreenPos(int & spx, int & spy);
 
 protected:
   PIContainerGen        *parent;
-  long                  myMsg;
+  PIMessage              myMsg;
 
 private:
Index: /trunk/SophyaPI/PI/piwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piwdgmac.cc	(revision 23)
@@ -81,5 +81,7 @@
 
 void
-PIWdgMac::SetBinding(bool left, bool top, bool right, bool bottom)
+PIWdgMac::SetBinding(PIBindingKind left, PIBindingKind top, 
+                     PIBindingKind right, PIBindingKind bottom)
+//  $CHECK$ Reza 13/10/96    Code a modifier
 {
   SBooleanRect r;
Index: /trunk/SophyaPI/PI/piwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.h	(revision 22)
+++ /trunk/SophyaPI/PI/piwdgmac.h	(revision 23)
@@ -20,5 +20,6 @@
   virtual void           SetPos(int px, int py);
   virtual void           SetBorderWidth(int /*bw*/) {}
-  virtual void           SetBinding(bool left, bool top, bool right, bool bottom);
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
   virtual int            XSize();
   virtual int            YSize();
Index: /trunk/SophyaPI/PI/piwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piwdgx.cc	(revision 23)
@@ -117,5 +117,5 @@
 #endif
 
-SetBinding(false, false, false, false);
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
 return(0);
 }
@@ -210,5 +210,6 @@
 
 /* --Methode-- */
-void PIWdgX::SetBinding(bool left, bool top, bool right, bool bottom)
+void PIWdgX::SetBinding(PIBindingKind left, PIBindingKind top, 
+                        PIBindingKind right, PIBindingKind bottom)
 {
 Arg  wargs[3];
@@ -217,73 +218,92 @@
 if (!parent)  return;
 
-if (left) 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_FORM);  n++;
-  XtSetArg(wargs[n],XmNleftOffset, XPos() );  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }
-else 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }  
-
-if (top)
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_FORM);  n++;
-  XtSetArg(wargs[n],XmNtopOffset, YPos() );  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }
-else 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
-  XtSetValues(this->sdw, wargs, n);
+/*
+n = 0;
+XtSetArg(wargs[n],XmNfractionBase, 500);  n++;
+XtSetValues(this->sdw, wargs, n);
+*/
+switch (left)
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNleftOffset, XPos() );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNleftPosition, (XPos()*100/parent->XSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+
+switch (top)
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNtopOffset, YPos() );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNtopPosition, (YPos()*100/parent->YSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
   }
   
-if (right) 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
-  XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }
-else 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }  
-
-if (right) 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
-  XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }
-else 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }  
-
-if (bottom) 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_FORM);  n++;
-  XtSetArg(wargs[n],XmNbottomOffset, parent->YSize()-(YSize()+YPos()) );  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }
-else 
-  {
-  n = 0;
-  XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
-  XtSetValues(this->sdw, wargs, n);
-  }  
+switch (right) 
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNrightPosition, ((XPos()+XSize())*100/parent->XSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+
+switch (bottom) 
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNbottomOffset, parent->YSize()-(YSize()+YPos()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNbottomPosition, ((YPos()+YSize())*100/parent->YSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
 
 return;
@@ -359,4 +379,43 @@
 return(bw);
 }
+
+/* --Methode-- */
+void PIWdgX::GetScreenPos(int & spx, int & spy)
+{
+PIWdgX * wc;
+Display *mdsp;
+Window w, rw, pw, *cw;
+unsigned int ncw;
+Status st;
+int x,y;
+unsigned int bw, l, h, d;
+
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc)
+  { spx += wc->XPos();
+  spy += wc->YPos();  wc = (PIWdgX *)wc->Parent();
+  }
+
+mdsp = XtDisplay(XtWdg());
+w = XtWindow(XtWdg());
+ncw = 0;
+st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw);
+if (st) 
+  { XFree(cw);
+  if (pw == rw)  return; }
+
+while (st && (pw != rw))  
+  {
+  w = pw;
+  st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw); 
+  if (st)   XFree(cw);
+  XGetGeometry(mdsp, w, &rw, &x, &y, &l, &h, &bw, &d);  
+  spy += y;  spx += x;
+  }  
+return;
+}
+
 
 
Index: /trunk/SophyaPI/PI/piwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.h	(revision 22)
+++ /trunk/SophyaPI/PI/piwdgx.h	(revision 23)
@@ -41,5 +41,6 @@
   virtual void   SetBorderWidth(int bw);
   virtual void   SetLabel(string const & lab);
-  virtual void   SetBinding(bool left, bool top, bool right, bool bottom);
+  virtual void   SetBinding(PIBindingKind left, PIBindingKind top, 
+                            PIBindingKind right, PIBindingKind bottom);
 
   virtual int    XSize();
@@ -50,4 +51,5 @@
 
   virtual string Nom()  { return mNom; }
+  virtual void   GetScreenPos(int & spx, int & spy);
 
   void Manage();
Index: /trunk/SophyaPI/PI/piwindowgen.cc
===================================================================
--- /trunk/SophyaPI/PI/piwindowgen.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piwindowgen.cc	(revision 23)
@@ -17,10 +17,15 @@
 
 /* --Methode-- */
-void PIWindowGen::Process(long msg, PIMsgHandler* sender, void* data)
-/*  On intercepte le message ActiveWdg, avant de le renvoyer, */
-/*  avec un message ActiveWdg de la part de la fenetre        */
+void PIWindowGen::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+/*  On intercepte le message Active, et Close avant de les renvoyer */
+/*  avec un message ActiveWdg de la part de la fenetre              */
 {
-if (msg == PIMsg_ActiveWdg)
-  Send(msg);
+
+if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this)) 
+  Hide();   // Action par defaut en cas de MsgClose.
+
+if (ModMsg(msg) == PIMsg_Active)
+  Send(Msg(),PIMsg_Active);
+
 ReSend(msg, sender, data);
 return;  
Index: /trunk/SophyaPI/PI/piwindowgen.h
===================================================================
--- /trunk/SophyaPI/PI/piwindowgen.h	(revision 22)
+++ /trunk/SophyaPI/PI/piwindowgen.h	(revision 23)
@@ -9,5 +9,6 @@
   PIWK_normal = 0,
   PIWK_dialog = 1,
-  PIWK_floating = 2
+  PIWK_transient = 2,
+  PIWK_floating = 3
 };
 
@@ -21,5 +22,5 @@
   virtual long      kind() {return ClassId; }
 
-  virtual void      Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
   
 protected:  
Index: /trunk/SophyaPI/PI/piwindowx.cc
===================================================================
--- /trunk/SophyaPI/PI/piwindowx.cc	(revision 22)
+++ /trunk/SophyaPI/PI/piwindowx.cc	(revision 23)
@@ -2,4 +2,6 @@
 
 #include "piwindowx.h"
+
+#include <X11/Xlib.h>
 
 #include <X11/Intrinsic.h>
@@ -8,5 +10,24 @@
 #include <X11/Shell.h>
 #include <Xm/Form.h>
-// #include <Xm/BulletinB.h>
+
+/* Fonctions (Callback et action) pour traiter le message Close de WM  */
+
+/* Nouvelle-Fonction */
+static void popdwn_cb(Widget /*w*/, XtPointer *usd,  XtPointer * )
+{
+PIWindowX * dw = (PIWindowX *) usd;
+dw->Process(dw->BuildMsg(dw->Msg(),PIMsg_Close), dw, NULL) ;
+}
+
+
+/* Nouvelle-Fonction */
+static int fgactl = 0;
+
+static void CloseWindow (Widget w, XEvent*, String*,Cardinal*)
+{
+XtCallCallbacks(w,  XtNpopdownCallback, NULL);
+}
+
+
 
 /* --Methode-- */
@@ -15,11 +36,56 @@
 : PIWindowGen(par, nom, k, -1, -1, 0, 0)
 {
+XtTranslations trans;
+
 pwm = new PIWdgX(NULL, nom, sx, sy, px, py);
 
-if (k == PIWK_normal )
-  pwm->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, sx, sy, px, py);
-else 
-  pwm->CreateXtWdg(nom, transientShellWidgetClass, NULL, sx, sy, px, py);
-//  pwm->CreateXtWdg(nom, overrideShellWidgetClass, NULL, sx, sy, px, py);
+switch (k)
+  {
+  case PIWK_normal :
+  case PIWK_floating :
+    pwm->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_dialog :
+    pwm->CreateXtWdg(nom, transientShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_transient :
+    pwm->CreateXtWdg(nom, overrideShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  }
+
+
+/*  Il faut "attraper" l'action close, genere par le window-manager       */
+/*  2 actions sont necessaires, installation d'une action (CloseWindow()) */
+/*  et j'utilise ensuite un callback ds CloseWindow()                     */
+/*  Il faut aussi desactiver l'action de destruction du widget par defaut */
+/*  (XtSetArg(warg, XmNdeleteResponse, ...                                */
+/*  Attention, voir la fonction Show(), pour l'appel a XSetWMProptocols() */
+/*  Pour une fenetre donnee, on peut recuperer les Map, UnMap, Destroy,   */
+/*  etc... il faut appeler XtAddEventHandler( w, Mask, ...)               */
+/*    Mask =  StructureNotifyMask | SubstructureNotifyMask                */
+
+
+
+if ((k == PIWK_normal) || (k == PIWK_floating) || (k == PIWK_dialog))
+  { 
+
+  /* XtAddEventHandler(pwm->XtWdg(), StructureNotifyMask | SubstructureNotifyMask, 
+                  FALSE, wmaction_evthandler, this);*/
+
+  XtAddCallback(pwm->XtWdg(), XtNpopdownCallback,
+                popdwn_cb, (XtPointer)this);
+
+  if (!fgactl) 
+    { 
+    XtActionsRec desact = {"CloseWindow" ,CloseWindow};
+    XtAddActions(&desact, 1);  fgactl = 1; 
+    }
+
+  trans = XtParseTranslationTable("<Message>WM_PROTOCOLS:CloseWindow()");
+  XtOverrideTranslations(pwm->XtWdg() , trans);
+  Arg warg[2];
+  XtSetArg(warg[0], XmNdeleteResponse, XmDO_NOTHING);
+  XtSetValues(pwm->XtWdg(), warg, 1);
+  }
 
 CreateXtWdg(nom, xmFormWidgetClass, pwm->XtWdg(), sx, sy, 0, 0);
@@ -31,6 +97,8 @@
 delete pwm;
 }
+
 /* --Methode-- */
-void PIWindowX::SetBinding(bool left, bool top, bool right, bool bottom)
+void PIWindowX::SetBinding(PIBindingKind /*left*/, PIBindingKind /*top*/, 
+                           PIBindingKind /*right*/, PIBindingKind /*bottom*/)
 {
 // On ne doit rien faire pour les fenetres 
@@ -56,7 +124,30 @@
 void PIWindowX::Show()
 {
+int fgr = 0;
+Display *mdsp;
+
+mdsp = XtDisplay(pwm->XtWdg());
+
 PIContainerGen::Show();
 Manage();
+if (!XtIsRealized(pwm->XtWdg()))  fgr = 1;
 pwm->Manage();
+if (fgr) 
+  {
+  Atom wmd;
+  if ((mWtyp == PIWK_normal) || (mWtyp == PIWK_floating) || (mWtyp == PIWK_dialog))
+    { 
+    wmd = XInternAtom(mdsp, "WM_DELETE_WINDOW",False);
+    XSetWMProtocols(mdsp, XtWindow(pwm->XtWdg()), &wmd, 1);
+    }
+  else 
+    XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg()));
+  }
+
+// XRaiseWindow est necessaire, sinon la fenetre passe des fois derriere ...
+if (mWtyp == PIWK_transient)  
+  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
+ 
+return;
 }
 
Index: /trunk/SophyaPI/PI/piwindowx.h
===================================================================
--- /trunk/SophyaPI/PI/piwindowx.h	(revision 22)
+++ /trunk/SophyaPI/PI/piwindowx.h	(revision 23)
@@ -12,6 +12,6 @@
   virtual                ~PIWindowX();
   
-  virtual void           SetBinding(bool left, bool top, bool right, bool bottom);
-
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
   virtual void           SetSize(int sx, int sy);
   virtual void           SetPos(int px, int py);  
