Index: /trunk/SophyaPI/PI/Makefile
===================================================================
--- /trunk/SophyaPI/PI/Makefile	(revision 5)
+++ /trunk/SophyaPI/PI/Makefile	(revision 6)
@@ -85,5 +85,5 @@
 
 $(EXE)pitest : $(OBJ)pitestapp.o
-	g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lXm -lXt -lX11
+	g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm
 
 $(OBJ)ex_dessin.o: ex_dessin.cc ex_dessin.h pisysdep.h pibwdgx.h pibwdggen.h \
@@ -166,3 +166,3 @@
  piwindowgen.h pioptmenux.h pioptmenugen.h pistdwdgx.h pistdwdggen.h \
  pibwdgx.h pibwdggen.h pipixmapx.h pipixmapgen.h picmap.h picmapx.h \
- picmapgen.h pifilechox.h pifilechogen.h ex_dessin.h
+ picmapgen.h pifilechox.h pifilechogen.h piimage.h ex_dessin.h
Index: /trunk/SophyaPI/PI/pi.rsc
===================================================================
--- /trunk/SophyaPI/PI/pi.rsc	(revision 5)
+++ /trunk/SophyaPI/PI/pi.rsc	(revision 6)
@@ -8,13 +8,13 @@
 PeidaInt*activeTopShadowColor:               White
 PeidaInt*default*activeTopShadowColor:       White
-PeidaInt*background:                         Grey
-PeidaInt*default*background:                 Grey
+PeidaInt*background:                         LightGrey
+PeidaInt*default*background:                 LightGrey
 PeidaInt*bottomShadowColor:                  Black
 PeidaInt*default*bottomShadowColor:          Black
-PeidaInt*Foreground:                         Yellow
-PeidaInt*default*Foreground:                 Yellow
+PeidaInt*Foreground:                         Black
+PeidaInt*default*Foreground:                 Black
 PeidaInt*topShadowColor:                     White
 PeidaInt*default*topShadowColor:             White
-PeidaInt*borderColor:                        Yellow
+PeidaInt*borderColor:                        Black
 
 PeidaInt*XmLabel.borderWidth:                1
@@ -23,6 +23,6 @@
 PeidaInt*XmPushButton*borderWidth:           0
 
-PeidaInt*XmText*XmNshadowThickness:          0
-PeidaInt*XmText*XmNhighlightThickness:          0
+PeidaInt*XmText*XmNshadowThickness:          1
+PeidaInt*XmText*XmNhighlightThickness:          2
 
 
Index: /trunk/SophyaPI/PI/piapplx.cc
===================================================================
--- /trunk/SophyaPI/PI/piapplx.cc	(revision 5)
+++ /trunk/SophyaPI/PI/piapplx.cc	(revision 6)
@@ -46,5 +46,7 @@
 #endif
 topwdg->Unmanage();
-delete topcont;
+delete menubar;
+if (topcont != MBCont())  delete topcont;
+delete intcont;
 delete topwdg;
 exit(0);
Index: /trunk/SophyaPI/PI/pibwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.h	(revision 5)
+++ /trunk/SophyaPI/PI/pibwdggen.h	(revision 6)
@@ -16,5 +16,6 @@
 enum PILineAtt { PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };
 
-enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, PI_HandPointer = 3 };
+enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, 
+                 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 };
 
 class PIBaseWdgGen : public PIWdg
Index: /trunk/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgx.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pibwdgx.cc	(revision 6)
@@ -131,5 +131,5 @@
 void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)
 {
-XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 
+XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 
                   DefGC(), x, y, s, strlen(s));
 return;
@@ -262,7 +262,7 @@
 void PIBaseWdgX::Refresh()
 {
-if ( (XtIsRealized(this->XtWdg())) &&  
+if ( (XtIsRealized(XtWdg())) &&  
    (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )        
-  { this->Draw(); }
+  { /* EraseWindow(); */ Draw(); }
 
 return;
@@ -457,5 +457,6 @@
 curs[PI_CrossPointer] =  XCreateFontCursor(mdsp, XC_crosshair);
 curs[PI_HandPointer] =  XCreateFontCursor(mdsp, XC_hand2);
-
-return;
-}
+curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
+
+return;
+}
Index: /trunk/SophyaPI/PI/pifilechox.cc
===================================================================
--- /trunk/SophyaPI/PI/pifilechox.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pifilechox.cc	(revision 6)
@@ -80,4 +80,5 @@
 PIFileChooserX::~PIFileChooserX()
 {
+delete mWin;
 }
 
Index: /trunk/SophyaPI/PI/piimage.cc
===================================================================
--- /trunk/SophyaPI/PI/piimage.cc	(revision 5)
+++ /trunk/SophyaPI/PI/piimage.cc	(revision 6)
@@ -14,5 +14,5 @@
 
 /* --Methode-- */
-PIImage::PIImage(PIContainerGen *par, char *nom, RzImage *pim,
+PIImage::PIImage(PIContainerGen *par, char *nom,
    int sx, int sy, int px, int py) :
   PIPixmap(par, nom, sx, sy, px, py)
@@ -31,9 +31,10 @@
 
 SetColMap(CMAP_COLRJ32);
-SetImage(pim);
 
 ActivateButton(1);
+ActivateMove(1);
 ActivateButton(2);
-//ActivateMove(1);
+ActivateMove(2);
+
 
 }
@@ -50,17 +51,14 @@
 void PIImage::SetImage(RzImage *pim)
 {
-int xwsz, ywsz;
-
+
+offx = offy = 0;
+xpav = ypav = 0;
 img = pim;
 if (img)
   {
   SetSize(img->XSize(), img->YSize());
-  xwsz = XSize();  ywsz = YSize();
-  if (xwsz > img->XSize()) xwsz = img->XSize();
-  if (ywsz > img->YSize()) ywsz = img->YSize();
-  xpav = xwsz/2; 
-  ypav = ywsz/2;
+  SetPave();
   if (img->minPix>img->maxPix) img->CheckDyn();
-  SetLut(img->minPix, img->maxPix, kLutType_Lin, 2);
+  SetLut(img->minPix, img->maxPix, kLutType_Lin, 1);
   }
 //printf("Debug_SetImage: %ld %ld \n", (long)img, (long)lut);
@@ -101,4 +99,5 @@
 lut = new LUT(min, max, NbCol(), typlut);
 
+Apply();
 return;
 }
@@ -111,4 +110,6 @@
 lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
 if (olut) delete olut;
+
+Apply();
 return;
 }
@@ -122,10 +123,14 @@
 else if (zm < -10) zoom = -10;
 else zoom = zm;
-return;
-}
-/* --Methode-- */
-void PIImage::SelectColor(CMapId cmap)
-{
-SetColMap(cmap);
+SetOffset();
+Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetColMap(CMapId cmap)
+{
+PIPixmap::SetColMap(cmap);
 if (zow)  zow->SetColMap(cmap);
 return;
@@ -134,11 +139,20 @@
 
 /* --Methode-- */
-void PIImage::Apply()
-{
-ComputePixmap();
-Refresh();
-if (zow == NULL)  return;
-ComputeZoomPixmap();
-zow->Refresh();
+void PIImage::Apply(bool mw)
+{
+if (mw) ComputePixmap();
+if (zow != NULL) 
+  {
+  zow->SetColMap(GetColMapId());
+  ComputeZoomPixmap();
+  }
+if (txw)
+  {
+  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);
+  }
+Send(PIMsg_ActiveWindow, (char *)this);
 return;
 }
@@ -147,6 +161,7 @@
 void PIImage::Resize()
 {
-printf("PIImage::Resize\n");
-ComputePixmap();
+// printf("PIImage::Resize\n");
+SetPave();
+Apply();
 return;
 }
@@ -157,57 +172,79 @@
 int xp, yp;
 
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+SelPointerShape(PI_CrossPointer);
+xpav = xp;  ypav = yp; 
+Apply(false);
+return;
+}
+
+/* --Methode-- */
+void PIImage::Ptr1Move(int x, int y)
+{
+int xp, yp;
 if (img == NULL)  return;
 if ( PosW2Img(x, y, &xp, &yp) )  return;
 xpav = xp;  ypav = yp; 
-if (zow)
-  {
-  ComputeZoomPixmap();
-  zow->Refresh();
-  }
+Apply(false);
+return;
+}
+
+/* --Methode-- */
+void PIImage::But1Release(int /*x*/,  int /*y*/)
+{
+SelPointerShape(PI_ArrowPointer);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But2Press(int x, int y)
+{
+int xp, yp;
+
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+SelPointerShape(PI_TDLRArrowPointer);
+xmv0 = xp;
+ymv0 = yp;
+Send(PIMsg_ActiveWindow, (char *)this);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr2Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
 if (txw)
   {
   char buff[256];
-  sprintf(buff,"Image %s : X= %d , Y= %d  PixVal= %g ", 
-          img->name, xpav, ypav, img->FValue(xpav, ypav));
-  txw->SetLabel(buff);
-  }
-return;
-}
-
-
-/* --Methode-- */
-void PIImage::But2Press(int x, int y)
+  sprintf(buff,"%s : DelX= %d , DelY= %d ", (char *)Nom().c_str(), xp-xmv0, yp-ymv0);
+  txw->SetLabel((string)buff);
+  }
+}
+
+/* --Methode-- */
+void PIImage::But2Release(int x, int y)
 {
 int xp, yp;
-int xwsz, ywsz;
-
+
+SelPointerShape(PI_ArrowPointer);
 if (img == NULL)  return;
 if ( PosW2Img(x, y, &xp, &yp) )  return;
-xpav = xp;  ypav = yp; 
-
-xwsz = XSize();
-ywsz = YSize();
-if (zoom > 0)
-  {
-  offx = xpav-(xwsz/2/zoom);
-  offy = ypav-(ywsz/2/zoom);
-  }
-else 
-  {
-  offx = xpav+(xwsz*zoom/2);
-  offy = ypav+(ywsz*zoom/2);
-  }
+
+offx -= (xp-xmv0);
+offy -= (yp-ymv0);
+
 if (offx < 0)  offx = 0;
 if (offy < 0)  offy = 0;
 if (offx >= img->XSize())  offx = img->XSize();
 if (offy >= img->YSize())  offy = img->YSize();
-
-ComputePixmap();
-Refresh();
-if (zow)
-  {
-  ComputeZoomPixmap();
-  zow->Refresh();
-  }
+xpav = xmv0;  ypav = ymv0;
+
+Apply();
 return;
 }
@@ -226,6 +263,6 @@
 
 if ( (img == NULL) || (lut == NULL) ) 
-  { printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n", 
-            (long)img, (long)lut);
+  { /* printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n", 
+            (long)img, (long)lut); */
   *oxsp = *oysp = 0; return(NULL); }
 
@@ -253,5 +290,5 @@
 if ( oszp != nszp )
   {
-  if (opix)  delete opix;
+  if (opix)  delete[] opix;
   pix = new unsigned char[nppx*nppy];
   if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
@@ -260,6 +297,8 @@
 *oxsp = nppx; *oysp = nppy;
 
+/*
 printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 
       ofx, ofy, zm, npx,nppx, npy,nppy);
+*/
 
 pp = pix;
@@ -312,4 +351,5 @@
 pixm = ComputePixmap(offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
 SetPixmap(pixm, xspxm, yspxm); 
+// Refresh();
 return; 
 }
@@ -345,4 +385,5 @@
 zow->SetPixmap(zpixm, xszpxm, yszpxm); 
 zow->SetUserData((void *)this, 0);
+// zow->Refresh();
 return; 
 
@@ -372,2 +413,37 @@
 
 
+/* --Methode-- */
+void PIImage::SetOffset()
+{
+if (zoom > 0)
+  {
+  offx = xpav-XSize()/2/zoom;
+  offy = ypav-YSize()/2/zoom;
+  }
+else
+  {
+  offx = xpav-XSize()/2*zoom;
+  offy = ypav-YSize()/2*zoom;
+  }
+
+if (offx < 0)  offx = 0;
+if (offx >= (img->XSize()-1))  offx = img->XSize()-2;
+if (offy < 0)  offy = 0;
+if (offy >= (img->YSize()-1))  offy = img->YSize()-2;
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetPave()
+{
+int xwsz, ywsz;
+
+xwsz = XSize();  ywsz = YSize();
+if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
+if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
+xpav = offx+xwsz/2; 
+ypav = offx+ywsz/2;
+
+return;
+}
Index: /trunk/SophyaPI/PI/piimage.h
===================================================================
--- /trunk/SophyaPI/PI/piimage.h	(revision 5)
+++ /trunk/SophyaPI/PI/piimage.h	(revision 6)
@@ -33,9 +33,9 @@
   PILabel * txw;
   int xpav, ypav;
-
+  int xmv0, ymv0;
 public:
 //  Les methodes 
 
-  PIImage(PIContainerGen *par, char *nom=NULL, RzImage *pim=NULL,
+  PIImage(PIContainerGen *par, char *nom=NULL, 
            int sx=0, int sy=0, int px=0, int py=0);
   ~PIImage();
@@ -49,16 +49,22 @@
   void SetLut(LUT *clut);
   void SetZoom(int zm);
-  void SelectColor(CMapId cmap);
 
-  void Apply();
-  void Resize();
+  virtual void SetColMap(CMapId cmap);
 
-//  void Ptr1Move(int x, int y);
-  void But1Press(int x, int y);
-  void But1Release(int x, int y);
-  void But2Press(int x, int y);
+  inline RzImage * Image() { return(img); }
+  inline LUT *     Lut() { return(lut); }
+  inline int XPave() { return(xpav); } ;
+  inline int YPave() { return(ypav); } ;
 
-  inline int GetXPave() { return(xpav); } ;
-  inline int GetYPave() { return(ypav); } ;
+  void Apply(bool mw=true);
+
+  virtual void Resize();
+
+  virtual void But1Press(int x, int y);
+  virtual void But1Release(int x, int y);
+  virtual void Ptr1Move(int x, int y);
+  virtual void But2Press(int x, int y);
+  virtual void But2Release(int x, int y);
+  virtual void Ptr2Move(int x, int y);
 
 private:
@@ -71,4 +77,6 @@
 
   int PosW2Img(int xiw, int yiw, int * xp, int * yp);
+  void SetOffset();
+  void SetPave();
 };
 
Index: /trunk/SophyaPI/PI/pimenux.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenux.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pimenux.cc	(revision 6)
@@ -25,5 +25,5 @@
 
 // pim->Unmanage();
-pim->Send(cusd->msg, pim->ItemName(cusd->itb).c_str());
+pim->Send(cusd->msg, (void *)pim->ItemNameWdg(cusd->itb).c_str());
 #ifdef DEBUG_PIMenuX
 printf("%%%Debug_menub_action: Msg= %d  \n", (int)cusd->msg);
@@ -58,17 +58,4 @@
 }
 
-/* --Methode-- */
-void PIMenuX::Show()
-{
-Manage();
-}
-
-/* --Methode-- */
-void PIMenuX::Hide()
-{
-Unmanage();
-}
-
-
 
 /* --Methode-- */
@@ -84,5 +71,5 @@
 
 for(int i=0; i<mNItem; i++)
-  if (ItemName(mBut[i].itb) == s)  
+  if (ItemName(i) == s)  
     { DeleteItemNum(i);  break; }
 
@@ -127,5 +114,5 @@
 
 for(int i=0; i<mNItem; i++)
-  if (ItemName(mBut[i].itb) == s)  
+  if (ItemName(i) == s)  
     { CheckItemNum(i, st);  break; }
 
@@ -148,4 +135,82 @@
 printf("PIMenuX::CheckItemNum(%d,bool) Error/ Not yet implemented \n", n);
 return;
+}
+
+/* --Methode-- */
+void PIMenuX::Show()
+{
+Manage();
+}
+
+/* --Methode-- */
+void PIMenuX::Hide()
+{
+Unmanage();
+}
+
+
+
+/* --Methode-- */
+string PIMenuX::ItemName(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return("");
+return (ItemNameWdg(mBut[n].itb));
+}
+
+
+/* --Methode-- */
+string PIMenuX::ItemNameWdg(SysDWdg itw)
+{
+string s;
+char *buff;
+XmString xmstr;
+Arg warg[2];
+
+XtSetArg(warg[0], XmNlabelString, &xmstr);
+XtGetValues(itw, warg, 1);
+if (xmstr)
+  {
+  XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &buff);
+  s=buff;
+  XmStringFree(xmstr);
+  }
+else s = "";
+
+return(s);
+}
+
+
+/* --Methode-- */
+long PIMenuX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mBut[n].msg);
+}
+
+
+
+/* --Methode-- */
+int PIMenuX::GetNumItem(char *nom)
+{
+string s(nom);
+
+for(int i=0; i<mNItem; i++)
+  if (ItemName(i) == s)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIMenuX::GetNumItemMsg(long msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)   return(i);  
+return(-1);
+}
+
+/* --Methode-- */
+SysDWdg PIMenuX::GetItemWdg(int n)
+{
+if ((n<0) || (n>=mNItem))  return(NULL);
+else return(mBut[n].itb);
 }
 
@@ -203,25 +268,4 @@
 
 
-/* --Methode-- */
-string PIMenuX::ItemName(SysDWdg itb)
-{
-string s;
-char *buff;
-XmString xmstr;
-Arg warg[2];
-
-
-XtSetArg(warg[0], XmNlabelString, &xmstr);
-XtGetValues(itb, warg, 1);
-if (xmstr)
-  {
-  XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &buff);
-  s=buff;
-  XmStringFree(xmstr);
-  }
-else s = "";
-
-return(s);
-}
 
 /* --Methode-- */
Index: /trunk/SophyaPI/PI/pimenux.h
===================================================================
--- /trunk/SophyaPI/PI/pimenux.h	(revision 5)
+++ /trunk/SophyaPI/PI/pimenux.h	(revision 6)
@@ -35,5 +35,11 @@
   virtual void    Hide();
 
-  string          ItemName(SysDWdg itb);
+// Pour usage prive et par OptionMenu, ...
+  long            ItemMsg(int n);
+  int             GetNumItem(char *nom);
+  int             GetNumItemMsg(long msg);
+  SysDWdg         GetItemWdg(int n);
+  string          ItemName(int n);
+  string          ItemNameWdg(SysDWdg itw);
 
 protected:
Index: /trunk/SophyaPI/PI/pimsghandler.h
===================================================================
--- /trunk/SophyaPI/PI/pimsghandler.h	(revision 5)
+++ /trunk/SophyaPI/PI/pimsghandler.h	(revision 6)
@@ -7,17 +7,11 @@
 
 enum {
- // Les flags
- 
- 	PIMsg_FgBtn    = 0x00010000,
- 	PIMsg_FgText   = 0x00020000,
- 	PIMsg_FgScale  = 0x00040000,
- 	PIMsg_FgMenu   = 0x00080000,
- 
  // Les messages
-	PIMsg_OK          = 1,
-	PIMsg_Cancel      = 2,
-	PIMsg_Help        = 3,
-	PIMsg_DataChanged = 4,
-	PIMsg_Click       = 5
+	PIMsg_ActiveWindow  = 1,
+	PIMsg_OK            = 2,
+	PIMsg_Cancel        = 3,
+	PIMsg_Help          = 4,
+	PIMsg_DataChanged   = 5,
+	PIMsg_Click         = 6
 };
 
Index: /trunk/SophyaPI/PI/pioptmenugen.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenugen.h	(revision 5)
+++ /trunk/SophyaPI/PI/pioptmenugen.h	(revision 6)
@@ -19,4 +19,6 @@
   virtual string     GetValueStr() = 0;    // Option choisie
   virtual long       GetValue() = 0;       // Message correspondant a l'option choisie
+  virtual void       SetValueStr(string & s) = 0;
+  virtual void       SetValue(long msg) = 0;
 
 protected:
Index: /trunk/SophyaPI/PI/pioptmenux.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenux.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pioptmenux.cc	(revision 6)
@@ -28,4 +28,5 @@
 wmis == k_wmi_normal ;
 stmng = 0;
+mMen = pdm;
 
 cb = XmOptionButtonGadget (XtWdg());
@@ -37,5 +38,5 @@
 // SetLabel(pdm->Nom());
 
-pdm->SetMsgParent(this);
+mMen->SetMsgParent(this);
 Manage();
 }
@@ -55,2 +56,35 @@
 }
 
+
+/* --Methode-- */
+void PIOptMenuX::SetValueStr(string & s)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItem((char *)s.c_str());
+if (n < 0)  return;  
+
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = s;
+mSmsg  = mMen->ItemMsg(n);
+
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::SetValue(long msg)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItemMsg(msg);
+if (n < 0)  return;
+  
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = mMen->ItemName(n);
+mSmsg  = msg;
+
+return;
+}
+
Index: /trunk/SophyaPI/PI/pioptmenux.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenux.h	(revision 5)
+++ /trunk/SophyaPI/PI/pioptmenux.h	(revision 6)
@@ -14,4 +14,7 @@
   virtual string    GetValueStr() { return(mStext); }
   virtual long      GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(long msg);
+  
   
   inline void       Select(char *txt, long msg) { mStext = txt;  mSmsg = msg; }
@@ -19,4 +22,5 @@
 
 protected:
+  PIPDMenu *mMen;
   string   mStext;
   long     mSmsg;
Index: /trunk/SophyaPI/PI/pipixmapgen.cc
===================================================================
--- /trunk/SophyaPI/PI/pipixmapgen.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pipixmapgen.cc	(revision 6)
@@ -32,5 +32,5 @@
 {
 pixmap = pix; nx = sx; ny = sy;
-Refresh();
+Refresh();   
 }
 
@@ -41,5 +41,5 @@
   if (cmap) delete cmap;
   cmap = new PIColorMap(cmapid);
-  Refresh();
+  Refresh();  
 }
 
Index: /trunk/SophyaPI/PI/pipixmapx.cc
===================================================================
--- /trunk/SophyaPI/PI/pipixmapx.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pipixmapx.cc	(revision 6)
@@ -27,5 +27,10 @@
 void PIPixmapX::Draw()
 {
-// EraseWindow();
+Window xw;
+Display * mdsp;
+xw = XtWindow(XtWdg());
+mdsp = PIXDisplay();
+if (nx < XSize())  XClearArea(mdsp, xw, nx, 0, XSize()-nx, YSize(), False);
+if (ny < YSize())  XClearArea(mdsp, xw, 0, ny, XSize(), YSize()-ny, False);
 Draw(0,0,XSize(),YSize());
 }
@@ -73,5 +78,5 @@
 XSync(mdsp, 0);
 
-delete ximg->data;
+delete[] ximg->data;
 XFree(ximg);
 return;
Index: /trunk/SophyaPI/PI/pippmenubar.cc
===================================================================
--- /trunk/SophyaPI/PI/pippmenubar.cc	(revision 6)
+++ /trunk/SophyaPI/PI/pippmenubar.cc	(revision 6)
@@ -0,0 +1,27 @@
+#include "pippmenubar.h"
+
+PIPPMenuBar::PIPPMenuBar()
+: LMenuBar(MBAR_Initial)
+{
+
+}
+
+PIPPMenuBar::~PIPPMenuBar()
+{}
+
+CommandT
+PIPPMenuBar::MenuCommandSelection(
+	const EventRecord	&inMouseEvent,
+	Int32				&outMenuChoice) const
+{
+	outMenuChoice = ::MenuSelect(inMouseEvent.where);
+	
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
Index: /trunk/SophyaPI/PI/pippmenubar.h
===================================================================
--- /trunk/SophyaPI/PI/pippmenubar.h	(revision 6)
+++ /trunk/SophyaPI/PI/pippmenubar.h	(revision 6)
@@ -0,0 +1,18 @@
+#ifndef PIPPMENUBAR_H_SEEN
+#define PIPPMENUBAR_H_SEEN
+
+#include <LMenuBar.h>
+#include "pimenumac.h"
+
+class PIPPMenuBar : public LMenuBar {
+public:
+                           PIPPMenuBar();
+                          ~PIPPMenuBar();
+
+	virtual CommandT	   MenuCommandSelection(const EventRecord &inMouseEvent,
+								Int32 &outMenuChoice) const;
+
+};
+
+
+#endif
Index: /trunk/SophyaPI/PI/pitestapp.cc
===================================================================
--- /trunk/SophyaPI/PI/pitestapp.cc	(revision 5)
+++ /trunk/SophyaPI/PI/pitestapp.cc	(revision 6)
@@ -17,5 +17,7 @@
 
 #include "ex_dessin.h"
-
+#include "piimage.h"
+
+RzImage * RzReadFits(char *flnm);
 
 int SysBeep(int n)
@@ -57,5 +59,7 @@
     PIPUMenu  * menu;
     PIPDMenu * pdm;
-    PIOptMenu * opt;
+    PIOptMenu * opt, * opt2;
+    PIPixmap * zoom;
+    PILabel  * labimg;
 
 };
@@ -111,4 +115,5 @@
   text = new PIText(this->MainWin(), "TEXTE", 100, 30, 20,40);
   label  = new PILabel(this->MainWin(), "Label", 140, 20, 20,80);
+  label->SetBorderWidth(1);
   bouton = new PIButton(this->MainWin(), "OK", 66, 40, 25, 20, 120);
   bouton2 = new PIButton(this->MainWin(), "Image", 133, 40, 25, 80, 120);
@@ -116,4 +121,7 @@
   bouton4 = new PIButton(this->MainWin(), "Menu", 555, 40, 25, 200, 120);
   scl = new PIScale(this->MainWin(), "Scale", 88, 5, 45, 100, 20, 10, 150);
+
+  zoom = new PIPixmap(this->MainWin(), "Zoom", 100,100,5,195);
+  labimg = new PILabel(this->MainWin(), "PixelValue", 250, 20, 10, 320);
 
   menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
@@ -133,7 +141,6 @@
 
   opt = new PIOptMenu(this->MainWin(), pdm, 80, 20, 110, 150);
-
-  printf("Debug_PITestApp::PITestApp() MenBarSizeX,Y= %d %d \n", 
-         Menubar()->XSize(), Menubar()->YSize());
+  opt->SetValueStr("Sqrt");
+  opt2 = new PIOptMenu(this->MainWin(), m[1], 80, 20, 150, 200);
 
 }
@@ -151,7 +158,17 @@
   delete menu;
   delete m[0]; delete m[1]; delete m[2];
-//  delete menb;
-
-}
+  delete opt;
+  delete opt2;
+  delete pdm;
+  delete zoom;
+  delete labimg;
+
+}
+
+static int nimg = 0;
+static PIImage *pimg[5];
+static RzImage *img[5];
+static PIWindow *imgw[5];
+static PIImage *cur=NULL;
 
 static PIWindow * wp3, *wp2, *wp4;
@@ -172,4 +189,9 @@
   sprintf(truc,"< %ld - %d (%d)>",msg,x++, (int)((PIWdgGen *)sender)->kind());
   this->label->SetLabel(truc);
+
+  if (msg == PIMsg_ActiveWindow) 
+    { /* printf("Process: Setting active ImageWindow (%lx) \n", (long)data); */
+    cur = (PIImage *)data; }
+    
   if (msg == 133)
     {
@@ -179,5 +201,12 @@
     if ((x % 3) == 1)  pxm->SetColMap(CMAP_COLRJ32);
     if ((x % 3) == 2)  pxm->SetColMap(CMAP_COLBR32);
-    pxm->Refresh();
+//    pxm->Refresh();
+    if (cur)
+      {
+//      printf("Process: Setting ColMap for (%lx) \n", (long)cur);
+      if ((x % 3) == 0)  cur->SetColMap(CMAP_GREY32);
+      if ((x % 3) == 1)  cur->SetColMap(CMAP_COLRJ32);
+      if ((x % 3) == 2)  cur->SetColMap(CMAP_COLBR32);
+      }
     }
   if (msg == 233)
@@ -193,7 +222,17 @@
 
   if (msg == 10301)  
-   { numsg++;    m[1]->AppendItem((char *)text->GetText().c_str(), numsg); }
+   { 
+   numsg++;    
+   m[1]->AppendItem((char *)text->GetText().c_str(), numsg); 
+   opt2->SetValue(numsg);
+   }
+
   if (msg == 10302)  { m[1]->DeleteItem((char *)text->GetText().c_str()); }
-  if (msg == 10303)  { m[1]->DeleteItemMsg(atol(text->GetText().c_str())); }
+  if (msg == 10303)  
+    {
+    long ml =  atol(text->GetText().c_str());
+    m[1]->DeleteItemMsg(ml);
+    opt2->SetValue(10201);
+    }
 
   if (msg == 555)  wp4->Show();
@@ -202,8 +241,28 @@
   if ((msg > 8000) && data) printf("PITestApp::MenubarReturn: %s \n", (char *)data);
   if (msg == 5000)  
-    { if (data) printf("PITestApp::Process(5000) : %s \n", (char *)data); 
+    { 
+    if (data) 
+      { 
+      printf("PITestApp::Process(5000) : %s \n", (char *)data); 
+      if (nimg < 5)  img[nimg] = RzReadFits((char *)data);
+      if (img[nimg])
+        {
+        imgw[nimg] = new PIWindow(this, "WindImage", 
+                                  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]->SetZoomWin(zoom);
+        pimg[nimg]->SetTextWin(labimg);
+        pimg[nimg]->SetImage(img[nimg]);
+        pimg[nimg]->Apply();
+        imgw[nimg]->Show();
+        nimg++;
+        }
+    }
     else printf("PITestApp::Process(5000) (data=NULL) \n");  }
+
   if (msg == 66) ckb->SetState(true);
-  if ((msg / 100) == 56) printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data); 
+  if ((msg / 100) == 56) 
+    printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data); 
 
 }
@@ -212,5 +271,5 @@
 {
   PITestApp * app;
-  app = new PITestApp(300, 200);
+  app = new PITestApp(350, 350);
 
   wp2 = new PIWindow(app, "Window-2", PIWK_normal,  150, 150, 250, 250);
@@ -238,5 +297,5 @@
 
   pfc = new PIFileChooser(app,"FileChooser", 5000); 
-  pfc->SetPath("/users/eros/ansari/Images++");
+  pfc->SetPath("/exp/eros/ImagRed/");
 
 
Index: /trunk/SophyaPI/PI/piwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.h	(revision 5)
+++ /trunk/SophyaPI/PI/piwdggen.h	(revision 6)
@@ -35,4 +35,5 @@
   virtual void           SetSize(int sx, int sy)=0;
   virtual void           SetPos(int px, int py)=0;
+  virtual void           SetBorderWidth(int bw)=0;
   virtual void           SetLabel(string const&) {}
   virtual void           SetBinding(bool left, bool top, bool right, bool bottom)=0;
Index: /trunk/SophyaPI/PI/piwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.h	(revision 5)
+++ /trunk/SophyaPI/PI/piwdgx.h	(revision 6)
@@ -39,7 +39,7 @@
   virtual void   SetSize(int sx, int sy);
   virtual void   SetPos(int px, int py);
-  virtual void   SetBinding(bool left, bool top, bool right, bool bottom);
   virtual void   SetBorderWidth(int bw);
   virtual void   SetLabel(string const & lab);
+  virtual void   SetBinding(bool left, bool top, bool right, bool bottom);
 
   virtual int    XSize();
