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

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1389
Date       : Thu Jun 29 12:29:55 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/camview.cpp
   M /Trunk/XaraLX/wxOil/prdlgctl.cpp
   M /Trunk/XaraLX/wxOil/psdc.cpp

Fix printing inversion problem
Enable printing on retail builds as it is now semi-useful


Diff:
Index: Trunk/XaraLX/wxOil/prdlgctl.cpp
===================================================================
--- Trunk/XaraLX/wxOil/prdlgctl.cpp	(revision 1388)
+++ Trunk/XaraLX/wxOil/prdlgctl.cpp	(revision 1389)
@@ -128,7 +128,6 @@
 //#include "resource.h"	// _R(IDS_OK)/CANCEL
 //#include "simon.h"		// _R(IDS_HELP)
 
-
 #ifdef _DEBUG
 #include "optsprin.h"
 #include "keypress.h"
@@ -2541,6 +2540,8 @@
 
 BOOL CCPrintInfo::OnPreparePrinting(BOOL bPrintSetupOnly /*=FALSE*/)
 {
+	wxPostScriptDC::SetResolution(600); // temporary bodge
+
 	// Zap any existing print dialog
 	if (pOurPD)
 	{
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp	(revision 1388)
+++ Trunk/XaraLX/wxOil/camview.cpp	(revision 1389)
@@ -873,10 +873,12 @@
 #ifndef WEBSTER
 void CCamView::OnFilePrint()
 {
+#if 0
 #ifndef _DEBUG
 	::wxMessageBox(_T("Printing currently disabled in retail builds"));
 	return;
 #endif
+#endif
 
 	SetCurrentStates();
 
Index: Trunk/XaraLX/wxOil/psdc.cpp
===================================================================
--- Trunk/XaraLX/wxOil/psdc.cpp	(revision 1388)
+++ Trunk/XaraLX/wxOil/psdc.cpp	(revision 1389)
@@ -292,6 +292,35 @@
 		OutputToken(_T("save"));
 		OutputNewLine();
 
+		// wxWidgets and Windows both use (0,0) to mean the top left hand origin of the
+		// paper in logical coordinates. However, they do something rather different in
+		// terms of physical coordinates. What windows printer drivers do (and thus what
+		// Camelot expects) is use a postcript page transformation matrix to invert the
+		// page, and for the postscript to be written in native DPI coordinates with the
+		// origin at the TOP left of the page. What wxWidgets does is write its postscript
+		// in the more natural way with the origin at the BOTTOM of the page, and handle
+		// the coordinate inversion wihin wxWidgets.
+		//
+		// Note that this means while our internally generated PS expects a transformation
+		// matrix that flips the Y coordinate (as the windows drivers produce). We
+		// can't change the transformation matrix in the prologue because this would
+		// affect wxWidgets output (and also it's technically difficult to do). We can't
+		// change our own rendering matrix (so we produce the right coordinates) because
+		// lots of things seem to explode with a matrix which flips the Y access (negative
+		// scale factors etc.). We can't just change the coordinates we write because
+		// other things (e.g. bitmaps) use the native render matrix. So what we do is
+		// temporarily invert the PS transformation matrix during the period of our output.
+		// This seems arcane but reasonably extensive research suggests it is the best
+		// way forward. It's restored before we do any OS output.
+
+		TCHAR flipbuf[256];
+		INT32 translate = GetDC()->GetSize().GetHeight();
+		camSprintf(flipbuf, _T("0 %d translate 1 -1 scale"), translate);
+		OutputToken(flipbuf);
+		OutputNewLine();
+
+		// Now start plate writing etc.
+
 		if (!pPSRegion->WritePhotoNegative(this))
 			return FALSE;
 
@@ -678,14 +707,8 @@
 	// We need a view to scale the coords.
 	ERROR2IF(pView == NULL, FALSE, "No view attached to PostScript DC!");
 
-	// Use the rendering matrix of our parent render region to transform
-	// the co-ordinate to device units before proceeding.
-	OilCoord NewCoord(Coord.x, Coord.y);
-	RenderMatrix.transform(&NewCoord);
+	WinCoord PSCoord = TransformCoord(Coord);
 
-	// Convert to Windows device units.
-	WinCoord PSCoord = NewCoord.ToWin(pView);
-
 	// Output to PostScript stream.
 	BOOL Ok = (OutputValue(PSCoord.x) && OutputValue(PSCoord.y));
 


Xara