#include <nodetext.h>
Inheritance diagram for CaretNode:
Public Member Functions | |
CaretNode () | |
Simple CaretNode constructor, it is required so that SimpleCopy will work. | |
CaretNode (Node *ContextNode, AttachNodeDirection Direction) | |
The main CaretNode constructor. | |
virtual void | SetSelected (BOOL Status) |
Overides the normal SetSelected call so we can ensure that the caret is not selected outside the TextTool. | |
virtual BOOL | DiscardsAttributeChildren () const |
When attributes are applied to the caret, we cannot generate undo info as children of the CaretNode are thrown away in a non-undoable way. | |
BOOL | DoApplyAttrsTo (UndoableOperation *pUndoOp, VisibleTextNode *pDstVTN, BOOL bDeleteDups=TRUE) |
Apply attrs on caret to given VTN (on same line) ensuring tree left optimal. | |
Path * | CreatePath (Matrix *pMatrix) |
Create a caret path. | |
void | RenderObjectBlobs (RenderRegion *pRender) |
Renders the caret's path into the pRender render region. | |
BOOL | RenderObjectBlobsCore (RenderRegion *pRender) |
Renders the caret's path into the pRender render region. | |
virtual BOOL | ValidateBoundingRect (FormatRegion *pFormatRegion=NULL) |
recache the caret's renderable and blob bounding rects | |
virtual DocRect | GetBoundingRect (BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE) |
virtual DocRect | GetBlobBoundingRect () |
get the caret's blob bounds Note: Abuse of bounding box cache should really be for renderable bounds but the caret has none! | |
virtual BOOL | ExportRender (RenderRegion *pRegion) |
This function is called when the render function passes through this node It outputs the Text Object start and end tokens. | |
virtual UINT32 | GetNodeSize () const |
For finding the size of the CaretNode. | |
virtual void | GetDebugDetails (StringBase *Str) |
For obtaining debug information about the Node. This fn can be deleted before we ship. | |
virtual String | Describe (BOOL Plural, BOOL Verbose) |
For obtaining a desciption about the node to use in the status line. | |
virtual BOOL | IsACaret () const |
BOOL | HasMoved () |
reposition the caret after it has moved If possible to the right of the previous char as the caret takes its attributes from this char so the caret's position reflects it's baseline shift correctly | |
virtual BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter) |
Writes a caret node record to the new file format filter. | |
virtual BOOL | WritePreChildrenNative (BaseCamelotFilter *pFIlter) |
virtual BOOL | CanWriteChildrenWeb (BaseCamelotFilter *pFilter) |
If the node does not mind the filter automatically writing out its child nodes, then return TRUE. | |
virtual BOOL | CanWriteChildrenNative (BaseCamelotFilter *pFilter) |
Protected Member Functions | |
virtual Node * | SimpleCopy () |
It is illegal to copy a CaretNode, therefore this function will generate an error if called. But blends, moulds etc. call this function so I (Peter) have implemented it Fix after the show. | |
Private Attributes | |
DocRect | BlobBounds |
The Caret's path will be rendered by the TextStory as an object blob, this is so that it only gets shown if the Text object is selected.
The appearance of the Caret will vary depending on what is going on around it. In particular its height will be dependent on the heights of its ajacent chars. Because of this it makes sense to delay generating the caret's path until it needs to be rendered.
Definition at line 423 of file nodetext.h.
|
Simple CaretNode constructor, it is required so that SimpleCopy will work.
Definition at line 2534 of file nodetext.cpp. 02534 : VisibleTextNode() // Call the base class 02535 { 02536 }
|
|
The main CaretNode 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 2559 of file nodetext.cpp. 02560 : VisibleTextNode(ContextNode, Direction) 02561 { 02562 }
|
|
Reimplemented from Node. Definition at line 3124 of file nodetext.cpp. 03125 { 03126 return FALSE; 03127 }
|
|
If the node does not mind the filter automatically writing out its child nodes, then return TRUE. > virtual BOOL Node::CanWriteChildrenWeb(BaseCamelotFilter* pFilter)
Reimplemented from Node. Definition at line 3119 of file nodetext.cpp. 03120 { 03121 return FALSE; 03122 }
|
|
Create a caret path.
Definition at line 2633 of file nodetext.cpp. 02634 { 02635 ERROR2IF(pMatrix==NULL,NULL,"CaretNode::CreatePath() - pMatrix==NULL"); 02636 02637 TextLine* pTextLine=(TextLine*)FindParent(); 02638 ERROR2IF(pTextLine==NULL,FALSE,"CaretNode::CreatePath() - pTextLine==NULL"); 02639 02640 // find italic status on caret 02641 NodeAttribute* pAttr; 02642 BOOL Italic=FALSE; 02643 if (FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTxtItalic), &pAttr)) 02644 Italic=((TxtItalicAttribute*)(pAttr->GetAttributeValue()))->ItalicOn; 02645 02646 // find script offest 02647 FIXED16 ScriptOffset=0; 02648 if (FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTxtScript), &pAttr)) 02649 ScriptOffset=((TxtScriptAttribute*)(pAttr->GetAttributeValue()))->Offset; 02650 02651 // find caret height 02652 MILLIPOINT LineSize = pTextLine->GetLineSize(); 02653 MILLIPOINT CaretSize = LineSize; 02654 if (FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTxtFontSize), &pAttr)) 02655 CaretSize=((TxtFontSizeAttribute*)(pAttr->GetAttributeValue()))->FontSize; 02656 02657 // find baseline shift 02658 // MILLIPOINT BaseLineShift=0; 02659 // if (FindAppliedAttribute(CC_RUNTIME_CLASS(AttrTxtBaseLine), &pAttr)) 02660 // BaseLineShift=((TxtBaseLineAttribute*)(pAttr->GetAttributeValue()))->Value; 02661 02662 // calc caret top and bottom points accounting for italic and baseline shift 02663 FIXED16 CaretRatio=(LineSize!=0) ? Div32By32(CaretSize,LineSize) : 1; 02664 DocCoord CaretTop(0, XLONG(pTextLine->GetLineDescent()) * CaretRatio ); 02665 DocCoord CaretBot(0, XLONG(pTextLine->GetLineAscent()) * CaretRatio ); 02666 if (Italic && ScriptOffset==0) 02667 { 02668 const double SlantRatio = tan(15.0*PI/180); 02669 CaretTop.x = (INT32) ((double)CaretTop.y * SlantRatio); 02670 CaretBot.x = (INT32) ((double)CaretBot.y * SlantRatio); 02671 } 02672 02673 // get caret path 02674 Path* pCaretPath=new Path(); 02675 BOOL ok=(pCaretPath!=NULL); 02676 if (ok) ok=pCaretPath->Initialise(2,12); 02677 if (ok) ok=pCaretPath->AddMoveTo(CaretTop); 02678 if (ok) ok=pCaretPath->AddLineTo(CaretBot); 02679 02680 // apply transform to caret path 02681 DocCoord* pPathCoords=NULL; 02682 if (ok) pPathCoords=pCaretPath->GetCoordArray(); 02683 if (ok) ok=(pPathCoords!=NULL); 02684 if (ok) pMatrix->transform((Coord*)pPathCoords, pCaretPath->GetNumCoords()); 02685 02686 // if not OK, delete caret path and set return path pointer to NULL 02687 if (!ok) 02688 { 02689 delete pCaretPath; 02690 pCaretPath=NULL; 02691 } 02692 02693 return pCaretPath; 02694 }
|
|
For obtaining a desciption about the node to use in the status line.
Reimplemented from Node. Definition at line 2796 of file nodetext.cpp. 02797 { 02798 if (Plural) 02799 return(String(_R(IDS_CARETSDESCRIPTION))); 02800 else 02801 return(String(_R(IDS_CARETDESCRIPTION))); 02802 }
|
|
When attributes are applied to the caret, we cannot generate undo info as children of the CaretNode are thrown away in a non-undoable way.
Reimplemented from Node. Definition at line 2985 of file nodetext.cpp. 02986 { 02987 return TRUE; 02988 }
|
|
Apply attrs on caret to given VTN (on same line) ensuring tree left optimal.
Definition at line 3001 of file nodetext.cpp. 03002 { 03003 ERROR2IF(pUndoOp==NULL,FALSE,"CaretNode::DoApplyAttrsTo() - pUndoOp==NULL"); 03004 ERROR2IF(pDstVTN==NULL,FALSE,"CaretNode::DoApplyAttrsTo() - pDstVTN==NULL"); 03005 03006 TextLine* pCaretLine = this->FindParentLine(); 03007 ERROR2IF(pCaretLine==NULL,FALSE,"CaretNode::DoApplyAttrsTo() - caret has no TextLine parent"); 03008 TextLine* pDstVTNLine = pDstVTN->FindParentLine(); 03009 ERROR2IF(pDstVTNLine==NULL,FALSE,"CaretNode::DoApplyAttrsTo() - dest VTN has no TextLine parent"); 03010 if (bDeleteDups) 03011 { 03012 ERROR2IF(pDstVTNLine!=pCaretLine,FALSE,"CaretNode::DoApplyAttrsTo() - caret and pDstVTN not on same line"); 03013 } 03014 03015 // determine if attr types on caret are already localised 03016 AbstractTextChar* pATC = (AbstractTextChar*)(pCaretLine->FindFirstChild(CC_RUNTIME_CLASS(AbstractTextChar))); 03017 ERROR2IF(pATC==NULL,FALSE,"OpTextFormat::DoInsertCharHelper() - caret line has no AbstaractTextChars"); 03018 BOOL CommonAttrsAffected = !pATC->HasAttrTypesOn(this); 03019 03020 // if attr types on the caret are not localised, localise them 03021 AttrTypeSet CaretsAttrTypes; 03022 this->AddChildAttrTypesToSet(&CaretsAttrTypes); 03023 if (CommonAttrsAffected) 03024 if (!pUndoOp->DoLocaliseForAttrChange(pDstVTN,&CaretsAttrTypes,NULL)) 03025 return FALSE; 03026 03027 // BODGE WORDWRAP - causes dup attrs if applying defalut attr on caret to new char in line of non-default 03028 03029 // now copy carets attrs to new char, deleting any duplicates 03030 NodeAttribute* pCaretAttr = (NodeAttribute*)(this->FindFirstChild(CC_RUNTIME_CLASS(NodeAttribute))); 03031 while (pCaretAttr!=NULL) 03032 { 03033 NodeAttribute* pDupAttr = pDstVTN->GetChildAttrOfType(pCaretAttr->GetAttributeType()); 03034 03035 // If we have found a duplicate and we are allowed to delete it, do so 03036 if (pDupAttr!=NULL && bDeleteDups) 03037 { 03038 pDupAttr->CascadeDelete(); 03039 delete pDupAttr; 03040 } 03041 03042 // If we didn't find a duplicate or we did and we deleted it then 03043 // copy the caret's attribute 03044 if (pDupAttr==NULL || bDeleteDups) 03045 { 03046 Node* pAttrCopy; 03047 if (!pCaretAttr->NodeCopy(&pAttrCopy)) 03048 return FALSE; 03049 pAttrCopy->AttachNode(pDstVTN, LASTCHILD); 03050 } 03051 03052 pCaretAttr = (NodeAttribute*)(pCaretAttr->FindNext(CC_RUNTIME_CLASS(NodeAttribute))); 03053 } 03054 03055 // if attr types on caret were localised, factor them out 03056 if (CommonAttrsAffected) 03057 if (!pUndoOp->DoFactorOutAfterAttrChange(pDstVTN, &CaretsAttrTypes)) 03058 return FALSE; 03059 03060 return TRUE; 03061 }
|
|
This function is called when the render function passes through this node It outputs the Text Object start and end tokens.
Reimplemented from NodeRenderableInk. Definition at line 2769 of file nodetext.cpp. 02770 { 02771 #if EXPORT_TEXT 02772 // BODGE TEXT - need to export caret in a comment! 02773 if (pRegion->IsKindOf(CC_RUNTIME_CLASS(EPSRenderRegion))) 02774 { 02775 /*EPSExportDC *pDC=*/(EPSExportDC*)pRegion->GetRenderDC(); 02776 // pDC->OutputToken("ctk"); 02777 // pDC->OutputNewLine(); 02778 return TRUE; 02779 } 02780 #endif 02781 return FALSE; 02782 }
|
|
get the caret's blob bounds Note: Abuse of bounding box cache should really be for renderable bounds but the caret has none!
Reimplemented from NodeRenderable. Definition at line 2816 of file nodetext.cpp. 02817 { 02818 if (IsBoundingRectValid==FALSE) 02819 if (ValidateBoundingRect()==FALSE) 02820 InformError(); 02821 02822 return BlobBounds; 02823 }
|
|
Reimplemented from NodeRenderableBounded. Definition at line 2836 of file nodetext.cpp. 02837 { 02838 if (IsBoundingRectValid==FALSE) 02839 if (ValidateBoundingRect()==FALSE) 02840 InformError(); 02841 02842 return BoundingRectangle; 02843 }
|
|
For obtaining debug information about the Node. This fn can be deleted before we ship.
Reimplemented from VisibleTextNode. Definition at line 2615 of file nodetext.cpp. 02616 { 02617 #if DEBUG_TREE 02618 VisibleTextNode::GetDebugDetails(Str); 02619 #endif 02620 }
|
|
For finding the size of the CaretNode.
Reimplemented from VisibleTextNode. Definition at line 2599 of file nodetext.cpp. 02600 { 02601 return (sizeof(CaretNode)); 02602 }
|
|
reposition the caret after it has moved If possible to the right of the previous char as the caret takes its attributes from this char so the caret's position reflects it's baseline shift correctly
Definition at line 2925 of file nodetext.cpp. 02926 { 02927 #if !defined(EXCLUDE_FROM_RALPH) 02928 AbstractTextChar* pPrevATC=(AbstractTextChar*)(this->FindPrevious(CC_RUNTIME_CLASS(AbstractTextChar))); 02929 BOOL AfterPrevChar = (pPrevATC!=NULL); 02930 02931 // if positioning the caret after the previous char and its a kern code 02932 // and its on a path and a silly size, position the caret before the next char 02933 if (AfterPrevChar && IS_A(pPrevATC,KernCode)) 02934 { 02935 TextStory* pTextStory = this->FindParentStory(); 02936 ERROR2IF(pTextStory==NULL,FALSE,"CaretNode::HasMoved() - could not find caret's parent story!"); 02937 if ( pTextStory->GetTextPath()!=NULL && ((KernCode*)pPrevATC)->GetValue().x>1000 ) 02938 AfterPrevChar = FALSE; 02939 } 02940 02941 // if positioning caret after last char, use prev char's info plus advance 02942 // else just use next char's info 02943 Matrix matrix; 02944 MILLIPOINT pos=0; 02945 if (AfterPrevChar) 02946 { 02947 const MILLIPOINT advance=pPrevATC->GetVisibleAdvance(); 02948 matrix = Matrix(advance,0); 02949 matrix *= pPrevATC->GetMatrix(); 02950 pos = pPrevATC->GetPosInLine()+advance; 02951 } 02952 else 02953 { 02954 AbstractTextChar* pNextATC=(AbstractTextChar*)(this->FindNext(CC_RUNTIME_CLASS(AbstractTextChar))); 02955 ERROR2IF(pNextATC==NULL,FALSE,"CaretNode::HasMoved() - no AbstractTextChar before or after caret!"); 02956 matrix = pNextATC->GetMatrix(); 02957 pos = pNextATC->GetPosInLine(); 02958 } 02959 02960 SetMatrix(matrix); 02961 SetPosInLine(pos); 02962 InvalidateBoundingRect(); 02963 #endif 02964 return TRUE; 02965 }
|
|
Reimplemented from VisibleTextNode. Definition at line 449 of file nodetext.h. 00449 {return TRUE;};
|
|
Renders the caret's path into the pRender render region.
Reimplemented from NodeRenderable. Definition at line 2707 of file nodetext.cpp. 02708 { 02709 if (RenderObjectBlobsCore(pRenderRegion)==FALSE) 02710 InformError(); 02711 }
|
|
Renders the caret's path into the pRender render region.
Definition at line 2724 of file nodetext.cpp. 02725 { 02726 #if !defined(EXCLUDE_FROM_RALPH) 02727 ERROR2IF(pRenderRegion==NULL,FALSE,"CaretNode::RenderObjectBlobsCore() - pRenderRegion==NULL"); 02728 02729 TextStory* pTextStory = this->FindParentStory(); 02730 ERROR2IF(pTextStory==NULL,FALSE,"CaretNode::RenderObjectBlobsCore() - pTextStory==NULL"); 02731 02732 // get the caret path transformed to the correct place in the doc 02733 Matrix matrix; 02734 if (GetStoryAndCharMatrix(&matrix)==FALSE) 02735 return FALSE; 02736 Path* pCaretPath=CreatePath(&matrix); 02737 BOOL ok=(pCaretPath!=NULL); 02738 02739 // draw the caret path in red (line width?) 02740 if (ok) 02741 { 02742 pRenderRegion->SaveContext(); 02743 pRenderRegion->SetLineColour(RED); 02744 pRenderRegion->DrawPath(pCaretPath); 02745 pRenderRegion->RestoreContext(); 02746 } 02747 02748 // delete the caret path 02749 delete pCaretPath; 02750 02751 return ok; 02752 #else 02753 return TRUE; 02754 #endif 02755 }
|
|
Overides the normal SetSelected call so we can ensure that the caret is not selected outside the TextTool.
Reimplemented from Node. Definition at line 3075 of file nodetext.cpp. 03076 { 03077 #if !defined(EXCLUDE_FROM_RALPH) 03078 if (!TextTool::IsCurrentTool()) 03079 { 03080 TextStory* pStory = this->FindParentStory(); 03081 if (pStory != NULL) 03082 pStory->SetSelected(Status); 03083 } 03084 else 03085 BaseTextClass::SetSelected(Status); 03086 #endif 03087 }
|
|
It is illegal to copy a CaretNode, therefore this function will generate an error if called. But blends, moulds etc. call this function so I (Peter) have implemented it Fix after the show.
Reimplemented from VisibleTextNode. Definition at line 2576 of file nodetext.cpp. 02577 { 02578 // Make a new CaretNode and then copy things into it 02579 CaretNode* NodeCopy = new CaretNode(); 02580 02581 ERROR1IF(NodeCopy == NULL, NULL, _R(IDE_NOMORE_MEMORY)); 02582 02583 if (NodeCopy != NULL) 02584 CopyNodeContents(NodeCopy); 02585 02586 return NodeCopy; 02587 }
|
|
recache the caret's renderable and blob bounding rects
Reimplemented from VisibleTextNode. Definition at line 2856 of file nodetext.cpp. 02857 { 02858 #if !defined(EXCLUDE_FROM_RALPH) 02859 BOOL ok=TRUE; 02860 02861 // get the overall matrix to apply to the caret 02862 Matrix matrix; 02863 if (GetStoryAndCharMatrix(&matrix)==FALSE) 02864 return FALSE; 02865 02866 // get a zero size rect at the correct position in the doc 02867 // for the renderable bounds of the caret (uses by ScrollToShow) 02868 DocCoord temp(0,0); 02869 matrix.transform((Coord*)&temp,1); 02870 DocRect RendRect(temp,temp); 02871 02872 // get the bounds of the caret path for the blob bounds 02873 Path* pCaretPath=CreatePath(&matrix); 02874 DocRect BlobRect(0,0,0,0); 02875 ok=(pCaretPath!=NULL); 02876 if (ok) 02877 { 02878 DocCoord* pCoords=pCaretPath->GetCoordArray(); 02879 PathVerb* pVerbs=pCaretPath->GetVerbArray(); 02880 ok=(pVerbs!=NULL && pCoords!=NULL); 02881 if (ok) 02882 { 02883 GDrawContext *GD = GRenderRegion::GetStaticDrawContext(); 02884 02885 if (GD != NULL) 02886 { 02887 ok=!(GD->CalcStrokeBBox((POINT*)pCoords, pVerbs, pCaretPath->GetNumCoords(), 02888 (LPRECT)(&BlobRect), 0, 2, CAPS_ROUND, JOIN_ROUND, NULL)); 02889 } 02890 02891 if (!ok) ERROR2RAW("CaretNode::ValidateBoundingRect() - GDraw_CalcStrokeBBox() failed"); 02892 } 02893 delete pCaretPath; 02894 } 02895 02896 // Inflate the blob bounds, so that the Caret is at least a pixel wide 02897 if (View::GetCurrent() != NULL) 02898 { 02899 INT32 PixWidth = (View::GetCurrent()->GetScaledPixelWidth()).MakeLong(); 02900 BlobRect.Inflate(PixWidth/2); 02901 } 02902 02903 // update the cached values 02904 BoundingRectangle = RendRect; 02905 BlobBounds = BlobRect; 02906 IsBoundingRectValid = TRUE; 02907 return ok; 02908 #else 02909 return TRUE; 02910 #endif 02911 }
|
|
Reimplemented from Node. Definition at line 3110 of file nodetext.cpp. 03111 { 03112 //#ifdef DO_EXPORT 03113 // return CXaraFileTxtCaret::WritePreChildrenNative(pFilter, this); 03114 //#else 03115 return FALSE; 03116 //#endif 03117 }
|
|
Writes a caret node record to the new file format filter.
Reimplemented from Node. Definition at line 3101 of file nodetext.cpp. 03102 { 03103 //#ifdef DO_EXPORT 03104 // return CXaraFileTxtCaret::WritePreChildrenWeb(pFilter, this); 03105 //#else 03106 return FALSE; 03107 //#endif 03108 }
|
|
Definition at line 462 of file nodetext.h. |