nodetext.h

Go to the documentation of this file.
00001 // $Id: nodetext.h 1535 2006-07-25 16:50:32Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #ifndef INC_NODETEXT
00100 #define INC_NODETEXT
00101 
00102 #ifdef DO_EXPORT
00103 #define EXPORT_TEXT 1
00104 #else
00105 #define EXPORT_TEXT 0
00106 #endif
00107 
00108 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "matrix.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "nodetxts.h"
00111 #include "textfuns.h"
00112 
00113 class AbstractTextChar;
00114 class TextChar;
00115 
00116 /********************************************************************************************
00117 >   class VisibleTextNode: public BaseTextClass
00118 
00119     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00120     Created:    21/12/94
00121     Purpose:    The VisibleTextNode is an abstract base class. All visible objects which 
00122                 appear on text lines such as characters, kerns, carets, etc. will be instances 
00123                 of derived classes of VisibleTextNode.
00124 ********************************************************************************************/
00125 
00126 class VisibleTextNode: public BaseTextClass
00127 {
00128     CC_DECLARE_DYNAMIC(VisibleTextNode)
00129 
00130 public:
00131     VisibleTextNode();  
00132     VisibleTextNode(Node* ContextNode, AttachNodeDirection Direction);
00133 
00134     VisibleTextNode*  FindNextVTNInStory();
00135     VisibleTextNode*  FindPrevVTNInStory();
00136     AbstractTextChar* FindNextAbstractTextCharInStory();
00137     AbstractTextChar* FindPrevAbstractTextCharInStory();
00138     TextChar*         FindNextTextCharInStory();
00139     TextChar*         FindPrevTextCharInStory();
00140 
00141     VisibleTextNode*  FindNextVTNInLine();
00142     VisibleTextNode*  FindPrevVTNInLine();
00143 
00144     AbstractTextChar*  FindNextAbstractTextCharInLine();
00145     AbstractTextChar*  FindPrevAbstractTextCharInLine();
00146 
00147     TextLine*         FindParentLine();
00148               
00149     virtual CopyType GetCopyType();
00150     virtual INT32 ComplexCopy(CopyStage Stage, Range& RangeToCopy, Node** pOutput);
00151     virtual INT32 ComplexHide(UndoableOperation* pOp, Node* pNextNode);
00152 
00153     BOOL RenderChildAttrs(RenderRegion* pRenderRegion);
00154     virtual BOOL CanAttrBeAppliedToMe(CCRuntimeClass* AttrType);
00155 
00156     virtual UINT32 GetNodeSize() const;
00157     virtual void GetDebugDetails(StringBase* Str);
00158 
00159     virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00160     void ScrollToShow();
00161 
00162     BOOL GetStoryAndCharMatrix(Matrix* pMatrix);
00163     virtual BOOL ValidateBoundingRect(FormatRegion* pFormatRegion=NULL)
00164         { ERROR2(FALSE,"VisibleTextNode::ValidateBoundingRect() - should never be called!"); }
00165 
00166     MILLIPOINT CalcCharDistAlongLine(BOOL IncludeThisChar);
00167     BOOL WrapRestOfLineForward(UndoableOperation* pUndoOp);
00168     BOOL WrapFromStartOfLineBack(UndoableOperation* pUndoOp);
00169     BOOL DoMoveNodes(UndoableOperation* pUndoOp, VisibleTextNode* pLastNode,
00170                         Node* pDestNode, AttachNodeDirection Direction);
00171     BOOL DoMoveNode(UndoableOperation* pUndoOp, Node* pDestNode, AttachNodeDirection Direction);
00172 
00173     inline virtual BOOL IsAVisibleTextNode() const { return TRUE;  }
00174     inline virtual BOOL IsACaret()           const { return FALSE; }
00175     inline virtual BOOL IsAnEOLNode()        const { return FALSE; }
00176     inline virtual BOOL IsASpace()        { return FALSE; }
00177     inline virtual BOOL IsAVisibleSpace() { return FALSE; }
00178     inline virtual BOOL IsAHyphen()       { return FALSE; }
00179     inline virtual BOOL IsADecimalPoint() { return FALSE; }
00180 
00181     virtual MILLIPOINT GetCharAdvance()                 { return 0; }
00182     virtual MILLIPOINT GetCharWidth()                   { return 0; }
00183     virtual MILLIPOINT GetBaseLineShift()               { return 0; }
00184     virtual MILLIPOINT GetAutoKernSize(FormatRegion*)   { return 0; }   // Jonathan (17/10/2000
00185 
00186     // private member access functions
00187     MILLIPOINT GetPosInLine()             { return PosInLine; }
00188     void       SetPosInLine(MILLIPOINT x) { PosInLine=x; }
00189 
00190     void SetMatrix( const Matrix &matrix ) { CharMatrix = matrix; }
00191     Matrix  GetMatrix()  { return CharMatrix; }
00192     Matrix* GetpMatrix() { return &CharMatrix; }
00193 
00194 protected:
00195     void Init();
00196     void CopyNodeContents(VisibleTextNode* NodeCopy);
00197     virtual Node* SimpleCopy();
00198 
00199 private:
00200     Matrix     CharMatrix;      // character matrix
00201     MILLIPOINT PosInLine;       // x pos of char in line
00202 };
00203 
00204 
00205 /********************************************************************************************
00206 >   class AbstractTextChar: public VisibleTextNode
00207 
00208     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00209     Created:    21/12/94
00210     Purpose:    This is the base class for all VisibleTextNodes which have an associated
00211                 Unicode character.
00212 ********************************************************************************************/
00213 
00214 class AbstractTextChar: public VisibleTextNode
00215 {
00216     CC_DECLARE_DYNAMIC(AbstractTextChar)
00217 
00218 public:
00219     AbstractTextChar();     
00220     AbstractTextChar(Node* ContextNode, AttachNodeDirection Direction);
00221 
00222     virtual String Describe(BOOL Plural, BOOL Verbose);            
00223     virtual UINT32 GetNodeSize() const;
00224     virtual void GetDebugDetails(StringBase* Str);
00225 
00226     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00227     virtual DocRect GetBlobBoundingRect();
00228     virtual DocRect GetImagemapClickableRectangle();
00229     
00230     void  RenderObjectBlobs(RenderRegion* pRenderRegion);
00231     void  RenderTinyBlobs(RenderRegion* pRenderRegion);
00232 
00233     virtual BOOL ReCacheMetrics(FormatRegion* pFormatRegion);
00234     Path* CreateMetricsRectPath();
00235     BOOL  GetMetricsRect(DocRect* pRect);
00236     BOOL  GetMetricsRectInStory(DocRect* pRect);
00237     BOOL  GetMetricsRectBounds(DocRect* pRect);
00238 
00239     BOOL IsAnAbstractTextChar() const { return TRUE; }
00240     virtual WCHAR GetUnicodeValue() { return FONTEMCHAR; }
00241     MILLIPOINT GetVisibleAdvance();
00242 
00243     virtual MILLIPOINT GetCharWidth()     { return mCharWidth; }
00244     virtual MILLIPOINT GetCharAdvance()   { return mCharAdvance; }
00245     virtual MILLIPOINT GetBaseLineShift() { return mBaseLineShift; }
00246 
00247     MILLIPOINT GetFontAscent()    { return mFontAscent; }
00248     MILLIPOINT GetFontDescent()   { return mFontDescent; }
00249     MILLIPOINT GetFontSize()      { return mFontSize; }
00250 
00251     void SetCharAdvance(  MILLIPOINT Advance) { mCharAdvance   = Advance; }
00252     void SetCharWidth(    MILLIPOINT Width)   { mCharWidth     = Width; }
00253     void SetFontAscent(   MILLIPOINT Ascent)  { mFontAscent    = Ascent; }
00254     void SetFontDescent(  MILLIPOINT Descent) { mFontDescent   = Descent; }
00255     void SetFontSize(     MILLIPOINT Size)    { mFontSize      = Size; }
00256     void SetBaseLineShift(MILLIPOINT Size)    { mBaseLineShift = Size; }
00257 
00258     void    SetAttrdCharBounds(DocRect& rect) { mAttrdCharBounds = rect; }
00259     DocRect GetAttrdCharBounds()              { return mAttrdCharBounds; }
00260 
00261     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00262 
00263 protected:
00264     void Init();
00265     void CopyNodeContents(AbstractTextChar* NodeCopy);
00266     virtual Node* SimpleCopy();
00267 
00268     DocRect GetImagemapRectForAdjacentChars(BOOL fForwards);
00269 
00270 private:
00271     MILLIPOINT mCharWidth;
00272     MILLIPOINT mCharAdvance;
00273     MILLIPOINT mBaseLineShift;
00274     MILLIPOINT mFontAscent;
00275     MILLIPOINT mFontDescent;
00276     MILLIPOINT mFontSize;
00277     DocRect    mAttrdCharBounds;    // bounds of char path (including effects of text attributes)
00278 };
00279 
00280 
00281 /********************************************************************************************
00282 >   class TextChar: public AbstractTextChar
00283 
00284     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00285     Created:    21/12/94
00286     Purpose:    Simplest type of TextStory character. The only data stored is a Unicode value.
00287 ********************************************************************************************/
00288 
00289 class TextChar: public AbstractTextChar
00290 {
00291     CC_DECLARE_DYNAMIC(TextChar)
00292 
00293 public:
00294     TextChar();     
00295     TextChar(Node* ContextNode, AttachNodeDirection Direction, WCHAR ChCode);
00296 
00297     virtual BOOL SupportsClipboardFormat(InternalClipboardFormat *Format) const;
00298     virtual BOOL Snap(DocCoord* pDocCoord);
00299 
00300     virtual UINT32 GetNodeSize() const;     // Returns size of node in bytes
00301     virtual void GetDebugDetails(StringBase* Str); // Can be deleted before we ship
00302 
00303     virtual void Render(RenderRegion* pRenderRegion);
00304     BOOL RenderCore(RenderRegion* pRenderRegion);
00305     void RenderEorDrag(RenderRegion* pRenderRegion);
00306     BOOL CreateNodePath(NodePath** ppNodePath, FormatRegion* pFormatRegion); 
00307 
00308     virtual BOOL IsATextChar() const            { return TRUE; }
00309     virtual BOOL IsSetCandidate() const         { return TRUE; }
00310 
00311     virtual BOOL IsASpace()        { return Ch==' '; }
00312     virtual BOOL IsAVisibleSpace() { return iswspace(Ch); }
00313     virtual BOOL IsAHyphen()       { return Ch=='-'; }
00314 
00315     virtual WCHAR GetUnicodeValue() { return Ch; }
00316     virtual void SetUnicodeValue(WCHAR Char) { Ch = Char; }
00317 
00318     virtual MILLIPOINT GetAutoKernSize(FormatRegion* pFormatRegion);
00319 
00320     virtual BOOL  ExportRender(RenderRegion* pRegion);      // Graeme (13/10/99).
00321 
00322     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00323 
00324 protected:
00325     virtual Node* SimpleCopy();
00326     void CopyNodeContents(TextChar* NodeCopy);
00327 
00328 public:
00329     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00330     virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFIlter);
00331     virtual BOOL WritePostChildrenWeb(BaseCamelotFilter* pFilter);
00332     virtual BOOL WritePostChildrenNative(BaseCamelotFilter* pFilter);
00333     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00334     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00335 
00336 private:
00337     WCHAR Ch;   // 16 bit unicode character
00338 };
00339 
00340 
00341 /********************************************************************************************
00342 >   class KernCode: public AbstractTextChar
00343 
00344     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00345     Created:    21/12/94
00346     Purpose:    A Kern code. 
00347 ********************************************************************************************/
00348 
00349 class KernCode: public AbstractTextChar
00350 {
00351     CC_DECLARE_DYNAMIC(KernCode)
00352 
00353 public:
00354     KernCode();
00355     KernCode(DocCoord& Value);
00356     KernCode(Node* ContextNode, AttachNodeDirection Direction, DocCoord& Value);
00357 
00358     virtual BOOL  ExportRender(RenderRegion* pRegion);
00359     virtual UINT32 GetNodeSize() const;
00360     virtual void  GetDebugDetails(StringBase* Str);
00361 
00362     void     SetValue(DocCoord& KernValue) { Value = KernValue; } 
00363     DocCoord GetValue()                    { return Value; }
00364 
00365     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00366 
00367 protected:
00368     virtual Node* SimpleCopy();
00369     void CopyNodeContents(KernCode* NodeCopy);
00370     
00371 public:
00372     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00373     virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFIlter);
00374 
00375 private:
00376     DocCoord Value; // Defines Kern offset
00377 };
00378 
00379 /********************************************************************************************
00380 >   class HorizontalTab: public AbstractTextChar
00381 
00382     Author:     Martin Wuerthner (xara@mw-software.com)
00383     Created:    07/06/06
00384     Purpose:    A horizontal tab character
00385 ********************************************************************************************/
00386 
00387 class HorizontalTab: public AbstractTextChar
00388 {
00389     CC_DECLARE_DYNAMIC(HorizontalTab)
00390 
00391 public:
00392     HorizontalTab() {}
00393     HorizontalTab(Node* ContextNode, AttachNodeDirection Direction);
00394 
00395     virtual BOOL  ExportRender(RenderRegion* pRegion);
00396     virtual UINT32 GetNodeSize() const;
00397     void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00398 protected:
00399     virtual Node* SimpleCopy();
00400 public:
00401     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00402     virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFIlter);
00403 };
00404 
00405 /********************************************************************************************
00406 >   class CaretNode: public VisibleTextNode
00407 
00408     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00409     Created:    7/2/95
00410     Purpose:    Some Notes about the Caret
00411     
00412                 There will be a single CaretNode stored in every TextObject.
00413             
00414                 The Caret's path will be rendered by the TextStory as an object blob, this 
00415                 is so that it only gets shown if the Text object is selected.
00416                                                        
00417                 The appearance of the Caret will vary depending on what is going on around it.
00418                 In particular its height will be dependent on the heights of its ajacent chars.
00419                 Because of this it makes sense to delay generating the caret's path until it 
00420                 needs to be  rendered.
00421 ********************************************************************************************/
00422 
00423 class CaretNode: public VisibleTextNode
00424 {
00425     CC_DECLARE_DYNAMIC(CaretNode)
00426 
00427 public:
00428     CaretNode();    
00429     CaretNode(Node* ContextNode, AttachNodeDirection Direction);
00430  
00431     virtual void SetSelected(BOOL Status);
00432     virtual BOOL DiscardsAttributeChildren() const;
00433     BOOL DoApplyAttrsTo(UndoableOperation* pUndoOp, VisibleTextNode* pDstVTN, BOOL bDeleteDups = TRUE);
00434 
00435     Path* CreatePath(Matrix* pMatrix); 
00436     void RenderObjectBlobs(RenderRegion* pRender); 
00437     BOOL RenderObjectBlobsCore(RenderRegion* pRender); 
00438     
00439     virtual BOOL ValidateBoundingRect(FormatRegion* pFormatRegion=NULL);
00440     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00441     virtual DocRect GetBlobBoundingRect();
00442         
00443     virtual BOOL ExportRender(RenderRegion* pRegion);
00444 
00445     virtual UINT32 GetNodeSize() const;     
00446     virtual void GetDebugDetails(StringBase* Str); 
00447     virtual String Describe(BOOL Plural, BOOL Verbose);
00448 
00449     inline virtual BOOL IsACaret() const {return TRUE;};
00450     BOOL HasMoved();
00451 
00452 protected:
00453     virtual Node* SimpleCopy(); 
00454 
00455 public:
00456     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00457     virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFIlter);
00458     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00459     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00460 
00461 private:
00462     DocRect BlobBounds;
00463 };
00464 
00465 /********************************************************************************************
00466 >   class EOLNode: public VisibleTextNode
00467 
00468     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00469     Created:    7/2/95
00470     Purpose:    Every TextLine that is created will have a EOLNode as its last child.
00471                 This means that every TextLine will always have at least one child node.
00472 ********************************************************************************************/
00473 
00474 class EOLNode: public AbstractTextChar
00475 {
00476     CC_DECLARE_DYNAMIC(EOLNode)
00477 
00478 public:
00479     EOLNode();  
00480     EOLNode(Node* ContextNode, AttachNodeDirection Direction);
00481 
00482     virtual DocRect GetBlobBoundingRect();
00483     virtual void RenderObjectBlobs(RenderRegion* pRender);
00484     virtual void RenderTinyBlobs(RenderRegion* pRender);
00485     BOOL GetBlobPath(Path*);
00486 
00487     virtual BOOL  ExportRender(RenderRegion* pRegion);
00488     virtual UINT32 GetNodeSize() const; 
00489     virtual void GetDebugDetails(StringBase* Str);
00490     virtual String Describe(BOOL Plural, BOOL Verbose);
00491 
00492     virtual BOOL ValidateBoundingRect(FormatRegion* pFormatRegion=NULL);
00493     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00494 
00495     inline virtual BOOL IsAnEOLNode() const {return TRUE;};
00496 
00497     BOOL IsVirtual() const       { return Virtual; }
00498     void SetVirtual(BOOL Status) { Virtual = Status; }
00499 
00500     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00501 
00502 protected:
00503     virtual Node* SimpleCopy();
00504     void CopyNodeContents(EOLNode* NodeCopy);
00505 
00506 public:
00507     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00508     virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFIlter);
00509     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00510     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00511 
00512 private:
00513     BYTE Virtual   : 1; // EOL is transient ie when converting a cut/copied selection to a story on the clipboard
00514 };
00515  
00516 #endif

Generated on Sat Nov 10 03:46:09 2007 for Camelot by  doxygen 1.4.4