Index: /trunk/SophyaPI/PI/parradapter.cc
===================================================================
--- /trunk/SophyaPI/PI/parradapter.cc	(revision 368)
+++ /trunk/SophyaPI/PI/parradapter.cc	(revision 369)
@@ -145,6 +145,6 @@
 double minhis, maxhis, binwidth;
 int under,over,tothis;
-int *phis;
-int *q;
+int_4 *phis;
+int_4 *q;
 
 double MINDYNAMIC = 1.e-8;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
Index: /trunk/SophyaPI/PI/piapplmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piapplmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/piapplmac.cc	(revision 369)
@@ -23,4 +23,8 @@
 
 PIInit piInit;
+
+static PIApplication* cur_piapp = NULL;
+PIApplication* PIApplicationGetApp() { return cur_piapp; }
+
 
 class PISIOUXAttachment : public LAttachment {
@@ -74,4 +78,6 @@
     menubar = new PIMenubar(this, "DefMenubar");
     topcont = new PIWindowMac(this, "TopLevel", PIWK_floating, sx, sy, 10, 45);
+
+  cur_piapp = this;
 }
 
@@ -96,13 +102,15 @@
 
 /* --Methode-- */
-int PIApplicationMac::PrefXSize()
+void PIApplicationMac::PrefCompSz(int& szx, int& szy)
 {
-  return(10);  // $CHECK$ A remplacer Reza 13/02/98 
+  szx = 10;
+  szy = 10;
 }
 
 /* --Methode-- */
-int PIApplicationMac::PrefYSize()
+void PIApplicationMac::ScreenSz(int& szx, int& szy)
 {
-  return(18);  // $CHECK$ A remplacer Reza 13/02/98 
+  szx = 800;
+  szy = 600;
 }
 
Index: /trunk/SophyaPI/PI/piapplmac.h
===================================================================
--- /trunk/SophyaPI/PI/piapplmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/piapplmac.h	(revision 369)
@@ -13,6 +13,6 @@
 	virtual void    Stop();
 	
-  virtual int     PrefXSize();
-  virtual int     PrefYSize();
+        virtual void              PrefCompSz(int& szx, int& szy);
+        virtual void              ScreenSz(int& szx, int& szy);
 
         virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
@@ -24,3 +24,5 @@
 typedef PIApplicationMac PIApplication;
 
+//  Pour recuperer un objet PIApplication 
+PIApplication* PIApplicationGetApp();
 #endif
Index: /trunk/SophyaPI/PI/pibwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdgmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pibwdgmac.h	(revision 369)
@@ -24,10 +24,14 @@
   virtual void       ActivateKeyboard();
 
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White);
   virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
   virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
-  virtual void       SetBackgroundColor(PIColors col=PI_White);
   virtual PIColors   GetBackgroundColor();
   virtual PIPointer  GetPointerShape();
   virtual void       AssignKeyboard() {}
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
 
 protected:
Index: /trunk/SophyaPI/PI/pifontmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pifontmac.cc	(revision 369)
+++ /trunk/SophyaPI/PI/pifontmac.cc	(revision 369)
@@ -0,0 +1,185 @@
+// Module PI : Peida Interactive     PIFontMac
+// Gestion de fontes - Implementation Mac    
+// DAPNIA/SPP     E. Aubourg 1999
+
+#include <stdio.h>
+
+#include "pisysdep.h"
+#include "pifontmac.h"
+#include PIWDG_H
+
+#include "UDrawingState.h"
+
+/* --Methode-- */
+PIFontMac::PIFontMac(PIFontName fn)
+  : PIFontGen(fn)
+{
+  SelectFont(fn, PI_RomanFont, PI_NormalSizeFont);
+}
+
+/* --Methode-- */
+PIFontMac::PIFontMac(int npt, PIFontName fn, PIFontAtt fa)
+  : PIFontGen(npt, fn, fa)
+{
+  SelectFontPt(fn, fa, npt);
+}
+
+/* --Methode-- */
+PIFontMac::PIFontMac(PIFontMac const & fnt)
+  : PIFontGen(fnt.mFName)
+{
+  SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+}
+
+/* --Methode-- */
+PIFontMac::~PIFontMac()
+{
+}
+
+/* --Methode-- */
+PIFontMac & PIFontMac::operator = (PIFontMac const & fnt)
+{
+  SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+  return(*this);
+}
+
+/* --Methode-- */
+bool PIFontMac::operator == (PIFontMac const & fnt)
+{
+  if ((fnt.mFName == mFName) && (fnt.mFAtt == mFAtt) && (fnt.mFSize == mFSize)) 
+    return(true);
+  else 
+    return(false);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFont(PIFontName fn)
+{
+  SelectFontPt(fn, mFAtt, mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontAtt(PIFontAtt fa)
+{
+  SelectFontPt(mFName, fa, mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontSz(PIFontSize fs)
+{
+  SelectFont(mFName, mFAtt, fs);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontSzPt(int npt)
+{
+  SelectFontPt(mFName, mFAtt, npt);
+}
+
+/* --Methode-- */
+PIFontName PIFontMac::GetFontName()
+{
+  return(mFName);
+}
+
+/* --Methode-- */
+PIFontAtt PIFontMac::GetFontAtt()
+{
+  return(mFAtt);
+}
+
+/* --Methode-- */
+int PIFontMac::GetFontSize()
+{
+  return(mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::Apply()
+{
+  ::TextFont(mFNum);
+  ::TextSize(mFSize);
+  ::TextFace(mFStyle);
+}
+
+/* --Methode-- */
+int PIFontMac::GetFontHeight(int& asc, int& desc)
+{
+  StTextState saver;
+  Apply();
+  ::FontInfo finfo;
+  GetFontInfo(&finfo);
+  asc = finfo.ascent;
+  desc = finfo.descent;
+  return(asc+desc);
+}
+
+/* --Methode-- */
+int PIFontMac::GetStringWidth(char const* s)
+{
+  StTextState saver;
+  Apply();
+  return(::TextWidth(s, 0, strlen(s)));
+}
+
+
+#define NMAXFONTSZ    7
+#define NMAXFONTATT   3
+#define NMAXFONTTYP   5
+
+/*  Variables globales pour la gestion des fontes  */
+static const int fontSizes[4] = {8,12,18,24};
+
+/* --Methode-- */
+void PIFontMac::SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs)
+{
+  if (fs < 0 || fs >=4) fs = PI_NormalSizeFont;
+  int isz = fontSizes[fs];
+  SelectFontPt(fn, fa, isz);
+}
+
+/* --Methode-- */
+void PIFontMac::SelectFontPt(PIFontName fn, PIFontAtt fa, int npt)
+{
+  if ((fn == mFName) && (fa == mFAtt) && (npt == mFSize)) return;
+  mFName = fn;
+  mFAtt  = fa;
+  mFSize = npt;
+  
+  switch (fa) {
+    case PI_RomanFont :
+      mFStyle = 0;
+      break;
+    case PI_BoldFont :
+      mFStyle = bold;
+      break;
+    case PI_ItalicFont :
+      mFStyle = italic;
+      break;
+    default :
+      mFStyle = 0;
+      break;
+  }
+
+  switch (fn) {
+	  case PI_DefaultFont :
+	    mFNum = 0;
+	    break;
+	  case PI_CourierFont :
+	    GetFNum("\pCourier", &mFNum);
+	    break;
+	  case PI_HelveticaFont :
+	    GetFNum("\pHelvetica", &mFNum);
+	    break;
+	  case PI_TimesFont :
+	    GetFNum("\pTimes", &mFNum);
+	    break;
+	  case PI_SymbolFont :
+	    GetFNum("\pSymbol", &mFNum);
+	    break;
+	  default :
+	    mFNum = 0;
+	    break;
+  }
+}
+
Index: /trunk/SophyaPI/PI/pifontmac.h
===================================================================
--- /trunk/SophyaPI/PI/pifontmac.h	(revision 369)
+++ /trunk/SophyaPI/PI/pifontmac.h	(revision 369)
@@ -0,0 +1,51 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIFontMac
+// DAPNIA/SPP          E. Aubourg  99
+
+#ifndef PIFONTMAC_H_SEEN
+#define PIFONTMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pifontgen.h"
+
+
+class PIFontMac : public PIFontGen 
+{
+public :
+		PIFontMac(PIFontName fn = PI_DefaultFont);
+		PIFontMac(int npt, PIFontName fn = PI_DefaultFont, 
+                        PIFontAtt fa = PI_RomanFont);
+		PIFontMac(PIFontMac const & fnt);
+  virtual	~PIFontMac();
+
+  virtual PIFontMac & operator = (PIFontMac const & fnt);
+  virtual bool operator == (PIFontMac const & fnt);
+
+  virtual void		SetFont(PIFontName fn);
+  virtual void		SetFontAtt(PIFontAtt fa);
+  virtual void		SetFontSz(PIFontSize fs);
+  virtual void		SetFontSzPt(int npt);
+
+  virtual PIFontName    GetFontName();
+  virtual PIFontAtt     GetFontAtt();
+  virtual int		GetFontSize();
+
+  virtual int		GetFontHeight(int& asc, int& desc);
+  virtual int		GetStringWidth(char const* s);
+  
+  virtual void      Apply();
+
+protected:
+  void           SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs);
+  void           SelectFontPt(PIFontName fn, PIFontAtt fa, int npt);
+
+  PIFontName mFName;
+  PIFontAtt  mFAtt;
+  int        mFSize;
+  short      mFNum;
+  int        mFStyle;
+};
+
+typedef PIFontMac PIFont;
+
+#endif      // PIFONTMAC_H_SEEN
Index: /trunk/SophyaPI/PI/pigraph3d.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraph3d.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pigraph3d.cc	(revision 369)
@@ -6,4 +6,8 @@
 #include <math.h>
 #include "pigraph3d.h"
+
+#ifndef M_PI_2
+#define M_PI_2 (M_PI/2)
+#endif
 
 //++
Index: /trunk/SophyaPI/PI/pigraphmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pigraphmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pigraphmac.cc	(revision 369)
@@ -2,4 +2,5 @@
 
 #include "pigraphmac.h"
+#include "UDrawingState.h"
 
 
@@ -29,10 +30,11 @@
 
 /* --Methode-- */
-void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
+void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
 {
   if (!mPane->FocusDraw()) {
     ::MoveTo(x, y);
     LStr255 ps = s;
-    ::TextFont(applFont);
+    StTextState saver;
+    myFont.Apply();
     ::DrawString(ps);
   }
@@ -40,10 +42,11 @@
 
 /* --Methode-- */
-void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int /*pos*/)
+void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
 {
   if (mPane->FocusDraw()) {
     ::MoveTo(x, y);
     LStr255 ps = s;
-    ::TextFont(applFont);
+    StTextState saver;
+    myFont.Apply();
 	Rect box;
 	box.left = x;
@@ -52,5 +55,5 @@
 	box.right = box.left + iWidth;
 	int z;
-	box.top = box.bottom + GetFontHeight(z,z);
+	box.top = box.bottom + myFont.GetFontHeight(z,z);
     ::TETextBox(s,strlen(s),&box,teForceLeft);
   }
@@ -114,7 +117,29 @@
 }
 
-
-/* --Methode-- */
-void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n)
+/* --Methode-- */
+void PIGraphicMac::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintOval(&rr);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
 {
   PolyHandle h = MakePoly(x,y,n);
@@ -127,5 +152,5 @@
 
 /* --Methode-- */
-void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n)
+void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
 {
   PolyHandle h = MakePoly(x,y,n);
@@ -135,4 +160,30 @@
   }
 }
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameArc(&rr, degdeb, degfin-degdeb);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintArc(&rr, degdeb, degfin-degdeb);
+  }
+}
+
 
 /* --Methode-- */
@@ -364,21 +415,6 @@
 void PIGraphicMac::SelFontSzPt(int npt, PIFontAtt att)
 {
-  if (mPane->FocusDraw()) {
-    ::TextFont(applFont);
-    ::TextSize(npt);
-    switch(att) {
-      case PI_RomanFont:
-        ::TextFace(0);
-        break;
-      case PI_BoldFont:
-        ::TextFace(bold);
-        break;
-      case PI_ItalicFont:
-        ::TextFace(italic);
-        break;
-    }
-  }
-  mFSize = npt;
-  mFAtt  = att;
+  myFont.SetFontSzPt(npt);
+  myFont.SetFontAtt(att);
 }
 
@@ -386,17 +422,13 @@
 void PIGraphicMac::SelFont(PIFontSize sz, PIFontAtt att)
 {
-  switch(sz) {
-      case PI_SmallSizeFont:
-        SelFontSzPt(9, att);
-        break;
-      case PI_NormalSizeFont:
-        SelFontSzPt(12, att);
-        break;
-      case PI_BigSizeFont:
-        SelFontSzPt(14, att);
-        break;
-  }
-}
-
+  myFont.SetFontSz(sz);
+  myFont.SetFontAtt(att);
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelFont(PIFont & fnt)
+{
+  myFont = fnt;
+}
 
 
@@ -464,5 +496,5 @@
 PIFontAtt  PIGraphicMac::GetFontAtt()
 {
-return (mFAtt);
+return (myFont.GetFontAtt());
 }
 
@@ -470,5 +502,5 @@
 int        PIGraphicMac::GetFontSize()
 {
-return (mFSize);
+return (myFont.GetFontSize());
 }
 
@@ -491,45 +523,3 @@
 }
 
-/* --Methode-- */
-int        PIGraphicMac::GetFontHeight(int& asc, int& desc)   
-{
-  if (mPane->FocusDraw()) {
-    FontInfo info;
-    GetFontInfo(&info);
-    asc = info.ascent;
-    desc = info.descent;
-    return (asc + desc);
-  } else {
-    return 0;
-  }
-}
-
-/* --Methode-- */
-PIGrCoord PIGraphicMac::CalcStringWidth(char const* s)
-{
-//  if (mPane->FocusDraw())
-//    ::TextFont(applFont);
-  return ::TextWidth(s,0,strlen(s));
-}
-
-/* --Methode-- */
-void PIGraphicMac::SaveGraphicAtt()
-{  
-// Pour optimier l'implementation de PIBaseWdgGen
-
-// $CHECK$ faut faire quoi en plus de Gen ?
-PIGraphicGen::SaveGraphicAtt(); 
-return;
-}
-
-/* --Methode-- */
-void PIGraphicMac::RestoreGraphicAtt()
-{
-PIGraphicGen::RestoreGraphicAtt();
-}
-
-
-
-
-
-
+
Index: /trunk/SophyaPI/PI/pigraphmac.h
===================================================================
--- /trunk/SophyaPI/PI/pigraphmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pigraphmac.h	(revision 369)
@@ -1,2 +1,7 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphicMac
+// Trace graphiques- Implementation Mac  E. Aubourg 99
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
 #ifndef PIGRAPHICMAC_H_SEEN
 #define PIGRAPHICMAC_H_SEEN
@@ -13,6 +18,6 @@
 //  Trace graphiques
   virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
-  virtual void       DrawString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
-  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, char* s, int pos = 0);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
   virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
   virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
@@ -20,6 +25,12 @@
   virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
   virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
-  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n);  
-  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n);  
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
   virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
   virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
@@ -33,4 +44,5 @@
   virtual void       SelBackground(PIColorMap& cmap, int cid);
   virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void	     SelFont(PIFont & fnt);
   virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
                              PIFontAtt att=PI_RomanFont);
@@ -53,10 +65,10 @@
   virtual int        GetMarkerSize();
 
-  virtual int        GetFontHeight(int& asc, int& desc);
-  virtual PIGrCoord  CalcStringWidth(char const* s);
+  //virtual int        GetFontHeight(int& asc, int& desc);
+  //virtual PIGrCoord  CalcStringWidth(char const* s);
 
 // Sauvegarde des attributs graphiques 
-  virtual void       SaveGraphicAtt();
-  virtual void       RestoreGraphicAtt();
+ // virtual void       SaveGraphicAtt();
+ // virtual void       RestoreGraphicAtt();
 
 protected:
@@ -67,7 +79,5 @@
   PIColors  mFCol, mBCol;
   PIGOMode  mGOm;
-  PIFontAtt mFAtt;
   PILineAtt mLAtt;
-  int       mFSize;
   PIMarker  mMrk;
   int       mMrkSz;
Index: /trunk/SophyaPI/PI/pilistmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pilistmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pilistmac.cc	(revision 369)
@@ -35,5 +35,5 @@
 
 /* --Methode-- */
-void PIListMac::DeleteItem(PIMessage msg)
+void PIListMac::DeleteItemMsg(PIMessage msg)
 {
   mPIPPList->DeleteItem(msg);
@@ -72,5 +72,5 @@
 
 /* --Methode-- */
-void PIListMac::SelectItem(PIMessage msg)
+void PIListMac::SelectItemMsg(PIMessage msg)
 {
   mPIPPList->SelectItem(msg);
@@ -85,5 +85,5 @@
 
 /* --Methode-- */
-void PIListMac::ClearSelItem(PIMessage msg)
+void PIListMac::ClearSelItemMsg(PIMessage msg)
 {
   mPIPPList->ClearSelItem(msg);
Index: /trunk/SophyaPI/PI/pilistmac.h
===================================================================
--- /trunk/SophyaPI/PI/pilistmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pilistmac.h	(revision 369)
@@ -13,5 +13,10 @@
   virtual void	     AppendItem(const char * item, PIMessage msg);
   virtual void       DeleteItem(const char *item);
-  virtual void       DeleteItem(PIMessage msg);
+  virtual void       DeleteItemMsg(PIMessage msg);
+  virtual void	     DeleteAllItems();
+
+  virtual int	       GetNbItems();
+  virtual PIMessage  GetItemMsg(int n);
+  virtual string     GetItem(int n);
 
   virtual void       SetMultipleSelect(bool ms=false);
@@ -22,7 +27,7 @@
 
   virtual void       SelectItem(const char * item);
-  virtual void       SelectItem(PIMessage msg);
+  virtual void       SelectItemMsg(PIMessage msg);
   virtual void       ClearSelItem(const char * item);
-  virtual void       ClearSelItem(PIMessage msg);
+  virtual void       ClearSelItemMsg(PIMessage msg);
 
 
Index: /trunk/SophyaPI/PI/pimenubarmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenubarmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pimenubarmac.cc	(revision 369)
@@ -13,6 +13,24 @@
 
 void
-PIMenubarMac::AppendMenu(PIPDMenu *pdm)
+PIMenubarMac::AppendMenu(PIMenu *pdm)
 {
   LMenuBar::GetCurrentMenuBar()->InstallMenu(pdm->macMenu, InstallMenu_AtEnd);
 }
+
+void
+PIMenubarMac::RemoveMenu(PIMenu *pdm)
+{
+  LMenuBar::GetCurrentMenuBar()->RemoveMenu(pdm->macMenu);
+}
+
+void
+PIMenubarMac::SetSensitivity(PIMenu *pdm, bool sens)
+{
+
+}
+
+bool
+PIMenubarMac::IsSensitive(PIMenu *pdm)
+{
+  return true;
+}
Index: /trunk/SophyaPI/PI/pimenubarmac.h
===================================================================
--- /trunk/SophyaPI/PI/pimenubarmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pimenubarmac.h	(revision 369)
@@ -8,5 +8,9 @@
 	            PIMenubarMac(PIApplicationGen* par, char* nom);
 	           ~PIMenubarMac();
- virtual void	AppendMenu(PIPDMenu *pdm);
+	           
+  virtual void      AppendMenu(PIMenu *pdm);
+  virtual void      RemoveMenu(PIMenu *pdm);
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true);
+  virtual bool      IsSensitive(PIMenu *pdm);
 
 };
Index: /trunk/SophyaPI/PI/pimenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pimenumac.cc	(revision 369)
@@ -2,79 +2,145 @@
 #include "pimenumac.h"
 #include <algorithm>
+#include <iostream>
 
 int PIMenuMac::lastId = 1024;
-list<PIMenuMac*> PIMenuMac::sMenus;
-
-PIMenuMac::PIMenuMac(PIMsgHandler *par, char *nom, PIMenuType pdpu) 
+vector<PIMenuMac::menuInfo> mMenuInfos;
+
+/* --Methode-- */
+PIMenuMac::PIMenuMac(PIWdg* par, const char *nom, PIMenuType pdpu) 
 : PIMenuGen(par, nom, pdpu)
 {
    macMenu = new LMenu(lastId, LStr255(nom));
-   mMenuId = lastId;
-   sMenus.push_back(this);
+   menuInfo info;
+   info.mId = lastId;
+   info.pimenu = this;
+   mMenuInfos.push_back(info);
    lastId++;
 }
 
 
+/* --Methode-- */
 PIMenuMac::~PIMenuMac()
 {
   LMenuBar::GetCurrentMenuBar()->RemoveMenu(macMenu);
-  sMenus.remove(this);
+  mMenuInfos.erase(mMenuInfos.begin() + GetMenuNum());
   delete macMenu;
 }
 
-int
-PIMenuMac::FindItemByMsg(PIMessage msg)
-{
-  if (mMsgs.size() == 0) return -1;
-  int i = find(mMsgs.begin(), mMsgs.end(), msg) - mMsgs.begin();
-  return (i>=mMsgs.size()) ? -1 : i;
-}
-
-int
-PIMenuMac::FindItemByName(string const& s)
-{
-  int n = ::CountMItems(GetMacMenuHandle());
-  for (int i=0; i<n; i++)
-    if (GetMenuItemText(i) == s)
-      return i;
-  return -1;
-}
-
-
-void
-PIMenuMac::AppendItem(char* nom, PIMessage msg, char* sc)  // sc = short-cut , raccourci clavier
-{
+/* --Methode-- */
+void PIMenuMac::AppendItem(const char* nom, PIMessage msg, char* sc)
+{
+  AddItem(nom, msg, 0, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuMac::AppendCheckItem(const char* nom, PIMessage msg, char* sc)
+{
+  AddItem(nom, msg, 1, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuMac::AppendPDMenu(PIMenuGen *pdm, char* sc)
+{
+  if (pdm->MType() !=  k_PulldownMenu) {
+    cerr << "PIMenuX::AppendPDMenu()/Erreur: PullDownMenu seulement ... " << endl;
+    return;
+  }
+  AddItem(NULL, pdm->Msg(), 2, sc, (PIMenuMac*)pdm);
+}
+
+/* --Methode-- */
+void PIMenuMac::AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm)
+{
+  macMenu->InsertCommand("\ptemp", -2000, 1000);
+  MenuHandle mh = GetMacMenuHandle();
+  short i = ::CountMenuItems(mh);
   LStr255 titre(nom);
-  if (titre.BeginsWith("-",1))
-    titre.Insert(" ", 1, 0);
-  if (sc) {
-    titre.Append('/');
-    titre.Append(*sc);
+  ::SetMenuItemText(mh, i, titre);
+
+  // Gestion menus hiérarchiques
+  if (tog == 2 && pdm != NULL) {
+    ::SetItemCmd(mh, i, hMenuCmd);
+    ::SetItemMark(mh, i, pdm->GetMacMenuID());
   }
-  macMenu->InsertCommand(titre, -2000, 1000); // ou cmd_UseMenuItem ???
-  mMsgs.push_back(msg);
-}
-
-void
-PIMenuMac::CheckItemNum(int n, bool st)
-{
-  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  // Le menu hierarchique sera "insere" au moment de l'insertion dans la
+  // menubar...
+  
+  itemInfo info;
+  info.pimsg  = msg;
+  info.name   = nom;
+  mItemInfos.push_back(info);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetItemNum(const char *nom)
+{
+  int j=0;
+  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
+    if ((*i).name == nom) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetItemNumMsg(PIMessage msg)
+{
+  int j=0;
+  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
+    if ((*i).pimsg == msg) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetMenuNum()
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).pimenu == this) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetMenuNum(short menuId)
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).mId == menuId) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+PIMenu* PIMenuMac::GetMenu(short menuId)
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).mId == menuId) return (*i).pimenu;
+  return(NULL);
+}
+
+
+/* --Methode-- */
+void
+PIMenuMac::SetStateNum(int n, bool st)
+{
+  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
   ::CheckItem(macMenu->GetMacMenuH(), n, st);
 }
 
-void
-PIMenuMac::CheckItemMsg(PIMessage msg, bool st)
-{
-  int i = FindItemByMsg(msg);
-  if (i>=0)
-    CheckItemNum(i, st);
-}
-
-void
-PIMenuMac::CheckItem(char* nom, bool st)
-{
-  int i = FindItemByName(nom);
-  if (i>=0)
-    CheckItemNum(i, st);
+/* --Methode-- */
+void
+PIMenuMac::SetStateMsg(PIMessage msg, bool st)
+{
+  int i = GetItemNumMsg(msg);
+  if (i>=0)
+    SetStateNum(i, st);
+}
+
+/* --Methode-- */
+void
+PIMenuMac::SetState(const char* nom, bool st)
+{
+  int i = GetItemNum(nom);
+  if (i>=0)
+    SetStateNum(i, st);
 }
 
@@ -82,7 +148,7 @@
 PIMenuMac::DeleteItemNum(int n)
 {
-  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
   macMenu->RemoveItem(n+1);
-  mMsgs.erase(mMsgs.begin()+n);
+  mItemInfos.erase(mItemInfos.begin()+n);
 }
 
@@ -90,5 +156,5 @@
 PIMenuMac::DeleteItemMsg(PIMessage msg)
 {
-  int i = FindItemByMsg(msg);
+  int i = GetItemNumMsg(msg);
   if (i>=0)
     DeleteItemNum(i);
@@ -96,19 +162,32 @@
 
 void
-PIMenuMac::DeleteItem(char* nom)
-{
-  int i = FindItemByName(nom);
+PIMenuMac::DeleteItem(const char* nom)
+{
+  int i = GetItemNum(nom);
   if (i>=0)
     DeleteItemNum(i);
 }
 
-
-
 void
 PIMenuMac::ItemSelected(int item)
 {
-  if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ?
-  Send(mMsgs[item], PIMsg_Click, (void*) GetMenuItemText(item).c_str());
-}
+  if (item<0 || item >= mItemInfos.size()) return; // $CHECK$ exception ?
+  Send(mItemInfos[item].pimsg, PIMsg_Click, (void*) mItemInfos[item].name.c_str());
+}
+
+string
+PIMenuMac::GetMenuItemText(int item)
+{
+  if (item<0 || item >= mItemInfos.size()) return ""; // $CHECK$ exception ?
+  return mItemInfos[item].name;
+}
+
+PIMessage
+PIMenuMac::GetMenuItemMsg(int item)
+{
+  if (item<0 || item >= mItemInfos.size()) return -1; // $CHECK$ exception ?
+  return mItemInfos[item].pimsg;
+}
+
 
 
@@ -121,20 +200,4 @@
 {}
 
-void
-PIMenuMac::Hide()
-{}
-
-PIMenuMac*
-PIMenuMac::findMenu(int id)
-{
-  list<PIMenuMac*>::iterator i = sMenus.begin();
-  
-  while (i != sMenus.end()) {
-    if ((*i)->MenuId()==id) return *i;
-    i++;
-  }
-  
-  return NULL;
-}
 
 MenuHandle
@@ -151,60 +214,2 @@
 
 
-string
-PIMenuMac::GetMenuItemText(int item)
-{
-  if (item<0 || item >= mMsgs.size()) return ""; // $CHECK$ exception ?
-  MenuHandle h = GetMacMenuHandle();
-  Str255 txt;
-  ::GetMenuItemText(h, item+1, txt);
-  p2cstr(txt);
-  return (char*) txt;
-}
-
-PIMenuMac::GetMenuItemMsg(int item)
-{
-  if (item<0 || item >= mMsgs.size()) return -1; // $CHECK$ exception ?
-  return mMsgs[item];
-}
-
-
-
-/* --Methode-- */
-PIPUMenuMac::PIPUMenuMac(PIMsgHandler* par, char* nom)
-: PIMenuMac(par, nom, k_PopupMenu)
-{
-}
-
-/* --Methode-- */
-PIPUMenuMac::~PIPUMenuMac()
-{
-}
-
-void
-PIPUMenuMac::Show()
-{
-  Point pt;
-  ::GetMouse(&pt);
-  ::LocalToGlobal(&pt);
-  int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),pt.v,pt.h,1);
-  ItemSelected(item);
-}
-
-void
-PIPUMenuMac::Show(PIWdg *w, int px, int py)
-{
-  int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),py,px,1);
-  ItemSelected(item);
-}
-
-/* --Methode-- */
-PIPDMenuMac::PIPDMenuMac(PIMsgHandler* par, char* nom)
-: PIMenuMac(par, nom, k_PulldownMenu)
-{
-}
-
-/* --Methode-- */
-PIPDMenuMac::~PIPDMenuMac()
-{
-}
-
Index: /trunk/SophyaPI/PI/pimenumac.h
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pimenumac.h	(revision 369)
@@ -10,37 +10,51 @@
 class PIMenuMac : public PIMenuGen {
 public:
-					PIMenuMac(PIMsgHandler* par, char* nom, PIMenuType pdpu);
+					PIMenuMac(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu);
 				   ~PIMenuMac();
 				   
-    virtual void    AppendItem(char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL);
 
-    virtual void    DeleteItem(char *nom);
-    virtual void    DeleteItemMsg(PIMessage msg);
-    virtual void    DeleteItemNum(int n);
+  virtual void    DeleteItem(const char *nom);
+  virtual void    DeleteItemMsg(PIMessage msg);
+  virtual void    DeleteItemNum(int n);
 
-    virtual void    CheckItem(char *nom, 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    SetSensitivity(const char *nom, bool sens=true); 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true); 
+  virtual void    SetSensitivityNum(int n, bool sens=true);
 
-    virtual void    Hide();
-    
-    int             MenuId() {return mMenuId;}
-    void            ItemSelected(int item);
-    
-	string          GetMenuItemText(int item);
-	int             GetMenuItemMsg(int item);
-	int             FindItemByMsg(PIMessage msg);
-	int             FindItemByName(string const& nom);
-	
+  virtual bool    IsSensitive(const char *nom);
+  virtual bool    IsSensitiveMsg(PIMessage msg);
+  virtual bool    IsSensitiveNum(int n);
+
+  virtual void    SetState(const char *nom, bool st=false); 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false); 
+  virtual void    SetStateNum(int n, bool st=false);
+ 
+  virtual bool    GetState(const char *nom); 
+  virtual bool    GetStateMsg(PIMessage msg); 
+  virtual bool    GetStateNum(int n); 
+
+  virtual void    Show();
+  virtual void    Show(PIWdg *w, int px, int py);
+
+  LMenu*          GetPPMenu() {return macMenu;}
+  void            ItemSelected(int item);
+  string          GetMenuItemText(int item);
+  PIMessage       GetMenuItemMsg(int item);	
 protected:
-	static PIMenuMac* findMenu(int id);
 	LMenu*          macMenu;
-	int             mMenuId;
-	vector<PIMessage>    mMsgs;
+	struct menuInfo {
+	  short      mId;
+	  PIMenuMac* pimenu;
+	};
+	struct itemInfo {
+	  PIMessage  pimsg;
+	  string     name;
+	};
+	static vector<menuInfo> mMenuInfos;
+	vector<itemInfo> mItemInfos;
 	static int      lastId;
-	static list<PIMenuMac*> sMenus;
 	
 	friend class    PIMenubarMac;
@@ -51,29 +65,14 @@
 	ResIDT          GetMacMenuID();
 	
-   
-};
-
-// Menu popup
-class PIPUMenuMac : public PIMenuMac
-{
-public:
-               PIPUMenuMac(PIMsgHandler* par, char* nom);
-               ~PIPUMenuMac();
-virtual void   Show();
-virtual void   Show(PIWdg *w, int px, int py);
-};
-
-// Menu pull-down
-class PIPDMenuMac : public PIMenuMac
-{
-public:
-               PIPDMenuMac(PIMsgHandler* par, char* nom);
-               ~PIPDMenuMac();
+    int             GetItemNum(const char* nom);
+	int             GetItemNumMsg(PIMessage msg);
+	int             GetMenuNum();
+	static int      GetMenuNum(short menuId);
+	static PIMenuMac*  GetMenu(short menuId);
+    void            AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm);
 };
 
 
 typedef PIMenuMac      PIMenu;
-typedef PIPUMenuMac    PIPUMenu;
-typedef PIPDMenuMac    PIPDMenu;
 
 #endif
Index: /trunk/SophyaPI/PI/pioptmenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 369)
@@ -3,10 +3,15 @@
 
 /* --Methode-- */
-PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,
+PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, char const* nom,
                      int sx, int sy, int px, int py)
-: PIOptMenuGen(par, pdm, sx, sy, px, py), mPUMenu(pdm)
+: PIOptMenuGen(par, nom, sx, sy, px, py)
 {
   delete mPane;
-  //LStr255 titre(Nom().c_str());
+  
+  char buff[128];
+  strncpy(buff, nom, 64);
+  strcat(buff,"_Menu");
+  mMen = new PIMenu((PIWdg*)par, buff, k_PopupMenu);
+  mMen->SetMsgParent(this);
   LStr255 titre("");
   
@@ -17,16 +22,7 @@
   int titleWidth = ::StringWidth(titre);
   
-  //mPane = new LStdPopupMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
   mPane = new PIPPOptMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
-  //macMenu = ((LStdPopupMenu*)mPane)->GetMacMenuH();
   
-  // On va changer la resource de menu au passage...
-//  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
-//  PopupPrivateDataHandle	dataH =
-////		(PopupPrivateDataHandle) (**((LStdPopupMenu*)mPane)->GetMacControl()).contrlData;
-//  (**dataH).mHandle = pdm->GetMacMenuHandle();
-//  (**dataH).mID = pdm->GetMacMenuID();
-  
-  ((PIPPOptMenu*)mPane)->SetMenu(pdm);
+  ((PIPPOptMenu*)mPane)->SetMenu(mMen);
   ((LStdPopupMenu*)mPane)->AddListener(this);
   
@@ -37,4 +33,5 @@
 PIOptMenuMac::~PIOptMenuMac()
 {
+  delete mMen;
 }
 
@@ -42,6 +39,9 @@
 void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
 {
-Select((char *)data, UserMsg(msg));  //  Reza 17/10/96 $CHECK$ ???
-ReSend(msg, sender, data);
+if (sender == mMen)   {
+  SetValue(UserMsg(msg));
+  ReSend(msg, this, NULL);
+}
+return;
 }
 
@@ -50,11 +50,8 @@
 {
 //  if (inMessage == msg_Click)
-    mPUMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1);
-}
-
-void
-PIOptMenuMac::Select(char *txt, PIMessage msg)
-{ // Ca doit faire quoi ????
-mStext = txt;  mSmsg = msg;
+  int n = ((LStdPopupMenu*)mPane)->GetValue()-1;
+  mMen->ItemSelected(n);
+  mStext = mMen->GetMenuItemText(n);
+  mSmsg  = mMen->GetMenuItemMsg(n);
 }
 
@@ -62,13 +59,13 @@
 void PIOptMenuMac::SetValueStr(string & s)
 {
-int n;
-n=mPUMenu->FindItemByName((char *)s.c_str());
-if (n < 0)  return;  
+  int n;
+  n=mMen->GetItemNum((char *)s.c_str());
+  if (n < 0)  return;  
 
-((LStdPopupMenu*)mPane)->SetValue(n+1);
-mStext = s;
-mSmsg  = mPUMenu->GetMenuItemMsg(n);
-
-return;
+  StopListening();
+  ((LStdPopupMenu*)mPane)->SetValue(n+1);
+  StartListening();
+  mStext = s;
+  mSmsg  = mMen->GetMenuItemMsg(n);
 }
 
@@ -76,15 +73,13 @@
 void PIOptMenuMac::SetValue(PIMessage msg)
 {
-int n;
-n=mPUMenu->FindItemByMsg(msg);
-if (n < 0)  return;
+  int n;
+  n=mMen->GetItemNumMsg(msg);
+  if (n < 0)  return;
   
-StopListening();
-((LStdPopupMenu*)mPane)->SetValue(n+1);
-StartListening();
-mStext = mPUMenu->GetMenuItemText(n);
-mSmsg  = msg;
-
-return;
+  StopListening();
+  ((LStdPopupMenu*)mPane)->SetValue(n+1);
+  StartListening();
+  mStext = mMen->GetMenuItemText(n);
+  mSmsg  = msg;
 }
 
Index: /trunk/SophyaPI/PI/pioptmenumac.h
===================================================================
--- /trunk/SophyaPI/PI/pioptmenumac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pioptmenumac.h	(revision 369)
@@ -6,5 +6,5 @@
 class PIOptMenuMac : public PIOptMenuGen {
 public:
-	                PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,  
+	                PIOptMenuMac(PIContainerGen* par, const char* nom,  
                                int sx=10, int sy=10, int px=0, int py=0);
 	               ~PIOptMenuMac();
@@ -18,12 +18,8 @@
   virtual void      SetValue(PIMessage msg);
   
-  inline void       Select(char *txt, PIMessage msg); // public ou protege ???
-
 
 protected:
   string    mStext;
   PIMessage mSmsg;
-  //MenuHandle macMenu;
-  PIPUMenu* mPUMenu;
 };
 
Index: /trunk/SophyaPI/PI/piperiodmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piperiodmac.cc	(revision 369)
+++ /trunk/SophyaPI/PI/piperiodmac.cc	(revision 369)
@@ -0,0 +1,36 @@
+#include "piperiodmac.h"
+
+
+
+/* --Methode-- */
+PIPeriodMac::PIPeriodMac(int dt, UsPeriodicAction act, void * usp)
+: Periodic(dt, act, usp), mLastTick(-1)
+{
+}
+
+/* --Methode-- */
+PIPeriodMac::~PIPeriodMac()
+{
+}
+
+/* --Methode-- */
+void PIPeriodMac::Start(int dt)
+{
+  StartRepeating();
+  if (dt > 0)  { mDt = dt; mDtms = 1000*dt;}
+}
+
+/* --Methode-- */
+void PIPeriodMac::Stop()
+{
+  StopRepeating();
+}
+
+/* --Methode-- */
+void PIPeriodMac::SpendTime(const EventRecord&)
+{
+  long ticks = ::TickCount();
+  if ((ticks - mLastTick) * 1000. / 60. < mDtms) return;
+  mLastTick = ticks;
+  DoPeriodic();
+}
Index: /trunk/SophyaPI/PI/piperiodmac.h
===================================================================
--- /trunk/SophyaPI/PI/piperiodmac.h	(revision 369)
+++ /trunk/SophyaPI/PI/piperiodmac.h	(revision 369)
@@ -0,0 +1,22 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODMAC_H
+#define PIPERIODMAC_H
+
+#include "periodic.h"
+#include "LPeriodical.h"
+
+class PIPeriodMac : public Periodic, public LPeriodical {
+public:
+  PIPeriodMac(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  ~PIPeriodMac();
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+  virtual void SpendTime(const EventRecord&);
+protected:
+  long mLastTick;
+};
+
+typedef PIPeriodMac PIPeriodic;
+
+#endif
Index: /trunk/SophyaPI/PI/pipixmapmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pipixmapmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pipixmapmac.cc	(revision 369)
@@ -12,5 +12,5 @@
 
 /* --Methode-- */
-void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr)
+void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
 {
   if (nx != sx || ny != sy)
Index: /trunk/SophyaPI/PI/pipixmapmac.h
===================================================================
--- /trunk/SophyaPI/PI/pipixmapmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pipixmapmac.h	(revision 369)
@@ -11,5 +11,5 @@
   virtual      ~PIPixmapMac();
 
-  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true);
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0);
   virtual void  Draw(PIGraphic* g);
   virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
Index: /trunk/SophyaPI/PI/pippmenubar.cc
===================================================================
--- /trunk/SophyaPI/PI/pippmenubar.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pippmenubar.cc	(revision 369)
@@ -20,5 +20,5 @@
 	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
 	
-	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
 	if (menu)
 	  menu->ItemSelected(menuItem);
@@ -37,5 +37,5 @@
 	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
 	
-	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
 	if (menu)
 	  menu->ItemSelected(menuItem);
Index: /trunk/SophyaPI/PI/pippoptmenu.cc
===================================================================
--- /trunk/SophyaPI/PI/pippoptmenu.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pippoptmenu.cc	(revision 369)
@@ -47,5 +47,5 @@
 
 void
-PIPPOptMenu::SetMenu(PIPUMenu* pdm)
+PIPPOptMenu::SetMenu(PIMenu* pdm)
 {
   // On va changer la resource de menu au passage...
Index: /trunk/SophyaPI/PI/pippoptmenu.h
===================================================================
--- /trunk/SophyaPI/PI/pippoptmenu.h	(revision 368)
+++ /trunk/SophyaPI/PI/pippoptmenu.h	(revision 369)
@@ -29,5 +29,5 @@
 							LStream				*inStream);
 							
-					void SetMenu(PIPUMenu* pdm);
+					void SetMenu(PIMenu* pdm);
 protected:
 	virtual void		HotSpotResult(
Index: /trunk/SophyaPI/PI/pippviewadapter.cc
===================================================================
--- /trunk/SophyaPI/PI/pippviewadapter.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pippviewadapter.cc	(revision 369)
@@ -26,9 +26,21 @@
                                   PIBindingKind right, PIBindingKind bottom)
 {
-  piBindings.left = left;
-  piBindings.right = right;
-  piBindings.top = top;
+  piBindings.left   = left;
+  piBindings.right  = right;
+  piBindings.top    = top;
   piBindings.bottom = bottom;
 }
+
+bool PIPPViewAdapter::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                  PIBindingKind& right, PIBindingKind& bottom)
+{
+  left   = (PIBindingKind)piBindings.left;
+  right  = (PIBindingKind)piBindings.right;
+  top    = (PIBindingKind)piBindings.top;
+  bottom = (PIBindingKind)piBindings.bottom;
+  
+  return false;
+}
+
 
 void PIPPViewAdapter::AdaptToSuperFrameSize(
Index: /trunk/SophyaPI/PI/pippviewadapter.h
===================================================================
--- /trunk/SophyaPI/PI/pippviewadapter.h	(revision 368)
+++ /trunk/SophyaPI/PI/pippviewadapter.h	(revision 369)
@@ -15,4 +15,6 @@
 	virtual void        SetBinding(PIBindingKind left, PIBindingKind top, 
                                    PIBindingKind right, PIBindingKind bottom);
+	bool                GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                   PIBindingKind& right, PIBindingKind& bottom);
 	virtual void		AdaptToSuperFrameSize(
 								Int32				inSurrWidthDelta,
Index: /trunk/SophyaPI/PI/pistdwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/pistdwdgmac.cc	(revision 369)
@@ -23,6 +23,6 @@
 
 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)
+                         int sx, int sy, int px, int py)
+: PIButtonGen(par, nom, msg, sx, sy, px, py)
 {
   delete mPane;
@@ -36,4 +36,12 @@
 
 void
+PIButtonMac::SetLabel(string const& str)
+{
+  LStr255 sstr(str.c_str());
+  ((LStdButton*)mPane)->SetDescriptor(sstr);
+}
+
+
+void
 PIButtonMac::ListenToMessage(MessageT inMessage, void *)
 {
@@ -46,5 +54,5 @@
 #include <LEditField.h>
 
-PITextMac::PITextMac(PIContainerGen *par, char *nom,
+PITextMac::PITextMac(PIContainerGen *par, const char *nom,
                          int sx, int sy, int px, int py)
 : PITextGen(par, nom, sx, sy, px, py)
@@ -54,4 +62,15 @@
   mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
 }
+
+PITextMac::PITextMac(PIContainerGen *par, const char *nom,
+                     bool vsb, bool hsb,
+                     int sx, int sy, int px, int py)
+: PITextGen(par, nom, vsb, hsb, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
+}
+
 
 PITextMac::~PITextMac()
@@ -127,4 +146,11 @@
 
 void
+PIScaleMac::GetMinMax(int &min, int &max)
+{
+  min = ((LStdControl*)mPane)->GetMinValue();
+  max = ((LStdControl*)mPane)->GetMaxValue();
+}
+
+void
 PIScaleMac::SetValue(int val)
 {
@@ -219,4 +245,12 @@
 
 void
+PIScrollBarMac::GetMinMax(int &min, int &max)
+{
+  min = ((LStdControl*)mPane)->GetMinValue();
+  max = ((LStdControl*)mPane)->GetMaxValue();
+}
+
+
+void
 PIScrollBarMac::SetValue(int val)
 {
Index: /trunk/SophyaPI/PI/pistdwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/pistdwdgmac.h	(revision 369)
@@ -11,4 +11,5 @@
                                  int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PILabelMac();
+  virtual void       SetLabel(string const&);
 };
 
@@ -17,7 +18,7 @@
 public:
                      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);
+                                 int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PIButtonMac();
+  virtual void       SetLabel(string const&);
   virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
   virtual void       ActivatePress(bool=false) {}
@@ -27,5 +28,8 @@
 {
 public:
-                     PITextMac(PIContainerGen *par, char *nom,
+                     PITextMac(PIContainerGen *par, const char *nom,
+                               int sx=10, int sy=10, int px=0, int py=0);
+                     PITextMac(PIContainerGen *par, const char *nom,
+                               bool vsb, bool hsb,
                                int sx=10, int sy=10, int px=0, int py=0);
   virtual           ~PITextMac();
@@ -47,4 +51,5 @@
 
   virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
   virtual void       SetValue(int val);
   virtual int        GetValue(); 
@@ -67,4 +72,5 @@
   virtual void       ActivateDrag(bool /*acd*/=false) {};
   virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
   virtual void       SetValue(int val);
   virtual int        GetValue(); 
Index: /trunk/SophyaPI/PI/piupdattachment.cc
===================================================================
--- /trunk/SophyaPI/PI/piupdattachment.cc	(revision 368)
+++ /trunk/SophyaPI/PI/piupdattachment.cc	(revision 369)
@@ -23,5 +23,5 @@
     switch(msg) {
       case msg_DrawOrPrint:
-        myWdg->Draw(myGraphic);
+        myWdg->Draw(myGraphic,0,0,999999,999999);
  		break;
       case msg_Resize:
Index: /trunk/SophyaPI/PI/piwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.cc	(revision 368)
+++ /trunk/SophyaPI/PI/piwdgmac.cc	(revision 369)
@@ -122,4 +122,22 @@
 }
 
+bool
+PIWdgMac::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                     PIBindingKind& right, PIBindingKind& bottom)
+{
+  if (mAdapter)  
+    mAdapter->GetBinding(left, top, right, bottom);
+  //else
+  //  mPane->SetBinding(left, top, right, bottom);
+  return false;
+}
+
+void PIWdgMac::Refresh()
+{
+  if (mPane) mPane->Refresh();
+  if (mAdapter) mAdapter->Refresh();
+}
+
+
 int
 PIWdgMac::XSize()
@@ -169,5 +187,5 @@
 bool PIWdgMac::ClaimSelection(unsigned int)
 {
-  int l;
+  unsigned int l;
   char* txt = SelectionString(l);
   LClipboard::GetClipboard()->SetData('TEXT',txt,l,true);
@@ -211,5 +229,5 @@
 
 /* --Methode-- */
-char* PIWdgMac::SelectionString(int& len)
+char* PIWdgMac::SelectionString(unsigned int& len)
 {
 char *rs = new char[60];
@@ -250,2 +268,65 @@
   return(mPane->IsVisible());
 }
+
+
+// -------- La classe PIScreenBuffer ----------
+/* --Methode-- */
+PIScreenBuffer::PIScreenBuffer(int sx, int sy)
+{
+  if (sx < 1) sx = 1;
+  if (sy < 1) sy = 1;
+  Rect bounds = {0,0,sy,sx};
+  mGWorld = new LGWorld(bounds);
+}
+/* --Methode-- */
+PIScreenBuffer::~PIScreenBuffer()
+{
+  delete mGWorld; 
+}
+
+/* --Methode-- */
+int PIScreenBuffer::XSize()
+{
+  Rect bounds;
+  mGWorld->GetBounds(bounds);
+  return bounds.right - bounds.left;
+}
+
+/* --Methode-- */
+int PIScreenBuffer::YSize()
+{
+  Rect bounds;
+  mGWorld->GetBounds(bounds);
+  return bounds.bottom - bounds.top;
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+  mGWorld->BeginDrawing();
+  LPane* pane = wdg->GetPane();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&pane->GetMacPort()->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
+  mGWorld->EndDrawing();
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+  LPane* pane = wdg->GetPane();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&GrafPtr(mGWorld->GetMacGWorld())->portBits,&pane->GetMacPort()->portBits,&srcRect,&destRect,srcCopy,NULL);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+{
+
+  mGWorld->BeginDrawing();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&GrafPtr(grb->mGWorld->GetMacGWorld())->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
+  mGWorld->EndDrawing();
+}
Index: /trunk/SophyaPI/PI/piwdgmac.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgmac.h	(revision 368)
+++ /trunk/SophyaPI/PI/piwdgmac.h	(revision 369)
@@ -21,6 +21,9 @@
   virtual void           SetPos(int px, int py);
   virtual void           SetBorderWidth(int /*bw*/) {}
+  
   virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
                                     PIBindingKind right, PIBindingKind bottom);
+  virtual bool           GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                    PIBindingKind& right, PIBindingKind& bottom);
   virtual int            XSize();
   virtual int            YSize();
@@ -29,4 +32,5 @@
   virtual string         Nom()  { return mNom; }
 
+// Pour activer, desactiver un composant graphique (PIWdg)
   virtual void           Manage();
   virtual void           UnManage();
@@ -34,8 +38,14 @@
   virtual bool           IsVisible();
   
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh();
+  
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+//  aux actions utilisateur (souris, clavier, ...)
+  virtual void           SetSensitive();
+  virtual void           SetUnSensitive();
+  virtual bool           IfSensitive();
+
 //  Gestion de copier-coller
-// $$CHECK$$ Pourquoi les noms ont-ils change ???
-// En plus, pour des trucs tout aussi obscurs...
-// Et c'est quoi, typ, qui en plus n'est pas utilise sous X ???
   virtual bool           ClaimSelection(unsigned int typ=PICP_string);
   virtual void           SelectionLost();
@@ -44,7 +54,19 @@
   virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
   virtual void           CopyFromSelection(char *, int l);
-  virtual char*          SelectionString(int& len);
+  virtual char*          SelectionString(unsigned int& len);
   virtual void           SelectionTransferEnd();
 
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+
+  LPane*                 GetPane() {return mPane;}
+  
 protected:
   LPane*				 mPane;
@@ -61,4 +83,24 @@
 typedef PIWdgMac PIWdg;
 
+// -------- La classe PIScreenBuffer ----------
+
+#include <UGWorld.h>
+
+class PIScreenBuffer {
+public :
+                 PIScreenBuffer(int sx, int sy);
+  virtual       ~PIScreenBuffer();
+
+  virtual int       XSize();
+  virtual int       YSize();
+  virtual void      CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual void      CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual void      CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+
+protected :
+  LGWorld* mGWorld;
+};
+
+
 
 #endif
Index: unk/SophyaPI/PI/piwdgxt.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdgxt.cc	(revision 368)
+++ 	(revision )
@@ -1,22 +1,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "piwdggen.h"
-#include "picontainergen.h"
-
-
-/* --Methode-- */
-PIWdgGen::PIWdgGen(PIContainerGen *par, char*, int, int, int, int)
-: PIMsgHandler(par)
-{
-parent = par;
-return;
-}
-
-
-/* --Methode-- */
-PIWdgGen::~PIWdgGen()
-{
-}
-
-
Index: unk/SophyaPI/PI/piwdgxt.h
===================================================================
--- /trunk/SophyaPI/PI/piwdgxt.h	(revision 368)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/* Classe pour enrobage generique des widgets Xt, Mac, etc  */
-/*                                    Reza 10/95            */
-
-#ifndef PIWDG_XT_H_SEEN
-#define PIWDG_XT_H_SEEN
-
-#include <string>
-#include "piwdggen.h"
-
-class PIWdgXt : public PIWdgGen
-{
-public:
-                         PIWdgGen(PIContainerGen *par, char *nom,
-                                   int sx=10, int sy=10, int px=0, int py=0);
-  virtual               ~PIWdgGen();
-  virtual void		 FinishCreate()=0; // apres avoir installe les sous-vues
-
-
-  virtual void           SetSize(int sx, int sy)=0;
-  virtual void           SetPos(int px, int py)=0;
-  virtual void           SetLabel(string const&) {}
-
-  virtual int            XSize();
-  virtual int            YSize();
-  virtual int            XPos();
-  virtual int            YPos();
-
-  
-};
-
-
-  
-
-#endif/* PIWDG_H_SEEN */
