[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1302
Date       : Mon Jun 12 22:02:08 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/Makefile.am
   M /Trunk/XaraLX/Kernel/aw_eps.cpp
   M /Trunk/XaraLX/Kernel/aw_eps.h
   M /Trunk/XaraLX/Kernel/cameleps.cpp
   M /Trunk/XaraLX/Kernel/cameleps.h
   M /Trunk/XaraLX/Kernel/dialogop.cpp
   M /Trunk/XaraLX/Kernel/doccomp.cpp
   M /Trunk/XaraLX/Kernel/doccomp.h
   M /Trunk/XaraLX/Kernel/document.cpp
   M /Trunk/XaraLX/Kernel/document.h
   M /Trunk/XaraLX/Kernel/epsfiltr.cpp
   M /Trunk/XaraLX/Kernel/epsfiltr.h
   M /Trunk/XaraLX/Kernel/epssitem.cpp
   M /Trunk/XaraLX/Kernel/epssitem.h
   M /Trunk/XaraLX/Kernel/epsstack.cpp
   M /Trunk/XaraLX/Kernel/epsstack.h
   M /Trunk/XaraLX/Kernel/nativeps.cpp
   M /Trunk/XaraLX/Kernel/rndrgn.cpp
   M /Trunk/XaraLX/Kernel/rndrgn.h
   M /Trunk/XaraLX/Kernel/saveeps.cpp
   M /Trunk/XaraLX/Kernel/saveeps.h
   M /Trunk/XaraLX/Kernel/view.cpp
   M /Trunk/XaraLX/Kernel/view.h
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/camview.cpp
   M /Trunk/XaraLX/wxOil/camview.h
   M /Trunk/XaraLX/wxOil/ccdc.cpp
   M /Trunk/XaraLX/wxOil/ccdc.h
   M /Trunk/XaraLX/wxOil/dlgmgr.cpp
   M /Trunk/XaraLX/wxOil/psdc.h
   M /Trunk/XaraLX/wxOil/rendwnd.cpp
   M /Trunk/XaraLX/wxOil/rendwnd.h

Restore derivation of CCDC from something non-abstract
Restore CCPaintDC's derivation from CCDC
Remove deletion of wxDC's on idle events, and delete them with the render window and render regions
Convert EPS filters (or most of them) to be Unicode compatible
Put EPS filters in build (but don't use them just yet)


Diff:
Index: Trunk/XaraLX/Kernel/epsfiltr.h
===================================================================
--- Trunk/XaraLX/Kernel/epsfiltr.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/epsfiltr.h	(revision 1302)
@@ -137,7 +137,7 @@
 //
 // This is an arbitrary name chosen which assumes the user will never decide to
 // name a colour with this sequence of characters (reasonably safe assumption).
-#define ImmediateColourFudgeyBodgeName ("ciamcawahh42")
+#define ImmediateColourFudgeyBodgeName (_T("ciamcawahh42"))
 
 // The factor to scale standard EPS coordinates by to convert them to Camelot 
 // internal coordinates.
@@ -281,7 +281,7 @@
 {
 public:
 	EPSCommand Cmd;
-	char       CmdStr[20];
+	TCHAR       CmdStr[20];
 };
 
 /********************************************************************************************
@@ -481,7 +481,7 @@
 	// Must it export the print componets?
 	virtual BOOL NeedsPrintComponents ( void );
 
-	char *GetEPSCommand(EPSCommand Cmd);
+	TCHAR *GetEPSCommand(EPSCommand Cmd);
 
 	EPSExportDC *GetExportDC() { return ExportDCPtr; }
 	EPSRenderRegion* GetExportRegion() { return ExportRegion; }
@@ -616,7 +616,7 @@
 	CCLexFile *EPSFile;
 	
 	// Buffer to hold the current token
-	const char *TokenBuf;
+	const TCHAR *TokenBuf;
 	
 	// How many characters we had read the last time we updated the progress display.
 	INT32 LastProgressUpdate;
@@ -630,8 +630,8 @@
 		INT32		Long;
 		FIXEDPOINT	FixedPoint;
 		double		Double;
-		char   	   *String;
-		char       *Comment;
+		TCHAR   	*String;
+		TCHAR       *Comment;
 	} TokenData;
 
 	// The EPS stack - quite handy!
Index: Trunk/XaraLX/Kernel/view.h
===================================================================
--- Trunk/XaraLX/Kernel/view.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/view.h	(revision 1302)
@@ -276,6 +276,7 @@
 									BOOL fDeleteRegionAfter = TRUE,
 									BOOL bForceImmediate = FALSE) = 0;
 	virtual wxDC* GetRenderDC() = 0;
+	virtual void DoneWithDC();
 	virtual BOOL RenderTreeCallback(Node* pNode, RenderRegion* pRender) {return TRUE;}
 
 	Quality RenderQuality;						// WYSIWYG value (only freinds of Quality can
Index: Trunk/XaraLX/Kernel/saveeps.h
===================================================================
--- Trunk/XaraLX/Kernel/saveeps.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/saveeps.h	(revision 1302)
@@ -255,7 +255,7 @@
 	// Member variables.
 	BOOL			ValidPen;
 	CCLexFile		*ExportFile;
-	char			*CreatorString;
+	TCHAR			*CreatorString;
 
 	// This render regions caps. We keep a cached version here as it can be needed in rendering
 	RRCaps Caps;
Index: Trunk/XaraLX/Kernel/aw_eps.cpp
===================================================================
--- Trunk/XaraLX/Kernel/aw_eps.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/aw_eps.cpp	(revision 1302)
@@ -101,7 +101,7 @@
 #include "camtypes.h"
 #include "aw_eps.h"
 
-#include <strstrea.h>
+#include <sstream>
 #include <math.h>
 
 #include "nodepath.h"
@@ -133,79 +133,79 @@
 // This is the array of ArtWorks EPS command/keyword names.
 CommandMap ArtWorksEPSFilter::ArtWorksCommands[] =
 {
-	EPSC_aoa,		"aoa",
-	EPSC_aafs,		"aafs",
+	{ EPSC_aoa,		_T("aoa")},
+	{ EPSC_aafs,		_T("aafs")},
 	
 	// Path related procedures
-	EPSC_ar,		"ar",
-	EPSC_arr,		"arr",
-	EPSC_ae,		"ae",
-	EPSC_apl,		"apl",
-	EPSC_apc,		"apc",
-	EPSC_aof,		"aof",
+	{ EPSC_ar,		_T("ar")},
+	{ EPSC_arr,		_T("arr")},
+	{ EPSC_ae,		_T("ae")},
+	{ EPSC_apl,		_T("apl")},
+	{ EPSC_apc,		_T("apc")},
+	{ EPSC_aof,		_T("aof")},
 	
 	// Text related procedures
-	EPSC_asto,		"asto",
-	EPSC_aeto,		"aeto",
-	EPSC_aco,		"aco",
-	EPSC_atc,		"atc",
-	EPSC_atph,		"atph",
-	EPSC_atof,		"atof",
+	{ EPSC_asto,		_T("asto")},
+	{ EPSC_aeto,		_T("aeto")},
+	{ EPSC_aco,		_T("aco")},
+	{ EPSC_atc,		_T("atc")},
+	{ EPSC_atph,		_T("atph")},
+	{ EPSC_atof,		_T("atof")},
 	
 	// Blend related procedures
-	EPSC_asbd,		"asbd",
-	EPSC_aebd,		"aebd",
-	EPSC_asbr,		"asbr",
-	EPSC_aebr,		"aebr",
+	{ EPSC_asbd,		_T("asbd")},
+	{ EPSC_aebd,		_T("aebd")},
+	{ EPSC_asbr,		_T("asbr")},
+	{ EPSC_aebr,		_T("aebr")},
 	
 	// Mould related procedures
-	EPSC_asev,		"asev",
-	EPSC_aeev,		"aeev",
-	EPSC_aspr,		"aspr",
-	EPSC_aepr,		"aepr",
-	EPSC_amm,		"amm",
-	EPSC_aml,		"aml",
-	EPSC_amc,		"amc",
-	EPSC_amcp,		"amcp",
-	EPSC_amep,		"amep",
+	{ EPSC_asev,		_T("asev")},
+	{ EPSC_aeev,		_T("aeev")},
+	{ EPSC_aspr,		_T("aspr")},
+	{ EPSC_aepr,		_T("aepr")},
+	{ EPSC_amm,		_T("amm")},
+	{ EPSC_aml,		_T("aml")},
+	{ EPSC_amc,		_T("amc")},
+	{ EPSC_amcp,		_T("amcp")},
+	{ EPSC_amep,		_T("amep")},
 	
 	// Group related procedures
-	EPSC_anu,		"anu",
+	{ EPSC_anu,		_T("anu")},
 	
 	// Linear/radial fills
-	EPSC_az,		"az",
-	EPSC_ax,		"ax",
-	EPSC_axm,		"axm",
+	{ EPSC_az,		_T("az")},
+	{ EPSC_ax,		_T("ax")},
+	{ EPSC_axm,		_T("axm")},
 	
 	// Overprint related procedures
-	EPSC_axop,		"axop",
+	{ EPSC_axop,		_T("axop")},
 	
 	// Others(!)
-	EPSC_awr,		"awr",
-	EPSC_asc,		"asc",
-	EPSC_aec,		"aec",
-	EPSC_aca,		"aca",
-	EPSC_asah,		"asah",
-	EPSC_aeah,		"aeah",
-	EPSC_asat,		"asat",
-	EPSC_aeat,		"aeat",
+	{ EPSC_awr,		_T("awr")},
+	{ EPSC_asc,		_T("asc")},
+	{ EPSC_aec,		_T("aec")},
+	{ EPSC_aca,		_T("aca")},
+	{ EPSC_asah,		_T("asah")},
+	{ EPSC_aeah,		_T("aeah")},
+	{ EPSC_asat,		_T("asat")},
+	{ EPSC_aeat,		_T("aeat")},
 	
 	// Procedures that define a text object
-	EPSC_atp,		"atp",
-	EPSC_atf,		"atf",
-	EPSC_atxy,		"atxy",
-	EPSC_atrk,		"atrk",
-	EPSC_akrn,		"akrn",
+	{ EPSC_atp,		_T("atp")},
+	{ EPSC_atf,		_T("atf")},
+	{ EPSC_atxy,		_T("atxy")},
+	{ EPSC_atrk,		_T("atrk")},
+	{ EPSC_akrn,		_T("akrn")},
 	
 	// Layer procedure
-	EPSC_alyr,		"alyr",
+	{ EPSC_alyr,		_T("alyr")},
 	
 	// Sprite procedure
-	EPSC_ass,		"ass",
-	EPSC_aes,		"aes",
+	{ EPSC_ass,		_T("ass")},
+	{ EPSC_aes,		_T("aes")},
 
 	// Sentinel
-	EPSC_Invalid,	"Invalid"
+	{ EPSC_Invalid,	_T("Invalid")}
 };
 
 /********************************************************************************************
@@ -288,15 +288,17 @@
 
 INT32 ArtWorksEPSFilter::EPSHeaderIsOk(ADDR pFileHeader, UINT32 HeaderSize)
 {
+	// this function is not Unicode
+
 	// Check the first line in EPS file
-	if (camStrncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
+	if (strncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
 	{
 		// Incorrect version of EPS header line - we don't want this
 		return 0;
 	}
 
 	// !PS-Adobe line is ok - check creator line...
-	istrstream HeaderFile((char *) pFileHeader, HeaderSize);
+	std::istringstream HeaderFile((char *) pFileHeader, ios_base::in /*, HeaderSize*/);
 	char Buffer[200];
 
 	UINT32 Lines = 0;
@@ -306,11 +308,11 @@
 		Lines++;
 
 		// Return TRUE if this file was created by ArtWorks
-		if (camStrncmp(Buffer, "%%Creator: ArtWorks", 19) == 0)
+		if (strncmp(Buffer, "%%Creator: ArtWorks", 19) == 0)
 		{
 			// ArtWorks is the creator - but has it exported it in an alien format?
 			// Return 10 if it hasn't, 1 if it has.
-			if (camStrstr(Buffer, "exported") == NULL)
+			if (strstr(Buffer, "exported") == NULL)
 				return 10;
 			else
 				// 5 because it *might* be "ArtWorks (exported by Mr. Blobby)", and
@@ -320,7 +322,7 @@
 
 		// If we find the compression token then stop the search as we don't want to start
 		// looking in the compressed data!
-		if (camStrncmp(Buffer, "%%Compression:", 14)==0)
+		if (strncmp(Buffer, "%%Compression:", 14)==0)
 			break;
 	}
 
@@ -385,7 +387,7 @@
 			return FALSE;
 
 		// Attach to the right device.
-		ExportRegion->AttachDevice(DocView::GetSelected(), ExportDCPtr, pSpread);
+		ExportRegion->AttachDevice(DocView::GetSelected(), ExportDCPtr->GetDC(), pSpread);
 	}
 
 	// All ok
@@ -955,7 +957,7 @@
 
 /********************************************************************************************
 
->	char *ArtWorksEPSFilter::GetEPSCommand(EPSCommand Cmd)
+>	TCHAR *ArtWorksEPSFilter::GetEPSCommand(EPSCommand Cmd)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	28/02/94
@@ -966,7 +968,7 @@
 
 ********************************************************************************************/
 
-char *ArtWorksEPSFilter::GetEPSCommand(EPSCommand Cmd)
+TCHAR *ArtWorksEPSFilter::GetEPSCommand(EPSCommand Cmd)
 {
 	INT32 i = 0;
 	while (ArtWorksCommands[i].Cmd != EPSC_Invalid)
@@ -1519,7 +1521,7 @@
 {
 	// Sanity check
 	ERROR3IF(!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeMouldGroup)), "No mouldgroup in ArtWorksEPSFilter::EndMould");
-	NodeMouldGroup* pNodeMGroup = (NodeMouldGroup*)pNode;
+//	NodeMouldGroup* pNodeMGroup = (NodeMouldGroup*)pNode;
 	pNode = pNode->FindParent();
 	ERROR3IF(!pNode->IsKindOf(CC_RUNTIME_CLASS(NodeMould)), "No MouldParent in ArtWorksEPSFilter::EndMould");
 	NodeMould* pNodeMould = (NodeMould*)pNode;
@@ -2258,7 +2260,7 @@
 												 FIXED16 ViewScale) 
 	: EPSRenderRegion(ClipRect, ConvertMatrix, ViewScale)
 {
-	CreatorString = "ArtWorks";
+	CreatorString = _T("ArtWorks");
 }
 
 
@@ -2323,11 +2325,11 @@
 		// Output the fill type
 		if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(LinearFillAttribute)))
 		{
-			pDC->OutputToken("1");
+			pDC->OutputToken(_T("1"));
 		}
 		else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(RadialFillAttribute)))
 		{
-			pDC->OutputToken("2");
+			pDC->OutputToken(_T("2"));
 		}
 		else
 		{
@@ -2348,7 +2350,7 @@
 		pDC->OutputCoord(pGradFillAttr->EndPoint);
 
 		// Output the grad fill token
-		pDC->OutputToken("ax");
+		pDC->OutputToken(_T("ax"));
 		pDC->OutputNewLine();
 	}
 
@@ -2361,15 +2363,15 @@
 		{
 			case NonZeroWinding:
 				// Change winding rule to 0, which means non-zero in ArtWorks EPS.
-				pDC->OutputToken("0");
-				pDC->OutputToken("awr");
+				pDC->OutputToken(_T("0"));
+				pDC->OutputToken(_T("awr"));
 				pDC->OutputNewLine();
 				break;
 
 			case EvenOddWinding:
 				// Change winding rule to 1, which means even-odd in ArtWorks EPS.
-				pDC->OutputToken("1");
-				pDC->OutputToken("awr");
+				pDC->OutputToken(_T("1"));
+				pDC->OutputToken(_T("awr"));
 				pDC->OutputNewLine();
 				break;
 
@@ -2410,25 +2412,25 @@
 	const double	Scale			= 25.4 / 72000.0;
 
 	// Cast a pointer to the appropriate DC.
-	KernelDC		*pDC			= static_cast<KernelDC*> ( RenderDC );
+	KernelDC		*pDC			= static_cast<KernelDC*> ( CCDC::ConvertFromNativeDC(RenderDC) );
 	DocRect			PageBounds		= RenderSpread->GetPageBounds ();
 	DocRect			DrawingBounds	= RenderSpread->GetDrawingSize ();
 	TCHAR			Buffer [256];
 
 	// Set up the output buffer.
-	_stprintf( Buffer, "%gmm %gmm",
+	camSnprintf( Buffer, 256, _T("%gmm %gmm"),
 			   static_cast<double> ( PageBounds.Width () )  * Scale,
 			   static_cast<double> ( PageBounds.Height () ) * Scale );
 
 	// Output the page size data.
-	pDC->OutputToken	("%%DocumentPageSize:");
+	pDC->OutputToken	(_T("%%DocumentPageSize:"));
 	pDC->OutputToken	( Buffer );
 	pDC->OutputNewLine	();
 
 	// Write the AW bounding box out. I'm doing this manually because ArtWorks runs at a
 	// higher resolution than standard EPS files. This way I get an extra two decimal
 	// places of accuracy.
-	pDC->OutputToken	( "%%BoundingBox:" );
+	pDC->OutputToken	( _T("%%BoundingBox:") );
 	pDC->OutputCoord	( DrawingBounds.lo, ACCURACY_NORMAL );
 	pDC->OutputCoord	( DrawingBounds.hi, ACCURACY_NORMAL );
 	pDC->OutputNewLine	();
@@ -2454,12 +2456,12 @@
 BOOL ArtWorksEPSRenderRegion::WriteEPSTrailerComments ( void )
 {
 	// Get a pointer to the kernel DC.
-	KernelDC	*pDC	= static_cast<KernelDC*> ( RenderDC );
+	KernelDC	*pDC	= static_cast<KernelDC*> ( CCDC::ConvertFromNativeDC(RenderDC) );
 
 	// Write out the trailer comments.
-	pDC->OutputToken	( "%%Trailer" );
+	pDC->OutputToken	( _T("%%Trailer") );
 	pDC->OutputNewLine	();
-	pDC->OutputToken	( "showpage" );
+	pDC->OutputToken	( _T("showpage") );
 	pDC->OutputNewLine	();
 
 	// Success.
Index: Trunk/XaraLX/Kernel/Makefile.am
===================================================================
--- Trunk/XaraLX/Kernel/Makefile.am	(revision 1301)
+++ Trunk/XaraLX/Kernel/Makefile.am	(revision 1302)
@@ -69,6 +69,8 @@
 	xpfcaps.cpp xpfilter.cpp xpfrgn.cpp layerprp.cpp prpsgds.cpp prpslyrs.cpp \
 	aprps.cpp prevwdlg.cpp frameops.cpp newcol.cpp tracedlg.cpp tracectl.cpp \
 	tracergn.cpp bfxbase.cpp coldlog.cpp colmenu.cpp sgline.cpp sgline2.cpp \
-	sgstroke.cpp sgbrush.cpp lattrops.cpp la_base.cpp maskedrr.cpp
+	sgstroke.cpp sgbrush.cpp lattrops.cpp la_base.cpp maskedrr.cpp  \
+	cameleps.cpp epscdef.cpp epsclist.cpp epssitem.cpp epsstack.cpp \
+	nativeps.cpp epsfiltr.cpp aw_eps.cpp saveeps.cpp
 
 AM_CXXFLAGS = $(XARAFLAGS)
Index: Trunk/XaraLX/Kernel/rndrgn.cpp
===================================================================
--- Trunk/XaraLX/Kernel/rndrgn.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/rndrgn.cpp	(revision 1302)
@@ -659,6 +659,11 @@
 		pCapture = GetTopCapture();
 	}
 
+	if (RenderView)
+	{
+		RenderView->DoneWithDC(); // hint that we might like to drop this DC so a fresh one will be created
+	}
+	
 	if( m_fOwned )
 	{
 		delete RenderDC;
@@ -851,6 +856,12 @@
 
 ********************************************************************************************/
 
+BOOL RenderRegion::AttachDevice(View* ViewToAttach, CCDC* DCToAttach,
+								Spread* SpreadToAttach, bool fOwned /*= false*/)
+{
+	return AttachDevice(ViewToAttach, DCToAttach->GetDC(), SpreadToAttach, fOwned);
+}
+
 BOOL RenderRegion::AttachDevice(View* ViewToAttach, wxDC* DCToAttach,
 								Spread* SpreadToAttach, bool fOwned /*= false*/)
 {
Index: Trunk/XaraLX/Kernel/saveeps.cpp
===================================================================
--- Trunk/XaraLX/Kernel/saveeps.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/saveeps.cpp	(revision 1302)
@@ -158,7 +158,7 @@
 	VectorFileRenderRegion(ClipRect, ConvertMatrix, ViewScale)
 {
 	ValidPen = FALSE;
-	CreatorString = "Adobe Illustrator 3.0 (exported by Camelot)";
+	CreatorString = _T("Adobe Illustrator 3.0 (exported by Camelot)");
 
 	ExportFile = NULL;
 	m_bValidPathAttrs = TRUE;
@@ -209,7 +209,7 @@
 
 ********************************************************************************************/
 
-BOOL EPSRenderRegion::AttachDevice(View* pView, CDC* pDC, Spread* pSpread)
+BOOL EPSRenderRegion::AttachDevice(View* pView, CNativeDC* pDC, Spread* pSpread, bool /*fOwned = false*/)
 {
 	// Sanity checks
 //	ENSURE(pView == NULL, "Bad window pointer in EPSRenderRegion::AttachDevice");
@@ -254,7 +254,7 @@
 	GetRenderRegionCaps(&Caps);
 
 	// Buffer used to build up the %%For and %%CreationDate comments.
-	char buf[300];
+	TCHAR buf[300];
 
 	// Find out which document we're using
 	ENSURE(RenderView->GetDoc() != NULL, "View's document is NULL!");
@@ -266,7 +266,7 @@
 	WriteEPSVersion ();
 
 	// Name of program that created this file.
-	pDC->OutputToken	( "%%Creator:" );
+	pDC->OutputToken	( _T("%%Creator:") );
 	pDC->OutputToken	( CreatorString );
 	pDC->OutputNewLine	();
 	
@@ -274,13 +274,13 @@
 	WriteFileVersion ( pDC );
 
 	// Output the %%For comment
-	_stprintf(buf, "%%%%For: (%s) (%s)", ReleaseInfo::GetLicensee(), ReleaseInfo::GetCompany());
+	camSprintf(buf, _T("%%%%For: (%s) (%s)"), ReleaseInfo::GetLicensee(), ReleaseInfo::GetCompany());
 	pDC->OutputToken(buf);
 	pDC->OutputNewLine();
 
 	// The title of the picture
    	String_256 DocumentTitle = TheDocument->GetTitle();
-	_stprintf(buf, "%%%%Title: (%s)", (TCHAR *) DocumentTitle);
+	camSprintf(buf, _T("%%%%Title: (%s)"), (TCHAR *) DocumentTitle);
 	pDC->OutputToken(buf);
 	pDC->OutputNewLine();
 
@@ -288,7 +288,18 @@
 	time_t Now;
 	time(&Now);
 	struct tm *pNow = localtime(&Now);
+#if 1
+	char buf2[100];
+	strftime(buf2, 100, "%%%%CreationDate: (%d/%m/%y) (%I:%M %p)", pNow);
+	INT32 i;
+	while (buf2[i])
+	{
+		buf[i]=buf2[i]; // 1:1 char/TCHAR conversion
+	}
+
+#else
 	_tcsftime(buf, 100, "%%%%CreationDate: (%d/%m/%y) (%I:%M %p)", pNow);
+#endif
 	pDC->OutputToken(buf);
 	pDC->OutputNewLine();
 
@@ -331,11 +342,11 @@
 	}
 
 	// No more comments
-	pDC->OutputToken	( "%%EndComments" );
+	pDC->OutputToken	( _T("%%EndComments") );
 	pDC->OutputNewLine	();
 
 	// Do the prolog...
-	pDC->OutputToken	( "%%BeginProlog" );
+	pDC->OutputToken	( _T("%%BeginProlog") );
 	pDC->OutputNewLine	();
 
 	// Do the render region specific prolog.
@@ -355,11 +366,11 @@
 		pComponent = TheDocument->EnumerateDocComponents(pComponent);
 	}
 
-	pDC->OutputToken("%%EndProlog");
+	pDC->OutputToken(_T("%%EndProlog"));
 	pDC->OutputNewLine();
 
 	// Do the setup...
-	pDC->OutputToken("%%BeginSetup");
+	pDC->OutputToken(_T("%%BeginSetup"));
 	pDC->OutputNewLine();
 
 	// Do the render region specific setup.
@@ -384,7 +395,7 @@
 	WriteGradientFills ( TheDocument );
 
 	// Wrap up the header section
-	pDC->OutputToken("%%EndSetup");
+	pDC->OutputToken(_T("%%EndSetup"));
 	pDC->OutputNewLine();
 
 	// We are into the main script of the EPS file here, so give the
@@ -474,8 +485,8 @@
 
 	Author:		Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	19/3/95
-	Inputs:		ch      - unicode value of char
-				pMatrix - matrix specifying transforms to place char correctly in document
+	Inputs:		ch      - unicode value of TCHAR
+				pMatrix - matrix specifying transforms to place TCHAR correctly in document
 	Returns:	FALSE if fails
 	Purpose:	
 ********************************************************************************************/
@@ -498,18 +509,18 @@
 // BODGE TEXT - need to account for unicode!
 	KernelDC *pDC = (KernelDC *) RenderDC;
 
-	char Buf[64];
+	TCHAR Buf[64];
 
-	wsprintf(Buf,"%c",ch);
+	camSprintf(Buf,_T("%c"),ch);
 
 	pDC->OutputString(Buf);
-	pDC->OutputToken("Tx");
+	pDC->OutputToken(_T("Tx"));
 	pDC->OutputNewLine();
 
 #else
 	// just do what RenderRegion::RenderChar() would do!
 
-	// create the char's path
+	// create the TCHAR's path
 	Path* pCharPath=CreateCharPath(ch,pMatrix);
 	if (pCharPath==NULL)
 		return FALSE;
@@ -540,15 +551,15 @@
 
 BOOL EPSRenderRegion::WriteNewLine ( void )
 {
-	EPSExportDC	*pDC	= static_cast<EPSExportDC*> ( RenderDC );
+	EPSExportDC	*pDC	= static_cast<EPSExportDC*> ( CCDC::ConvertFromNativeDC(RenderDC) );
 
 	// Check for changed attributes.
 	GetValidPathAttributes ();
 	GetValidTextAttributes ();
 
 	// Output the tokens
-	pDC->OutputToken	( "(\r)" );
-	pDC->OutputToken	( "TX" );
+	pDC->OutputToken	( _T("(\r)") );
+	pDC->OutputToken	( _T("TX") );
 	pDC->OutputNewLine	();
 
 	return TRUE;
@@ -573,7 +584,7 @@
 
 	String_64 FontName;
 	String_64 EncodedFontName;
-	String_64 Append("/_");
+	String_64 Append(_T("/_"));
 
 	// get information about the current font
 	FONTMANAGER->GetFontName(RR_TXTFONTTYPEFACE(), FontName);
@@ -582,7 +593,7 @@
 	// appears to map an existing, encoded font name onto its Postscript counterpart.
 	FONTMANAGER->EncodeAndMapFontName(FontName, EncodedFontName, GetFontStyle());
 	
-	EncodedFontName.Insert(&Append,0);
+	EncodedFontName.Insert(Append,0);
 	pDC->OutputToken((TCHAR *)EncodedFontName);
 
 	// Output the fontsize next
@@ -590,7 +601,7 @@
 	pDC->OutputFloat(PointSize,3);
 	
 	// finally do output the font token
-	pDC->OutputToken("Tf");
+	pDC->OutputToken(_T("Tf"));
 	pDC->OutputNewLine();
 }
 
@@ -753,16 +764,16 @@
 
 	switch (Style)
 	{
-		case 0: pDC->OutputToken("3 Tr");		// Invisible
+		case 0: pDC->OutputToken(_T("3 Tr"));		// Invisible
 				pDC->OutputNewLine();
 				break;
-		case 1: pDC->OutputToken("0 Tr");		// filled only
+		case 1: pDC->OutputToken(_T("0 Tr"));		// filled only
 				pDC->OutputNewLine();
 				break;
-		case 2: pDC->OutputToken("1 Tr");		// stroked only
+		case 2: pDC->OutputToken(_T("1 Tr"));		// stroked only
 				pDC->OutputNewLine();
 				break;
-		case 3: pDC->OutputToken("2 Tr");		// filled and stroked
+		case 3: pDC->OutputToken(_T("2 Tr"));		// filled and stroked
 				pDC->OutputNewLine();
 				break;
 	}
@@ -785,7 +796,7 @@
 	KernelDC *pDC = (KernelDC *) RenderDC;
 
    	pDC->OutputReal(RR_TXTASPECTRATIO().MakeDouble()*100.0);	// convert from ratio to %
-   	pDC->OutputToken("Tz");
+   	pDC->OutputToken(_T("Tz"));
 	pDC->OutputNewLine();
 }
 
@@ -809,7 +820,7 @@
 	// 1 em = point size of font.
 	// Tracking internally =millipoints.
    	pDC->OutputValue(RR_TXTTRACKING());
-   	pDC->OutputToken("Tt");
+   	pDC->OutputToken(_T("Tt"));
 	pDC->OutputNewLine();
 }
 
@@ -845,7 +856,7 @@
    		pDC->OutputValue((INT32)3);
 		break;
 	}
-   	pDC->OutputToken("Ta");
+   	pDC->OutputToken(_T("Ta"));
 	pDC->OutputNewLine();
 }
 
@@ -897,7 +908,7 @@
 
 	pDC->OutputReal(ptLineSpace);
 	pDC->OutputReal(ptParaSpace);
-	pDC->OutputToken("Tl");
+	pDC->OutputToken(_T("Tl"));
 	pDC->OutputNewLine();
 }
 
@@ -920,7 +931,7 @@
 	// format = rise Ts
 	double BaseLine = ((double)RR_TXTBASELINE())/1000;
 	pDC->OutputFloat(BaseLine,3);
-	pDC->OutputToken("Ts");
+	pDC->OutputToken(_T("Ts"));
 	pDC->OutputNewLine();
 }
 
@@ -946,19 +957,19 @@
 	double offset = (pScript->Offset).MakeDouble();
 	double size = (pScript->Size).MakeDouble();
 
-	pDC->OutputToken("%%XSScript");
+	pDC->OutputToken(_T("%%XSScript"));
 	pDC->OutputNewLine();
 
 	double rise = FontSize*offset;
 
 	pDC->OutputFloat(rise,3);
-	pDC->OutputToken("Ts");
+	pDC->OutputToken(_T("Ts"));
 	pDC->OutputNewLine();
 
 	double ptsize = FontSize*size;
 
 	String_64 MappedFont;
-	String_64 Append("/_");
+	String_64 Append(_T("/_"));
 
 	String_64 FontName;
 	FONTMANAGER->GetFontName(RR_TXTFONTTYPEFACE(), FontName);
@@ -968,12 +979,12 @@
 
 	// Graeme (14-6-00) - I should add ascent and descent values, but Camelot doesn't
 	// seem to store them anywhere.
-	MappedFont.Insert(&Append,0);
+	MappedFont.Insert(Append,0);
 	pDC->OutputToken((TCHAR *)MappedFont);
 	pDC->OutputFloat(ptsize,3);
 	// Output the ascent.
 	// Output the descent.
-	pDC->OutputToken("Tf");
+	pDC->OutputToken(_T("Tf"));
 	pDC->OutputNewLine();
 }
 
@@ -1079,7 +1090,7 @@
 
 	// Set line width
 	pDC->OutputUserSpaceValue(RR_LINEWIDTH());
-	pDC->OutputToken("w");
+	pDC->OutputToken(_T("w"));
 	pDC->OutputNewLine();
 }
 
@@ -1100,7 +1111,7 @@
 
 	// Set line Join Type
 	pDC->OutputValue((UINT32)RR_JOINTYPE());
-	pDC->OutputToken("j");
+	pDC->OutputToken(_T("j"));
 	pDC->OutputNewLine();
 }
 
@@ -1167,7 +1178,7 @@
 	// If the dash patterns need scaling, then we need to scale them
 	// here, as Illustrator format uses absolute sizes for the dash
 	// patterns, rather than the 'relative to line width' that we use
-	INT32 DashLineWidth 	= RR_DASHPATTERN().LineWidth;
+//	INT32 DashLineWidth 	= RR_DASHPATTERN().LineWidth;
 	INT32 LineWidth 		= RR_LINEWIDTH();
 
 	BOOL DoScale = RR_DASHPATTERN().ScaleWithLineWidth;
@@ -1210,7 +1221,7 @@
 	INT32 Offset = LongMulFixed16(RR_DASHPATTERN().DashStart, Scale);
 	pDC->OutputUserSpaceValue(Offset);
 
-	pDC->OutputToken("d");
+	pDC->OutputToken(_T("d"));
 	pDC->OutputNewLine();
 }
 
@@ -1231,7 +1242,7 @@
 
 	// Set line cap style
 	pDC->OutputValue((UINT32)RR_STARTCAP());
-	pDC->OutputToken("J");
+	pDC->OutputToken(_T("J"));
 	pDC->OutputNewLine();
 }
 
@@ -1248,7 +1259,7 @@
 
 void EPSRenderRegion::OutputMitreLimit()
 {
-	KernelDC *pDC = (KernelDC *) RenderDC;
+//	KernelDC *pDC = (KernelDC *) RenderDC;
 
 		// Set mitre limit
 
@@ -1325,14 +1336,14 @@
 		if (RR_STROKECOLOUR().FindParentIndexedColour() == NULL)
 		{
 			// Unnamed colour - just add 'K' token
-			pDC->OutputToken("K");
+			pDC->OutputToken(_T("K"));
 		}
 		else
 		{
 			// Named colour - add Name, tint value, and 'X' token
 			pDC->OutputColourName(&(RR_STROKECOLOUR()));
-			pDC->OutputValue(0l);
-			pDC->OutputToken("X");
+			pDC->OutputValue((INT32)0);
+			pDC->OutputToken(_T("X"));
 		}
 	}
 	else
@@ -1344,13 +1355,13 @@
 			RR_STROKECOLOUR().GetCMYKValue(pContext, &CMYK);
 			BYTE c = 0xFF - CMYK.Key;
 			pDC->OutputColourValue(c);
-			pDC->OutputToken("G");
+			pDC->OutputToken(_T("G"));
 		}
 		else
 		{
 			RR_STROKECOLOUR().GetCMYKValue(pContext, &CMYK);
 			pDC->OutputColour(&CMYK);
-			pDC->OutputToken("X");
+			pDC->OutputToken(_T("X"));
 		}
 	}
 
@@ -1402,15 +1413,15 @@
 		if (RR_STROKECOLOUR().FindParentIndexedColour() == NULL)
 		{
 			// Unnamed colour - just add 'XA' token
-			pDC->OutputToken ("XA");
+			pDC->OutputToken (_T("XA"));
 		}
 		else
 		{
 			// Named colour - add Name, tint value, RGB flag and 'XX' token
 			pDC->OutputColourName (&(RR_STROKECOLOUR()));
-			pDC->OutputValue(0l);
-			pDC->OutputValue(1l);
-			pDC->OutputToken("XX");
+			pDC->OutputValue((INT32)0);
+			pDC->OutputValue((INT32)1);
+			pDC->OutputToken(_T("XX"));
 		}
 	}
 	else
@@ -1424,13 +1435,13 @@
 			RR_STROKECOLOUR().GetCMYKValue(pContext, &CMYK);
 			BYTE c = 0xFF - CMYK.Key;
 			pDC->OutputColourValue(c);
-			pDC->OutputToken("G");
+			pDC->OutputToken(_T("G"));
 		}
 		else
 		{
 			RR_STROKECOLOUR().GetCMYKValue(pContext, &CMYK);
 			pDC->OutputColour(&CMYK);
-			pDC->OutputToken("X");
+			pDC->OutputToken(_T("X"));
 		}
 	}
 
@@ -1500,14 +1511,14 @@
 		if (RR_FILLCOLOUR().FindParentIndexedColour() == NULL)
 		{
 			// Unnamed colour - add 'k' token
-			pDC->OutputToken("k");
+			pDC->OutputToken(_T("k"));
 		}
 		else
 		{
 			// Named colour - add Name, tint and 'x' token
 			pDC->OutputColourName(&(RR_FILLCOLOUR()));
-			pDC->OutputValue(0l);
-			pDC->OutputToken("x");
+			pDC->OutputValue((INT32)0);
+			pDC->OutputToken(_T("x"));
 		}
 	}
 	else
@@ -1519,13 +1530,13 @@
 			RR_FILLCOLOUR().GetCMYKValue(pContext, &CMYK);
 			BYTE c = 0xFF - CMYK.Key;
 			pDC->OutputColourValue(c);
-			pDC->OutputToken("g");
+			pDC->OutputToken(_T("g"));
 		}
 		else
 		{
 			RR_FILLCOLOUR().GetCMYKValue(pContext, &CMYK);
 			pDC->OutputColour(&CMYK);
-			pDC->OutputToken("k");
+			pDC->OutputToken(_T("k"));
 		}
 	}
 
@@ -1572,15 +1583,15 @@
 		if (RR_FILLCOLOUR().FindParentIndexedColour() == NULL)
 		{
 			// Unnamed colour - add 'Xa' token
-			pDC->OutputToken("Xa");
+			pDC->OutputToken(_T("Xa"));
 		}
 		else
 		{
 			// Named colour - add Name, tint, RGB flag and 'Xx' token
 			pDC->OutputColourName(&(RR_FILLCOLOUR()));
-			pDC->OutputValue(0l);
-			pDC->OutputValue(1l);
-			pDC->OutputToken("Xx");
+			pDC->OutputValue((INT32)0);
+			pDC->OutputValue((INT32)1);
+			pDC->OutputToken(_T("Xx"));
 		}
 	}
 	else
@@ -1592,13 +1603,13 @@
 			RR_FILLCOLOUR().GetCMYKValue(pContext, &CMYK);
 			BYTE c = 0xFF - CMYK.Key;
 			pDC->OutputColourValue(c);
-			pDC->OutputToken("g");
+			pDC->OutputToken(_T("g"));
 		}
 		else
 		{
 			RR_FILLCOLOUR().GetCMYKValue(pContext, &CMYK);
 			pDC->OutputColour(&CMYK);
-			pDC->OutputToken("k");
+			pDC->OutputToken(_T("k"));
 		}
 	}
 
@@ -1755,13 +1766,13 @@
 	if (CompoundPath && !PureDataOnly)
 	{
 		// Bracket compound paths./
-		pDC->OutputToken("*u");
+		pDC->OutputToken(_T("*u"));
 		pDC->OutputNewLine();
 	}
 
 	// Work out how to render the path (stroke, fill, both, none, etc.)
-	char PathTypeOpen[2] = "N";
-	char PathTypeClosed[2];
+	TCHAR PathTypeOpen[2] = _T("N");
+	TCHAR PathTypeClosed[2];
 
 	// Work out if the path is filled.
 	BOOL IsFilled = TRUE;
@@ -1807,7 +1818,7 @@
 	while(ReadPos < NumCoords)
 	{
 		// Find out the type of element that we are over (after the close flag has been removed)
-		Coord P[4];
+//		Coord P[4];
 		switch ( (Verbs[ReadPos]) & (~PT_CLOSEFIGURE) )
 		{
 			case PT_MOVETO:
@@ -1879,7 +1890,7 @@
 	if (CompoundPath && !PureDataOnly)
 	{
 		// End compound path
-		pDC->OutputToken("*U");
+		pDC->OutputToken(_T("*U"));
 		pDC->OutputNewLine();
 	}
 }
@@ -2147,10 +2158,10 @@
 BOOL EPSRenderRegion::WriteEPSVersion ( void )
 {
 	// Cast a pointer to the appropriate DC.
-	KernelDC *pDC = static_cast<KernelDC*> ( RenderDC );
+	KernelDC *pDC = static_cast<KernelDC*> ( CCDC::ConvertFromNativeDC(RenderDC) );
 
 	// Output the standard EPS header start token.
-	pDC->OutputToken	( "%!PS-Adobe-2.0 EPSF-1.2" );
+	pDC->OutputToken	( _T("%!PS-Adobe-2.0 EPSF-1.2") );
 	pDC->OutputNewLine	();
 
 	// Success.
@@ -2174,7 +2185,7 @@
 BOOL EPSRenderRegion::WriteEPSBoundingBox ( void )
 {
 	// Cast a pointer to the appropriate DC.
-	KernelDC	*pDC	= static_cast<KernelDC*> ( RenderDC );
+	KernelDC	*pDC	= static_cast<KernelDC*> ( CCDC::ConvertFromNativeDC(RenderDC) );
 	DocRect		BBox	= RenderSpread->GetBoundingRect ();
 
 	// Bounding box type stuff - get the spread's bounding box and convert from DocCoords
@@ -2182,7 +2193,7 @@
 	RenderSpread->DocCoordToSpreadCoord(&BBox);
 
 	// Write the bounding box to the file.
-	pDC->OutputToken	( "%%BoundingBox:" );
+	pDC->OutputToken	( _T("%%BoundingBox:") );
 	pDC->OutputCoord	( BBox.lo, ACCURACY_ROUNDDOWN );
 	pDC->OutputCoord	( BBox.hi, ACCURACY_ROUNDUP );
 	pDC->OutputNewLine	();
@@ -2275,7 +2286,7 @@
 BOOL EPSRenderRegion::WriteEPSTrailerComments ( void )
 {
 	// Get a pointer to the kernel DC.
-	KernelDC	*pDC		= static_cast<KernelDC*>	( RenderDC );
+	KernelDC	*pDC		= static_cast<KernelDC*>	( CCDC::ConvertFromNativeDC(RenderDC) );
 	EPSExportDC	*pExportDC	= static_cast<EPSExportDC*>	( pDC );
 	EPSFilter	*pFilter	= static_cast<EPSFilter *>	( pExportDC->GetParentFilter () );
 	Document	*pDocument	= RenderView->GetDoc ();
@@ -2283,11 +2294,11 @@
 	ENSURE ( pDocument != NULL, "View's document is NULL!" );
 
 	// Write out the page trailer.
-	pDC->OutputToken	( "%%PageTrailer" );
+	pDC->OutputToken	( _T("%%PageTrailer") );
 	pDC->OutputNewLine	();
-	pDC->OutputToken	( "showpage" );
+	pDC->OutputToken	( _T("showpage") );
 	pDC->OutputNewLine	();
-	pDC->OutputToken	( "%%Trailer" );
+	pDC->OutputToken	( _T("%%Trailer") );
 	pDC->OutputNewLine	();
 
 	// Write out the Documents trailer comments
@@ -2297,7 +2308,7 @@
 	WriteEndCompressionState ( pDC );
 
 	// End of file token.
-	pDC->OutputToken	( "%%EOF" );
+	pDC->OutputToken	( _T("%%EOF") );
 	pDC->OutputNewLine	();
 
 	// Success!
@@ -2641,7 +2652,7 @@
 BOOL EPSExportDC::OutputNewLine()
 {
 	// Graeme (22-2-00) - Windows uses 
 as the newline code in its files.
-	static char NewLine[] = "
";
+	static TCHAR NewLine[] = _T("
");
 	if (ExportFile->write(NewLine, 2).fail())
 		// Error occured
 		return FALSE;
@@ -2682,7 +2693,7 @@
 BOOL EPSExportDC::OutputToken(TCHAR *Str)
 {
 	// Special tokens
-	static char Space = ' ';
+	static TCHAR Space = ' ';
 
 	if (LineWidth > 100)
 	{
Index: Trunk/XaraLX/Kernel/epssitem.h
===================================================================
--- Trunk/XaraLX/Kernel/epssitem.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/epssitem.h	(revision 1302)
@@ -109,7 +109,7 @@
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	13/10/93
 	Purpose:	This class provides objects that make up an EPSStack object.  The object
-				is polymorphic, and can contain either a INT32, a double, or a char* string
+				is polymorphic, and can contain either a INT32, a double, or a TCHAR* string
 				object.
 	SeeAlso:	EPSStack
 
@@ -126,7 +126,7 @@
 	void Init ( INT32 );
 	void Init ( FIXEDPOINT );
 	void Init ( double );
-	void Init ( char *Str, BOOL IsName = FALSE );
+	void Init ( TCHAR *Str, BOOL IsName = FALSE );
 	void Init ( EPSCommand );
 	
 	union
@@ -134,7 +134,7 @@
 		INT32		Long;
 		FIXEDPOINT	FixedPoint;
 		double		Double;
-		char		*pString;
+		TCHAR		*pString;
 		EPSCommand	Cmd;
 	} Data;
 
Index: Trunk/XaraLX/Kernel/doccomp.cpp
===================================================================
--- Trunk/XaraLX/Kernel/doccomp.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/doccomp.cpp	(revision 1302)
@@ -475,7 +475,7 @@
 /********************************************************************************************
 
 >	ProcessEPSResult DocComponent::ProcessEPSComment(EPSFilter *pFilter, 
-													 const char *pComment)
+													 const THCAR *pComment)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	01/08/94
@@ -514,7 +514,7 @@
 ********************************************************************************************/
 
 ProcessEPSResult DocComponent::ProcessEPSComment(EPSFilter *pFilter, 
-												 const char *pComment)
+												 const TCHAR *pComment)
 {
 	return EPSCommentUnknown;
 }
Index: Trunk/XaraLX/Kernel/view.cpp
===================================================================
--- Trunk/XaraLX/Kernel/view.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/view.cpp	(revision 1302)
@@ -102,7 +102,7 @@
 */
 
 #include "camtypes.h"
-
+#include "camview.h"
 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
 #include "vstate.h"
 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
@@ -220,6 +220,8 @@
 
 View::~View()
 {
+	DoneWithDC();
+	
 	if (this == Current)
 		SetNoCurrent();
 
@@ -245,8 +247,25 @@
 	}
 }
 
+/********************************************************************************************
 
+>	void View::DoneWithDC()
 
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	12/06/2006
+	Purpose:	Hints that we've done with our DC
+	SeeAlso:	View; PaperRenderRegion.
+
+Note this is merely a hint. This routine is not guaranteed to eb called
+
+********************************************************************************************/
+
+void View::DoneWithDC()
+{
+	if (pViewWindow)
+		pViewWindow->DoneWithDC();
+}
+
 /********************************************************************************************
 
 >	void View::Deinit()
@@ -3579,7 +3598,7 @@
 	{
 		// Attach a device to the scanning render region
 		// Since this rr does no real rendering, it does not need a Device context
-		Scanner.AttachDevice(this, NULL, pSpread);
+		Scanner.AttachDevice(this, (CNativeDC *)NULL, pSpread);
 
 		// Get it ready to render
 		Scanner.SetMatrix(ViewTrans);
Index: Trunk/XaraLX/Kernel/document.h
===================================================================
--- Trunk/XaraLX/Kernel/document.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/document.h	(revision 1302)
@@ -564,7 +564,7 @@
 	virtual BOOL WriteEPSFonts(EPSFilter *);
 	virtual BOOL WriteEPSComments(EPSFilter *);
 	virtual BOOL WriteEPSTrailer(EPSFilter *);
-	virtual ProcessEPSResult ProcessEPSComment(EPSFilter *, const char *);
+	virtual ProcessEPSResult ProcessEPSComment(EPSFilter *, const TCHAR *);
 	virtual void EndOfEPSComment(EPSFilter *);
 
 	// More general function to control progress display.
Index: Trunk/XaraLX/Kernel/epssitem.cpp
===================================================================
--- Trunk/XaraLX/Kernel/epssitem.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/epssitem.cpp	(revision 1302)
@@ -191,19 +191,19 @@
 
 /********************************************************************************************
 
->	void EPSStackItem::Init(char *pString, BOOL IsName = FALSE)
+>	void EPSStackItem::Init(TCHAR *pString, BOOL IsName = FALSE)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	13/10/93
 	Inputs:		pString -  pointer to the data to put into the stack item.
 				IsName - this is true if the string is a PostScript name object, and FALSE
 				if it is a PostScript string object.
-	Purpose:	Initialise an EPSStackItem object to hold a char * string.  
+	Purpose:	Initialise an EPSStackItem object to hold a TCHAR * string.  
 				The string is copied.
 
 ********************************************************************************************/
 
-void EPSStackItem::Init(char *pString, BOOL IsName)
+void EPSStackItem::Init(TCHAR *pString, BOOL IsName)
 {
 	if (IsName)
 		Type = EPSTYPE_NAME;
Index: Trunk/XaraLX/Kernel/rndrgn.h
===================================================================
--- Trunk/XaraLX/Kernel/rndrgn.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/rndrgn.h	(revision 1302)
@@ -382,7 +382,8 @@
 	// Function to copy all the parameters from another render region to this render region
 	virtual BOOL CopyRenderInfo( const RenderRegion &Other);
 
-	virtual BOOL AttachDevice(View *, CNativeDC *, Spread *SpreadToAttach = NULL, bool fOwned = false );
+	virtual BOOL AttachDevice(View *, CNativeDC *, Spread *SpreadToAttach = NULL, bool fOwned = false ); // OVERRIDE THIS
+	virtual BOOL AttachDevice(View *, CCDC *, Spread *SpreadToAttach = NULL, bool fOwned = false ); // DO NOT OVERRIDE THIS
 	virtual BOOL InitDevice();
 
 	virtual BOOL ImmediateRender();
Index: Trunk/XaraLX/Kernel/epsfiltr.cpp
===================================================================
--- Trunk/XaraLX/Kernel/epsfiltr.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/epsfiltr.cpp	(revision 1302)
@@ -154,6 +154,7 @@
 #include "ai_bmp.h"
 //#include "epsclist.h" - in camtypes.h [AUTOMATICALLY REMOVED]
 #include "epscdef.h"
+#include "nodetext.h"
 
 DECLARE_SOURCE("$Revision$");
 
@@ -806,121 +807,121 @@
 CommandMap EPSFilter::Commands[] =
 {
 	// Path Construction operators
-	{ EPSC_l,		"l" },
-	{ EPSC_c,		"c" },
-	{ EPSC_m,		"m" },
-	{ EPSC_L,		"L" },
-	{ EPSC_C,		"C" },
-	{ EPSC_v,		"v" },
-	{ EPSC_V,		"V" },
-	{ EPSC_y,		"y" },
-	{ EPSC_Y,		"Y" },
+	{ EPSC_l,		_T("l") },
+	{ EPSC_c,		_T("c") },
+	{ EPSC_m,		_T("m") },
+	{ EPSC_L,		_T("L") },
+	{ EPSC_C,		_T("C") },
+	{ EPSC_v,		_T("v") },
+	{ EPSC_V,		_T("V") },
+	{ EPSC_y,		_T("y") },
+	{ EPSC_Y,		_T("Y") },
 
 	// Colour operators
-	{ EPSC_g,		"g" },
-	{ EPSC_G,		"G" },
-	{ EPSC_k,		"k" },
-	{ EPSC_K,		"K" },
-	{ EPSC_x,		"x" },
-	{ EPSC_X,		"X" },
-	{ EPSC_p,		"p" },
-	{ EPSC_P,		"P" },
+	{ EPSC_g,		_T("g") },
+	{ EPSC_G,		_T("G") },
+	{ EPSC_k,		_T("k") },
+	{ EPSC_K,		_T("K") },
+	{ EPSC_x,		_T("x") },
+	{ EPSC_X,		_T("X") },
+	{ EPSC_p,		_T("p") },
+	{ EPSC_P,		_T("P") },
 	
 	// Path Painting operators
-	{ EPSC_N,		"N" },
-	{ EPSC_n,		"n" },
-	{ EPSC_F,		"F" },
-	{ EPSC_f,		"f" },
-	{ EPSC_S,		"S" },
-	{ EPSC_s,		"s" },
-	{ EPSC_B,		"B" },
-	{ EPSC_b,		"b" },
-	{ EPSC__u,		"*u" },
-	{ EPSC__U,		"*U" },
+	{ EPSC_N,		_T("N") },
+	{ EPSC_n,		_T("n") },
+	{ EPSC_F,		_T("F") },
+	{ EPSC_f,		_T("f") },
+	{ EPSC_S,		_T("S") },
+	{ EPSC_s,		_T("s") },
+	{ EPSC_B,		_T("B") },
+	{ EPSC_b,		_T("b") },
+	{ EPSC__u,		_T("*u") },
+	{ EPSC__U,		_T("*U") },
 
 	// Group operators
-	{ EPSC_u,		"u" },
-	{ EPSC_U,		"U" },
+	{ EPSC_u,		_T("u") },
+	{ EPSC_U,		_T("U") },
 	
 	// Graphics state operators
-	{ EPSC_A,		"A" },
-	{ EPSC_d,		"d" },
-	{ EPSC_i,		"i" },
-	{ EPSC_D,		"D" },
-	{ EPSC_j,		"j" },
-	{ EPSC_J,		"J" },
-	{ EPSC_M,		"M" },
-	{ EPSC_w,		"w" },
+	{ EPSC_A,		_T("A") },
+	{ EPSC_d,		_T("d") },
+	{ EPSC_i,		_T("i") },
+	{ EPSC_D,		_T("D") },
+	{ EPSC_j,		_T("j") },
+	{ EPSC_J,		_T("J") },
+	{ EPSC_M,		_T("M") },
+	{ EPSC_w,		_T("w") },
 
 	// Special operators
-	{ EPSC_ArrayStart,"[" },
-	{ EPSC_ArrayEnd,"]" },
-	{ EPSC_Slash,	"/" },
+	{ EPSC_ArrayStart,_T("[") },
+	{ EPSC_ArrayEnd,_T("]") },
+	{ EPSC_Slash,	_T("/") },
 
 	// Overprint operators
-	{ EPSC_O,		"O" },
-	{ EPSC_R,		"R" },
+	{ EPSC_O,		_T("O") },
+	{ EPSC_R,		_T("R") },
 
 	// Clipping operators
-	{ EPSC_q,		"q" },
-	{ EPSC_Q,		"Q" },
-	{ EPSC_H,		"H" },
-	{ EPSC_h,		"h" },
-	{ EPSC_W,		"W" },
+	{ EPSC_q,		_T("q") },
+	{ EPSC_Q,		_T("Q") },
+	{ EPSC_H,		_T("H") },
+	{ EPSC_h,		_T("h") },
+	{ EPSC_W,		_T("W") },
 	
 	// Text operators
-	{ EPSC_To,		"To" },
-	{ EPSC_TO,		"TO" },
-	{ EPSC_Tp,		"Tp" },
-	{ EPSC_TP,		"TP" },
+	{ EPSC_To,		_T("To") },
+	{ EPSC_TO,		_T("TO") },
+	{ EPSC_Tp,		_T("Tp") },
+	{ EPSC_TP,		_T("TP") },
 
 	// Matrix operators
-	{ EPSC_Tm,		"Tm" },
-	{ EPSC_Td,		"Td" },
-	{ EPSC_T_,		"T*" },
-	{ EPSC_TR,		"TR" },
+	{ EPSC_Tm,		_T("Tm") },
+	{ EPSC_Td,		_T("Td") },
+	{ EPSC_T_,		_T("T*") },
+	{ EPSC_TR,		_T("TR") },
 
 	// Text Attribute operators
-	{ EPSC_Tr,		"Tr" },
-	{ EPSC_Tf,		"Tf" },
-	{ EPSC_Ta,		"Ta" },
-	{ EPSC_Tl,		"Tl" },
-	{ EPSC_Tt,		"Tt" },
-	{ EPSC_TW,		"TW" },
-	{ EPSC_Tw,		"Tw" },
-	{ EPSC_TC,		"TC" },
-	{ EPSC_Tc,		"Tc" },
-	{ EPSC_Ts,		"Ts" },
-	{ EPSC_Ti,		"Ti" },
-	{ EPSC_Tz,		"Tz" },
-	{ EPSC_TA,		"TA" },
-	{ EPSC_Tq,		"Tq" },
+	{ EPSC_Tr,		_T("Tr") },
+	{ EPSC_Tf,		_T("Tf") },
+	{ EPSC_Ta,		_T("Ta") },
+	{ EPSC_Tl,		_T("Tl") },
+	{ EPSC_Tt,		_T("Tt") },
+	{ EPSC_TW,		_T("TW") },
+	{ EPSC_Tw,		_T("Tw") },
+	{ EPSC_TC,		_T("TC") },
+	{ EPSC_Tc,		_T("Tc") },
+	{ EPSC_Ts,		_T("Ts") },
+	{ EPSC_Ti,		_T("Ti") },
+	{ EPSC_Tz,		_T("Tz") },
+	{ EPSC_TA,		_T("TA") },
+	{ EPSC_Tq,		_T("Tq") },
 
 	// Text Body operators
-	{ EPSC_Tx,		"Tx" },
-	{ EPSC_Tj,		"Tj" },
-	{ EPSC_TX,		"TX" },
-	{ EPSC_Tk,		"Tk" },
-	{ EPSC_TK,		"TK" },
-	{ EPSC_Tplus,	"T+" },
-	{ EPSC_Tminus,	"T-" },
+	{ EPSC_Tx,		_T("Tx") },
+	{ EPSC_Tj,		_T("Tj") },
+	{ EPSC_TX,		_T("TX") },
+	{ EPSC_Tk,		_T("Tk") },
+	{ EPSC_TK,		_T("TK") },
+	{ EPSC_Tplus,	_T("T+") },
+	{ EPSC_Tminus,	_T("T-") },
 
 	// Misc
-	{ EPSC_showpage,"showpage" },
-	{ EPSC_end,		"end" },
-	{ EPSC_ctx,		"ctx" },
-	{ EPSC_ctex,	"ctex" },
+	{ EPSC_showpage,_T("showpage") },
+	{ EPSC_end,		_T("end") },
+	{ EPSC_ctx,		_T("ctx") },
+	{ EPSC_ctex,	_T("ctex") },
 
-	{ EPSC_Invalid,	"Invalid" },
+	{ EPSC_Invalid,	_T("Invalid") },
 
-	{ EPSC_Name,	"Name" },
-	{ EPSC_Integer,	"Integer" },
-	{ EPSC_Double,	"Double" },
-	{ EPSC_FixedPoint,"FixedPt" },
-	{ EPSC_String,	"String" },
-	{ EPSC_Comment,	"Comment" },
-	{ EPSC_EOL,		"EOL" },
-	{ EPSC_EOF,		"EOF" }
+	{ EPSC_Name,	_T("Name") },
+	{ EPSC_Integer,	_T("Integer") },
+	{ EPSC_Double,	_T("Double") },
+	{ EPSC_FixedPoint,_T("FixedPt") },
+	{ EPSC_String,	_T("String") },
+	{ EPSC_Comment,	_T("Comment") },
+	{ EPSC_EOL,		_T("EOL") },
+	{ EPSC_EOF,		_T("EOF") }
 };
 
 
@@ -1109,7 +1110,7 @@
 	while (camStrclen(FontMappings[i][0]) > 0)
 	{
 		Camelot.SetPrefDirect( _T("EPSFontMapping"), 
-							  &FontMappings[i][0][0], 
+							  (TCHAR *) &FontMappings[i][0][0], 
 							  &FontMappings[i][1][0]); 
 		i++;
 	}
@@ -1381,15 +1382,17 @@
 
 INT32 EPSFilter::EPSHeaderIsOk(ADDR pFileHeader, UINT32 HeaderSize)
 {
+	// This function is not unicode
+
 	// Check the first line in EPS file
-	if (camStrncmp((char *) pFileHeader, "%!PS-Adobe", 10) != 0)
+	if (strncmp((char *) pFileHeader, "%!PS-Adobe", 10) != 0)
 	{
 		// Incorrect version of EPS header line - we don't want this
 		return 0;
 	}
 
 	// !PS-Adobe line is ok - check creator line...
-	istrstream HeaderFile((char *) pFileHeader, HeaderSize);
+	std::istringstream HeaderFile((char *) pFileHeader, ios_base::in /*HeaderSize*/);
 	char Buffer[200];
 
 	UINT32 Lines = 0;
@@ -1400,14 +1403,14 @@
 
 		// Return TRUE if this file was created by Illustrator, or has been exported in 
 		// Illustrator format.
-		if (camStrncmp(Buffer, "%%Creator: Adobe Illustrator", 28) == 0)
+		if (strncmp(Buffer, "%%Creator: Adobe Illustrator", 28) == 0)
 			// We definitely want this.
 			return 8;
 
-		if (camStrncmp(Buffer, "%%Creator:", 10) == 0)
+		if (strncmp(Buffer, "%%Creator:", 10) == 0)
 		{
 			// Found the creator line - does it contain the word Illustrator?
-			if (camStrstr(Buffer, "Illustrator") != NULL)
+			if (strstr(Buffer, "Illustrator") != NULL)
 				return 9;
 			else
 				break;
@@ -1415,7 +1418,7 @@
 
 		// If we find the compression token then stop the search as we don't want to start
 		// looking in the compressed data!
-		if (camStrncmp(Buffer, "%%Compression:", 14)==0)
+		if (strncmp(Buffer, "%%Compression:", 14)==0)
 			break;
 	}
 
@@ -1478,6 +1481,7 @@
 	{
 		// OK, we will have to check for a preview bmp and skip to the Postscript if there is one
 		// read the first 4 bytes and see if they match the magic PostScript word
+		// Note this works in non-unicode mode
 		char Buf[4];
 		
 		// clear the buffer
@@ -1595,8 +1599,7 @@
 	INT32 filesize = EPSFile->Size();
 	if (filesize == -1)
 	{
-		if (IsUserName("JustinF"))
-			TRACE( _T("Couldn't take size of the EPS file
"));
+		TRACEUSER("JustinF", _T("Couldn't take size of the EPS file
"));
 		return FALSE;
 	}
 
@@ -1725,7 +1728,7 @@
 
 BOOL EPSFilter::HandleToken()
 {
-	BOOL Error = FALSE;	
+//	BOOL Error = FALSE;	
 
 	// At the end of a line or the file?
 	if ((Token != EPSC_EOL) && (Token != EPSC_EOF))
@@ -1780,7 +1783,7 @@
 	//
 	// Determine what we just read into TokenBuf.
 	//
-	ENSURE(camStrcmp(TokenBuf,"}bd") != 0, "Found a }bd token!");
+	ENSURE(camStrcmp(TokenBuf,_T("}bd")) != 0, "Found a }bd token!");
 		
 	// Not interested in comments, unless it's actually a strange token
 	if (Token == EPSC_Comment)
@@ -1810,7 +1813,7 @@
 
 	while (TokenBuf[i] != 0)
 	{
-		char c = TokenBuf[i];
+		TCHAR c = TokenBuf[i];
 		
 		if (c == '.')
 		{
@@ -1871,7 +1874,8 @@
 		{
 			// Floating point
 			Token = EPSC_Double;
-			TokenData.Double = atof(TokenBuf);
+			TokenData.Double=0.0;
+			camSscanf(TokenBuf,_T("%f"),TokenData.Double);
 		}
 		else if (FoundDot)
 		{
@@ -1883,7 +1887,8 @@
 		{
 			// Integer
 			Token = EPSC_Integer;
-			TokenData.Long = _ttol(TokenBuf);
+			TokenData.Long=0;
+			camSscanf(TokenBuf,_T("%d"),TokenData.Long);
 		}
 
 		return; // All done - found a number
@@ -1979,6 +1984,9 @@
 		case TOKEN_COMMENT:
 			Token = EPSC_Comment;
 			break; // Comments may be tokens in some EPS formats.
+
+		default:
+			break;
 	}
 
 	ENSURE((EPSFile->GetTokenType() == TOKEN_NORMAL) || (EPSFile->GetTokenType() == TOKEN_COMMENT), 
@@ -2043,6 +2051,9 @@
 			Token = EPSC_Comment;
 			DecodeToken();
 			return TRUE;
+
+		default:
+			break;
 	}
 
 	ENSURE((EPSFile->GetTokenType() == TOKEN_NORMAL) || 
@@ -2476,7 +2487,7 @@
 			{
 				// Try adding a number instead of "Imported"
 				TCHAR NumBuf[10];
-				wsprintf(NumBuf, TEXT(" %d"), Number);
+				camSprintf(NumBuf, TEXT(" %d"), Number);
 				NewName = LayerName;
 				NewName += NumBuf;
 
@@ -2692,7 +2703,8 @@
 			(StrokeColourAttribute *) CurrentAttrs[ATTR_STROKECOLOUR].pAttr;
 
 		OldCol = pAttr->Colour;
-		if (!SetLineColour(DocColour(COLOUR_TRANS)))
+		DocColour trans(COLOUR_TRANS);
+		if (!SetLineColour(trans))
 			return FALSE;
 	}
 
@@ -2774,9 +2786,9 @@
 			pIndexed = pColours->FindNamedColour((TCHAR *) (*ColName), DestCol, 
 												 (TintVal * 100) / FixedPointScale);
 
-			if (IsUserName("Tim") && (pIndexed == NULL))
+			if (!pIndexed)
 			{
-				TRACE( _T("Unable to find named colour: %s
"), (TCHAR *) (*ColName));
+				TRACEUSER("Tim", _T("Unable to find named colour: %s
"), (TCHAR *) (*ColName));
 			}
 		}
 		else
@@ -2803,9 +2815,9 @@
 		{
 			pIndexed = pColours->FindNamedColour(String_64(_R(IDS_K_EPSFILTER_UNNAMED)), DestCol, 100, TRUE);
 
-			if (IsUserName("Tim") && (pIndexed == NULL))
+			if (!pIndexed)
 			{
-				TRACE( _T("Unable to construct an unnamed colour
"));
+				TRACEUSER("Tim", _T("Unable to construct an unnamed colour
"));
 			}
 		}
 	}
@@ -3758,6 +3770,9 @@
 				return FALSE;
 			}
 			break;
+
+		default:
+			break;
 	}
 
 	if (EPSFlags.ComplexPath == 0)
@@ -3983,12 +3998,12 @@
 
 BOOL EPSFilter::ProcessComment(BOOL BypassDocComponents)
 {
-	if ((camStrncmp(TokenBuf, "%%Trailer", 9) == 0) ||
-		(camStrncmp(TokenBuf, "%%PageTrailer", 13) == 0))
+	if ((camStrncmp(TokenBuf, _T("%%Trailer"), 9) == 0) ||
+		(camStrncmp(TokenBuf, _T("%%PageTrailer"), 13) == 0))
 	{
 		ProcessEPSTrailer();
 	}
-	else if (camStrncmp(TokenBuf, "%%BoundingBox:", 14) == 0)
+	else if (camStrncmp(TokenBuf, _T("%%BoundingBox:"), 14) == 0)
 	{
 		ProcessBoundingBox();
 	}
@@ -4039,8 +4054,8 @@
 
 					// Special case for brain-damaged formats that don't bother to
 					// bracket prolog segments correctly
-					if ((camStrncmp(TokenBuf, "%%EndProlog", 11) == 0) ||
-						(camStrncmp(TokenBuf, "%%EndSetup", 10) == 0))
+					if ((camStrncmp(TokenBuf, _T("%%EndProlog"), 11) == 0) ||
+						(camStrncmp(TokenBuf, _T("%%EndSetup"), 10) == 0))
 					{
 						// Found the end of the prolog/setup - this means we're not in the
 						// prolog or setup processing loop (otherwise the above test
@@ -4103,7 +4118,7 @@
 BOOL EPSFilter::ProcessFilterComment()
 {
 	// This is the base class - there are no EPS comments specific to this filter.
-	if (camStrncmp(TokenBuf, "%%XSScript", 10) == 0)
+	if (camStrncmp(TokenBuf, _T("%%XSScript"), 10) == 0)
 	{
 		TextComment[0]=2;
 		return TRUE;
@@ -4166,7 +4181,7 @@
 		// Get the next token
 		GetToken();
 
-		if ((Token != EPSC_Comment) || (camStrncmp(TokenBuf, "%%+", 3) != 0))
+		if ((Token != EPSC_Comment) || (camStrncmp(TokenBuf, _T("%%+"), 3) != 0))
 		{
 			// Not a continuation comment - so we're finished
 			if (Result == EPSCommentOK)
@@ -4268,34 +4283,60 @@
 	DocRect BBox;
 
 	// Take a copy of the bounding box line so we can decompose it.
-	char BBoxStr[50];
+	TCHAR BBoxStr[50];
 	camStrncpy(BBoxStr, TokenBuf + 14, 50);
 
 	// Extract the minimum values (converting to millipoints)
+	TCHAR *Next = BBoxStr;
+	TCHAR *Num;
 
-	char *Num = _tcstok(BBoxStr, " ");
-	if (Num == NULL)
+	Num=Next;
+	while(*Next && (*Next!=_T(' ')))
+		Next++;
+	if (*Next)
+		*(Next++)=0;
+	if (!Num || !*Num)
 		// Error encountered in bounding box data - ignore it.
 		return TRUE;
-	BBox.lo.x = _ttol(Num) * 1000;
+	BBox.lo.x = 0;
+	camScanf(Num, _T("%d"), &BBox.lo.x);
+	BBox.lo.x *= 1000;
 
-	Num = _tcstok(NULL, " ");
-	if (Num == NULL)
+	Num=Next;
+	while(*Next && (*Next!=_T(' ')))
+		Next++;
+	if (*Next)
+		*(Next++)=0;
+	if (!Num || !*Num)
 		// Error encountered in bounding box data - ignore it.
 		return TRUE;
-	BBox.lo.y = _ttol(Num) * 1000;
+	BBox.lo.y = 0;
+	camScanf(Num, _T("%d"), &BBox.lo.y);
+	BBox.lo.y *= 1000;
 
-	Num = _tcstok(NULL, " ");
-	if (Num == NULL)
+	Num=Next;
+	while(*Next && (*Next!=_T(' ')))
+		Next++;
+	if (*Next)
+		*(Next++)=0;
+	if (!Num || !*Num)
 		// Error encountered in bounding box data - ignore it.
 		return TRUE;
-	BBox.hi.x = _ttol(Num) * 1000;
+	BBox.hi.x = 0;
+	camScanf(Num, _T("%d"), &BBox.hi.x);
+	BBox.hi.x *= 1000;
 
-	Num = _tcstok(NULL, " ");
-	if (Num == NULL)
+	Num=Next;
+	while(*Next && (*Next!=_T(' ')))
+		Next++;
+	if (*Next)
+		*(Next++)=0;
+	if (!Num || !*Num)
 		// Error encountered in bounding box data - ignore it.
 		return TRUE;
-	BBox.hi.y = _ttol(Num) * 1000;
+	BBox.hi.y = 0;
+	camScanf(Num, _T("%d"), &BBox.hi.y);
+	BBox.hi.y *= 1000;
 
 	// Is this bounding box within the spread area?
 	if (!SpreadRect.ContainsRect(BBox))
@@ -4322,7 +4363,7 @@
 void EPSFilter::HandleEPSError()
 {
 	// Error - EPS contains a syntax error.
-	TRACE( _T("EPS syntax error at token <%s> (line %ld, char %d)
"), 
+	TRACE( _T("EPS syntax error at token <%s> (line %ld, TCHAR %d)
"), 
 		  TokenBuf, EPSFile->GetLineNumber(), EPSFile->GetCharOffset());
 
 	// Destroy any half-created paths
@@ -4429,7 +4470,7 @@
 
 /********************************************************************************************
 
->	char *EPSFilter::GetEPSCommand(EPSCommand Cmd)
+>	TCHAR *EPSFilter::GetEPSCommand(EPSCommand Cmd)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	24/02/94
@@ -4440,7 +4481,7 @@
 
 ********************************************************************************************/
 
-char *EPSFilter::GetEPSCommand(EPSCommand Cmd)
+TCHAR *EPSFilter::GetEPSCommand(EPSCommand Cmd)
 {
 	INT32 i = 0;
 	while (Commands[i].Cmd != EPSC_Invalid)
@@ -4487,7 +4528,7 @@
 {
 #ifdef DO_EXPORT
 	// Output the header here
-	char Buf[30];
+	TCHAR Buf[30];
 
 	// Clear it to zero
 	memset(Buf, 0, 30);
@@ -4723,16 +4764,15 @@
 	if (ExportDCPtr == NULL)
 		return FALSE;
 
-	TRY
+	try
 	{
 		ExportDCPtr->Init(pFile);
 	}
-	CATCH(CFileException, e)
+	catch(CFileException)
 	{
 		// Could not open the export file - return error
 		return FALSE;
 	}
-	END_CATCH
 
 	// Get the position of the first page, and use this to set the origin.
 	Page *pPage = pSpread->FindFirstPageInSpread(); 
@@ -4763,7 +4803,7 @@
 			return FALSE;
 
 		// Attach to the right device.
-		ExportRegion->AttachDevice(DocView::GetSelected(), ExportDCPtr, pSpread);
+		ExportRegion->AttachDevice(DocView::GetSelected(), ExportDCPtr->GetDC(), pSpread);
 	}
 
 	// Inform all the document components that we are about to export
@@ -4995,7 +5035,7 @@
 		INT32 Length = EPSEnd - EPSStart;
 		if (Length < 1024)
 		{
-			const char PadChar = '
';
+			const TCHAR PadChar = '
';
 			// Pad the file up the required size
 			FilePos	CurrentPosition = pFile->tell();
 			while ((CurrentPosition - EPSEnd) < 1024)
@@ -5037,13 +5077,13 @@
 {
 #ifdef DO_EXPORT
 	// What we are looking for
-	char Message[] =  "1992 ACCUSOFT INC, ALL RIGHTS RESERVED";
-	String_64 Replace("Xara Studio, Xara Studio, Xara Studio.");
+	TCHAR Message[] =  _T("1992 ACCUSOFT INC, ALL RIGHTS RESERVED");
+	String_64 Replace(_T("Xara Studio, Xara Studio, Xara Studio."));
 	INT32 Length = camStrlen(Message);
-	char Ch = 0;
+	TCHAR Ch = 0;
 	FilePos StartOfStr = 0;
 
-	TRY
+	try
 	{
 		// Go to the start of the Preview bitmap
 		if (pFile->seekIn(PreviewStart, ios::beg).fail())
@@ -5053,25 +5093,27 @@
 		INT32 CharsToSearch = PreviewEnd - PreviewStart;
 		INT32 MatchedChars = 0;
 		
-		// Get the first char and start looking
-		pFile->get(Ch);
+		// Get the first TCHAR and start looking
+		char cch;
+		pFile->get(cch);
+		Ch=TCHAR(cch); // convert using 1:1 map
 		while ((!pFile->eof()) && (!pFile->fail()) && (MatchedChars<Length) && (CharsToSearch>0))
 		{
-			// Count this char
+			// Count this TCHAR
 			CharsToSearch--;
 
 			// see if matches our string
 			if (Ch==Message[MatchedChars])
 			{
-				// see if it is the first char in the string
+				// see if it is the first TCHAR in the string
 				if (MatchedChars==0)
 				{
-					// We have just read the first char so the start is
+					// We have just read the first TCHAR so the start is
 					// where we are now, minus 1
 					StartOfStr = pFile->tell() - 1;
 				}
 
-				// Count the char
+				// Count the TCHAR
 				MatchedChars++;
 			}
 			else
@@ -5080,8 +5122,10 @@
 				MatchedChars=0;
 			}
 
-			// Get the next char in the file and return if there is a problem
-			pFile->get(Ch);
+			// Get the next TCHAR in the file and return if there is a problem
+			char cch;
+			pFile->get(cch);
+			Ch=TCHAR(cch); // convert using 1:1 map
 		}
 
 		// If we found the whole string, replace it
@@ -5094,12 +5138,12 @@
 		}
 	}
 
-	CATCH(CFileException, e)
+	catch(CFileException)
 	{
 		// There was a problem, so don't change the message
 		return;
 	}
-	END_CATCH
+	
 #endif
 }
 
@@ -5209,7 +5253,7 @@
 	// Decode the string two characters at a time
 	for (INT32 i = nStart; (i < TokenLen) && (i < MaxOfs); i += 2)
 	{
-		char Ch = camToupper(TokenBuf[i]);
+		TCHAR Ch = camToupper(TokenBuf[i]);
 		BYTE Byte;
 
 		// Decode first digit.
@@ -5417,7 +5461,7 @@
 				if (!Stack.Pop(&Text))
 					goto error;
 
-				char * buf = (TCHAR*)Text;
+				TCHAR * buf = (TCHAR*)Text;
 				INT32 len = Text.Length();
 			
 				TextChar* pCh = NULL;
@@ -5425,7 +5469,7 @@
 				for ( INT32 i = 0; i < len; i++)
 				{
 					// check for a carriage return
-					if (buf[i]=='
')
+					if (buf[i]==_T('
'))
 					{
 						PastAnEOL = TRUE;
 
@@ -5927,7 +5971,8 @@
 
 	// Line Colour must be NONE.
 	StrokeColourAttribute* pLineCol = (StrokeColourAttribute*)CurrentAttrs[ATTR_STROKECOLOUR].pAttr;
-	pLineCol->SetStartColour(&DocColour(COLOUR_NONE));
+	DocColour none(COLOUR_NONE);
+	pLineCol->SetStartColour(&none);
 	// All worked ok.
 	return TRUE;
 }
@@ -5965,7 +6010,8 @@
 
 	// Fill Colour must be NONE.
 	FlatFillAttribute* pFillCol = (FlatFillAttribute*)CurrentAttrs[ATTR_FILLGEOMETRY].pAttr;
-	pFillCol->SetStartColour(&DocColour(COLOUR_NONE));
+	DocColour none(COLOUR_NONE);
+	pFillCol->SetStartColour(&none);
 	// All worked ok.
 	return TRUE;
 }
Index: Trunk/XaraLX/Kernel/epsstack.cpp
===================================================================
--- Trunk/XaraLX/Kernel/epsstack.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/epsstack.cpp	(revision 1302)
@@ -112,7 +112,7 @@
 
 /********************************************************************************************
 
->	void FIXEDPOINT::FromAscii(const char *FltPtString)
+>	void FIXEDPOINT::FromAscii(const TCHAR *FltPtString)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	28/02/94
@@ -124,7 +124,7 @@
 
 ********************************************************************************************/
 
-void FIXEDPOINT::FromAscii(const char *Str)
+void FIXEDPOINT::FromAscii(const TCHAR *Str)
 {
 	// Initialise data member.
 	Long = 0;
@@ -141,19 +141,22 @@
 	{
 		// Found a decimal point - extract the integer and fractional parts and use them
 		// to construct the fixed point number.
-		char Tmp[20];
-		strcpy(Tmp, Str);
+		TCHAR Tmp[20];
+		camStrcpy(Tmp, Str);
 		Tmp[i] = 0;
-		Long = (atol(Tmp) * 1000);
+		Long = 0;
+		camScanf(Tmp, _T("%d"), &Long);
+		Long *= 1000;
 
 		// Force fraction to be 3 digits at the most (as we only store with 3 digits accuracy)
 		Tmp[i + 4] = 0;
 
 		// Convert fraction to integer
-		INT32 Frac = atol(Tmp + i + 1);
+		INT32 Frac = 0;
+		camScanf(&(Tmp[i+1]), _T("%d"), &Frac);
 
 		// The fraction can be of the form .1, .10, or .100 - we must scale it correctly.
-		INT32 FracLen = strlen(Tmp + i + 1);
+		INT32 FracLen = camStrlen(Tmp + i + 1);
 
 		if (FracLen == 1)
 			Frac *= 100;
@@ -171,7 +174,9 @@
 	else
 	{
 		// No decimal point found - just scale the integer part.
-		Long = (atol(Str) * 1000);
+		Long = 0;
+		camScanf(Str, _T("%d"), &Long);
+		Long *= 1000;
 	}
 }
 
@@ -325,18 +330,18 @@
 
 /********************************************************************************************
 
->	BOOL EPSStack::Push ( const char *pString,
+>	BOOL EPSStack::Push ( const TCHAR *pString,
 						  BOOL IsName = FALSE )
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	13/10/93
 	Inputs:		pString - pointer to the string data to push onto the stack.
 	Returns:	TRUE if successful, FALSE if out of memory or stack space.
-	Purpose:	Push a char* string item onto the stack.
+	Purpose:	Push a TCHAR* string item onto the stack.
 
 ********************************************************************************************/
 
-BOOL EPSStack::Push ( const char *pString,
+BOOL EPSStack::Push ( const TCHAR *pString,
 					  BOOL IsName )
 {
 	EPSStackItem *pItem = new EPSStackItem;
@@ -352,9 +357,9 @@
 	}
 	
 	// Try to copy string
-	char *NewStr = new char[strlen(pString) + 1];
+	TCHAR *NewStr = new TCHAR[camStrlen(pString) + 1];
 	ERRORIF(NewStr == NULL,  _R(IDT_EPS_NOMEMORY), FALSE);
-	strcpy(NewStr, pString);
+	camStrcpy(NewStr, pString);
 
 	// Initialise stack item.
 	pItem->Init ( NewStr );
@@ -609,17 +614,17 @@
 
 /********************************************************************************************
 
->	BOOL EPSStack::Pop(char* pString)
+>	BOOL EPSStack::Pop(TCHAR* pString)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	13/10/93
 	Outputs:	pString - the buffer to put the string value into.
 	Returns:	TRUE if there is a string value on the top of the stack; FALSE if not.
-	Purpose:	Pop a char* string value from the top of the stack.
+	Purpose:	Pop a TCHAR* string value from the top of the stack.
 
 ********************************************************************************************/
 
-BOOL EPSStack::Pop ( char* pString )
+BOOL EPSStack::Pop ( TCHAR* pString )
 {
 	// Get pointer to the stack item.
 	EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () );
@@ -632,7 +637,7 @@
 	if ( pItem->Type == EPSTYPE_STRING )
 	{
 		// Correct type - remove item from stack and return to caller.
-		strcpy ( pString, pItem->Data.pString );
+		camStrcpy ( pString, pItem->Data.pString );
 		delete pItem;
 		return TRUE;
 	}
Index: Trunk/XaraLX/Kernel/cameleps.h
===================================================================
--- Trunk/XaraLX/Kernel/cameleps.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/cameleps.h	(revision 1302)
@@ -268,7 +268,7 @@
 	BOOL Init();
 	BOOL IsDefaultDocRequired(const TCHAR* pcszPathName);
 	BOOL PrepareToExport(CCLexFile*, Spread* pSpread);
-	char* GetEPSCommand(EPSCommand Cmd);
+	TCHAR* GetEPSCommand(EPSCommand Cmd);
 	BOOL ExportBitmap(KernelBitmap&);
 	
 	// This filter can include a Preview Bmp
Index: Trunk/XaraLX/Kernel/dialogop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/dialogop.cpp	(revision 1302)
@@ -2690,7 +2690,7 @@
 	if (pRender!=NULL)
 	{
 		// Try and create the bitmap etc
-		if (pRender->AttachDevice(pDialogView, ExtraInfo->pDC, NULL))
+		if (pRender->AttachDevice(pDialogView, ExtraInfo->pDC->GetDC(), NULL))
 		{
 			// Try and start the render region
 			if (pRender->StartRender())
Index: Trunk/XaraLX/Kernel/doccomp.h
===================================================================
--- Trunk/XaraLX/Kernel/doccomp.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/doccomp.h	(revision 1302)
@@ -180,7 +180,7 @@
 	virtual BOOL WriteEPSComments(EPSFilter *);
 	virtual BOOL WriteScript(EPSFilter*);
 
-	virtual ProcessEPSResult ProcessEPSComment(EPSFilter *, const char *);
+	virtual ProcessEPSResult ProcessEPSComment(EPSFilter *, const TCHAR *);
 	virtual void EndOfEPSComment(EPSFilter *);
 
 	// More general function to control progress display.
Index: Trunk/XaraLX/Kernel/epsstack.h
===================================================================
--- Trunk/XaraLX/Kernel/epsstack.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/epsstack.h	(revision 1302)
@@ -112,7 +112,7 @@
 {
 public:
 	INT32 Long;
-	void FromAscii(const char *FltPtString);
+	void FromAscii(const TCHAR *FltPtString);
 	operator INT32() const { return (INT32) Long; }
 	FIXEDPOINT& operator= (INT32 Val) { this->Long = Val; return *this; }
 };
@@ -174,14 +174,14 @@
 	BOOL Push(const INT32);
 	BOOL Push(const FIXEDPOINT);
 	BOOL Push(const double);
-	BOOL Push(const char*, BOOL IsName = FALSE);
+	BOOL Push(const TCHAR*, BOOL IsName = FALSE);
 	BOOL Push(const EPSCommand Cmd);
 	
 	BOOL Pop(INT32 *);
 	BOOL Pop(UINT32 *);
 	BOOL Pop(FIXEDPOINT *);
 	BOOL Pop(double *);
-	BOOL Pop(char*);
+	BOOL Pop(TCHAR*);
 	BOOL Pop(StringBase*);
 
 	BOOL PopCmd(EPSCommand*);
Index: Trunk/XaraLX/Kernel/document.cpp
===================================================================
--- Trunk/XaraLX/Kernel/document.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/document.cpp	(revision 1302)
@@ -3366,7 +3366,7 @@
 /********************************************************************************************
 
 >	ProcessEPSResult Document::ProcessEPSComment(EPSFilter *pFilter, 
-												 const char *pComment)
+												 const TCHAR *pComment)
 
 	Author:		Tim_Browse (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	01/08/94
@@ -3402,7 +3402,7 @@
 ********************************************************************************************/
 
 ProcessEPSResult Document::ProcessEPSComment(EPSFilter *pFilter, 
-										     const char *pComment)
+										     const TCHAR *pComment)
 {
 	PORTNOTETRACE("filters","Document::ProcessEPSComment - do nothing");
 #ifndef EXCLUDE_FROM_XARALX
Index: Trunk/XaraLX/Kernel/nativeps.cpp
===================================================================
--- Trunk/XaraLX/Kernel/nativeps.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/nativeps.cpp	(revision 1302)
@@ -153,10 +153,10 @@
 CommandMap CamelotNativeEPSFilter::NativeCommands[] =
 {
 	// Bitmap Pool Tokens
-	{ EPSC_cbmp,		"cbmp" },
+	{ EPSC_cbmp,	_T("cbmp") },
 
 	// Sentinel
-	{ EPSC_Invalid,	"Invalid" }
+	{ EPSC_Invalid,	_T("Invalid") }
 };
 
 
@@ -962,15 +962,17 @@
 
 INT32 CamelotNativeEPSFilter::EPSHeaderIsOk(ADDR pFileHeader, UINT32 HeaderSize)
 {
+	// This function is NOT unicode
+
 	// Check the first line in EPS file
-	if (camStrncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
+	if (strncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
 	{
 		// Incorrect version of EPS header line - we don't want this
 		return 0;
 	}
 
 	// !PS-Adobe line is ok - check creator line...
-	istrstream HeaderFile((char *) pFileHeader, HeaderSize);
+	std::istringstream HeaderFile((char *) pFileHeader, ios_base::in /* HeaderSize*/);
 	char Buffer[200];
 
 	UINT32 Lines = 0;
@@ -980,12 +982,12 @@
 		Lines++;
 
 		// if the file is native camelot, return indicating strong 'interest'!
-		if (camStrncmp(Buffer, "%%Creator: Xara Studio (Native)", 31) == 0)
+		if (strncmp(Buffer, "%%Creator: Xara Studio (Native)", 31) == 0)
 			return 10;
 
 		// If we find the compression token then stop the search as we don't want to start
 		// looking in the compressed data!
-		if (camStrncmp(Buffer, "%%Compression:", 14)==0)
+		if (strncmp(Buffer, "%%Compression:", 14)==0)
 			break;
 	}
 
@@ -1239,9 +1241,9 @@
 {
 	// read chars until we get a >
 	INT32 CountDown = 50;
-	char Ch;
+	TCHAR Ch;
 	do {
-		// Read a char
+		// Read a TCHAR
 		if (EPSFile->read(&Ch, 1).fail())
 		{
 			HandleEPSError();
@@ -1266,7 +1268,7 @@
 		return FALSE;
 	}
 
-	// Read char and check that it is a <
+	// Read TCHAR and check that it is a <
 	if (EPSFile->read(&Ch, 1).fail())
 	{
 		HandleEPSError();
@@ -1317,18 +1319,18 @@
 BOOL CamelotNativeEPSFilter::ProcessFilterComment()
 {
 	// read the build version number of the app which saved this file
-	if (camStrncmp(TokenBuf, "%%Creator: Xara Studio (Native)", 31) == 0)
+	if (camStrncmp(TokenBuf, _T("%%Creator: Xara Studio (Native)"), 31) == 0)
 	{
-		BuildVersionNumber = atof(TokenBuf+31);
 		return TRUE;
 	}
 
 	// Go and have a look at the token buffer and see if it is our special
 	// file version comment. If so, then extract the version number from it. 
-	if (camStrncmp(TokenBuf, "%%File version:", 15)==0)
+	if (camStrncmp(TokenBuf, _T("%%File version:"), 15)==0)
 	{
-		char* pVersion = ((char*)TokenBuf)+15;
-		double Version = atof(pVersion);
+		TCHAR* pVersion = &(((TCHAR*)TokenBuf)[15]);
+		double Version=0.0;
+		camSscanf(pVersion, _T("%f"), &Version);
 		TRACEUSER( "Neville", _T("Native file version = %f
"), Version);
 		FileVersionNumber = Version;
 		// Must stop later file versions loading back into this version.
@@ -1347,7 +1349,7 @@
 	
 	// Go and have a look at the token buffer and see if it is our special
 	// compression comment
-	if (camStrncmp(TokenBuf, "%%Compression:", 14)==0)
+	if (camStrncmp(TokenBuf, _T("%%Compression:"), 14)==0)
 	{
 //#ifdef STANDALONE
 //		// First release of the file viewer will not have the native file compression
@@ -1363,8 +1365,8 @@
 //		// We recokonised the token but it is invalid
 //		return TRUE;
 //#endif
-		char* pType = ((char*)TokenBuf)+14;
-		CompressionType = _ttoi(pType);
+		TCHAR* pType = &(((TCHAR*)TokenBuf)[14]);
+		camSscanf(pType, _T("%d"), &CompressionType);
 		TRACEUSER( "Neville", _T("CamelotNativeEPSFilter::ProcessFilterComment compression type %d
"), CompressionType);
 
 		// We have found our compression token so turn compression on
@@ -1383,10 +1385,11 @@
 
 		return TRUE;
 	}
-	if (camStrncmp(TokenBuf, "%%Compression info:", 19)==0)
+	if (camStrncmp(TokenBuf, _T("%%Compression info:"), 19)==0)
 	{
-		char* pVersion = ((char*)TokenBuf)+19;
-		double CompVersion = atof(pVersion);
+		TCHAR* pVersion = &(((TCHAR*)TokenBuf)[19]);
+		double CompVersion=0.0;
+		camSscanf(pVersion, _T("%f"), &CompVersion);
 		TRACEUSER( "Neville", _T("Compression version = %f
"), CompVersion);
 		double StreamVersion = GZipFile::GetStreamVersionNo();
 		// If the version stored in the file is later than the one in the stream class
@@ -1404,7 +1407,7 @@
 
 		return TRUE;
 	}
-	if (camStrncmp(TokenBuf, "%%EndCompression:", 17)==0)
+	if (camStrncmp(TokenBuf, _T("%%EndCompression:"), 17)==0)
 	{
 		// We have found our compression token so turn compression on
 		BOOL ok = EPSFile->SetCompression(FALSE);
@@ -1421,16 +1424,16 @@
 
 		return TRUE;
 	}
-	if (camStrncmp(TokenBuf, "%%EndCompressionInfo:", 21)==0)
+	if (camStrncmp(TokenBuf, _T("%%EndCompressionInfo:"), 21)==0)
 	{
 		return TRUE;
 	}
 	  
 	// Go and have a look at the token buffer and see if it looks like bitmap count
-	if (camStrncmp(TokenBuf, "%%BitmapPoolCount", 17)==0)
+	if (camStrncmp(TokenBuf, _T("%%BitmapPoolCount"), 17)==0)
 	{
-		char* pCount = ((char*)TokenBuf)+17;
-		BitmapCount = _ttoi(pCount);
+		TCHAR* pCount = &(((TCHAR*)TokenBuf)[17]);
+		camSscanf(pCount, _T("%d"), &BitmapCount);
 		TRACEUSER( "Rik", _T("%d
"), BitmapCount);
 
 		// There are no bitmaps in this file
@@ -1447,7 +1450,7 @@
 	}
 
 	// Check for any text comments
-	if (camStrncmp(TokenBuf, "%%XSScript",	10)==0)
+	if (camStrncmp(TokenBuf, _T("%%XSScript"), 10)==0)
 	{
 		TextComment[0]=2;
 		return TRUE;
@@ -2299,8 +2302,8 @@
 
 	Author:		Mike_Kenny (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	25/05/95
-	Inputs:		ch      - unicode value of char
-				pMatrix - matrix specifying transforms to place char correctly in document
+	Inputs:		ch      - unicode value of TCHAR
+				pMatrix - matrix specifying transforms to place TCHAR correctly in document
 	Returns:	FALSE if fails
 	Purpose:	
 
@@ -2332,7 +2335,7 @@
 #else
 	// just do what RenderRegion::RenderChar() would do!
 
-	// create the char's path
+	// create the TCHAR's path
 	Path* pCharPath=CreateCharPath(ch,pMatrix);
 	if (pCharPath==NULL)
 		return FALSE;
@@ -2368,7 +2371,7 @@
 BOOL NativeRenderRegion::WriteFileVersion(KernelDC *pDC)
 {
 	// Buffer used to build up the file version comment.
-	char buf[50];
+	TCHAR buf[50];
 
 	// Output the current file version in the format 1.00 for NativeFileVersion 100
 	_stprintf(buf, "%%%%File version: %.2f", WriteNativeVersion);
@@ -2436,7 +2439,7 @@
 		// We must output text rather than numbers and must never output LF or CR in the
 		// middle as this will screw the lexer
 		double StreamVersion = GZipFile::GetStreamVersionNo();
-		char buf[300];
+		TCHAR buf[300];
 		_stprintf(buf, " %.2fD", StreamVersion);	// version in form 0.92 followed by D for deflated
 		pDC->OutputToken(buf);
 TRACEUSER( "Neville", _T("WriteCompressionState wrote version %.2f
"),StreamVersion); 
@@ -2676,7 +2679,7 @@
 	//ExportFile.setMode(filebuf::binary);
 
 	// Output a character to mark the begining of the binary section
-	static char Begin = '>';
+	static TCHAR Begin = '>';
 	if (ExportFile->write(&Begin, 1).fail())
 		// Error
 		return -1;
@@ -2700,7 +2703,7 @@
 	if (Padding > 0)
 	{
 		// Put the string "00" into a Buffer
-		char Buffer[2];
+		TCHAR Buffer[2];
 		Buffer[0] = 0;
 		Buffer[1] = 0;
 
@@ -2717,7 +2720,7 @@
 	}
 
 	//output an end marker
-	static char End = '<';
+	static TCHAR End = '<';
 	if (ExportFile->write(&End, 1).fail())
 		// Error
 		return -1;
Index: Trunk/XaraLX/Kernel/cameleps.cpp
===================================================================
--- Trunk/XaraLX/Kernel/cameleps.cpp	(revision 1301)
+++ Trunk/XaraLX/Kernel/cameleps.cpp	(revision 1302)
@@ -186,96 +186,96 @@
 CommandMap CamelotEPSFilter::CamelotCommands[] =
 {
 	// Line/Fill colours
-	{ EPSC_cx,		"cx" },
-	{ EPSC_cX,		"cX" },
-	{ EPSC_ck,		"ck" },
-	{ EPSC_cK,		"cK" },
+	{ EPSC_cx,		_T("cx") },
+	{ EPSC_cX,		_T("cX") },
+	{ EPSC_ck,		_T("ck") },
+	{ EPSC_cK,		_T("cK") },
 
 	// Stroke transparency
-	{ EPSC_cst,		"cst" },
+	{ EPSC_cst,		_T("cst") },
 		  			  
 	// Arrow heads
-	{ EPSC_csah,	"csah" },
-	{ EPSC_ceah,	"ceah" },
+	{ EPSC_csah,	_T("csah") },
+	{ EPSC_ceah,	_T("ceah") },
 
 	// Dash Patterns
-	{ EPSC_cdp,		"cdp" },
+	{ EPSC_cdp,		_T("cdp") },
 
 	// Bitmap objects/bitmap fills
-	{ EPSC_cbm,		"cbm" },
-	{ EPSC_csbm,	"csbm" },
-	{ EPSC_cebm,	"cebm" },
+	{ EPSC_cbm,		_T("cbm") },
+	{ EPSC_csbm,	_T("csbm") },
+	{ EPSC_cebm,	_T("cebm") },
 
 	// Chromatic fill geometries
-	{ EPSC_caz,		"caz" },
-	{ EPSC_cax,		"cax" },
+	{ EPSC_caz,		_T("caz") },
+	{ EPSC_cax,		_T("cax") },
 	
 	// Transparent fill geometries
-	{ EPSC_cxt,		"cxt" },
+	{ EPSC_cxt,		_T("cxt") },
 
 	// Chromatic fill effects
-	{ EPSC_cxe,		"cxe" },
+	{ EPSC_cxe,		_T("cxe") },
 
 	// Chromatic fill mappings
-	{ EPSC_cxm,		"cxm" },
+	{ EPSC_cxm,		_T("cxm") },
 
 	// Transparent fill mappings
-	{ EPSC_cxmt,	"cxmt" },
+	{ EPSC_cxmt,	_T("cxmt") },
 
 	// Blends
-	{ EPSC_csbd,	"csbd" },
-	{ EPSC_cebd,	"cebd" },
-	{ EPSC_csbr,	"csbr" },
-	{ EPSC_cebr,	"cebr" },
+	{ EPSC_csbd,	_T("csbd") },
+	{ EPSC_cebd,	_T("cebd") },
+	{ EPSC_csbr,	_T("csbr") },
+	{ EPSC_cebr,	_T("cebr") },
 
 	// Regular shapes
-	{ EPSC_csrs,	"csrs" },
-	{ EPSC_crsp,	"crsp" },
-	{ EPSC_crstm,	"crstm" },
-	{ EPSC_crsp1,	"crsp1" },
-	{ EPSC_crsp2,	"crsp2" },
-	{ EPSC_cers,	"cers" },
+	{ EPSC_csrs,	_T("csrs") },
+	{ EPSC_crsp,	_T("crsp") },
+	{ EPSC_crstm,	_T("crstm") },
+	{ EPSC_crsp1,	_T("crsp1") },
+	{ EPSC_crsp2,	_T("crsp2") },
+	{ EPSC_cers,	_T("cers") },
 
 	// Mould commands
-	{ EPSC_csev,	"csev" },
-	{ EPSC_ceev,	"ceev" },
-	{ EPSC_cspr,	"cspr" },
-	{ EPSC_cepr,	"cepr" },
-	{ EPSC_csmp,	"csmp" },
-	{ EPSC_cemp,	"cemp" },
-	{ EPSC_csso,	"csso" },
-	{ EPSC_ceso,	"ceso" },
-	{ EPSC_csdo,	"csdo" },
-	{ EPSC_cedo,	"cedo" },
+	{ EPSC_csev,	_T("csev") },
+	{ EPSC_ceev,	_T("ceev") },
+	{ EPSC_cspr,	_T("cspr") },
+	{ EPSC_cepr,	_T("cepr") },
+	{ EPSC_csmp,	_T("csmp") },
+	{ EPSC_cemp,	_T("cemp") },
+	{ EPSC_csso,	_T("csso") },
+	{ EPSC_ceso,	_T("ceso") },
+	{ EPSC_csdo,	_T("csdo") },
+	{ EPSC_cedo,	_T("cedo") },
 
 	// Text commands
- 	{ EPSC_ctf,		"ctf" },
- 	{ EPSC_ctb,		"ctb" },
-	{ EPSC_cti,		"cti" },
-	{ EPSC_cts,		"cts" },
-	{ EPSC_ctp,		"ctp" },
-	{ EPSC_ctls,	"ctls" },
+ 	{ EPSC_ctf,		_T("ctf") },
+ 	{ EPSC_ctb,		_T("ctb") },
+	{ EPSC_cti,		_T("cti") },
+	{ EPSC_cts,		_T("cts") },
+	{ EPSC_ctp,		_T("ctp") },
+	{ EPSC_ctls,	_T("ctls") },
 
-	{ EPSC_cso,		"cso" },
-	{ EPSC_ceo,		"ceo" },
-	{ EPSC_cfft,	"cfft" },
-	{ EPSC_cftf, 	"cftf" },
-	{ EPSC_cbot,	"cbot" },
+	{ EPSC_cso,		_T("cso") },
+	{ EPSC_ceo,		_T("ceo") },
+	{ EPSC_cfft,	_T("cfft") },
+	{ EPSC_cftf, 	_T("cftf") },
+	{ EPSC_cbot,	_T("cbot") },
 
-	{ EPSC_cpal,	"cpal" },
+	{ EPSC_cpal,	_T("cpal") },
 
 	// Guide layer & guideline
-	{ EPSC_glyr,	"glyr" },
-	{ EPSC_glne,	"glne" },
+	{ EPSC_glyr,	_T("glyr") },
+	{ EPSC_glne,	_T("glne") },
 
-	{ EPSC_cmth,	"cmth" },
+	{ EPSC_cmth,	_T("cmth") },
 
-	{ EPSC_cag,		"cag" },
+	{ EPSC_cag,		_T("cag") },
 
-	{ EPSC_cbti,	"cbti" },
+	{ EPSC_cbti,	_T("cbti") },
 
 	// Sentinel
-	{ EPSC_Invalid,	"Invalid" }
+	{ EPSC_Invalid,	_T("Invalid") }
 };
 
 /********************************************************************************************
@@ -642,7 +642,7 @@
 	INT32 i = 0;
 	while (CamelotCommands[i].Cmd != EPSC_Invalid)
 	{
-		if (strcmp(TokenBuf, CamelotCommands[i].CmdStr) == 0)
+		if (camStrcmp(TokenBuf, CamelotCommands[i].CmdStr) == 0)
 		{
 			// Found the token - set the token variable and return success
 			Token = CamelotCommands[i].Cmd;
@@ -752,11 +752,11 @@
 						LexTokenType Type = EPSFile->GetTokenType();
 						if ((Type != TOKEN_EOL) && (Type != TOKEN_EOF))
 						{
-							if (strcmp(TokenBuf, "cso") == 0)
+							if (camStrcmp(TokenBuf, _T("cso")) == 0)
 							{
 								ObjectNesting++;
 							}
-							else if (strcmp(TokenBuf, "ceo") == 0)
+							else if (camStrcmp(TokenBuf, _T("ceo")) == 0)
 							{
 								ObjectNesting--;
 							}							
@@ -1405,7 +1405,7 @@
 
 ********************************************************************************************/
 
-char *CamelotEPSFilter::GetEPSCommand(EPSCommand Cmd)
+TCHAR *CamelotEPSFilter::GetEPSCommand(EPSCommand Cmd)
 {
 	INT32 i = 0;
 	while (CamelotCommands[i].Cmd != EPSC_Invalid)
Index: Trunk/XaraLX/Kernel/aw_eps.h
===================================================================
--- Trunk/XaraLX/Kernel/aw_eps.h	(revision 1301)
+++ Trunk/XaraLX/Kernel/aw_eps.h	(revision 1302)
@@ -135,7 +135,7 @@
 	ArtWorksEPSFilter();
 	BOOL Init();
 	BOOL PrepareToExport(CCLexFile*, Spread *pSpread);
-	char* GetEPSCommand(EPSCommand Cmd);
+	TCHAR* GetEPSCommand(EPSCommand Cmd);
 	virtual BOOL NeedsPrintComponents ( void );
 
 	virtual BitmapFilterSupport GetBitmapSupportLevel();
Index: Trunk/XaraLX/wxOil/rendwnd.cpp
===================================================================
--- Trunk/XaraLX/wxOil/rendwnd.cpp	(revision 1301)
+++ Trunk/XaraLX/wxOil/rendwnd.cpp	(revision 1302)
@@ -154,7 +154,7 @@
 BOOL CRenderWnd::m_DoubleBuffer = FALSE;
 
 CRenderWnd::CRenderWnd(CCamView* pView) :
-	m_pView(pView)
+	m_pView(pView), m_pCCClientDC(NULL)
 {
 	// Nothing else to do for now...
 }
@@ -162,9 +162,59 @@
 CRenderWnd::~CRenderWnd()
 {
 	TRACEUSER("Gerry", _T("Deleting CRenderWnd at 0x%08x
"), this);
+	if (m_pCCClientDC)
+	{
+		delete(m_pCCClientDC);
+		m_pCCClientDC = NULL;
+	}
 }
 
 /*********************************************************************************************
+>	virtual wxClientDC * CRenderWnd::GetClientDC()
+
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	12/06/2006
+	Inputs:		None
+	Outputs:	None
+	Returns:	Pointer to the CCClientDC
+	Purpose:	Returns a pointer to the appropriate client DC, allocating it if necessary
+	Errors:		-
+	Scope:	    Public
+	SeeAlso:    CCamView::OnCreate()
+
+**********************************************************************************************/ 
+
+wxClientDC * CRenderWnd::GetClientDC()
+{
+	if (!m_pCCClientDC)
+		m_pCCClientDC = new CCClientDC(this); // OK if it fails
+	return (wxClientDC*)(m_pCCClientDC?m_pCCClientDC->GetDC():NULL);
+}
+
+/*********************************************************************************************
+>	virtual wxClientDC * CRenderWnd::GetClientDC()
+
+>	void CCamView::DoneWithDC()
+
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	12/06/2006
+	Purpose:	Hints that we've done with our DC
+	SeeAlso:	View; PaperRenderRegion.
+
+Note this is merely a hint. This routine is not guaranteed to eb called
+
+**********************************************************************************************/ 
+
+void CRenderWnd::DoneWithDC()
+{
+	if (m_pCCClientDC)
+	{
+		delete m_pCCClientDC;
+		m_pCCClientDC=NULL;
+	}
+}
+
+/*********************************************************************************************
 >	virtual BOOL CRenderWnd::Create(const wxRect& rect,
 									wxWindow* parent, UINT32 id)
 	Author:		Justin_Flude (Xara Group Ltd) <camelotdev@xxxxxxxx>
@@ -226,7 +276,7 @@
 //		wxPalette* OldPal = PaletteManager::StartPaintPalette(&dc);
 
 		if (m_pView)
-			m_pView->OnDraw(&dc);
+			m_pView->OnDraw(dc.GetDC());
 
 //		PaletteManager::StopPaintPalette(&dc, OldPal);
 	}
Index: Trunk/XaraLX/wxOil/rendwnd.h
===================================================================
--- Trunk/XaraLX/wxOil/rendwnd.h	(revision 1301)
+++ Trunk/XaraLX/wxOil/rendwnd.h	(revision 1302)
@@ -110,6 +110,7 @@
 
 #define OPTOKEN_TOGGLEDOUBLEBUFFER		TEXT("ToggleDoubleBuffer")
 
+class CCClientDC;
 class CCamView;
 
 /////////////////////////////////////////////////////////////////////////////
@@ -143,6 +144,9 @@
 	static void SetDoubleBuffer (BOOL DoubleBuffer);
 	static BOOL GetDoubleBuffer () {return m_DoubleBuffer;}
 
+	virtual wxClientDC * GetClientDC();
+	virtual void DoneWithDC();
+
 /////////////////////////////////////////////////////////////////////////////
 // Generated message map functions
 
@@ -180,6 +184,8 @@
 	static void ReflectDoubleBufferingInChildren(wxWindow * pWindow);
 
 	DECLARE_EVENT_TABLE()
+
+	CCClientDC * m_pCCClientDC;
 };
 
 
Index: Trunk/XaraLX/wxOil/camview.h
===================================================================
--- Trunk/XaraLX/wxOil/camview.h	(revision 1301)
+++ Trunk/XaraLX/wxOil/camview.h	(revision 1302)
@@ -198,7 +198,8 @@
 // Painting.
 
 public:
-	CNativeDC *GetRenderDC() const;
+	virtual CNativeDC *GetRenderDC() const;
+	virtual void DoneWithDC() const;
 	void GetClientSize(/* TYPENOTE: Correct */ int * width, /*TYPENOTE: Correct */ int * height) const;
 	
 	virtual void OnDraw( wxDC *pDc );
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp	(revision 1301)
+++ Trunk/XaraLX/wxOil/camview.cpp	(revision 1302)
@@ -629,18 +629,26 @@
 
 CNativeDC* CCamView::GetRenderDC() const
 {
-	wxClientDC* pDC = NULL;
-	
+	return RenderWindow?RenderWindow->GetClientDC():NULL;
+}
+
+/********************************************************************************************
+
+>	void CCamView::DoneWithDC()
+
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	12/06/2006
+	Purpose:	Hints that we've done with our DC
+	SeeAlso:	View; PaperRenderRegion.
+
+Note this is merely a hint. This routine is not guaranteed to eb called
+
+********************************************************************************************/
+
+void CCamView::DoneWithDC() const
+{
 	if (RenderWindow)
-	{
-		pDC = new wxClientDC(RenderWindow);
-		if (pDC)
-		{
-			CCDC::RegisterDC(pDC);
-		}
-	}
-
-	return(pDC);
+		RenderWindow->DoneWithDC();
 }
 
 /*********************************************************************************************
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 1301)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 1302)
@@ -1279,7 +1279,7 @@
 	}
 
 	// First thing we will clean up any "temporary" DCs
-	CCDC::CleanUpDCs();
+//	CCDC::CleanUpDCs();
 
 	ControlList::Idle();
 
Index: Trunk/XaraLX/wxOil/ccdc.h
===================================================================
--- Trunk/XaraLX/wxOil/ccdc.h	(revision 1301)
+++ Trunk/XaraLX/wxOil/ccdc.h	(revision 1302)
@@ -104,62 +104,59 @@
 //#include "rendtype.h" - in camtypes.h [AUTOMATICALLY REMOVED]
 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
 
-class CCDCListItem : public ListItem
-{
-public:
-	CC_DECLARE_DYNAMIC(CCDCListItem)
 
-	CCDCListItem(CNativeDC* pDC, RenderType Type = RENDERTYPE_SCREEN, BOOL bDeleteDC = TRUE)
-	{
-		m_pDC = pDC;
-		m_Type = Type;
-		m_bDeleteDC = bDeleteDC;
-	}
-	virtual ~CCDCListItem()
-	{
-		if (m_bDeleteDC && m_pDC)
-			delete m_pDC;
-	}
-
-	CNativeDC* GetDC() { return(m_pDC); }
-	RenderType GetRenderType() { return(m_Type); }
-
-protected:
-	CNativeDC* m_pDC;
-	RenderType m_Type;
-	BOOL m_bDeleteDC;
-};
-
-class CCDC : public wxDC
+class CCDC : public ListItem
 {
-	DECLARE_ABSTRACT_CLASS( CCDC )
+	CC_DECLARE_DYNAMIC( CCDC )
 
 public:
-	CCDC( RenderType );
+	CCDC( RenderType = RENDERTYPE_NONE);
 	CCDC( CNativeDC*, RenderType = RENDERTYPE_NONE );
 	~CCDC();
 
 protected:
 	RenderType Type;				// type of device being rendered to
 	LPRGNDATA lpRgnData;			// NULL if none
+	CNativeDC * m_pDC;
+	BOOL m_bDeleteDC;
 
 public:
+	CNativeDC* GetDC() const { return(m_pDC); }
+	operator CNativeDC & () { return (*m_pDC); }
+	void SetDC (CNativeDC * dc, BOOL bDeleteDC = TRUE);
+	RenderType GetRenderType() const { return Type; }
+
 	static UINT32 GetRectangleList(wxDC*, wxRect**);
 	static RenderType GetType(CNativeDC*, BOOL);
 	static BOOL IsPaperWanted(RenderType);
-	static BOOL RegisterDC(CNativeDC* pDC, RenderType rType = RENDERTYPE_SCREEN, BOOL bDeleteDC = TRUE);
 	static BOOL CleanUpDCs(void);
+	static CCDC *ConvertFromNativeDC( CNativeDC* pDC );
 
+
+
 protected:
 	static List s_DCList;
 };
 
-class CCPaintDC : public wxPaintDC
+class CCPaintDC : public CCDC
 {
 public:
 	CCPaintDC( wxWindow * );
 	~CCPaintDC();
+
+private:
+	wxPaintDC m_DC;
 };
 
+class CCClientDC : public CCDC
+{
+public:
+	CCClientDC( wxWindow * );
+	~CCClientDC();
 
+private:
+	wxClientDC m_DC;
+};
+
+
 #endif
Index: Trunk/XaraLX/wxOil/dlgmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgmgr.cpp	(revision 1301)
+++ Trunk/XaraLX/wxOil/dlgmgr.cpp	(revision 1302)
@@ -1203,7 +1203,7 @@
 			ExtraInfo.dx = (((INT32)WindowSize.GetWidth())*72000) / ExtraInfo.Dpi;
 			ExtraInfo.dy = (((INT32)WindowSize.GetHeight())*72000) / ExtraInfo.Dpi;
 		
-			MyDc.BeginDrawing();
+			MyDc.GetDC()->BeginDrawing();
 
 			wxRegionIterator upd(pGadget->GetUpdateRegion()); // get the update rect list
 
@@ -1224,7 +1224,7 @@
 
 				if (UseClipRect)
 				{
-					MyDc.SetClippingRegion(ClipRect);
+					MyDc.GetDC()->SetClippingRegion(ClipRect);
 					ClipRect.Inflate(1,1); // work around wxRect problems.
 				}
 				else
@@ -1254,7 +1254,7 @@
 				upd ++ ;
 			}
 		
-			MyDc.EndDrawing();		
+			MyDc.GetDC()->EndDrawing();		
 		
 			// if (OldPalette)
 			//	PaletteManager::StopPaintPalette(hDC, OldPalette);
Index: Trunk/XaraLX/wxOil/psdc.h
===================================================================
--- Trunk/XaraLX/wxOil/psdc.h	(revision 1301)
+++ Trunk/XaraLX/wxOil/psdc.h	(revision 1302)
@@ -131,6 +131,7 @@
 
 // Used for rendering text via GDI
 // (It is a simple cache system).
+class CFont;
 class PSDCFontInfo
 {
 public:
Index: Trunk/XaraLX/wxOil/ccdc.cpp
===================================================================
--- Trunk/XaraLX/wxOil/ccdc.cpp	(revision 1301)
+++ Trunk/XaraLX/wxOil/ccdc.cpp	(revision 1302)
@@ -116,7 +116,6 @@
 // It is set to be 10 rectangles by default.
 #define MAX_REGIONS (sizeof(RGNDATAHEADER) + (40 * sizeof(RECT)))
 
-CC_IMPLEMENT_DYNAMIC(CCDCListItem, ListItem)
 
 
 /********************************************************************************************
@@ -137,7 +136,7 @@
 
 // so we can runtime-check it
 
-IMPLEMENT_ABSTRACT_CLASS( CCDC, wxDC )
+CC_IMPLEMENT_DYNAMIC( CCDC, ListItem )
 
 List CCDC::s_DCList;
 
@@ -162,6 +161,8 @@
 {
 	lpRgnData = NULL;
 	Type = rType;
+	m_pDC = NULL;
+	m_bDeleteDC = TRUE;
 }
 
 /*********************************************************************************************
@@ -181,10 +182,12 @@
 
 *********************************************************************************************/ 
 
-CCDC::CCDC( wxDC *pDc, RenderType rType )
+CCDC::CCDC( CNativeDC *pDC, RenderType rType )
 {
 	lpRgnData = NULL;
 	Type = rType;
+	m_pDC = pDC;
+	m_bDeleteDC = FALSE;
 }
 
 /*********************************************************************************************
@@ -204,6 +207,7 @@
 
 CCDC::~CCDC()
 {
+	SetDC(NULL);
 	CCFree(lpRgnData);
 	lpRgnData = NULL;
 
@@ -214,7 +218,7 @@
 
 /*********************************************************************************************
 
->	static CCDC *ConvertFromCDC( CDC* pCDC )
+>	static CCDC *CCDC::ConvertFromNativeDC( CNativeDC* pDC )
 
 	Author:		Andy_Pennell (Xara Group Ltd) <camelotdev@xxxxxxxx>
 	Created:	12/10/93
@@ -228,11 +232,19 @@
 
 *********************************************************************************************/ 
 
-static CCDC *ConvertFromNativeDC( CNativeDC* pCDC )
+CCDC *CCDC::ConvertFromNativeDC( CNativeDC* pDC )
 {
-	if( !pCDC->IsKindOf( CLASSINFO(CCDC) ) )
-		return NULL;
-	return (CCDC *)pCDC;
+	// Scan the DCList to find the item
+	CCDC * pItem = (CCDC*)s_DCList.GetHead();
+	while (pItem)
+	{
+		if (pItem->GetDC() == pDC)
+			return pItem;
+
+		pItem = (CCDC*)s_DCList.GetNext(pItem);
+	}
+
+	return NULL;
 }
 
 /*********************************************************************************************
@@ -297,16 +309,6 @@
 
 	if (pCCDC == NULL)
 	{
-		// Scan the DCList to find the item
-		CCDCListItem* pItem = (CCDCListItem*)s_DCList.GetHead();
-		while (pItem)
-		{
-			if (pItem->GetDC() == pDC)
-				return(pItem->GetRenderType());
-
-			pItem = (CCDCListItem*)s_DCList.GetNext(pItem);
-		}
-
 		PORTNOTETRACE("other","CCDC::GetType - can't calculate device type yet");
 #ifndef EXCLUDE_FROM_XARALX
 		if (bCalculate)
@@ -435,19 +437,6 @@
 }
 
 
-BOOL CCDC::RegisterDC(CNativeDC* pDC, RenderType rType, BOOL bDeleteDC)
-{
-	CCDCListItem* pItem = new CCDCListItem(pDC, rType, bDeleteDC);
-	if (pItem)
-	{
-		s_DCList.AddTail(pItem);
-		return(TRUE);
-	}
-
-	return(FALSE);
-}
-
-
 BOOL CCDC::CleanUpDCs(void)
 {
 	// Delete all the entries in the list (the item destructors will delete the DCs)
@@ -457,7 +446,26 @@
 }
 
 
+void CCDC::SetDC (CNativeDC * dc, BOOL bDeleteDC /*= TRUE*/)
+{
+	if (m_pDC == dc)
+		return;
 
+	if (m_pDC)
+	{
+		if (m_bDeleteDC)
+			delete (m_pDC);
+		// take us off the list
+		s_DCList.RemoveItem(this);
+	}
+	m_pDC = dc;
+	if (m_pDC)
+	{
+		m_bDeleteDC = bDeleteDC;
+		// put us on the list
+		s_DCList.AddTail(this);
+	}
+}
 
 /********************************************************************************************
 
@@ -489,10 +497,10 @@
 
 *********************************************************************************************/ 
 
-CCPaintDC::CCPaintDC(wxWindow *pWnd) : wxPaintDC(pWnd)
+CCPaintDC::CCPaintDC(wxWindow *pWnd) : CCDC(RENDERTYPE_SCREEN), m_DC(pWnd)
 {
 	// Register this DC with the DC type system and set that it is temporary
-	CCDC::RegisterDC(this, RENDERTYPE_SCREEN, FALSE);
+	CCDC::SetDC(&m_DC, FALSE);
 
 #ifndef EXCLUDE_FROM_XARALX
 	// Loose the old region data
@@ -565,3 +573,46 @@
 CCPaintDC::~CCPaintDC()
 {
 }
+
+/*********************************************************************************************
+
+>	CCClientDC::CCClientDC(CWnd* pWnd)
+
+	Author:		Andy_Pennell (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	11/10/93
+	Inputs:		Pointer to owner window.
+	Outputs:	None
+	Returns:	None
+	Purpose:	Constructor for CCClientDC which gets the update rectangle list before doing
+				a BeginPaint.
+	Errors:		-
+	Scope:	    Public
+	SeeAlso:	CCDC;RenderType
+
+*********************************************************************************************/ 
+
+CCClientDC::CCClientDC(wxWindow *pWnd) : CCDC(RENDERTYPE_SCREEN), m_DC(pWnd)
+{
+	// Register this DC with the DC type system and set that it is temporary
+	CCDC::SetDC(&m_DC, FALSE);
+}
+
+
+/*********************************************************************************************
+
+>	CCClientDC::~CCClientDC()
+
+	Author:		Andy_Pennell (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	11/10/93
+	Inputs:		None
+	Outputs:	None
+	Returns:	None
+	Purpose:	Destructor for CCClientDC which does an EndPaint.
+	Errors:		-
+	Scope:	    Public
+
+*********************************************************************************************/ 
+
+CCClientDC::~CCClientDC()
+{
+}


Xara