Index: /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.cpp
===================================================================
--- /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.cpp	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.cpp	(revision 4078)
@@ -9,5 +9,4 @@
 #include "PIContainerQuartz.h"
 
-
 /* --Methode-- */
 PIContainerQuartz::PIContainerQuartz(PIContainerGen *par, const char *nom, 
@@ -17,10 +16,8 @@
 }
 
-
 /* --Methode-- */
 PIContainerQuartz::~PIContainerQuartz()
 {
 }
-
 
 /* --Methode-- */
@@ -30,12 +27,6 @@
 
 /* --Methode-- */
-HIViewRef PIContainerQuartz::GetHIViewRef()
-{
-    return viewH;
-}
-
-/* --Methode-- */
 WindowRef PIContainerQuartz::GetWindowRef()
 {
-    return HIViewGetWindow(viewH);
+    return HIViewGetWindow(wdgHIView);
 }
Index: /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.h
===================================================================
--- /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.h	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/PIContainerQuartz.h	(revision 4078)
@@ -24,6 +24,5 @@
     virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 	
-    virtual HIViewRef GetHIViewRef();
-	virtual WindowRef GetWindowRef();
+    virtual WindowRef GetWindowRef();
 };
 
Index: /trunk/SophyaPI/PI/Quartz/PIMenuBarQuartz.cpp
===================================================================
--- /trunk/SophyaPI/PI/Quartz/PIMenuBarQuartz.cpp	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/PIMenuBarQuartz.cpp	(revision 4078)
@@ -143,5 +143,5 @@
     else
     {
-		printf("Menu Item selected %u \n", commandStruct.commandID);
+		// printf("Menu Item selected %u \n", commandStruct.commandID);
 		fflush (stdout);		
 		MainMenuBar->Dispatch(commandStruct, userData);
Index: /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.cpp
===================================================================
--- /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.cpp	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.cpp	(revision 4078)
@@ -4,5 +4,4 @@
  *
  *  Created by Bruno MANSOUX on Tue Apr 13 2004.
- *  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
  *
  */
@@ -15,23 +14,24 @@
     OSStatus err = 0;
     WindowAttributes windowAttributes;
-    
-	/*
-	wParent = ((PIContainer *)par)->GetWindowRef();
-	SetPortWindowPort(wParent);
-	*/
+	HIRect bounds;
 	
     SetRect(&wdgRect,px,py,px+sx,py+sy);
 	windowAttributes = kWindowStandardDocumentAttributes | kWindowCompositingAttribute ;
 	
-	err = CreateNewWindow (kDocumentWindowClass,windowAttributes,&wdgRect,&wRef);
+	err = CreateNewWindow (kDocumentWindowClass, windowAttributes, &wdgRect, &wRef);
 
     if (err)
         printf ("PIWindowQuartz Create Err = %d \n",err);
-    fflush (stdout);
     
     err = SetWindowTitleWithCFString (wRef, title);
 
-	viewH = HIViewGetRoot(wRef);
-    InstallStandardEventHandler(GetWindowEventTarget(wRef)); /* installs the default */
+	wdgHIView = HIViewGetRoot(wRef);
+	HIViewGetBounds (wdgHIView, &bounds);
+
+	printf("PIWindowQuartz::PIWindowQuartz Window View Bounds (%g %g) [%g %g] \n",
+											bounds.origin.x, bounds.origin.y,
+											bounds.size.width, bounds.size.height);
+
+	InstallStandardEventHandler(GetWindowEventTarget(wRef)); /* installs the default */	
 }
 
@@ -77,4 +77,5 @@
 void PIWindowQuartz::Refresh()
 {
+	printf("PIWindowQuartz::Refresh \n");
     SetPortWindowPort(wRef);
     BeginUpdate(wRef);
@@ -82,4 +83,5 @@
     DrawControls(wRef);
     DrawGrowIcon(wRef);
+	// HIViewSetNeedsDisplay(wdgHIView, true);
     EndUpdate(wRef);
     ShowWindow (wRef);
@@ -142,3 +144,2 @@
     return;
 }
-
Index: /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.h
===================================================================
--- /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.h	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/PIWindowQuartz.h	(revision 4078)
@@ -14,8 +14,5 @@
 
 #include "piwindowgen.h"
-
-/*
-EventTypeSpec windowEvents[] = {{kEventClassWindow, kEventWindowUpdate}};
-*/
+#include "pieventquartz.h"
 
 class PIWindowQuartz : public PIWindowGen
@@ -53,4 +50,5 @@
   virtual void		 CallEventHandlers(unsigned long evt, int px, int py,
                                            int k, int km, unsigned long tm);
+
 protected:
     WindowRef	wRef;
Index: /trunk/SophyaPI/PI/Quartz/QuartzAppTest.cpp
===================================================================
--- /trunk/SophyaPI/PI/Quartz/QuartzAppTest.cpp	(revision 4077)
+++ /trunk/SophyaPI/PI/Quartz/QuartzAppTest.cpp	(revision 4078)
@@ -11,13 +11,8 @@
 #include <pistdwdgquartz.h>
 #include <pigraphquartz.h>
+#include <pibwdgquartz.h>
 #include <iostream>
 
 #define NBCOTE 7
-
-void FillDatas();
-
-PIGraphicWin* pig;
-PIGrCoord* tabx;
-PIGrCoord* taby;
 
 /* ============================== */
@@ -31,4 +26,18 @@
 
 /* ============================== */
+class TstBWdg : public PIBaseWdg
+{
+public:
+	TstBWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py);
+	virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+	void SetPolygon();
+	void UnsetPolygon();
+private:
+	bool fgPolygon;
+};
+
+PIWindow* windowFirst;
+TstBWdg* twdg;
+/* ============================== */
 QuartzApp::QuartzApp()
 : PIApplication()
@@ -45,19 +54,33 @@
 void QuartzApp::Process (PIMessage msg, PIMsgHandler* sender, void * data)
 {
+  std::cout << "QuartzApp::Process " ;
+  
   switch(UserMsg(msg))    
 	{	
 		case 777:
-		std::cout << " Erase " << std::endl;
-		pig->Erase(280,60,100,50);
+		std::cout << " Pas Polygone " << std::endl;
+		windowFirst->Refresh();	
+		twdg->UnsetPolygon();
 		break;
 
 		case 2001:
 		std::cout << " Circle " << std::endl;
-		pig->DrawCircle(360,100,30);
+		// twdg->DrawCircle(360,100,30);
 		break;
 		
 		case 2002:
 		std::cout << " Polygone " << std::endl;
-		pig->DrawPolygon(tabx, taby, NBCOTE, 0);
+		twdg->SetPolygon();
+		break;
+		
+		case 2003:
+		std::cout << " Draw " << std::endl;
+		twdg->Refresh();
+		break;
+		
+		
+		case 2004:
+		std::cout << " Show " << std::endl;
+		windowFirst->Refresh();
 		break;
 		
@@ -78,6 +101,10 @@
 }
 
-
-/* ============================== */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
 int main(int argc, char *argv[])
 {
@@ -89,13 +116,11 @@
 	PIOptMenu* optMenu;  
     PIMenubar* mBar;
-    PIWindow* windowFirst;	
 	PILabel *piLabel;
     PIButton* piButton;
     vector<int> points;
 
-    /* Creation of general graphical objects */
-
     mainApp = new QuartzApp();
 
+    /* Creation of Menu and Menu Items */
     firstMenu = new PIMenu((PIWdg *)mainApp, (const char *)"File Menu");
     firstMenu->AppendItem("One from file", 1000);
@@ -106,74 +131,119 @@
 	
 	underMenu = new PIMenu((PIWdg *)firstMenu,(const char *)"submenu");
-    firstMenu->AppendCascadeMenu(underMenu,1001);
-	underMenu->AppendItem("Sub 1 from 2",1010);
-	underMenu->AppendItem("Sub 2 from 2",1011);
+    firstMenu->AppendCascadeMenu(underMenu, 1001);
+	underMenu->AppendItem("Sub 1 from 2", 1010);
+	underMenu->AppendItem("Sub 2 from 2", 1011);
 
 	figuresMenu = new PIMenu((PIWdg *)mainApp, (const char *)"Figures");
-	figuresMenu->AppendItem("Circle",2001);
-	figuresMenu->AppendItem("Polygone",2002);
-
-	printf ("Menus created \n");
-    fflush (stdout);
-	
+	figuresMenu->AppendItem("Circle", 2001);
+	figuresMenu->AppendItem("Polygone", 2002);
+	figuresMenu->AppendItem("Draw", 2003);
+	figuresMenu->AppendItem("Show", 2004);
     mBar = mainApp->Menubar();
     mBar->AppendMenu(firstMenu);
     mBar->AppendMenu(figuresMenu);
 	
-    windowFirst = new PIWindow((PIMsgHandler *)mainApp, (const char *)"Window First",PIWK_normal,600,200,50,50);
-	
-	piLabel = new PILabel(windowFirst,(const char *)"Label",80,40,150,50);
-
-	piButton = new PIButton(windowFirst, "Hello",777,60,20,80,80);
-	
-	optMenu = new PIOptMenu(windowFirst, "Opt Menu", 100,25,150,80);
+    /* Creation of Main Window */	
+    windowFirst = new PIWindow((PIMsgHandler *)mainApp, (const char *)"Window First",PIWK_normal, 700, 300, 50, 50);
+	
+    /* Creation of general graphical objects */
+	piLabel = new PILabel(windowFirst,(const char *)"Label", 80, 40, 150, 50);
+
+	piButton = new PIButton(windowFirst, "Hello", 777, 60, 20, 80, 80);
+	
+	optMenu = new PIOptMenu(windowFirst, "Opt Menu", 100, 25, 150, 80);
 	popMenu = new PIMenu((PIWdg *)optMenu, (const char *)"Pop Menu",k_PopupMenu);
-	popMenu->AppendItem("pop 1",3001);
-	popMenu->AppendItem("pop 2",3002);
+	popMenu->AppendItem("pop 1", 3001);
+	popMenu->AppendItem("pop 2", 3002);
 	mBar->AppendPopupMenu(popMenu);
-
 	optMenu->AppendPDMenu(popMenu);
 	
 	piLabel->SetLabel("Etiquette");
-
-	windowFirst->Refresh();
-	fflush (stdout);
-	
-	pig = new PIGraphicWin (windowFirst);
-	// pig->SetClipRectangle(280,60,100,50);
-
-	PIGrCoord px(300);
-	PIGrCoord py(80);
+	
+	/* Creation of graphic Context */
+	twdg = new TstBWdg(windowFirst, "Test BaseQuartz", 400, 250, 300, 50);
+	windowFirst->Show();
+	
+    mainApp->Run(); // Main loop
+
+    return 0;
+}
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+/* ============================================================================================================ */
+
+/* ============================================================================================================ */
+TstBWdg::TstBWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py)
+: PIBaseWdg(par, nom, sx, sy, px, py)
+{
+	fgPolygon = false;
+}
+
+/* ============================================================================================================ */
+void TstBWdg::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+	std::cout << "TstBWdg::Draw ";
+
+	/*
+	CGContextRef cg = ((PIGraphicWin*)g)->GetCGContext();
+	printf(" cg : %lx ", (unsigned long)cg);
+	CGAffineTransform cat = CGContextGetCTM (cg);
+	*/
+	
+	CGAffineTransform cat = ((PIGraphicWin*)g)->GetCTM();
+	std::cout << " CGAffineTransform : " << cat.a << " " << cat.b << " " << cat.c << " " ; 
+	std::cout << cat.d << " t : " << cat.tx << " " << cat.ty << endl; 
+
+	PIGrCoord px(20);
+	PIGrCoord py(30);
 	PIGrCoord len(150);
 	PIGrCoord hei(50);
-	pig->SelForeground(PI_Blue);
-	pig->DrawFBox(px, py, len, hei);
-	pig->DrawString (px, py, "Graphic Text", 1);
-
-	PIGrCoord pxfin(450);
-	PIGrCoord pyfin(130);
-	pig->SelForeground(PI_Green);	
-	pig->DrawLine (px, py, pxfin, pyfin);
+	g->SelForeground(PI_Blue);
+	g->DrawFBox(px, py, len, hei);
+	
+	px = 200 ; py = 50;
+	g->DrawString (px, py, "Graphic Text", 1);
+
+	px = 20 ; py = 150;
+	PIGrCoord pxfin(200);
+	PIGrCoord pyfin(230);
+	g->SelForeground(PI_Green);	
+	g->DrawLine (px, py, pxfin, pyfin);
 
 	PIGrCoord deltax(60);
 	PIGrCoord deltay(30);
-	pig->SelForeground(PI_Red);	
-	pig->DrawArc (px, py, deltax, deltay, 0., 90.);
-
-	FillDatas();
-	
-    mainApp->Run(); // Main loop
-
-    return 0;
-}
-
-/* ============================== */
-void FillDatas()
-{
-	tabx = new PIGrCoord[NBCOTE];
-	taby = new PIGrCoord[NBCOTE];
-	
-	tabx[0] = 80 ;	tabx[1] = 100; tabx[2] = 120;	tabx[3] = 140;	tabx[4] = 130;	tabx[5] = 110; tabx[6] = 90;
-	taby[0] = 50;	taby[1] = 60; taby[2] = 70;	taby[3] = 80;	taby[4] = 60;	taby[5] = 40; taby[6] = 20;
+	g->SelForeground(PI_Red);	
+	g->DrawArc (px, py, deltax, deltay, 0., 90.);
+
+	if (fgPolygon)
+	{
+		g->SelForeground(PI_Black);	
+
+		PIGrCoord tabx[NBCOTE];
+		PIGrCoord taby[NBCOTE];
+		std::cout << " Draw Polygon " << std::endl;
+		tabx[0] = 80 ;	tabx[1] = 100; tabx[2] = 120;	tabx[3] = 140;	tabx[4] = 130;	tabx[5] = 110; tabx[6] = 90;
+		taby[0] = 50;	taby[1] = 60; taby[2] = 70;	taby[3] = 80;	taby[4] = 60;	taby[5] = 40; taby[6] = 20;
+
+		g->DrawPolygon(tabx, taby, NBCOTE, 0);
+	}
 	return;
 }
+
+/* ============================================================================================================ */
+void TstBWdg::SetPolygon()
+{
+	fgPolygon = true;
+	Refresh();
+}
+
+/* ============================================================================================================ */
+void TstBWdg::UnsetPolygon()
+{
+	fgPolygon = false;
+	Refresh();
+}
+
