Index: /trunk/SophyaPI/PI/Tests/pist.cc
===================================================================
--- /trunk/SophyaPI/PI/Tests/pist.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/Tests/pist.cc	(revision 1899)
@@ -334,5 +334,5 @@
 
 if (mTxtDir != PI_TextDirectionHorizontal) {
-  xpos = 50;  ypos = 350;
+  xpos = 50;  ypos = 450;
   s1 = "V_Top-H_Left-TxDUp";
   g->SelForeground(PI_Red);
@@ -343,5 +343,5 @@
 		PI_HorizontalLeft|PI_VerticalTop|PI_TextDirectionVerticalUp);  
 
-  xpos = 100;  ypos = 300;
+  xpos = 100;  ypos = 400;
   s1 = "V_Top-H_Center-TxDUp";
   g->SelForeground(PI_Red);
@@ -352,5 +352,5 @@
 		PI_HorizontalCenter|PI_VerticalTop|PI_TextDirectionVerticalUp);
 
-  xpos = 150;  ypos = 250;
+  xpos = 150;  ypos = 350;
   s1 = "V_Top-H_Right-TxDUp";
   g->SelForeground(PI_Red);
@@ -361,5 +361,33 @@
 		PI_HorizontalRight|PI_VerticalTop|PI_TextDirectionVerticalUp);
 
-  xpos = 200;  ypos = 50;
+  xpos = 50;  ypos = 250;
+  s1 = "V_Center-H_Left-TxDUp";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalLeft|PI_VerticalCenter|PI_TextDirectionVerticalUp);  
+
+  xpos = 100;  ypos = 200;
+  s1 = "V_Base-H_Center-TxDUp";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalCenter|PI_VerticalBaseLine|PI_TextDirectionVerticalUp);
+
+  xpos = 150;  ypos = 150;
+  s1 = "V_Bot-H_Right-TxDUp";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalRight|PI_VerticalBottom|PI_TextDirectionVerticalUp);
+
+
+  xpos = 200;  ypos = 100;
   s1 = "V_Top-H_Left-TxDown";
   g->SelForeground(PI_Red);
@@ -370,5 +398,5 @@
 		PI_HorizontalLeft|PI_VerticalTop|PI_TextDirectionVerticalDown);  
 
-  xpos = 250;  ypos = 100;
+  xpos = 250;  ypos = 150;
   s1 = "V_Top-H_Center-TxDown";
   g->SelForeground(PI_Red);
@@ -379,5 +407,5 @@
 		PI_HorizontalCenter|PI_VerticalTop|PI_TextDirectionVerticalDown);
 
-  xpos = 300;  ypos = 150;
+  xpos = 300;  ypos = 200;
   s1 = "V_Top-H_Right-TxDown";
   g->SelForeground(PI_Red);
@@ -387,4 +415,32 @@
   g->DrawString(xpos, ypos, s1, 
 		PI_HorizontalRight|PI_VerticalTop|PI_TextDirectionVerticalDown);
+
+  xpos = 200;  ypos = 300;
+  s1 = "V_Center-H_Left-TxDown";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalLeft|PI_VerticalCenter|PI_TextDirectionVerticalDown);  
+
+  xpos = 250;  ypos = 350;
+  s1 = "V_Base-H_Center-TxDown";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalCenter|PI_VerticalBaseLine|PI_TextDirectionVerticalDown);
+
+  xpos = 300;  ypos = 400;
+  s1 = "V_Bot-H_Right-TxDown";
+  g->SelForeground(PI_Red);
+  g->DrawLine(xpos-10, ypos, xpos+10, ypos); 
+  g->DrawLine(xpos, ypos-50, xpos, ypos+50);
+  g->SelForeground(PI_Black);
+  g->DrawString(xpos, ypos, s1, 
+		PI_HorizontalRight|PI_VerticalBottom|PI_TextDirectionVerticalDown);
+
 
   return;
@@ -443,5 +499,5 @@
 // --------------- Vertical BaseLine -----------------
 xpos = 30;  ypos = 250;
-s1 = "V_Bottom-H_Left";
+s1 = "V_Base-H_Left";
 g->SelForeground(PI_Red);
 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 
@@ -451,5 +507,5 @@
 
 xpos = XSize()/2;  ypos = 250;
-s1 = "V_Bottom-H_Center";
+s1 = "V_Base-H_Center";
 g->SelForeground(PI_Red);
 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 
@@ -459,5 +515,5 @@
 
 xpos = XSize()-30;  ypos = 250;
-s1 = "V_Bottom-H_Center";
+s1 = "V_Base-H_Center";
 g->SelForeground(PI_Red);
 g->DrawLine(xpos-50, ypos, xpos+50, ypos); 
Index: /trunk/SophyaPI/PI/picolist.h
===================================================================
--- /trunk/SophyaPI/PI/picolist.h	(revision 1898)
+++ /trunk/SophyaPI/PI/picolist.h	(revision 1899)
@@ -17,5 +17,6 @@
 		 PI_Violet = 16, PI_VioletRed = 17, 
 		 PI_BlueViolet = 18, PI_DarkViolet = 19, 
-                 PI_ColorAllBits0 = 19, PI_ColorAllBits1 = 20 };
+		 PI_HighlightBlue = 20,
+                 PI_ColorAllBits0 = 21, PI_ColorAllBits1 = 22 };
 
 #endif
Index: /trunk/SophyaPI/PI/pidrawer.cc
===================================================================
--- /trunk/SophyaPI/PI/pidrawer.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/pidrawer.cc	(revision 1899)
@@ -42,4 +42,5 @@
 PIDrawer::PIDrawer()
 {
+  mFgDeleteOnDetach = false;
   mBWdg = NULL; 
   mGrUC = NULL;
@@ -324,4 +325,5 @@
   for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
      if ( ((*it).id == id) && ((*it).wdg == wdg) ) { mBWdgList.erase(it);  break; }
+  if (mFgDeleteOnDetach && (mBWdgList.size() == 0))  delete this;
   return;
 }
@@ -332,4 +334,10 @@
   // On affiche par defaut la fenetre de gestion des attributs graphiques
    PIDrwTools::ShowPIDrwTools(wdg);
+}
+
+void
+PIDrawer::DeactivateControlWindow(PIBaseWdgGen* wdg)
+{
+  // On affiche par defaut la fenetre de gestion des attributs graphiques
 }
 
Index: /trunk/SophyaPI/PI/pidrawer.h
===================================================================
--- /trunk/SophyaPI/PI/pidrawer.h	(revision 1898)
+++ /trunk/SophyaPI/PI/pidrawer.h	(revision 1899)
@@ -30,4 +30,7 @@
   virtual           ~PIDrawer();
 
+  inline  void       SetAutoDeleteOnDetach(bool fg)
+                       { mFgDeleteOnDetach = fg; }
+
   virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
                                int axrl=kAxeDirSame, int ayud=kAxeDirSame);
@@ -101,4 +104,5 @@
   virtual void       ShowControlWindow(PIBaseWdgGen* wdg);
   inline  bool       HasSpecificControlWindow() const { return mFgSpecContWind; }
+  virtual void       DeactivateControlWindow(PIBaseWdgGen* wdg);
 
 //   Methode permettant de decoder des options a partir de chaines
@@ -135,5 +139,8 @@
   void DrawGrid(PIGraphicUC* g);
 
-  
+
+  bool mFgDeleteOnDetach;         // si true -> delete drawer on detach
+                                  // from last BaseWdg
+
   double xMin, xMax, yMin, yMax;  // Valeurs en unites user
   int xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
Index: /trunk/SophyaPI/PI/pigraphgen.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphgen.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphgen.cc	(revision 1899)
@@ -127,4 +127,5 @@
 myWdg = NULL;
 myGrb = NULL;
+myLockFCol = false;
 SelArrowMarker();
 }
@@ -135,4 +136,5 @@
 myWdg = wdg;
 myGrb = NULL;
+myLockFCol = false;
 SelArrowMarker();
 }
@@ -143,4 +145,5 @@
 myWdg = NULL;
 myGrb = grb;
+myLockFCol = false;
 SelArrowMarker();
 }
@@ -194,5 +197,6 @@
 void 
 PIGraphicGen::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s,
-			     const char* s_up, const char* s_dn, unsigned long pos)
+			     const char* s_up, const char* s_dn, 
+			     PIFont const & fntss, unsigned long pos)
 {
   if ((s_up == NULL) && (s_dn == NULL)) {
@@ -207,5 +211,5 @@
 
   PIFont fnt_save(myFont);
-  PIFont fnt_ss(myFont);
+  PIFont fnt_ss(fntss);
   fnt_ss.SetFontSzPt(2*myFont.GetFontSize()/3);
 
@@ -272,5 +276,5 @@
     else {
       xs = (int)x+sw_s;
-      if (s != NULL)  DrawString(x, y, s, PI_HorizontalRight | posv);
+      if (s != NULL)  DrawString(xs, y, s, PI_HorizontalRight | posv);
       SelFont(fnt_ss);
       xs = (int)x+sw_s+deltaposx;
Index: /trunk/SophyaPI/PI/pigraphgen.h
===================================================================
--- /trunk/SophyaPI/PI/pigraphgen.h	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphgen.h	(revision 1899)
@@ -164,5 +164,10 @@
   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, unsigned long pos = 0) = 0;
   virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 
-                                    const char* s_up, const char* s_dn, unsigned long pos = 0);
+                                    const char* s_up, const char* s_dn, 
+				    PIFont const & fntss, unsigned long pos = 0);
+  inline  void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 
+                                    const char* s_up, const char* s_dn, 
+				    unsigned long pos = 0)
+                     { DrawCompString(x, y, s, s_up, s_dn, GetFont(), pos); }
 
   virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
@@ -200,4 +205,8 @@
   virtual void       SelArrowMarker(int arrsz=5, 
                                     PIArrowMarker arrmrk=PI_BasicArrowMarker);
+
+  inline  void       LockForegroundColor() { myLockFCol = true; }
+  inline  void       UnLockForegroundColor() { myLockFCol = false; }
+
 // Modifications de fonte
   virtual void	     SelFont(PIFont & fnt)				       = 0; 
@@ -248,5 +257,5 @@
   PIArrowMarker sArrowMrk;
   int sArrowMrkSz;
-
+  bool myLockFCol;
 };
 
Index: /trunk/SophyaPI/PI/pigraphps.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphps.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphps.cc	(revision 1899)
@@ -115,12 +115,20 @@
 {
 if(mPSOut) {
-  int posh = pos & PI_HorizontalPosition;
-  int posv = pos & PI_VerticalPosition;
+  unsigned long txtdir = pos&PI_TextDirection;
+  unsigned long posh = pos & PI_HorizontalPosition;
+  unsigned long posv = pos & PI_VerticalPosition;
   int dx,dy;
   double xd = x;
   double yd = y;
-  if ( CalcStringPositionShift(s, posv, dx, dy) ) yd -= dy; 
+  bool fgcsps = CalcStringPositionShift(s, posv, dx, dy);
+  if (txtdir == PI_TextDirectionHorizontal) {
+    if (fgcsps) yd -= dy;
+  }
+  else {
+    if (txtdir == PI_TextDirectionVerticalDown) xd += dy; 
+    else xd -= dy; 
+  }
   mPSOut->DrawString(xd, yd, s, mFCol, myFont.GetFontName(), myFont.GetFontAtt(),
-		     myFont.GetFontSize(), posh); 
+		     myFont.GetFontSize(), posh|txtdir); 
 }
 return;
@@ -131,12 +139,20 @@
 {
 if(mPSOut) {
-  int posh = pos & PI_HorizontalPosition;
-  int posv = pos & PI_VerticalPosition;
+  unsigned long txtdir = pos&PI_TextDirection;
+  unsigned long posh = pos & PI_HorizontalPosition;
+  unsigned long posv = pos & PI_VerticalPosition;
   int dx,dy;
   double xd = x;
   double yd = y;
-  if ( CalcStringPositionShift(s, posv, dx, dy) ) yd -= dy; 
+  bool fgcsps = CalcStringPositionShift(s, posv, dx, dy);
+  if (txtdir == PI_TextDirectionHorizontal) {
+    if (fgcsps) yd -= dy;
+  }
+  else {
+    if (txtdir == PI_TextDirectionVerticalDown) xd += dy; 
+    else xd -= dy; 
+  }
   mPSOut->DrawString(xd, yd, s, mFCol, myFont.GetFontName(), myFont.GetFontAtt(),
-		     myFont.GetFontSize(), posh); 
+		     myFont.GetFontSize(), posh|txtdir); 
 }
 return;
Index: /trunk/SophyaPI/PI/pigraphuc.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphuc.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphuc.cc	(revision 1899)
@@ -154,5 +154,4 @@
                          int axrl, int ayud)
 {
-
   if (axrl == kAxeDirAuto) {
     double ff;
@@ -411,10 +410,11 @@
 /* --Methode-- */
 void PIGraphicUC::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 
-				 const char* s_up, const char* s_dn, unsigned long pos)
+				 const char* s_up, const char* s_dn, 
+				 PIFont const & fntss, unsigned long pos)
 {
   if (!mGrC) return;
   double xf, yf;
   UC2GrC(x, y, xf, yf);
-  mGrC->DrawCompString(xf, yf, s, s_up, s_dn, pos);
+  mGrC->DrawCompString(xf, yf, s, s_up, s_dn, fntss, pos);
 }
 
Index: /trunk/SophyaPI/PI/pigraphuc.h
===================================================================
--- /trunk/SophyaPI/PI/pigraphuc.h	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphuc.h	(revision 1899)
@@ -33,5 +33,5 @@
 //  Definition des coordonnees utilisateur
   virtual void       SetUCS(double xmin, double xmax, double ymin, double ymax,
-                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);     
+                            int axrl=kAxeDirSame, int ayud=kAxeDirSame); 
 // Echelle logarithmique
   virtual void	     SetLogScale(bool logx, bool logy);
@@ -46,5 +46,11 @@
   virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, unsigned long pos = 0);
   virtual void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 
-                                    const char* s_up, const char* s_dn, unsigned long pos = 0);
+                                    const char* s_up, const char* s_dn, 
+				    PIFont const & fntss, unsigned long pos = 0);
+  inline  void       DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 
+                                    const char* s_up, const char* s_dn, 
+				    unsigned long pos = 0)
+                     { DrawCompString(x, y, s, s_up, s_dn, GetFont(), pos); }
+
   virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
   virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
Index: /trunk/SophyaPI/PI/pigraphx.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphx.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/pigraphx.cc	(revision 1899)
@@ -14,5 +14,5 @@
 
 /*  Variables globales pour modifier les GC  */
-#define NMAXCOL  24
+#define NMAXCOL  32
 static  PIXColor colpix[NMAXCOL];
 
@@ -491,21 +491,31 @@
   }
   XPutImage(dsx, pxm2, gcbm, ximg2, 0, 0, 0, 0, fh, sw);
+  GC gcvis;
   GC gcvs = XCreateGC (dsx, mWId, GCFunction | GCPlaneMask, &xgv);
   XCopyGC(dsx, DefGC(), ~0, gcvs); 
   XSetStipple(dsx, gcvs, pxm2);
   XSetFillStyle(dsx, gcvs, FillStippled);
+  if (imgs) {
+    gcvis = XCreateGC (dsx, mWId, GCFunction | GCPlaneMask, &xgv);
+    XCopyGC(dsx, DefGC(), ~0, gcvis); 
+    if (mBCol == PI_ColorFromMap)  XSetForeground(mDisp, gcvis, mBCfMap);
+    else  XSetForeground(mDisp, gcvis, colpix[mBCol]); 
+  }
   if (fgdown) {
-    XSetTSOrigin(dsx, gcvs, x, y);
-    XFillRectangle(dsx, mWId, gcvs, x, y, fh, sw);
+    XSetTSOrigin(dsx, gcvs, x-fdes, y);
+    if (imgs)  XFillRectangle(dsx, mWId, gcvis, x-fdes, y, fh, sw);
+    XFillRectangle(dsx, mWId, gcvs, x-fdes, y, fh, sw);
   }
   else {
-    XSetTSOrigin(dsx, gcvs, x-fh, y-sw);
-    XFillRectangle(dsx, mWId, gcvs, x-fh, y-sw, fh, sw);
+    XSetTSOrigin(dsx, gcvs, x-fasc, y-sw);
+    if (imgs) XFillRectangle(dsx, mWId, gcvis, x-fasc, y-sw, fh, sw);
+    XFillRectangle(dsx, mWId, gcvs, x-fasc, y-sw, fh, sw);
   }
   // Cleaning  
   XDestroyImage(ximg);
   XDestroyImage(ximg2);
+  XFreeGC(dsx, gcbm);
   XFreeGC(dsx, gcvs);
-  XFreeGC(dsx, gcbm);
+  if (imgs) XFreeGC(dsx, gcvis);
   XFreePixmap(dsx, pxm);			     
   XFreePixmap(dsx, pxm2);			     
@@ -517,4 +527,5 @@
 void PIGraphicX::SelForeground(PIColors col)
 {
+if (myLockFCol)  return;
 if (col == mFCol)  return;
 if ( (col < 0) || (col >= NMAXCOL))  return;
@@ -537,4 +548,5 @@
 void PIGraphicX::SelForeground(PIColorMap& cmap, int cid)
 {
+if (myLockFCol)  return;
 SelectFCol(cmap.Color(cid));
 }
@@ -849,4 +861,8 @@
   colpix[PI_DarkViolet] = mycol.pixel;
 
+mycol.red = 0;
+mycol.blue = 65000;
+mycol.green = 45000;
+if ( XAllocColor (mdsp, cmap, &mycol) )  colpix[PI_HighlightBlue] = mycol.pixel;
 
 /*  le GC pour DrawPixmap  */
Index: /trunk/SophyaPI/PI/psfile.cc
===================================================================
--- /trunk/SophyaPI/PI/psfile.cc	(revision 1898)
+++ /trunk/SophyaPI/PI/psfile.cc	(revision 1899)
@@ -946,10 +946,20 @@
       fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
     else {
+      unsigned long txtdir = pos & PI_TextDirection;
       int posh = pos & PI_HorizontalPosition;
       int posv = pos & PI_VerticalPosition;
+      int angle = 0;
+      if (txtdir == PI_TextDirectionVerticalUp) angle = -90;
+      else if (txtdir == PI_TextDirectionVerticalDown) angle = 90;
+
       if ((posh == PI_HorizontalLeft)  && 
-	  ((posv == PI_VerticalBaseLine) || (posv == 0)) )
-	fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n", 
-		x, y, s) ; 
+	  ((posv == PI_VerticalBaseLine) || (posv == 0)) ) {
+	if (angle == 0) 
+	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlshstr gr\n", 
+		  x, y, s) ;
+	else 
+	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) hlshstr gr\n", 
+		  x, y, angle, s) ;
+      }
       else {
 	char ssvp = 'b';
@@ -960,7 +970,11 @@
 	  else sshp = 'l';
 	}
-	if (posv == 0) 
-	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n", 
-		  x, y, s, sshp) ;
+	if (posv == 0) {
+	  if (angle == 0) 
+	    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cshstr gr\n", 
+		    x, y, s, sshp) ;
+	  else fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cshstr gr\n", 
+		       x, y, angle, s, sshp) ;
+	}
 	else {
 	  if (posv == PI_VerticalCenter)  ssvp = 'c';
@@ -968,6 +982,10 @@
 	  else ssvp = 'b';
 	}
-	fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 
+	if (angle == 0) 
+	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 
 		  x, y, s, sshp, ssvp) ; 
+	else 
+	  fprintf(mPSFile, "gs %.2f Ux %.2f Uy m %d rotate (%s) h%cv%cshstr gr\n", 
+		  x, y, angle, s, sshp, ssvp) ; 
       }
     }
