Index: /trunk/SophyaPI/PI/ex_dessin.cc
===================================================================
--- /trunk/SophyaPI/PI/ex_dessin.cc	(revision 62)
+++ /trunk/SophyaPI/PI/ex_dessin.cc	(revision 63)
@@ -152,4 +152,13 @@
 DrawString(20, 75, buf);
 
+if ( (kmod == PIKM_Alt) && (key == 'c') ) {
+  printf("ExBWdg::Keyboard: Test-Copy ... \n"); 
+  ClaimSelection();
+}
+if ( (kmod == PIKM_Alt) && (key == 'v') ) {
+  printf("ExBWdg::Keyboard: Test-Paste ... \n"); 
+  RequestSelection();
+}
+
 return;
 }
Index: /trunk/SophyaPI/PI/pibwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.cc	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdggen.cc	(revision 63)
@@ -50,4 +50,42 @@
   return;
 }
+
+/* --Methode-- */
+void PIBaseWdgGen::Refresh()
+{
+if ( IsVisible() )  { 
+  Draw();
+  CallDrawers(); 
+}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+this->Draw();
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Draw()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! ");
+#endif
+this->EraseWindow();
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Resize()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Resize()  resize notify ");
+#endif
+return;
+}
+
 
 /* --Methode-- */
@@ -173,4 +211,17 @@
 drw->Attach((PIBaseWdg*)this, mDrwId);
 return(mDrwId);
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::MoveResizeDrawer(int id, int x0, int y0, int dx, int dy)
+{
+list<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).id == id) { 
+    (*it).x0 = x0;  (*it).y0 = y0;
+    (*it).dx = dx;  (*it).dy = dy;
+    break;
+  }
+return;
 }
 
@@ -226,3 +277,21 @@
 if (fgc)  ClearClipRectangle();
 
-}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::CallDrawer(int id)
+{
+list<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
+  if ((*it).id == id) {
+    SaveGraphicAtt();
+    (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy);
+    SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);
+    (*it).drw->Draw();
+    RestoreGraphicAtt();    
+    ClearClipRectangle();
+    break;
+  }
+return;
+}
Index: /trunk/SophyaPI/PI/pibwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.h	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdggen.h	(revision 63)
@@ -19,5 +19,5 @@
                    PIK_Previous = 21+0x2000, PIK_Next = 22+0x2000  } ; 
 
-enum PIColors  { PI_NotDefColor = -1, 
+enum PIColors  { PI_ColorFromMap = -2, PI_NotDefColor = -1, 
                  PI_Black = 0, PI_White = 1,  PI_Grey = 2,
                  PI_Red = 3, PI_Blue = 4, PI_Green = 5,  
@@ -72,4 +72,5 @@
   virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)   = 0;
   virtual void       DrawString(int x, int y, char* s, int pos = 0)        = 0;
+  virtual void       DrawOpaqueString(int x, int y, char* s, int pos = 0)  = 0;
   virtual void       DrawLine(int x1, int y1, int x2, int y2)              = 0;
   virtual void       DrawBox(int x0, int y0, int dx, int dy)               = 0;
@@ -89,4 +90,6 @@
   virtual void       SelForeground(PIColors col=PI_Black)                  = 0;
   virtual void       SelBackground(PIColors col=PI_White)                  = 0;
+//  virtual void       SelForeground(PIColorMap* cmap, int cid)              = 0;
+//  virtual void       SelBackground(PIColorMap* cmap, int cid)              = 0;
   virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                     = 0;
   virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
@@ -118,12 +121,13 @@
 
 
-//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
-  virtual void       Refresh()          = 0;
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       Refresh();
+
+//  Fonctions qui doivent contenir le dessin du contenu du widget lui-meme
+  virtual void       Draw();
+  virtual void       Draw(int x0, int y0, int dx, int dy);
   
 // Traitement des evenements   
-  virtual void       Resize()           = 0;
-  virtual void       Draw()             = 0;
-  virtual void       Draw(int x0, int y0, int dx, int dy) = 0;
-
+  virtual void       Resize();
   virtual void       Enter();
   virtual void       Leave();  
@@ -146,13 +150,16 @@
           int        AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, 
                                bool ad=false);
+          void       MoveResizeDrawer(int id, int x0, int y0, int dx, int dy);
           void       RemoveDrawer(int id);       // Ote un drawer de la liste
           void       DeleteDrawers();            // Ote et detruit tous les drawers
 
+//  Trace des Drawers ...          
+  virtual void       CallDrawers(int x0=0, int y0=0, int dx=0, int dy=0); 
+  virtual void       CallDrawer(int id);
+
 // Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
   struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; };
-          
+
 protected:
-  virtual void       CallDrawers(int x0, int y0, int dx, int dy); // Appel le trace des drawers
-
   PSFile * mPSOut;  /* Fichier PostScript eventuel */
 
Index: /trunk/SophyaPI/PI/pibwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgmac.cc	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdgmac.cc	(revision 63)
@@ -508,5 +508,5 @@
 }
 
-/* --Methode-- */
+/* --Methode-- 
 void PIBaseWdgMac::Refresh()
 {
@@ -514,32 +514,6 @@
   Draw();
 }
-
-/* --Methode-- */
-void PIBaseWdgMac::Resize()
-{
-#ifdef DEBUG_RZXB
-printf ("Debug_PIBaseWdgMac::ReSize %ld %ld NewSize= %d %d\n", 
-         (long)(this), (long)(this->sdw), 
-         (int)this->sdw->core.width, (int)this->sdw->core.height);
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgMac::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
-{
-this->Draw();
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgMac::Draw()
-{
-#ifdef DEBUG_RZXB
-this->PIEraseWindow();
-this->PIDrawFBox(10,10, XSize()*2/3, YSize()*2/3);
-#endif
-return;
-}
-
-
+   J'ai mis cette fonction ds PIWdgMac::IsVisible()    Reza $CHECK$  01/12/97 
+*/
+
+
Index: /trunk/SophyaPI/PI/pibwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdgmac.h	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdgmac.h	(revision 63)
@@ -27,4 +27,5 @@
   virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
   virtual void       DrawString(int x, int y, char* s, int pos = 0);
+  virtual void       DrawOpaqueString(int x, int y, char* s, int pos = 0);
   virtual void       DrawLine(int x1, int y1, int x2, int y2);
   virtual void       DrawBox(int x0, int y0, int dx, int dy);
@@ -61,12 +62,4 @@
   virtual int        GetMarkerSize();
 
-//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
-  virtual void       Refresh();
-
-// Traitement des evenements   
-  virtual void       Resize();
-  virtual void       Draw();
-  virtual void       Draw(int x0, int y0, int dx, int dy);
-
 
 protected:
Index: /trunk/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgx.cc	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdgx.cc	(revision 63)
@@ -171,4 +171,16 @@
 else
 XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 
+                  DefGC(), x, y, s, strlen(s));
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawOpaqueString(int x, int y, char* s, int /*pos*/)
+{
+if(mPSOut){
+mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
+}
+else
+XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 
                   DefGC(), x, y, s, strlen(s));
 return;
@@ -695,140 +707,4 @@
 }
 
-/* --Methode-- */
-void PIBaseWdgX::Refresh()
-{
-if ( (XtIsRealized(XtWdg())) &&  
-   (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )        
-  { /* EraseWindow(); */ Draw(); }
-
-return;
-}
-
-
-/* --Methode-- */
-void PIBaseWdgX::Resize()
-{
-#ifdef DEBUG_PIBWDGX
-printf ("PIBaseWdgX::ReSize %ld %ld NewSize= %d %d\n", 
-         (long)(this), (long)(this->XtWdg()), 
-         (int)this->XtWdg()->core.width, (int)this->XtWdg()->core.height);
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
-{
-this->Draw();
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::Draw()
-{
-#ifdef DEBUG_PIBWDGX
-this->EraseWindow();
-this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3);
-#endif
-CallDrawers(0,0,0,0);
-return;
-}
-
-
-/* --Methode-- */
-void PIBaseWdgX::Enter()
-{
-#ifdef DEBUG_PIBWDGX
-puts("PIBaseWdgX::Enter() enter notify ");
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::Leave()
-{
-#ifdef DEBUG_PIBWDGX
-puts("PIBaseWdgX::Leave() leave notify ");
-#endif
-return;
-}
-
-
-/* --Methode-- */
-void PIBaseWdgX::But1Press(int, int)
-{
-#ifdef DEBUG_PIBWDGX
-printf ("PIBaseWdgX::But1Press PosX,Y= %d %d \n", x, y);
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::But1Release(int, int)
-{
-Send(Msg(), PIMsg_Active);
-#ifdef DEBUG_PIBWDGX
-printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y);
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::But2Press(int /* x */, int /* y */)
-{
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::But2Release(int /* x */, int /* y */)
-{
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::But3Press(int /* x */, int /* y */) 
-{
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::But3Release(int /* x */, int /* y */) 
-{
-return;
-}
-
-
-/* --Methode-- */
-void PIBaseWdgX::Ptr1Move(int , int ) 
-{
-#ifdef DEBUG_PIBWDGX
-printf ("PIBaseWdgX::Ptr1Move PosX,Y= %d %d \n", x, y);
-#endif
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::Ptr2Move(int /* x */, int /* y */)  
-{
-return;
-}
-
-
-/* --Methode-- */
-void PIBaseWdgX::Ptr3Move(int /* x */, int /* y */)  
-{
-return;
-}
-
-/* --Methode-- */
-void PIBaseWdgX::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
-{
-
-#ifdef DEBUG_PIBWDGX
-printf("PIBaseWdgX::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod); 
-XFlush(XtDisplay(this->XtWdg()));
-#endif
-return;
-}
 
 
Index: /trunk/SophyaPI/PI/pibwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdgx.h	(revision 62)
+++ /trunk/SophyaPI/PI/pibwdgx.h	(revision 63)
@@ -27,4 +27,5 @@
   virtual void   EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
   virtual void   DrawString(int x, int y, char* s, int pos = 0);
+  virtual void   DrawOpaqueString(int x, int y, char* s, int pos = 0);
   virtual void   DrawLine(int x1, int y1, int x2, int y2);
   virtual void   DrawBox(int x0, int y0, int dx, int dy);
@@ -71,26 +72,4 @@
   virtual void       SaveGraphicAtt();
 
-//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
-  virtual void   Refresh();
-
-// Traitement des evenements   
-  virtual void   Resize();
-  virtual void   Draw();
-  virtual void   Draw(int x0, int y0, int dx, int dy);
-
-  virtual void   Enter();
-  virtual void   Leave();  
-  virtual void   But1Press(int x, int y);
-  virtual void   But1Release(int x, int y);
-  virtual void   But2Press(int x, int y);
-  virtual void   But2Release(int x, int y);
-  virtual void   But3Press(int x, int y);
-  virtual void   But3Release(int x, int y);
-  virtual void   Ptr1Move(int x, int y);
-  virtual void   Ptr2Move(int x, int y);
-  virtual void   Ptr3Move(int x, int y);
-  virtual void   Keyboard(int key, PIKeyModifier kmod);
-
-  inline  GC     DefGC() { return mDefGC; }
 
 protected:
@@ -98,4 +77,5 @@
   void           Init();
   void           SelectFont(int isz, int jat);
+  inline  GC     DefGC() { return mDefGC; }
 
   GC mDefGC;
Index: /trunk/SophyaPI/PI/picmap.cc
===================================================================
--- /trunk/SophyaPI/PI/picmap.cc	(revision 62)
+++ /trunk/SophyaPI/PI/picmap.cc	(revision 63)
@@ -1,33 +1,56 @@
 #include "picmap.h"
 
+#define  MXMAPIDS   10 
+static   int    MapNCols[MXMAPIDS] = {256, 256, 256, 256, 256, 256, 256, 256, 256, 256};
+static   char*  MapNoms[MXMAPIDS]  = {"Grey32","InvGrey32","ColRJ32","ColBR32",
+                               "ColRV32", "Grey128", "InvGrey128", "ColRJ128",
+                               "ColBR128", "Col16"};
+static   CMapId MapIds[MXMAPIDS] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
+                               CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128, 
+                               CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128,  
+                               CMAP_COL16 } ;
+
+static   int mColTNums[8192];   // Max 8192 tables differentes pour le moment  
+static   int CTNum = 0;        //  Numero des tables ds mColTNum - s'incremente a chaque creation 
+
+static   int NMaxTableAuto = 0;
+static   PIColorMap* mMaps[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+
 PIColorMap::PIColorMap(CMapId id)
-: PIColorMapNative(id)
-{
-   if (!*maps) { // Il faut allouer les trois maps de depart
-     maps[0] = new PIColorMap(CMAP_GREY32, 0);
-     maps[1] = new PIColorMap(CMAP_GREYINV32, 0);
-     maps[2] = new PIColorMap(CMAP_COLRJ32, 0);
+: PIColorMapNative()
+{
+   int k, kdx;
+   string mnom;
+
+   if (NMaxTableAuto == 0) { //  Il faut allouer les tables de depart
+     if ( TotNbColors() > 2048 ) NMaxTableAuto = MXMAPIDS-1;
+     else NMaxTableAuto = 3; 
+     for(k=0; k<NMaxTableAuto; k++)  { 
+        mnom = MapNoms[k]; 
+        mMaps[k] = new PIColorMap(MapIds[k], MapNCols[k], mnom);
+     }
    }
-   
-   switch (id) {
-     case CMAP_GREY32 : 
-       CopyFrom(maps[0]);
+
+//  Protection pour valeur de Id  
+   for(kdx=0; kdx<MXMAPIDS; kdx++)  if (id == MapIds[kdx])  break;
+   if (kdx == MXMAPIDS)  { id = MapIds[0];  kdx = 0; }
+   for(k=0; k<NMaxTableAuto; k++)  
+     if (id == mMaps[k]->Type()) {
+       CopyFrom(mMaps[k]);  
+       mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
        break;
-     case CMAP_GREYINV32 : 
-       CopyFrom(maps[1]);
-       break;
-     case CMAP_COLRJ32 : 
-       CopyFrom(maps[2]);
-       break;
-     default:
-       if (!maps[3] || maps[3]->Type() != id) {
-         if (maps[3])
-           {
-           maps[3]->FreeColors();
-           delete maps[3];
-	   }
-         maps[3] = new PIColorMap(id, 0);
+     }
+   if (Type() != id)  {  // Table pas encore trouve dans la liste
+     k = NMaxTableAuto;
+     if (!mMaps[k] || mMaps[k]->Type() != id) {
+       if ( mMaps[k] ) {  
+         mColTNums[mMaps[k]->mCTId] = 1;  // Je force a liberer les couleurs 
+         delete mMaps[k] ;
        }
-       CopyFrom(maps[3]);
+       mnom = MapNoms[kdx];
+       mMaps[k] = new PIColorMap(MapIds[kdx],  MapNCols[kdx], mnom); 
+     }
+    CopyFrom(mMaps[k]);  
+    mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
    }
 }
@@ -35,18 +58,227 @@
 
 PIColorMap::PIColorMap(string const& nom, int nCol)
-: PIColorMapNative(nom, nCol)
+: PIColorMapNative(CMAP_OTHER, nCol, nom)
 {
   MakeColMap();
-}
-
-PIColorMap::PIColorMap(CMapId id, int i)      // Fait une veritable allocation
-: PIColorMapNative(id,i)
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+}
+
+PIColorMap::PIColorMap(CMapId id, int nCol, string const& nom)
+: PIColorMapNative(id, nCol, nom)
 {
   MakeColMap();
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+//  printf("PIColorMap/Debug-Creation:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("  ..CRE.. %d %d \n", CTNum-1, mColTNums[CTNum-1]);
+}
+
+PIColorMap::PIColorMap(PIColorMap& cm)
+{
+  CopyFrom(&cm);
+  mCTId = cm.mCTId;
+  mColTNums[mCTId]++;
 }
 
 PIColorMap::~PIColorMap()
 {
-  if (mType == CMAP_OTHER)
-    FreeColors();
-}
+//  printf("PIColorMap/Debug-Delete:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("...DEL.CTNum,mColTNums= %d %d (%d %d) ", 
+//        CTNum, mColTNums[CTNum], mCTId,mColTNums[mCTId] );
+  mColTNums[mCTId]--; 
+  if ( mColTNums[mCTId] == 0 )  { FreeColors();  mColTNums[mCTId] = 0; }
+  printf("\n");
+}
+
+
+
+void PIColorMap::CleanColorMaps()
+{
+  int k;
+  for(k=0; k<MXMAPIDS; k++)  { 
+    if (!mMaps[k])  continue;
+    mMaps[k]->FreeColors();
+    delete mMaps[k];
+  }
+}
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+void PIColorMap::MakeColMap()
+{
+  PIColor mycol;
+  int i,j,k;
+
+  switch (mType) {
+
+    case CMAP_GREY32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, i*8+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, mNCol-(i*8+k)-1);
+      }
+      break;
+
+    case CMAP_COL16 :
+      for(i=0; i<16; i++) {
+        mycol.red = (int)(R_RGB1[i]*65535.);
+        mycol.green = (int)(G_RGB1[i]*65535.);
+        mycol.blue =(int)(B_RGB1[i]*65535.) ;
+        for(k=0; k<16; k++)     AllocColor(mycol, i*16+k);
+      }
+      break;
+
+    case CMAP_COLRJ32 :
+      for( i=0; i<32; i++) {
+        if (i < 12)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000);  }
+        else if (i < 24) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+        for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+        }
+      break;
+
+  case CMAP_COLBR32 :
+    for( i=0; i<32; i++) {
+      if (i < 5) { 
+        mycol.green = mycol.red = 0;    // Du bleu sombre au bleu clair
+        mycol.blue = 5535+i*15000; }
+      else if (i < 10) { 
+        mycol.blue = 65535;             // Plein bleu - On rajoute du vert -> bleu clair
+        mycol.green = 5535+(i-5)*9000;
+        mycol.red = 0;  }
+      else if (i < 15) { 
+        mycol.blue = 60000-(i-10)*15000;   // On passe au vert
+        mycol.green = 41535+(i-10)*6000;
+        mycol.red = 0;  }
+      else if (i < 21) { 
+        mycol.blue = 0;
+        mycol.green = 65535;               // Plein vert, on rajoute du rouge -> jaune
+        mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27) {  
+        mycol.blue = 0;                     //  On diminue vert -> Orange
+        mycol.green = 60000-(i-21)*12000;
+        mycol.red = 65535-(i-21)*2000;  }
+      else {
+        mycol.blue = 0;                     // Plein rouge
+        mycol.green = 0;
+        mycol.red = 57535+(i-27)*2000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+  case CMAP_COLRV32 :
+    for( i=0; i<32; i++) {
+      if (i < 8) {
+        mycol.green = 15000+(i*5000); mycol.blue = 0;  
+        mycol.red = 15000+(i*5000); }
+      else if (i < 21) {
+        mycol.green = 50000-(i-7)*5000;   
+        if (mycol.green < 0)  mycol.green = 0;
+        mycol.blue = 0;
+        mycol.red = 53535+(i-8)*1000;  }
+      else { 
+        mycol.green = 0;  mycol.red = 65535;
+        mycol.blue = 15535+(i-21)*5000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+    case CMAP_GREY128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, i*2+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, mNCol-(i*2+k)-1);
+      }
+      break;
+
+    case CMAP_COLRJ128 :
+      for( i=0; i<128; i++) {
+        if (i < 48)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 5375+(i*1280);  }
+        else if (i < 96) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 5375+((i-48)*1280);  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 3535+(i-96)*2000; }
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+        }
+      break;
+
+    case CMAP_COLBR128 :
+      for( i=0; i<128; i++) {
+        if (i < 20) { 
+          mycol.green = mycol.red = 0;  // Du bleu sombre au bleu clair
+          mycol.blue = 2835+i*3300; }
+        else if (i < 36) { 
+          mycol.blue = 65535;           // Plein bleu - On rajoute du vert -> bleu clair
+          mycol.green = 3000+(i-20)*2000;
+          mycol.red = 0;  }
+        else if (i < 56) { 
+          mycol.blue = 64600-(i-36)*3400;    // On passe au vert 
+          mycol.green = 32300+(i-36)*1700;
+          mycol.red = 0;  }
+        else if (i < 81) {         
+          mycol.blue = 0;              // Plein vert, on rajoute du rouge -> jaune
+          mycol.green = 65535;
+          mycol.red = 3135+(i-56)*2600;  }
+        else if (i < 96) { 
+          mycol.blue = 0;
+          mycol.green = 63535-(i-80)*2000;
+          mycol.red = 65535;  }
+        else if (i < 112) { 
+          mycol.blue = 0;
+          mycol.green = 30000-(i-96)*2000;
+          mycol.red = 65535-(i-96)*1000;  }
+        else {
+          mycol.blue = 0;
+          mycol.green = 0 ;
+          mycol.red = 50535+(i-112)*1000; }
+
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+      }
+      break;
+
+  default :
+    for(i=0; i<mNCol; i++) {
+      mycol.green = mycol.red = mycol.blue = 0;
+      AllocColor(mycol, i);
+    }
+    break;
+  }
+}
Index: /trunk/SophyaPI/PI/picmap.h
===================================================================
--- /trunk/SophyaPI/PI/picmap.h	(revision 62)
+++ /trunk/SophyaPI/PI/picmap.h	(revision 63)
@@ -5,4 +5,19 @@
 #include PICMAPNTV_H
 
+enum CMapId
+ {
+ CMAP_OTHER       = 0, 
+ CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
+ CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
+ CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
+ CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
+ CMAP_COLRV32     = 5,     // 32 couleurs 
+ CMAP_GREY128     = 6,     // 128 couleurs  niveaux de gris
+ CMAP_GREYINV128  = 7,     //    "     "      "      " 
+ CMAP_COLRJ128    = 8,     // 128 couleurs du rouge au jaune/blanc
+ CMAP_COLBR128    = 9,     // 128 couleurs du bleu au rouge
+ CMAP_COL16       = 10     // 16 Couleurs Arcenciel
+ };
+
 
 class PIColorMap : public PIColorMapNative {
@@ -10,7 +25,14 @@
   PIColorMap(CMapId);
   PIColorMap(string const& nom, int nCol); 
+  PIColorMap(PIColorMap&);
   virtual ~PIColorMap();
+
+  static void CleanColorMaps();
+
 protected:
-  PIColorMap(CMapId id, int i);     // Fait une veritable allocation
+  PIColorMap(CMapId id, int nc, string const& nom);  // Fait l'allocation des couleurs     
+  void     MakeColMap();
+
+  int mCTId;    // Pour tenir trace de la derniere table qui doit liberer les couleurs 
 };
 
Index: /trunk/SophyaPI/PI/picmapgen.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapgen.cc	(revision 62)
+++ /trunk/SophyaPI/PI/picmapgen.cc	(revision 63)
@@ -8,10 +8,19 @@
 
 
-PIColorMapGen* PIColorMapGen::maps[4] = {NULL,NULL,NULL,NULL};
+PIColorMapGen::PIColorMapGen()
+{
+  mNom = "";
+  mNCol = 0;
+  mType = -1;
+}
+PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom)
+{
+  mNom = nom;
+  mNCol = nc;
+  mType = id;
+}
 
-int PIColorMapGen::nCols[6] = {32,32,32,32,32,16};
-char* PIColorMapGen::noms[6] = {"Grey32","InvGrey32","ColRJ32","ColBR32","ColRV32","Col16"};
 
-PIColorMapGen::PIColorMapGen(CMapId)
+PIColorMapGen::~PIColorMapGen()
 {
 }
@@ -25,145 +34,2 @@
 
 
-PIColorMapGen::PIColorMapGen(string const& nom, int nCol)
-{
-  mNom = nom;
-  mNCol = nCol;
-  mType = CMAP_OTHER;
-}
-
-PIColorMapGen::PIColorMapGen(CMapId id, int)
-{
-  if (id < CMAP_GREY32 && id > CMAP_COL16)
-     id = CMAP_GREY32; // BEUARK
-  mNom = noms[id - 1];
-  mNCol = nCols[id - 1];
-  mType = id;
-}
-
-
-PIColorMapGen::~PIColorMapGen()
-{
-}
-
-/*  Definition d' une table de couleurs  R G B   */
-
-static float R_RGB1[16] =
-{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
-static float G_RGB1[16] =
-{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
-static float B_RGB1[16] =
-{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
-
-
-
-void PIColorMapGen::MakeColMap()
-{
-  PIColor mycol;
-  
-  switch (mType)
-  {
-  case CMAP_GREY32 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  case CMAP_GREYINV32 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  case CMAP_COL16 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      mycol.red = (int)(R_RGB1[i]*65535.);
-      mycol.green = (int)(G_RGB1[i]*65535.);
-      mycol.blue =(int)(B_RGB1[i]*65535.) ;
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  case CMAP_COLRJ32 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      if (i < 12) 
-        { mycol.green = mycol.blue = 0;  
-          mycol.red = 21535+(i*4000); }
-      else if (i < 24)
-        { mycol.blue = 0;   mycol.red = 65535;
-          mycol.green = 21535+(i-12)*4000;  }
-      else 
-        { mycol.green = mycol.red = 65535;
-          mycol.blue = 17535+(i-23)*6000; }
-
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  case CMAP_COLBR32 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      if (i < 5) 
-        { mycol.green = mycol.red = 0;  
-          mycol.blue = 5535+i*15000; }
-      else if (i < 10)
-        { mycol.blue = 65535;
-          mycol.green = 5535+(i-5)*9000;
-          mycol.red = 0;  }
-      else if (i < 15)
-        { mycol.blue = 60000-(i-10)*15000;
-          mycol.green = 41535+(i-10)*6000;
-          mycol.red = 0;  }
-      else if (i < 21)
-        { mycol.blue = 0;
-          mycol.green = 65535;
-          mycol.red = 5535+(i-15)*12000;  }
-      else if (i < 27)
-        { mycol.blue = 0;
-          mycol.green = 60000-(i-21)*12000;
-          mycol.red = 65535-(i-21)*2000;  }
-      else 
-        { mycol.blue = 0;
-          mycol.green = 0;
-          mycol.red = 57535+(i-27)*2000; }
-
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  case CMAP_COLRV32 :
-    {for(int i=0; i<mNCol; i++)
-      {
-      if (i < 8) 
-        { mycol.green = 15000+(i*5000); mycol.blue = 0;  
-          mycol.red = 15000+(i*5000); }
-      else if (i < 21)
-        { mycol.green = 50000-(i-7)*5000;   
-          if (mycol.green < 0)  mycol.green = 0;
-          mycol.blue = 0;
-          mycol.red = 53535+(i-8)*1000;  }
-      else 
-        { mycol.green = 0;  mycol.red = 65535;
-          mycol.blue = 15535+(i-21)*5000; }
-
-      AllocColor(mycol, i);
-      }
-    break;
-    }
-  default :
-    {for(int i=0; i<mNCol; i++)
-      {
-         mycol.green = mycol.red = mycol.blue = 0;
-         AllocColor(mycol, i);
-      }
-    break;
-    }
-  }
-}
-
-
Index: /trunk/SophyaPI/PI/picmapgen.h
===================================================================
--- /trunk/SophyaPI/PI/picmapgen.h	(revision 62)
+++ /trunk/SophyaPI/PI/picmapgen.h	(revision 63)
@@ -6,16 +6,4 @@
 #include <string.h>
 
-
-enum CMapId
- {
- CMAP_OTHER       = 0, 
- CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
- CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
- CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
- CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
- CMAP_COLRV32     = 5,     // 32 couleurs 
- CMAP_COL16       = 6     // 16 Couleurs Arcenciel
- };
- 
 
  
@@ -28,28 +16,25 @@
 class PIColorMapGen {
 public:
-  PIColorMapGen(CMapId);
-  PIColorMapGen(string const& nom, int nCol);  // CMapId : CMAP_OTHER automatiquement
+  PIColorMapGen();  
+  PIColorMapGen(int id, int nc, string const& nom);  
   virtual ~PIColorMapGen();
 
-  CMapId Type() const       {return mType;}
+  int Type() const          {return mType;}
   int NCol() const          {return mNCol;}
   string const& Nom() const {return mNom;}
 
   virtual PIColor GetColor(int n)=0;
-  virtual void AllocColor(PIColor const& col, int index)=0;
+  virtual bool AllocColor(PIColor const& col, int index)=0;
   virtual void FreeColors()=0;     // Desalloue les couleurs
+
+  virtual int   TotNbColors()=0;    // Donne le nombre total de couleurs disponibles
+  virtual int   NbAllocColors()=0;  // Nb de couleurs deja allouees 
 protected:
-  PIColorMapGen(CMapId, int);      // Fait une veritable allocation
-  virtual void MakeColMap();       // Alloue la table de couleurs en appelant AllocColor
   void CopyFromGen(PIColorMapGen*);
   virtual void CopyFrom(PIColorMapGen*)=0;
   
-  static int nCols[6];
-  static char* noms[6];
-  
-  static PIColorMapGen* maps[4];
 
   int    mNCol;
-  CMapId mType;
+  int    mType;
   string mNom;
   
Index: /trunk/SophyaPI/PI/picmapmac.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapmac.cc	(revision 62)
+++ /trunk/SophyaPI/PI/picmapmac.cc	(revision 63)
@@ -66,5 +66,6 @@
 }
 
-void PIColorMapMac::AllocColor(PIColor const& col, int index)
+
+bool PIColorMapMac::AllocColor(PIColor const& col, int index)
 {
   ColorSpec& sp = (**mCTab).ctTable[index+2];
@@ -73,4 +74,5 @@
   sp.rgb.blue  = col.blue;
   sp.value     = index+2;
+  return true;    //  $CHECK$  retourne true si OK - Reza 01/12/97
 }
 
Index: /trunk/SophyaPI/PI/picmapmac.h
===================================================================
--- /trunk/SophyaPI/PI/picmapmac.h	(revision 62)
+++ /trunk/SophyaPI/PI/picmapmac.h	(revision 63)
@@ -13,7 +13,9 @@
   PIColorMapMac(string const& nom, int nCol); 
   virtual PIColor GetColor(int n);
-  virtual void AllocColor(PIColor const& col, int index);
+  virtual bool AllocColor(PIColor const& col, int index);   // $CHECK$  Reza 01/12/97(Modif)
   virtual void FreeColors();
   virtual void MakeColMap();
+  virtual int  TotNbColor();         // A faire   $CHECK$  Reza 01/12/97
+  virtual int  NbAllocColors();      // A faire       "    "     "
 protected:
   PIColorMapMac(CMapId id, int i);      // Fait une veritable allocation
Index: /trunk/SophyaPI/PI/picmapx.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapx.cc	(revision 62)
+++ /trunk/SophyaPI/PI/picmapx.cc	(revision 63)
@@ -9,24 +9,17 @@
 
 /* --Methode-- */
-PIColorMapX::PIColorMapX(CMapId id)
-: PIColorMapGen(id) 
+PIColorMapX::PIColorMapX()    
+: PIColorMapGen()
 {
-int n = nCols[id-1];
-mColors = new PIXColor[n];
-mColRGB = new PIColor[n];
-for(int i=0; i<n; i++)  
-  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
-  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
-
-// printf("PIColorMapX::PIColorMapX(CMapId) %d %d \n", mNCol, Type());
-return;
+mColors = NULL;
+mColRGB = NULL;
 }
 
 /* --Methode-- */
-PIColorMapX::PIColorMapX(CMapId id, int i)       // Fait une veritable allocation
-: PIColorMapGen(id,i)
+PIColorMapX::PIColorMapX(int id, int nc, string const& nom)    
+: PIColorMapGen(id, nc, nom)
 {
 
-int n = nCols[id-1];
+int n = nc;
 mColors = new PIXColor[n];
 mColRGB = new PIColor[n];
@@ -41,25 +34,8 @@
 
 /* --Methode-- */
-PIColorMapX::PIColorMapX(string const& nom, int nCol)
-: PIColorMapGen(nom, nCol)
-{
-
-int n = nCol;
-mColors = new PIXColor[n];
-mColRGB = new PIColor[n];
-for(int i=0; i<n; i++)  
-  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
-  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
-// printf("PIColorMapX::PIColorMapX(nom, nCol) %d %d \n", mNCol, Type());
-
-return;
-
-}
-
-/* --Methode-- */
 PIColorMapX::~PIColorMapX()
 {
-delete[] mColors;
-delete[] mColRGB;
+if (mColors)  delete[] mColors;
+if (mColRGB)  delete[] mColRGB;
 }
 
@@ -82,7 +58,9 @@
 static  Colormap  defxcmap;
 static  xinicmap = 0;
+static int NTotColors = 0;
+static int NTotAllocCol = 0;
 
 /* --Methode-- */
-void PIColorMapX::AllocColor(PIColor const& col, int index)
+bool PIColorMapX::AllocColor(PIColor const& col, int index)
 {
 XColor myxcol;
@@ -94,5 +72,5 @@
   }
 
-if ( (index < 0) || (index > mNCol) )  return;
+if ( (index < 0) || (index > mNCol) )  return(false);
 
 if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
@@ -100,5 +78,5 @@
   mColors[index] = BlackPixel(PIXDisplay(), PIXScreen());
   mColRGB[index] = col; 
-  return;
+  return(true);
   }
 
@@ -108,15 +86,17 @@
 
 
-if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) )
-  {
+if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) {
   mColors[index] = myxcol.pixel;
   mColRGB[index] = col; 
 //  printf("PIColorMapX::AllocColor()  RGB= %d %d %d \n",
 //         (int) col.red, (int) col.blue, (int) col.green);
+  NTotAllocCol++;  
+  return(true);
   }
-else  
+else {
   printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
          (int) col.red, (int) col.blue, (int) col.green);
-return;
+  return(false);
+  }
 }
 
@@ -153,8 +133,40 @@
 }
 
+
+/* --Methode-- */
+int PIColorMapX::TotNbColors()
+{
+if (NTotColors > 0)  return(NTotColors);
+Visual* vis;
+// DefaultVisual(PIXDisplay(),  PIXScreen() );
+int k,kk;
+// On calcule le nombre de couleurs a partir du nb de plans image
+kk = DefaultDepth(PIXDisplay(),  PIXScreen() );
+NTotColors = 1;
+for(k=0; k<kk; k++) NTotColors *= 2;
+/*
+ printf("PIColorMapX::TotNbColor() / Debug : Nb Tot Colors = %d - D=%d - NCol=%d NP= %d \n", NTotColors, 
+ DefaultDepth(PIXDisplay(),  PIXScreen()), 
+ DisplayCells(PIXDisplay(),  PIXScreen()), 
+ DisplayPlanes(PIXDisplay(),  PIXScreen()) );
+*/
+return(NTotColors);
+}
+
+/* --Methode-- */
+int PIColorMapX::NbAllocColors()
+{
+return(NTotAllocCol);
+}
+
+
 /* --Methode-- */
 void PIColorMapX::CopyFrom(PIColorMapGen* x)
 {
+  if (mColors)  delete mColors;
+  if (mColRGB)  delete mColRGB;
   CopyFromGen(x);
+  mColors = new PIXColor[mNCol];
+  mColRGB = new PIColor[mNCol];
   for (int i=0; i<mNCol; i++)  
     { mColors[i] = ((PIColorMapX *)x)->mColors[i];
Index: /trunk/SophyaPI/PI/picmapx.h
===================================================================
--- /trunk/SophyaPI/PI/picmapx.h	(revision 62)
+++ /trunk/SophyaPI/PI/picmapx.h	(revision 63)
@@ -9,9 +9,7 @@
 class PIColorMapX : public PIColorMapGen {
 public:
-  friend class PIColorMapGen;
-  friend class PIPixmapX;
-
-  PIColorMapX(CMapId);
-  PIColorMapX(string const& nom, int nCol); 
+  PIColorMapX();  
+  PIColorMapX(int id, int nc, string const& nom);  
+  virtual ~PIColorMapX();
 
   inline PIXColor  Color(int index) 
@@ -19,10 +17,12 @@
 
   virtual PIColor GetColor(int n);
-  virtual void AllocColor(PIColor const& col, int index);
+  virtual bool AllocColor(PIColor const& col, int index);
   virtual void FreeColors();
-//  virtual void MakeColMap();
+
+  virtual int  TotNbColors();
+  virtual int  NbAllocColors();
+
 protected:
-  PIColorMapX(CMapId id, int i);      // Fait une veritable allocation
-  void CopyFrom(PIColorMapGen*);
+  virtual void CopyFrom(PIColorMapGen*);
   
   PIXColor  * mColors;     // La table des couleurs ...
Index: /trunk/SophyaPI/PI/pipixmapgen.cc
===================================================================
--- /trunk/SophyaPI/PI/pipixmapgen.cc	(revision 62)
+++ /trunk/SophyaPI/PI/pipixmapgen.cc	(revision 63)
@@ -53,6 +53,8 @@
 void PIPixmapGen::SetColMap(CMapId cmapid, bool refr)
 {
-if (cmap) delete cmap;
-cmap = new PIColorMap(cmapid);
+if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) {  
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(cmapid);
+}
 if (refr)  Refresh();  
 }
Index: /trunk/SophyaPI/PI/pipixmapgen.h
===================================================================
--- /trunk/SophyaPI/PI/pipixmapgen.h	(revision 62)
+++ /trunk/SophyaPI/PI/pipixmapgen.h	(revision 63)
@@ -29,5 +29,5 @@
                           bool refr=true, int ox=0, int oy=0);
   void          SetColMap(CMapId cmapid, bool refr=true);
-  inline CMapId GetColMapId() { return (cmap->Type()); }; 
+  inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); }; 
   inline int    NbCol() { return(cmap->NCol()); };
 
Index: /trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 62)
+++ /trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 63)
@@ -168,5 +168,4 @@
   DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19);
   CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19);
-  CallDrawers(0,0,0,0);
 }
 
Index: /trunk/SophyaPI/PI/piwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.h	(revision 62)
+++ /trunk/SophyaPI/PI/piwdggen.h	(revision 63)
@@ -11,5 +11,5 @@
 void PIBeep();
 
-// Les differents types d'accrochage aux containers  
+// Les differents types d accrochage aux containers  
 
 enum PIBindingKind {    
@@ -62,7 +62,15 @@
   virtual void           Manage()=0;
   virtual void           UnManage()=0;
-  virtual int            IfManaged()=0;
+  virtual bool           IfManaged()=0;
+  virtual bool           IsVisible()=0;
 
   virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection()=0;
+  virtual void           LoseSelection()=0;
+  virtual void           RequestSelection()=0;
+  virtual void           CopyFromSelection(char *, int l)=0;
+  virtual char*          SelectionString(int& len)=0;
 
 protected:
Index: /trunk/SophyaPI/PI/piwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.cc	(revision 62)
+++ /trunk/SophyaPI/PI/piwdgmac.cc	(revision 63)
@@ -125,2 +125,9 @@
 }
 
+
+bool 
+PIWdgMac::IsVisible()    // $CHECK$  REZA a verifier  01/12/97
+{
+if (mPane->IsVisible())  return(true);
+else return(false);
+}
Index: /trunk/SophyaPI/PI/piwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.h	(revision 62)
+++ /trunk/SophyaPI/PI/piwdgmac.h	(revision 63)
@@ -27,4 +27,10 @@
   virtual int            YPos();
   virtual string         Nom()  { return mNom; }
+
+  virtual void           Manage();
+  virtual void           UnManage();
+  virtual bool           IfManaged();
+  virtual bool           IsVisible();
+
 protected:
   LPane*				 mPane;
Index: /trunk/SophyaPI/PI/piwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.cc	(revision 62)
+++ /trunk/SophyaPI/PI/piwdgx.cc	(revision 63)
@@ -80,5 +80,5 @@
 sdw = top;
 wmis =  k_wmi_appshell;
-stmng = 0;
+stmng = false;
 #ifdef DEBUG_PIWdgX
 printf("Debug_PIWdgX::PIWdgX(int , char * [])  this=%lx  top=%lx \n", (long)this, (long)sdw);
@@ -142,5 +142,5 @@
 else wmis = k_wmi_normal ;
 
-stmng = 0;
+stmng = false;
 #ifdef DEBUG_PIWdgX
 printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom, 
@@ -182,5 +182,5 @@
 if (wmis != k_wmi_appshell)  XtManageChild(sdw);
 else if (!XtIsRealized(sdw))  XtRealizeWidget(sdw);  
-stmng = 1;
+stmng = true;
 return;
 }
@@ -195,12 +195,20 @@
 if (wmis != k_wmi_appshell) 
   XtUnmanageChild(sdw);
-stmng = 0;
-return;
-}
-
-/* --Methode-- */
-int PIWdgX::IfManaged()
+stmng = false;
+return;
+}
+
+/* --Methode-- */
+bool PIWdgX::IfManaged()
 {
 return(stmng);
+}
+
+/* --Methode-- */
+bool PIWdgX::IsVisible()
+{
+if ( (XtIsRealized(XtWdg())) &&  
+   ( (this->XtWdg())->core.visible) )  return(true);
+else return(false);       
 }
 
@@ -468,2 +476,109 @@
 return(0);
 }
+
+
+static Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format);
+
+static void forXt_LoseSelection(Widget w, Atom* sel);
+static void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ);
+static void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format );
+
+static PIWdgX* curselwdg = NULL;
+static char* selval = NULL;
+
+
+/* Nouvelle-Fonction */
+Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format)
+{
+if (*targ != XA_STRING)  return(FALSE);
+if (!curselwdg)  return(FALSE);
+int l;
+*value = curselwdg->SelectionString(l);
+*len=l;
+*typ = XA_STRING;
+*format = 8;
+return(TRUE);
+}
+
+/* Nouvelle-Fonction */
+void forXt_LoseSelection(Widget w, Atom* sel)
+{
+if (curselwdg)  curselwdg->LoseSelection();
+curselwdg = NULL;
+}
+
+/* Nouvelle-Fonction */
+void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ)
+{
+if (selval)   delete selval;
+selval = NULL;
+}
+
+/* Nouvelle-Fonction */
+void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format )
+{
+printf("forXt_SelectionValue()/Debug: %lx %lx - %lx - %d \n", (unsigned long)w,
+       (unsigned long)usd, (unsigned long)value, (*len));
+if ( (value != NULL) && (*len > 0) ) 
+  ((PIWdgX*)usd)->CopyFromSelection((char*)value, (*len)) ;
+}
+
+
+
+// Gestion de Copier/Coller
+/* --Methode-- */
+bool PIWdgX::ClaimSelection()
+{
+if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection, 
+                   forXt_LoseSelection, forXt_DoneSelection) ) {
+  printf("PIWdgX::ClaimSelection() - OK  (Wdg= %lx)\n", (unsigned long)this);
+  curselwdg = this;
+  return (true);
+}
+else {
+  printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this);
+  curselwdg = NULL;
+  return (false);
+}
+}
+
+/* --Methode-- */
+void PIWdgX::LoseSelection()
+{
+  printf("PIWdgX::LoseSelection()  Ne fait rien !(Wdg= %lx - %lx) \n", 
+        (unsigned long)this, (unsigned long)curselwdg);
+  if (curselwdg == this)  curselwdg = NULL; 
+}
+
+/* --Methode-- */
+void PIWdgX::RequestSelection()
+{
+printf("PIWdgX::RequestSelection() (Wdg= %lx - %lx) \n", 
+        (unsigned long)this, (unsigned long)curselwdg);
+XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue, 
+                    (XtPointer)this, PIXGetLastEventTime());
+}
+
+/* --Methode-- */
+void PIWdgX::CopyFromSelection(char * sv, int l)
+{
+char* buff = new char[l+2];
+strncpy(buff, sv, l);
+buff[l] = '\0';
+printf("PIWdgX::RequestSelection() L=%d [%s] \n", l, buff);
+delete buff;
+return;
+}
+
+/* --Methode-- */
+char* PIWdgX::SelectionString(int& len)
+{
+char *rs = new char[60];
+strcpy(rs, "Test-of-PIWdgX::SelectionString()");
+len = strlen(rs);
+return(rs);
+}
Index: /trunk/SophyaPI/PI/piwdgx.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgx.h	(revision 62)
+++ /trunk/SophyaPI/PI/piwdgx.h	(revision 63)
@@ -52,5 +52,13 @@
   virtual void   Manage();
   virtual void   UnManage();
-  virtual int    IfManaged();
+  virtual bool   IfManaged();
+  virtual bool   IsVisible();
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection();
+  virtual void           LoseSelection();
+  virtual void           RequestSelection();
+  virtual void           CopyFromSelection(char *, int l);
+  virtual char*          SelectionString(int& len);
 
   inline SysDWdg XtWdg() const {return(sdw); }; 
@@ -63,5 +71,5 @@
   SysDWdg sdw;
   WmIntState wmis;
-  int stmng;
+  bool stmng;
   
 };
Index: /trunk/SophyaPI/PI/pixtbase.cc
===================================================================
--- /trunk/SophyaPI/PI/pixtbase.cc	(revision 62)
+++ /trunk/SophyaPI/PI/pixtbase.cc	(revision 63)
@@ -188,4 +188,5 @@
   dx = xrec.width;  dy = xrec.height;
   (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Draw(x0, y0, dx, dy);
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->CallDrawers(x0, y0, dx, dy);
   }
 return;
