#include <nodetext.h>
Inheritance diagram for TextChar:
Public Member Functions | |
TextChar () | |
Simple TextChar constructor, it is required so that SimpleCopy will work. You should not normally call this constructor as it does not initialise the object. | |
TextChar (Node *ContextNode, AttachNodeDirection Direction, WCHAR ChCode) | |
The main TextChar constructor. | |
virtual BOOL | SupportsClipboardFormat (InternalClipboardFormat *Format) const |
Determine if a node supports a given internal data type. This is used by the clipboard when exporting to other applications in order to determine if certain data types can be supplied. | |
virtual BOOL | Snap (DocCoord *pDocCoord) |
Snaps to given coord to the nearest point on the characters render path. If it is not appropriate to snap the coord to the shape (at the moment this means the coord is too far awawy), then FALSE is returned. | |
virtual UINT32 | GetNodeSize () const |
For finding the size of the node. | |
virtual void | GetDebugDetails (StringBase *Str) |
For obtaining debug information about the Node. This fn can be deleted before we ship. | |
virtual void | Render (RenderRegion *pRenderRegion) |
render a TextChar with the current attributes specified in the RenderRegion | |
BOOL | RenderCore (RenderRegion *pRenderRegion) |
render a TextChar with the current attributes specified in the RenderRegion | |
void | RenderEorDrag (RenderRegion *pRenderRegion) |
Renders the selection blobs for this TextChar. | |
BOOL | CreateNodePath (NodePath **ppNodePath, FormatRegion *pFormatRegion) |
Transforms the TextChar into a NodePath. | |
virtual BOOL | IsATextChar () const |
virtual BOOL | IsSetCandidate () const |
Indicates that NodeRenderableInks are candidates for membership of Attribute gallery set. | |
virtual BOOL | IsASpace () |
virtual BOOL | IsAVisibleSpace () |
virtual BOOL | IsAHyphen () |
virtual WCHAR | GetUnicodeValue () |
virtual void | SetUnicodeValue (WCHAR Char) |
virtual MILLIPOINT | GetAutoKernSize (FormatRegion *pFormatRegion) |
Find auto kern between two TextChar and next TextChar in the story. | |
virtual BOOL | ExportRender (RenderRegion *pRegion) |
If pRenderRegion points to a FlashRenderRegion, the character will be processed as a Flash character, and ultimately stored in the export file in the appropriate manner. (As a set of three records: One referring to the paths, one mapping the paths onto characters, and one detailling the text string itself. | |
virtual void | PolyCopyNodeContents (NodeRenderable *pNodeCopy) |
Polymorphically copies the contents of this node to another. | |
virtual BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter) |
Writes a text char record to the new file format filter. | |
virtual BOOL | WritePreChildrenNative (BaseCamelotFilter *pFIlter) |
virtual BOOL | WritePostChildrenWeb (BaseCamelotFilter *pFilter) |
Tells the text node that all it's children have been exported (or skipped if CanWriteChildrenWeb() returned FALSE). | |
virtual BOOL | WritePostChildrenNative (BaseCamelotFilter *pFilter) |
virtual BOOL | CanWriteChildrenWeb (BaseCamelotFilter *pFilter) |
Asks if it's alright to write out the char's children. | |
virtual BOOL | CanWriteChildrenNative (BaseCamelotFilter *pFilter) |
Protected Member Functions | |
virtual Node * | SimpleCopy () |
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes of Node. | |
void | CopyNodeContents (TextChar *NodeCopy) |
This method copies the node's contents to the node pointed to by NodeCopy. | |
Private Attributes | |
WCHAR | Ch |
Definition at line 289 of file nodetext.h.
|
Simple TextChar constructor, it is required so that SimpleCopy will work. You should not normally call this constructor as it does not initialise the object.
Definition at line 1843 of file nodetext.cpp. 01843 : AbstractTextChar() 01844 { 01845 Ch = _T('\0'); 01846 }
|
|
The main TextChar constructor.
Specifies the direction in which the node is to be attached to the ContextNode. The values this variable can take are as follows: PREV : Attach node as a previous sibling of the context node NEXT : Attach node as a next sibling of the context node FIRSTCHILD: Attach node as the first child of the context node LASTCHILD : Attach node as a last child of the context node Definition at line 1869 of file nodetext.cpp. 01870 : AbstractTextChar(ContextNode, Direction) 01871 { 01872 Ch = ChCode; 01873 }
|
|
Reimplemented from Node. Definition at line 2413 of file nodetext.cpp. 02414 { 02415 return !AlreadyWritten(); 02416 }
|
|
Asks if it's alright to write out the char's children.
Reimplemented from Node. Definition at line 2405 of file nodetext.cpp. 02406 { 02407 return !AlreadyWritten(); 02408 }
|
|
This method copies the node's contents to the node pointed to by NodeCopy.
Definition at line 1935 of file nodetext.cpp. 01936 { 01937 // Ask the base class to do its bit 01938 AbstractTextChar::CopyNodeContents( NodeCopy ); 01939 // Copy the rest of the data in here 01940 NodeCopy->Ch = Ch; 01941 }
|
|
Transforms the TextChar into a NodePath.
Definition at line 2204 of file nodetext.cpp. 02205 { 02206 #ifndef DISABLE_TEXT_RENDERING 02207 ERROR2IF(pFormatRegion==NULL,FALSE,"TextChar::CreateNodePath() - pFormatRegion==NULL"); 02208 ERROR2IF( ppNodePath==NULL,FALSE,"TextChar::CreateNodePath() - ppNodePath==NULL"); 02209 02210 // get the char's path transformed to the correct place inthe doc 02211 Matrix matrix; 02212 if (GetStoryAndCharMatrix(&matrix)==FALSE) 02213 return FALSE; 02214 Path* pPath=pFormatRegion->CreateCharPath(GetUnicodeValue(), &matrix); 02215 if (pPath==NULL) 02216 return FALSE; 02217 pPath->InitialiseFlags(); 02218 02219 // Allocate a new NodePath node and copy path data into it 02220 BOOL ok=TRUE; 02221 NodePath* pNodePath=NULL; 02222 if (pPath->GetNumCoords()!=0) 02223 { 02224 pNodePath=new NodePath; 02225 ok=(pNodePath!=NULL); 02226 if (ok) ok=pNodePath->InkPath.Initialise(pPath->GetNumCoords(),1); 02227 if (ok) ok=pNodePath->InkPath.CopyPathDataFrom(pPath); 02228 if (!ok) 02229 { 02230 delete pNodePath; 02231 pNodePath=NULL; 02232 } 02233 } 02234 02235 delete pPath; 02236 02237 *ppNodePath=pNodePath; 02238 return ok; 02239 #else 02240 return FALSE; 02241 #endif 02242 }
|
|
If pRenderRegion points to a FlashRenderRegion, the character will be processed as a Flash character, and ultimately stored in the export file in the appropriate manner. (As a set of three records: One referring to the paths, one mapping the paths onto characters, and one detailling the text string itself.
Reimplemented from NodeRenderableInk. Definition at line 2167 of file nodetext.cpp. 02168 { 02169 BOOL bResult = FALSE; 02170 02171 // If the RenderRegion is a FlashRenderRegion, use custom Flash export code. 02172 if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( FlashRenderRegion ) ) ) 02173 { 02174 // Step 1: Cast the pRegion pointer to be a FlashRenderRegion pointer, so that 02175 // it can access the custom Flash export methods. 02176 FlashRenderRegion *pFlash = ( FlashRenderRegion* ) pRegion; 02177 02178 // Step 1a: If the character supports fill or line types that are unsupported by 02179 // Flash, return FALSE, and export them as paths. 02180 // (Option, may add later.) 02181 02182 // Step 2: Pass the character into the appropriate method to export the character. 02183 // This is where all the hard work is done. 02184 bResult = pFlash->ExportCharacter ( this ); 02185 } 02186 02187 // Step 3: The export has been done successfully. Return TRUE to prevent Camelot 02188 // from rendering the character out as paths as well as text. (If there's 02189 // been an error, bResult will have been set to FALSE.) 02190 return bResult; 02191 }
|
|
Find auto kern between two TextChar and next TextChar in the story.
Reimplemented from VisibleTextNode. Definition at line 2429 of file nodetext.cpp. 02430 { 02431 TextChar* pNextTC = FindNextTextCharInStory(); 02432 02433 if (pNextTC) 02434 { 02435 // If we get here, we know there is a TextChar (this) and a following textchar (pNextTC) 02436 // that might have a kern between them. Before asking for that kerning value, we have 02437 // to check that both 'this' and 'pNextTC' are of the same font and have the same bold/ 02438 // italic attribs. If we did not do this, GetCharsKerning would use the font currently 02439 // selected into pFormatRegion which is just the font the TextChar 'this'. 02440 02441 // The basic method I am using to do this is to look at the child attribs of 'this' 02442 // (don't care about attribs higher up the tree as they will apply to both 'this' and 02443 // 'pNextTC') and check that pNextTC also has child attribs of the same type. 02444 02445 // Well it should work... 02446 02447 // Hopefully... 02448 02449 Node *Child; // used to point to child attribs of 'this' 02450 Node *CompareChild; // used to point to child attribs of 'pNextTC' 02451 02452 Child = FindFirstChild(); 02453 while (Child) 02454 { 02455 if (IS_A(Child,AttrTxtFontTypeface) || 02456 IS_A(Child,AttrTxtItalic) || 02457 IS_A(Child,AttrTxtBold) || 02458 IS_A(Child,AttrTxtFontSize) || 02459 IS_A(Child,AttrTxtScript)) 02460 { 02461 // 'this' has a child node that could mean it has a difference between 02462 // it 'pNextTC' that could be important to us. Now we have to find out firstly 02463 // 'pNextTC' has this child node and if so if it has the same value. 02464 CompareChild = pNextTC->FindFirstChild(); 02465 while (CompareChild && Child->GetRuntimeClass() != CompareChild->GetRuntimeClass()) 02466 CompareChild = CompareChild->FindNext(); 02467 02468 if (CompareChild) 02469 { 02470 // If we get here we have found an attrib that is shared by 'this' and 'pNextTC' 02471 // with 'Child' pointing to the attrib of 'this' and 'CompareChild' pointing to the 02472 // attrib of 'pNextTC'. 02473 if (Child->IsDifferent(CompareChild)) 02474 return 0; // No kern 02475 } 02476 else 02477 { 02478 // We found an attrib on 'this' but not on 'pNextTC' so they must be different. 02479 // That means that we don't kern. 02480 return 0; // No kern 02481 } 02482 } 02483 02484 Child = Child->FindNext(); 02485 } 02486 02487 // If we get here, we know that 'this' has no attribs that are different from 'pNextTC'. 02488 // What we don't know is if 'pNextTC' has an attrib that 'this' does not have. This case 02489 // is made a little simpler as the mere existence of an attrib should be enough to make the 02490 // two different so there is no need to compare the attrib values. 02491 CompareChild = pNextTC->FindFirstChild(); 02492 while (CompareChild) 02493 { 02494 if (IS_A(CompareChild,AttrTxtFontTypeface) || 02495 IS_A(CompareChild,AttrTxtItalic) || 02496 IS_A(CompareChild,AttrTxtBold) || 02497 IS_A(CompareChild,AttrTxtFontSize) || 02498 IS_A(CompareChild,AttrTxtScript)) 02499 { 02500 // Found an attrib of 'pNextTC'. Just need to check that 'this' has this attrib as well 02501 // (if it does have that attrib, we will have checked they are the same in the IsDifferent() 02502 // call, above). 02503 Child = FindFirstChild(); 02504 while (Child && Child->GetRuntimeClass() != CompareChild->GetRuntimeClass()) 02505 Child = Child->FindNext(); 02506 02507 if (!Child) 02508 return 0; // No kern 02509 } 02510 02511 CompareChild = CompareChild->FindNext(); 02512 } 02513 02514 // Wow, we got through all the tests so I guess we might as well check for a kern now 02515 // (at last). Possible optimisation - we could do this at the top of the function and 02516 // then do all the all the checking afterwards - not sure if this would be faster or not. 02517 return pFormatRegion->GetCharsKerning(GetUnicodeValue(), pNextTC->GetUnicodeValue()); 02518 } 02519 else 02520 return 0; // No kern 02521 }
|
|
For obtaining debug information about the Node. This fn can be deleted before we ship.
Reimplemented from AbstractTextChar. Definition at line 1969 of file nodetext.cpp. 01970 { 01971 #ifdef _DEBUG 01972 AbstractTextChar::GetDebugDetails(Str); 01973 String_256 TempStr; 01974 01975 TempStr._MakeMsg( TEXT( "\r\nUnicode Ch code = #1%u ('#2%c')"),Ch, (Ch<256) ? Ch : ' ' ); 01976 (*Str) += TempStr; 01977 #endif 01978 }
|
|
For finding the size of the node.
Reimplemented from AbstractTextChar. Definition at line 1953 of file nodetext.cpp. 01954 { 01955 return (sizeof(TextChar)); 01956 }
|
|
Reimplemented from AbstractTextChar. Definition at line 315 of file nodetext.h. 00315 { return Ch; }
|
|
Reimplemented from VisibleTextNode. Definition at line 313 of file nodetext.h. 00313 { return Ch=='-'; }
|
|
Reimplemented from VisibleTextNode. Definition at line 311 of file nodetext.h. 00311 { return Ch==' '; }
|
|
Reimplemented from Node. Definition at line 308 of file nodetext.h. 00308 { return TRUE; }
|
|
Reimplemented from VisibleTextNode. Definition at line 312 of file nodetext.h. 00312 { return iswspace(Ch); }
|
|
Indicates that NodeRenderableInks are candidates for membership of Attribute gallery set.
Reimplemented from BaseTextClass. Definition at line 309 of file nodetext.h. 00309 { return TRUE; }
|
|
Polymorphically copies the contents of this node to another.
Reimplemented from AbstractTextChar. Definition at line 1914 of file nodetext.cpp. 01915 { 01916 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node"); 01917 ENSURE(IS_A(pNodeCopy, TextChar), "PolyCopyNodeContents given wrong dest node type"); 01918 01919 if (IS_A(pNodeCopy, TextChar)) 01920 CopyNodeContents((TextChar*)pNodeCopy); 01921 }
|
|
render a TextChar with the current attributes specified in the RenderRegion
Reimplemented from Node. Definition at line 1990 of file nodetext.cpp. 01991 { 01992 if (RenderCore(pRenderRegion)==FALSE) 01993 { 01994 // Mike 6/10/95: removed this call as it causes big problems if redraw fails 01995 // InformError(); 01996 } 01997 }
|
|
render a TextChar with the current attributes specified in the RenderRegion
Definition at line 2010 of file nodetext.cpp. 02011 { 02012 #ifndef DISABLE_TEXT_RENDERING 02013 ERROR2IF(pRenderRegion == NULL, FALSE, "TextChar::RenderCore() - pRenderRegion == NULL"); 02014 02015 // TRACEUSER("wuerthne", _T("TextChar::RenderCore %04x"), GetUnicodeValue()); 02016 // If the render region is being used for hit detection then render bounds 02017 // BODGE TEXT - should be in the render region RenderChar function 02018 if (pRenderRegion->IsHitDetect() && 02019 pRenderRegion->RRQuality.GetLineQuality() != Quality::BlackLine && 02020 Tool::GetCurrentID() == TOOLID_TEXT) 02021 { 02022 Path* pPath = CreateMetricsRectPath(); 02023 ERROR2IF(pPath == NULL, FALSE, "TextChar::RenderCore() - CreateMetricsRectPath() failed"); 02024 pRenderRegion->SaveContext(); 02025 pRenderRegion->SetFillColour(COLOUR_BLACK); 02026 pRenderRegion->DrawPath(pPath); 02027 pRenderRegion->RestoreContext(); 02028 delete pPath; 02029 return TRUE; 02030 } 02031 02032 Matrix matrix; 02033 if (GetStoryAndCharMatrix(&matrix) == FALSE) return FALSE; 02034 02035 // render the character through the matrix with current attributes in RenderRegion 02036 02037 // If the render region is a printing region then maybe print as shapes. 02038 if (pRenderRegion->IsPrinting()) 02039 { 02040 PrintControl* pCtrl = pRenderRegion->GetRenderView()->GetPrintControl(); 02041 TextStory* pStory = this->FindParentStory(); 02042 if ((pCtrl != NULL && pCtrl->GetTextOptions() == PRINTTEXTOPTIONS_ALLTEXTASSHAPES) || 02043 (pStory != NULL && pStory->IsPrintingAsShapes())) 02044 { 02045 return pRenderRegion->RenderRegion::RenderChar(GetUnicodeValue(), &matrix); 02046 } 02047 } 02048 02049 // if we're exporting to illustrator, make the text position relative to 02050 // the page. 02051 if (pRenderRegion->IsKindOf (CC_RUNTIME_CLASS(AIEPSRenderRegion))) 02052 { 02053 // (ChrisG 14/12/00) - Only transform if we're not exporting text as shapes, as this 02054 // will be done in CreateCharPath - in AIEPSRenderRegion::RenderChar 02055 if (((AIEPSRenderRegion *) pRenderRegion)->GetTextAsShapes () == FALSE) 02056 { 02057 DocCoord pos; 02058 matrix.GetTranslation(pos); 02059 02060 Spread* pCurSpread = FindParentSpread(); 02061 if (pCurSpread) 02062 { 02063 DocCoord result; 02064 pCurSpread->SpreadCoordToPagesCoord(&result, pos); 02065 matrix.SetTranslation(result); 02066 } 02067 } 02068 } 02069 02070 // Render into the given region region as characters 02071 BOOL Result = pRenderRegion->RenderChar(GetUnicodeValue(), &matrix); 02072 02073 #if EXPORT_TEXT 02074 02075 // Graeme (27/4/00) - This piece of code is here to fix a problem with the export of 02076 // paragraph text to an EPS varient file. Basically, because only the last line in a 02077 // paragraph is terminated by a line feed, the export filter isn't recognising that 02078 // there is a break, and so all the text appears on one line. This new piece of code 02079 // fixes the problem. 02080 02081 // This goes horribly wrong if it's printing to distiller, which picks up the paragraph 02082 // width anyway, making this only relevant for exporting eps files... 02083 if (pRenderRegion->IsPrinting () == FALSE) 02084 { 02085 // Determine whether this is the last node in a text line. 02086 if ( FindNextVTNInLine () == NULL ) 02087 { 02088 // Manually output a newline token. 02089 Result = pRenderRegion->WriteNewLine (); 02090 } 02091 } // if not printing (i.e. doing export) 02092 02093 #endif // EXPORT_TEXT 02094 02095 return Result; 02096 #else 02097 return FALSE; 02098 #endif 02099 }
|
|
Renders the selection blobs for this TextChar.
Reimplemented from NodeRenderableInk. Definition at line 2111 of file nodetext.cpp. 02112 { 02113 #if !defined(EXCLUDE_FROM_RALPH) && !defined(DISABLE_TEXT_RENDERING) 02114 // Before rendering the character we need to render its applied *TEXT* attributes 02115 // into the render region as EOR drag render regions don't maintain an attribute stack 02116 CCAttrMap* pAttribMap = new CCAttrMap(30); 02117 BOOL FoundAttributes = FALSE; 02118 if (pAttribMap) 02119 FoundAttributes = FindAppliedAttributes(pAttribMap); 02120 02121 if (FoundAttributes) 02122 { 02123 pRenderRegion->SaveContext(); 02124 // Render the text attributes 02125 CCAttrMap::iterator pos = pAttribMap->GetStartPosition(); 02126 CCAttrMap::iterator end = pAttribMap->GetEndPosition(); 02127 02128 while (pos != end) 02129 { 02130 CCRuntimeClass *pKey; 02131 void *pVal; 02132 pAttribMap->GetNextAssoc(pos, pKey, pVal); 02133 02134 if (((NodeAttribute*)pVal)->IsKindOfTextAttribute()) 02135 ((NodeAttribute*)pVal)->Render(pRenderRegion); 02136 } 02137 } 02138 02139 // Render the character 02140 if (RenderCore(pRenderRegion)==FALSE) 02141 InformError(); 02142 02143 if (FoundAttributes) 02144 pRenderRegion->RestoreContext(); 02145 02146 if (pAttribMap!=NULL) delete pAttribMap; 02147 #endif 02148 }
|
|
Definition at line 316 of file nodetext.h.
|
|
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes of Node.
Reimplemented from AbstractTextChar. Definition at line 1888 of file nodetext.cpp. 01889 { 01890 // Make a new BigChar and then copy things into it 01891 TextChar* NodeCopy = new TextChar(); 01892 01893 ERROR1IF(NodeCopy==NULL, NULL, _R(IDE_NOMORE_MEMORY)); 01894 01895 if (NodeCopy) 01896 CopyNodeContents(NodeCopy); 01897 01898 return NodeCopy; 01899 }
|
|
Snaps to given coord to the nearest point on the characters render path. If it is not appropriate to snap the coord to the shape (at the moment this means the coord is too far awawy), then FALSE is returned.
Reimplemented from NodeRenderableBounded. Definition at line 2260 of file nodetext.cpp. 02261 { 02262 BOOL Snapped = FALSE; 02263 02264 #if !defined(EXCLUDE_FROM_RALPH) 02265 // MILLIPOINT SnapDist = CSnap::GetSnapDist(); 02266 // MILLIPOINT SqrSnapDist = SnapDist*SnapDist; 02267 02268 // create a format region with an attribute stack 02269 FormatRegion FRegion; 02270 FormatRegion* pFormatRegion=&FRegion; 02271 BOOL ok = pFormatRegion->Init(this); 02272 pFormatRegion->SaveContext(); 02273 02274 // Get the path for this character 02275 NodePath* pPath = NULL; 02276 if (ok) 02277 ok = CreateNodePath(&pPath, pFormatRegion); 02278 02279 if (ok && (pPath!= NULL) && (pPath->InkPath.GetNumCoords() > 0)) 02280 { 02281 Snapped = CSnap::SnapCoordToPath(pDocCoord, &(pPath->InkPath)); 02282 delete pPath; 02283 } 02284 02285 pFormatRegion->RestoreContext(); 02286 #endif 02287 return Snapped; 02288 }
|
|
Determine if a node supports a given internal data type. This is used by the clipboard when exporting to other applications in order to determine if certain data types can be supplied.
Text - As well as paths, some objects can provide text chars Bitmap - Bitmap fills can render a filled object or supply the bitmap used for filling with. See InternalClipboardFormat (kernel.h) for more details Notes: TextChars can be exported as either "vector" or "text" data Reimplemented from Node. Definition at line 2318 of file nodetext.cpp. 02319 { 02320 #if !defined(EXCLUDE_FROM_RALPH) 02321 // TextChars can be exported as either "vector" or "text" data 02322 InternalClipboardFormat textformat(CLIPTYPE_TEXT); 02323 return(Format->IsSameFormat(textformat)); 02324 #else 02325 return FALSE; 02326 #endif 02327 }
|
|
Reimplemented from Node. Definition at line 2385 of file nodetext.cpp. 02386 { 02387 SetAlreadyWritten(FALSE); 02388 return TRUE; 02389 }
|
|
Tells the text node that all it's children have been exported (or skipped if CanWriteChildrenWeb() returned FALSE).
Reimplemented from Node. Definition at line 2376 of file nodetext.cpp. 02377 { 02378 SetAlreadyWritten(FALSE); 02379 return TRUE; 02380 }
|
|
Reimplemented from Node. Definition at line 2351 of file nodetext.cpp. 02352 { 02353 #ifdef DO_EXPORT 02354 return CXaraFileTxtChar::WritePreChildrenNative(pFilter, this); 02355 #else 02356 return FALSE; 02357 #endif 02358 }
|
|
Writes a text char record to the new file format filter.
Reimplemented from Node. Definition at line 2342 of file nodetext.cpp. 02343 { 02344 #ifdef DO_EXPORT 02345 return CXaraFileTxtChar::WritePreChildrenWeb(pFilter, this); 02346 #else 02347 return FALSE; 02348 #endif 02349 }
|
|
Definition at line 337 of file nodetext.h. |