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

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1593
Date       : Sat Jul 29 12:22:32 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/rndrgn.cpp
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/printprg.cpp
   M /Trunk/XaraLX/wxOil/printprg.h
   M /Trunk/XaraLX/wxOil/prncamvw.cpp
   M /Trunk/XaraLX/wxOil/prncamvw.h
   M /Trunk/XaraLX/wxOil/rendwnd.cpp

Fix problems created by yielding in printing properly - see bz #1336


Diff:
Index: Trunk/XaraLX/Kernel/rndrgn.cpp
===================================================================
--- Trunk/XaraLX/Kernel/rndrgn.cpp	(revision 1592)
+++ Trunk/XaraLX/Kernel/rndrgn.cpp	(revision 1593)
@@ -863,6 +863,7 @@
 {
 	return AttachDevice(ViewToAttach, DCToAttach->GetDC(), SpreadToAttach, fOwned);
 }
+#include "prncamvw.h"
 
 BOOL RenderRegion::AttachDevice(View* ViewToAttach, wxDC* DCToAttach,
 								Spread* SpreadToAttach, bool fOwned /*= false*/)
@@ -1170,6 +1171,11 @@
 
 BOOL RenderRegion::StartRender()
 {
+	if ((!RenderFlags.Printing) && (PrintMonitor::IsPrintingNow()))
+	{
+		::wxBell();
+	}
+
 	// If the device has not been Inited, then do it now
 	if (!RenderFlags.ValidDevice)
 	{
Index: Trunk/XaraLX/wxOil/rendwnd.cpp
===================================================================
--- Trunk/XaraLX/wxOil/rendwnd.cpp	(revision 1592)
+++ Trunk/XaraLX/wxOil/rendwnd.cpp	(revision 1593)
@@ -266,6 +266,9 @@
 
 void CRenderWnd::OnIdle(wxIdleEvent &event)
 {
+	if (PrintMonitor::IsPrintingNow())
+		return;
+
 	if ((m_DCUsers<=0) && m_pCCClientDC)
 	{
 		delete m_pCCClientDC;
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 1592)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 1593)
@@ -131,6 +131,7 @@
 #include "filedlgs.h"
 #include "progress.h"
 #include "prdlgctl.h"
+#include "prncamvw.h"
 #include "gbrush.h"
 
 #include "camprocess.h"
@@ -259,6 +260,21 @@
 {
 	static /*TYPENOTE: Correct*/ long	lLastTimeStamp = 0;
 
+	if (PrintMonitor::IsPrintingNow())
+	{
+		// Disable processing of paint messages for various controls which may use GDraw or GBrush to paint, as this
+		// appears to upset printing
+		if (event.IsKindOf(CLASSINFO(wxPaintEvent)))
+		{
+			wxObject* pEventObject = event.GetEventObject();
+			if (!pEventObject->IsKindOf(CLASSINFO(wxCamArtControl)))
+			{	
+				// TRACEUSER("amb", _T("CCamApp::FilterEvent caught paint for %s"), pEventObject->GetClassInfo()->GetClassName());
+				return false;
+			}
+		}
+	}
+
 // useful code to see where focus events originate from. Set a breakpoint below and look
 // at the call stack
 #if 0 && defined(_DEBUG)
@@ -1592,7 +1608,7 @@
 {
 //	TRACEUSER("Gerry", _T("CCamApp::OnIdle
"));
 
-	if ( IsDisabled() )
+	if ( IsDisabled() || PrintMonitor::IsPrintingNow() )
 	{
 //		TRACEUSER("Gerry", _T("Disabled - Is this a bad thing????????
"));
 		event.Skip();
@@ -1619,13 +1635,17 @@
 
 void CCamApp::OnTimer( wxTimerEvent& WXUNUSED(event) )
 {
+	if (!PrintMonitor::IsPrintingNow() )
+	{
+//		TRACEUSER("Gerry", _T("Disabled - Is this a bad thing????????
"));
+		//
+		// This should also exit the while loop if there are messages in the
+		// message queue.
+		//
+		while ( Camelot.ServiceRendering() )
+			;
+	}
 PORTNOTE("other","CCamApp::OnTimer - needs completing")
-	//
-	// This should also exit the while loop if there are messages in the
-	// message queue.
-	//
-	while ( Camelot.ServiceRendering() )
-		;
 }
 
 /*******************************************************************************************/
Index: Trunk/XaraLX/wxOil/printprg.h
===================================================================
--- Trunk/XaraLX/wxOil/printprg.h	(revision 1592)
+++ Trunk/XaraLX/wxOil/printprg.h	(revision 1593)
@@ -125,7 +125,7 @@
 	CC_DECLARE_DYNCREATE( PrintProgressDlg )  
 public:
 	PrintProgressDlg();
-	virtual ~PrintProgressDlg() { pPrintProgressDlg = NULL; }
+	virtual ~PrintProgressDlg() { pPrintProgressDlg = NULL; if (pDisabler) { delete pDisabler; pDisabler=NULL;} }
 
 	MsgResult Message( Msg* Message );  
 	void Do(OpDescriptor*);		// "Do" function        
@@ -186,6 +186,8 @@
 private:
 	static PrintProgressDlg* pPrintProgressDlg;		// Ptr to dlg used by AbortProc()
 
+	wxWindowDisabler * pDisabler;
+
 public:
 	static PrintProgressDlg * Get() {return pPrintProgressDlg;}
 };
Index: Trunk/XaraLX/wxOil/prncamvw.h
===================================================================
--- Trunk/XaraLX/wxOil/prncamvw.h	(revision 1592)
+++ Trunk/XaraLX/wxOil/prncamvw.h	(revision 1593)
@@ -127,6 +127,7 @@
 	static BOOL IsPrintingActive();
 	static BOOL IsPrintingNow();
 	static void WantFullRedraw(BOOL);
+	static BOOL IsYieldDisabled() {return s_YieldDisabled;}
 
 	typedef enum
 	{
@@ -140,6 +141,7 @@
 	static BOOL PrintWithDriverBands;
 	static MaskType PrintMaskType;
 	static BOOL FullRedrawNeeded;
+	static BOOL s_YieldDisabled;
 
 protected:
 	static CNativeDC * CurrentPrintJob;
Index: Trunk/XaraLX/wxOil/printprg.cpp
===================================================================
--- Trunk/XaraLX/wxOil/printprg.cpp	(revision 1592)
+++ Trunk/XaraLX/wxOil/printprg.cpp	(revision 1593)
@@ -116,6 +116,7 @@
 //#include "fixst256.h" - in camtypes.h [AUTOMATICALLY REMOVED]
 #include "camelot.h"
 //#include "justin2.h"
+#include "prncamvw.h"
 
 DECLARE_SOURCE("$Revision$");
 
@@ -159,6 +160,7 @@
 	SliderSubRangeStep = 1;
 
 	pPrintProgressDlg = this;
+	pDisabler = NULL;
 
 	Printing = FALSE;
 	IgnoreUpdates = FALSE;
@@ -259,6 +261,11 @@
 			SetSliderPos(0);
 			IgnoreUpdates = FALSE;
 			UpdateTime.Sample();
+
+			if (pDisabler)
+				delete pDisabler;
+			pDisabler = new wxWindowDisabler(WindowID);
+			::wxYield(); // flush anything out the system
 		}
 		else if (Msg->DlgMsg == DIM_CANCEL)
 		{
@@ -477,12 +484,12 @@
 	pPrintProgressDlg->PaintGadgetNow(0);
 
 	// Only sample if 750ms of printing has elapsed as the yield can take a while
-	if (pPrintProgressDlg->UpdateTime.Elapsed(750))
+	if (!PrintMonitor::IsYieldDisabled() && (pPrintProgressDlg->UpdateTime.Elapsed(750)))
 	{
 		// Save current doc view etc. around yield as paint can destroy them.
 		View * pCurrentView = View::GetCurrent();
 		Document * pCurrentDocument = Document::GetCurrent();
-//		::wxSafeYield(pPrintProgressDlg->WindowID, TRUE); - THIS YIELD CAUSES PROBLEMS (some bit of attribute stack is being corrupted) - AMB
+		AfxGetApp().Yield(TRUE);
 		pCurrentDocument->SetCurrent();
 		pCurrentView->SetCurrent();
 
Index: Trunk/XaraLX/wxOil/prncamvw.cpp
===================================================================
--- Trunk/XaraLX/wxOil/prncamvw.cpp	(revision 1592)
+++ Trunk/XaraLX/wxOil/prncamvw.cpp	(revision 1593)
@@ -265,6 +265,8 @@
 		   					   	  (INT32 *) &PrintMonitor::PrintMaskType, MASK_SIMPLE, MASK_OPTIMAL) &&
 		   	  Camelot.DeclarePref(TEXT("Printing"), TEXT("PrintWithDriverBands"),
 		   					   	  &PrintMonitor::PrintWithDriverBands, FALSE, TRUE);
+		   	  Camelot.DeclarePref(TEXT("Printing"), TEXT("DisableYield"),
+		   					   	  &PrintMonitor::s_YieldDisabled, FALSE, TRUE);
 	return ok;
 }
 
@@ -280,6 +282,7 @@
 // Default to printing without mask, but with bands.
 BOOL PrintMonitor::PrintWithDriverBands = TRUE;
 BOOL PrintMonitor::PrintWithMask = TRUE;
+BOOL PrintMonitor::s_YieldDisabled = FALSE;
 PrintMonitor::MaskType PrintMonitor::PrintMaskType = MASK_OPTIMAL;
 
 


Xara