Index: /trunk/SophyaPI/PI/pibwdgmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pibwdgmac.cc	(revision 69)
@@ -12,5 +12,6 @@
 PIBaseWdgMac::PIBaseWdgMac(PIContainerGen *par, char *nom,
                        int sx, int sy, int px, int py) :
-PIBaseWdgGen(par, nom, sx, sy, px, py)
+PIBaseWdgGen(par, nom, sx, sy, px, py), 
+mFCol(PI_Black), mBCol(PI_White)
 {
     mAdapter->AddAttachment(new PIUpdAttachment(this));
Index: /trunk/SophyaPI/PI/picmapmac.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/picmapmac.cc	(revision 69)
@@ -109,4 +109,6 @@
   mPalette = y->mPalette;
   mCTab = y->mCTab;
+  HandToHand(&(Handle)mCTab);
+  HandToHand(&(Handle)mPalette);
   Assert_(mPalette);
 }
Index: /trunk/SophyaPI/PI/pimenubarmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenubarmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pimenubarmac.cc	(revision 69)
@@ -1,3 +1,4 @@
 #include "pimenubarmac.h"
+#include "pippmenubar.h"
 #include <LMenuBar.h>
 
@@ -5,4 +6,5 @@
 :PIMenubarGen(par, nom)
 {
+	new PIPPMenuBar();
 }
 
Index: /trunk/SophyaPI/PI/pimenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pimenumac.cc	(revision 69)
@@ -46,5 +46,10 @@
 {
   LStr255 titre(nom);
-  
+  if (titre.BeginsWith("-",1))
+    titre.Insert(" ", 1, 0);
+  if (sc) {
+    titre.Append('/');
+    titre.Append(*sc);
+  }
   macMenu->InsertCommand(titre, -2000, 1000); // ou cmd_UseMenuItem ???
   mMsgs.push_back(msg);
Index: /trunk/SophyaPI/PI/pimenumac.h
===================================================================
--- /trunk/SophyaPI/PI/pimenumac.h	(revision 68)
+++ /trunk/SophyaPI/PI/pimenumac.h	(revision 69)
@@ -46,4 +46,5 @@
 	friend class    PIMenubarMac;
 	friend class    PIOptMenuMac;
+	friend class    PIPPOptMenu;
 	friend class    PIPPMenuBar;
 	MenuHandle      GetMacMenuHandle();
Index: /trunk/SophyaPI/PI/pioptmenumac.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pioptmenumac.cc	(revision 69)
@@ -1,3 +1,4 @@
 #include "pioptmenumac.h"
+#include "pippoptmenu.h"
 
 /* --Methode-- */
@@ -16,15 +17,18 @@
   int titleWidth = ::StringWidth(titre);
   
-  mPane = new LStdPopupMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
+  //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();
+//  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+//  PopupPrivateDataHandle	dataH =
+////		(PopupPrivateDataHandle) (**((LStdPopupMenu*)mPane)->GetMacControl()).contrlData;
+//  (**dataH).mHandle = pdm->GetMacMenuHandle();
+//  (**dataH).mID = pdm->GetMacMenuID();
   
+  ((PIPPOptMenu*)mPane)->SetMenu(pdm);
   ((LStdPopupMenu*)mPane)->AddListener(this);
+  
   Manage();
 }
Index: /trunk/SophyaPI/PI/pippapplmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pippapplmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pippapplmac.cc	(revision 69)
@@ -31,5 +31,5 @@
 PIPPApplMac::MakeMenuBar()
 {
-	new PIPPMenuBar();
+	//new PIPPMenuBar();
 }
 
Index: /trunk/SophyaPI/PI/pippmenubar.cc
===================================================================
--- /trunk/SophyaPI/PI/pippmenubar.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pippmenubar.cc	(revision 69)
@@ -26,2 +26,19 @@
 	return cmd_Nothing;
 }
+
+CommandT
+PIPPMenuBar::FindKeyCommand(
+	const EventRecord	&inKeyEvent,
+	Int32				&outMenuChoice) const
+{
+	char	theChar = inKeyEvent.message & charCodeMask;
+	outMenuChoice = ::MenuKey(theChar);
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
Index: /trunk/SophyaPI/PI/pippmenubar.h
===================================================================
--- /trunk/SophyaPI/PI/pippmenubar.h	(revision 68)
+++ /trunk/SophyaPI/PI/pippmenubar.h	(revision 69)
@@ -13,4 +13,7 @@
 								Int32 &outMenuChoice) const;
 
+	virtual CommandT	FindKeyCommand(
+								const EventRecord	&inKeyEvent,
+								Int32				&outMenuChoice) const;
 };
 
Index: /trunk/SophyaPI/PI/pippoptmenu.cc
===================================================================
--- /trunk/SophyaPI/PI/pippoptmenu.cc	(revision 69)
+++ /trunk/SophyaPI/PI/pippoptmenu.cc	(revision 69)
@@ -0,0 +1,67 @@
+#include "pippoptmenu.h"
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int16			inTitleOptions,
+	ResIDT			inMENUid,
+	Int16			inTitleWidth,
+	Int16			inPopupVariation,
+	ResIDT			inTextTraitsID,
+	Str255			inTitle,
+	OSType			inResTypeMENU,
+	Int16			inInitialMenuItem)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inTitleOptions,
+				inMENUid, inTitleWidth, inPopupVariation, inTextTraitsID,
+				inTitle, inResTypeMENU, inInitialMenuItem)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int32			inMaxValue,
+	ResIDT			inTextTraitsID,
+	ControlHandle	inMacControlH)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inMaxValue,
+						inTextTraitsID, inMacControlH)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	LStream	*inStream)
+		: LStdPopupMenu(inStream)
+{	
+}
+
+void
+PIPPOptMenu::HotSpotResult(
+	Int16	inHotSpot)
+{
+		BroadcastMessage(msg_ThumbDragged, (void*) this);
+}
+
+void
+PIPPOptMenu::SetMenu(PIPUMenu* pdm)
+{
+  // On va changer la resource de menu au passage...
+  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+  PopupPrivateDataHandle	dataH =
+		(PopupPrivateDataHandle) (**GetMacControl()).contrlData;
+  (**dataH).mHandle = pdm->GetMacMenuHandle();
+  (**dataH).mID = pdm->GetMacMenuID();
+  
+  //InitStdPopupMenu(1);
+  
+  mValue = 1;
+  mMinValue = 1;
+  mMaxValue = ::CountMItems(pdm->GetMacMenuHandle());
+
+  ::SetControlValue(mMacControlH, mValue);
+  ::SetControlMinimum(mMacControlH, mMinValue);
+  ::SetControlMaximum(mMacControlH, mMaxValue);
+}
Index: /trunk/SophyaPI/PI/pippoptmenu.h
===================================================================
--- /trunk/SophyaPI/PI/pippoptmenu.h	(revision 69)
+++ /trunk/SophyaPI/PI/pippoptmenu.h	(revision 69)
@@ -0,0 +1,36 @@
+#include "LStdControl.h"
+#include "pisysdep.h"
+#include PIMENU_H
+
+// Redefinir HotSpotResult pour envoyer un message au PIOptMenuMac (qui est un listener)
+// qui va envoyer une action.
+
+class PIPPOptMenu : public LStdPopupMenu {
+public:
+	enum { class_ID = 'PPop' };
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int16				inTitleOptions,
+							ResIDT				inMENUid,
+							Int16				inTitleWidth,
+							Int16				inPopupVariation,
+							ResIDT				inTextTraitsID,
+							Str255				inTitle,
+							OSType				inResTypeMENU,
+							Int16				inInitialMenuItem);
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int32				inMaxValue,
+							ResIDT				inTextTraitsID,
+							ControlHandle		inMacControlH);
+					PIPPOptMenu(
+							LStream				*inStream);
+							
+					void SetMenu(PIPUMenu* pdm);
+protected:
+	virtual void		HotSpotResult(
+								Int16			inHotSpot);
+
+};
Index: /trunk/SophyaPI/PI/pippwindowmac.cc
===================================================================
--- /trunk/SophyaPI/PI/pippwindowmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/pippwindowmac.cc	(revision 69)
@@ -9,4 +9,5 @@
 PIPPWindowMac::PIPPWindowMac()
 {
+  myPIWindow = NULL;
 }
 
@@ -21,4 +22,5 @@
 :LWindow(inWindowInfo)
 {
+  myPIWindow = NULL;
 }
 
@@ -36,4 +38,5 @@
 :LWindow(inWINDid, inAttributes, inSuperCommander)
 {
+  myPIWindow = NULL;
 }
 
@@ -55,4 +58,5 @@
 inProcID, inAttributes, inBehind, inStorage)
 {
+  myPIWindow = NULL;
 }
 
@@ -67,4 +71,5 @@
 :LWindow(inStream)
 {
+  myPIWindow = NULL;
 }
 
@@ -76,5 +81,13 @@
 
 PIPPWindowMac::~PIPPWindowMac()
-{}
+{
+}
+
+void
+PIPPWindowMac::AttemptClose()
+{
+  myPIWindow->Process(myPIWindow->BuildMsg(myPIWindow->Msg(),PIMsg_Close), myPIWindow, NULL) ;
+}
+
 
 const MessageT	msg_Resize			= 817;
Index: /trunk/SophyaPI/PI/pippwindowmac.h
===================================================================
--- /trunk/SophyaPI/PI/pippwindowmac.h	(revision 68)
+++ /trunk/SophyaPI/PI/pippwindowmac.h	(revision 69)
@@ -1,3 +1,4 @@
 #include <LWindow.h>
+#include "piwindowmac.h"
 
 class PIPPWindowMac : public LWindow {
@@ -30,3 +31,7 @@
 	virtual void		DoSetBounds(
 								const Rect			&inBounds);
+								
+	virtual void		AttemptClose();
+								
+	PIWindow* myPIWindow;
 };
Index: /trunk/SophyaPI/PI/piupdattachment.cc
===================================================================
--- /trunk/SophyaPI/PI/piupdattachment.cc	(revision 68)
+++ /trunk/SophyaPI/PI/piupdattachment.cc	(revision 69)
@@ -14,5 +14,5 @@
 PIUpdAttachment::~PIUpdAttachment()
 {
- // SysBeep(1);
+  if (lastCursPane == this) lastCursPane = NULL;
 }
 
@@ -30,4 +30,8 @@
 //        myWdg->Move();
         break;
+//      case cmd_Close: {
+//        delete myWdg;
+//        break;
+//      }
       case msg_Click: {
         SMouseDownEvent* evt = (SMouseDownEvent*) data;
Index: /trunk/SophyaPI/PI/piwindowmac.cc
===================================================================
--- /trunk/SophyaPI/PI/piwindowmac.cc	(revision 68)
+++ /trunk/SophyaPI/PI/piwindowmac.cc	(revision 69)
@@ -1,3 +1,4 @@
 #include "piwindowmac.h"
+#include "pippwindowmac.h"
 
 PIWindowMac::PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k, int sx, int sy, int px, int py)
@@ -40,4 +41,5 @@
 	//mPane = new LWindow(mWindowInfo);
 	mPane = LWindow::CreateWindow(1000+k,LCommander::GetTopCommander());
+    ((PIPPWindowMac*)mPane)->myPIWindow = this; 
 	Rect r = {py, px, py+sy, px+sx};
     ((LWindow*) mPane)->DoSetBounds(r);
