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

[XaraXtreme-dev] Convert text to shapes and eor rendering



Find attached below a patch to enable "Convert to editable shapes" for 
text objects and eor rendering during drags

nodetxtl.cpp:
enabled CreateNodeGroup, which is required for shape conversion

nodetext.cpp:
fixed and enabled RenderEorDrag (used to crash due to incorrect 
iterator usage), removed unnecessary #include

osrndrgn.cpp:
text rendering is delegated to RenderRegion, which renders it as paths 
- needed for eor rendering during drags

Martin
Index: Kernel/nodetxtl.cpp
===================================================================
--- Kernel/nodetxtl.cpp	(Revision 765)
+++ Kernel/nodetxtl.cpp	(Arbeitskopie)
@@ -417,7 +417,7 @@
 BOOL TextLine::CreateNodeGroup(NodeGroup** ppNodeGroup, FormatRegion* pFormatRegion, BecomeA* pBecomeA)
 {
 	PORTNOTETRACE("text","TextLine::CreateNodeGroup - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+#ifndef DISABLE_TEXT_RENDERING
 	ERROR2IF(pFormatRegion==NULL,FALSE,"TextChar::CreateNodeGroup() - pFormatRegion==NULL");
 	ERROR2IF(     pBecomeA==NULL,FALSE,"TextChar::CreateNodeGroup() - pBecomeA==NULL");
 	ERROR2IF(  ppNodeGroup==NULL,FALSE,"TextChar::CreateNodeGroup() - ppNodeGroup==NULL");
Index: Kernel/nodetext.cpp
===================================================================
--- Kernel/nodetext.cpp	(Revision 765)
+++ Kernel/nodetext.cpp	(Arbeitskopie)
@@ -112,7 +112,7 @@
 
 // Code headers
 #include "app.h"
-#include "becomea.h"
+//#include "becomea.h"
 #include "blobs.h"
 //#include "cameleps.h"
 #include "cliptype.h"
@@ -2109,20 +2109,22 @@
 
 void TextChar::RenderEorDrag(RenderRegion* pRenderRegion)
 {
-PORTNOTE("text", "so far, enabling this crashes when a text object is moved and an EOR display is attempted")
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
-	// Before rendering the character we need to render it's applied *TEXT* attributes
-	// into the render region as EOR drag render regions dosen't maintain an attribute stack
+#if !defined(EXCLUDE_FROM_RALPH) && !defined(DISABLE_TEXT_RENDERING)
+	// Before rendering the character we need to render its applied *TEXT* attributes
+	// into the render region as EOR drag render regions don't maintain an attribute stack
 	CCAttrMap* pAttribMap = new CCAttrMap(30);
-	BOOL FoundAttributes = FindAppliedAttributes(pAttribMap);
+	BOOL FoundAttributes = FALSE;
+	if (pAttribMap)
+		FoundAttributes = FindAppliedAttributes(pAttribMap);
 	
-	if (pAttribMap!=NULL)
+	if (FoundAttributes)
 	{
 		pRenderRegion->SaveContext();
-
 		// Render the text attributes
 		CCAttrMap::iterator pos = pAttribMap->GetStartPosition();
-		while (pos!=NULL)
+		CCAttrMap::iterator	end = pAttribMap->GetEndPosition();
+	
+		while (pos != end)
 		{
 			CCRuntimeClass *pKey;
 			void		   *pVal;
@@ -2131,13 +2133,14 @@
 			if (((NodeAttribute*)pVal)->IsKindOfTextAttribute())
 				((NodeAttribute*)pVal)->Render(pRenderRegion);
 		}
+	}
 
-		// Render the character
-		if (RenderCore(pRenderRegion)==FALSE)
-			InformError();
+	// Render the character
+	if (RenderCore(pRenderRegion)==FALSE)
+		InformError();
 
+	if (FoundAttributes)
 		pRenderRegion->RestoreContext();
-	}
 
 	if (pAttribMap!=NULL) delete pAttribMap;
 #endif
Index: wxOil/osrndrgn.cpp
===================================================================
--- wxOil/osrndrgn.cpp	(Revision 765)
+++ wxOil/osrndrgn.cpp	(Arbeitskopie)
@@ -7154,6 +7154,8 @@
 	RenderDC->SetTextAlign(OldTextAlign);
 	RenderDC->SetBkMode(OldBKMode);
 	RenderDC->SetTextColor(OldTextColor);
+#elif !defined(DISABLE_TEXT_RENDERING)
+	return RenderRegion::RenderChar(ch, pMatrix);
 #endif
 	return TRUE;
 }