00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #ifndef INC_NODETXTL
00101 #define INC_NODETXTL
00102
00103
00104
00105 #include "nodetxts.h"
00106
00107
00108 class EOLNode;
00109 class CharMetrics;
00110 class NodeGroup;
00111 class BecomeA;
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 class FormatRegion : public RenderRegion
00131 {
00132 CC_DECLARE_DYNAMIC(FormatRegion)
00133
00134 FormatRegion();
00135 ~FormatRegion();
00136
00137 BOOL Init(NodeRenderableInk* pFirstNode);
00138
00139
00140
00141
00142 virtual void DrawPathToOutputDevice(Path *PathToRender, PathShape shapePath=PATHSHAPE_PATH) {ERROR3("Rendering into a FormatRegion");};
00143 virtual void DrawRect(DocRect *RectToRender) {ERROR3("Rendering into a FormatRegion");};
00144 virtual void DrawDragRect(DocRect *RectToRender) {ERROR3("Rendering into a FormatRegion");};
00145 virtual void DrawLine(const DocCoord &StartPoint, const DocCoord &EndPoint) {ERROR3("Rendering into a FormatRegion");};
00146 virtual void DrawPixel(const DocCoord &Point) {ERROR3("Rendering into a FormatRegion");};
00147 virtual void DrawBlob(DocCoord p, BlobType type) {ERROR3("Rendering into a FormatRegion");};
00148 virtual void DrawCross(const DocCoord &Point, const UINT32 Size) {ERROR3("Rendering into a FormatRegion");};
00149 virtual void DrawBitmap(const DocCoord &Point, KernelBitmap* pBitmap) {ERROR3("Rendering into a FormatRegion");};
00150 virtual void DrawBitmap(const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID = NULL) {ERROR3("Rendering into a FormatRegion");};
00151 virtual void DrawBitmapBlob(const DocCoord &Point, KernelBitmap* BlobShape) {ERROR3("Rendering into a FormatRegion");};
00152 virtual void DrawBitmapBlob(const DocCoord &Point, ResourceID resID ) {ERROR3("Rendering into a FormatRegion");};
00153
00154
00155 virtual void DrawFixedSystemText(StringBase *TheText, DocRect &BoundsRect, UINT32 uFormat = DEFAULT_TEXT_FORMATTING) {ERROR3("Rendering into a FormatRegion");};
00156 virtual void SetFixedSystemTextColours(DocColour *TextCol, DocColour *Background) {ERROR3("Rendering into a FormatRegion");};
00157 virtual void GetFixedSystemTextSize(StringBase *TheText, DocRect *BoundsRect, double* atDpi = NULL) {ERROR3("Rendering into a FormatRegion");};
00158 virtual void DrawPixelRect(DocRect *RectToRender) {ERROR3("Rendering into a FormatRegion");};
00159 virtual void DrawPixelLine(const DocCoord &StartPoint, const DocCoord &EndPoint) {ERROR3("Rendering into a FormatRegion");};
00160
00161
00162 virtual BOOL StopRender(void) {return TRUE;};
00163 virtual void InitClipping(void) {};
00164 virtual void InitAttributes(void) {};
00165 virtual void SetLineAttributes(void) {};
00166 virtual void SetOSDrawingMode(void) {};
00167 virtual void SetQualityLevel(void) {};
00168 virtual INT32 CalcPixelWidth(void) {return 1;};
00169 virtual INT32 CalcScaledPixelWidth(void) {return 1;};
00170
00171 public:
00172 BOOL GetCharMetrics(CharMetrics* pCharMetrics, WCHAR ch);
00173 MILLIPOINT GetCharsKerning(WCHAR chLeft, WCHAR chRight);
00174
00175 MILLIPOINT GetTracking() { return RR_TXTTRACKING(); }
00176 Justification GetJustification() { return RR_TXTJUSTIFICATION(); }
00177 MILLIPOINT GetLineSpacing() { return RR_TXTLINESPACE(); }
00178 FIXED16 GetLineSpaceRatio(){ return ((TxtLineSpaceAttribute*)CurrentAttrs[ATTR_TXTLINESPACE].pAttr)->Ratio; }
00179 MILLIPOINT GetFontSize() { return RR_TXTFONTSIZE(); }
00180 MILLIPOINT GetBaseLineShift() { return RR_TXTBASELINE(); }
00181 MILLIPOINT GetLeftMargin() { return RR_TXTLEFTMARGIN(); }
00182 MILLIPOINT GetRightMargin() { return RR_TXTRIGHTMARGIN(); }
00183 MILLIPOINT GetFirstIndent() { return RR_TXTFIRSTINDENT(); }
00184 TxtRuler* GetRuler() { return RR_TXTRULER(); }
00185 private:
00186 std::auto_ptr<wxDC> m_pFormatDC;
00187 };
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 class FormatState: public CC_CLASS_MEMDUMP
00199 {
00200 public:
00201 const BOOL SetCharPositions;
00202 const MILLIPOINT FitWidth;
00203 VisibleTextNode* const pFirstVTN;
00204 const MILLIPOINT CharPosOffset;
00205 const MILLIPOINT ExtraOnChars;
00206 const MILLIPOINT ExtraOnSpaces;
00207 MILLIPOINT Width;
00208
00209
00210
00211
00212 TxtTabType ActiveTabType;
00213 MILLIPOINT ActiveTabPos;
00214 VisibleTextNode* pLastTabVTN;
00215
00216
00217
00218
00219 MILLIPOINT AnchorPos;
00220
00221
00222
00223
00224 MILLIPOINT RemainingSpace;
00225
00226
00227 WCHAR DecimalPointChar;
00228 BOOL DecimalPointFound;
00229
00230
00231 FormatState(MILLIPOINT AvailableWidth, BOOL SetPositions, VisibleTextNode* pFirstNode,
00232 MILLIPOINT Indent, MILLIPOINT _CharPosOffset,
00233 MILLIPOINT _ExtraOnChars, MILLIPOINT _ExtraOnSpaces):
00234 SetCharPositions(SetPositions),
00235 FitWidth(AvailableWidth), pFirstVTN(pFirstNode),
00236 CharPosOffset(_CharPosOffset),
00237 ExtraOnChars(_ExtraOnChars), ExtraOnSpaces(_ExtraOnSpaces),
00238 Width(Indent), ActiveTabType(LeftTab), ActiveTabPos(0),
00239 pLastTabVTN(NULL), AnchorPos(Indent) {};
00240 void AdvanceBy(MILLIPOINT Advance, BOOL IsADecimalPoint);
00241 BOOL FinishTabSection(VisibleTextNode* pLastFormattedNode, BOOL IsLastTabSection);
00242 BOOL IsAvailable(MILLIPOINT CharWidth, BOOL IsATab, BOOL IsADecimalPoint);
00243 };
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 class TextLineInfo : public CC_CLASS_MEMDUMP
00254 {
00255 CC_DECLARE_MEMDUMP(TextLineInfo);
00256
00257 public:
00258 TextLineInfo();
00259
00260 MILLIPOINT SumCharAdvances;
00261 Justification justification;
00262 MILLIPOINT LeftMargin;
00263 MILLIPOINT RightMargin;
00264
00265 MILLIPOINT ParaLeftMargin;
00266 MILLIPOINT ParaRightMargin;
00267 const TxtRuler* Ruler;
00268
00269 BOOL WordWrapping;
00270 INT32 NumChars;
00271 INT32 NumSpaces;
00272 };
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 class TextLine: public BaseTextClass
00288 {
00289 CC_DECLARE_DYNAMIC(TextLine)
00290
00291 public:
00292 TextLine();
00293 ~TextLine();
00294 TextLine(Node* ContextNode, AttachNodeDirection Direction);
00295 void Init();
00296
00297 virtual Node* SimpleCopy();
00298 void CopyNodeContents(TextLine* NodeCopy);
00299 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00300
00301 virtual CopyType GetCopyType();
00302 virtual INT32 ComplexCopy(CopyStage Stage, Range& RangeToCopy, Node** pOutput);
00303 virtual INT32 ComplexHide(UndoableOperation* pOp, Node* pNextNode);
00304
00305 virtual BOOL IsSetCandidate() const { return TRUE; }
00306 virtual BOOL IsCompound() const { return TRUE; }
00307
00308 virtual UINT32 GetNodeSize() const;
00309 virtual void GetDebugDetails(StringBase* Str);
00310 virtual String Describe(BOOL Plural, BOOL Verbose);
00311
00312 DocRect GetBlobBoundingRect();
00313 void RenderObjectBlobs(RenderRegion* pRRegion);
00314 void RenderTinyBlobs(RenderRegion* pRRegion);
00315 DocCoord GetTinyBlobPos();
00316
00317 BOOL CreateNodeGroup(NodeGroup** ppNodeGroup, FormatRegion* pFormatRegion, BecomeA* pBecomeA);
00318 static TextLine* CreateEmptyTextLine(Node* pContextNode=NULL, AttachNodeDirection Direction=FIRSTCHILD);
00319
00320 virtual BOOL ReCacheMetrics(FormatRegion* pFormmatRegion);
00321 BOOL Format(TextStoryInfo* pStoryInfo);
00322 BOOL EnsureNextLineOfParagraphHasSameLineLevelAttrs(UndoableOperation* pUndoOp);
00323 BOOL ReCalcLineInfo(TextLineInfo* pLineInfo);
00324 BOOL PositionCharsInLine(TextLineInfo* pLineInfo);
00325 BOOL CalcBaseAndDescentLine(MILLIPOINT* pBaseLine, MILLIPOINT* pDescentLine,
00326 MILLIPOINT LastDescentLine, BOOL FirstLine);
00327 BOOL SetCharMatrices(MILLIPOINT LinePos);
00328 BOOL FitTextToPath(TextStoryInfo* pPathInfo, MILLIPOINT LinePos);
00329 BOOL Wrap(UndoableOperation* pUndoOp, MILLIPOINT WrapWidth, MILLIPOINT Indent);
00330 VisibleTextNode* FindBreakChar(MILLIPOINT FitWidth, BOOL SetCharPositions,
00331 MILLIPOINT Indent, MILLIPOINT CharPosOffset = 0,
00332 MILLIPOINT ExtraOnChars = 0, MILLIPOINT ExtraOnSpaces = 0);
00333
00334 TextLine* FindFirstLineOfParagraph();
00335 static BOOL IsAttrTypeLineLevel(CCRuntimeClass* pAttrType);
00336 BOOL AddChildLineLevelAttrsToSet(AttrTypeSet* pAttrSet);
00337
00338 VisibleTextNode* FindCharAtDistAlongLine(MILLIPOINT Distance, BOOL* LeftHandSide);
00339 VisibleTextNode* FindFirstVTN() const;
00340 VisibleTextNode* FindLastVTN() const;
00341 EOLNode* FindEOLNode() const;
00342 CaretNode* FindCaret() const;
00343 TextLine* FindNextLine() const;
00344 TextLine* FindPrevLine() const;
00345 MILLIPOINT GetLastCharTracking();
00346
00347 BOOL WholeLineSelected();
00348
00349 BOOL WillLineWrapOnPath(FIXED16 xscale, MILLIPOINT PLength);
00350
00351
00352 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter *pFilter);
00353 virtual BOOL WritePreChildrenNative(BaseCamelotFilter *pFilter);
00354 virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00355 virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00356 virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00357 virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00358
00359
00360 MILLIPOINT GetLineDescent() { return mLineDescent; }
00361 MILLIPOINT GetLineAscent() { return mLineAscent; }
00362 MILLIPOINT GetLineSize() { return mLineSize; }
00363 void SetLineDescent(MILLIPOINT Descent) { mLineDescent = Descent; }
00364 void SetLineAscent( MILLIPOINT Ascent) { mLineAscent = Ascent; }
00365 void SetLineSize( MILLIPOINT Size) { mLineSize = Size; }
00366 void UpdateLineDescent(MILLIPOINT Descent) { if (Descent<mLineDescent) mLineDescent = Descent; }
00367 void UpdateLineAscent( MILLIPOINT Ascent) { if ( Ascent>mLineAscent ) mLineAscent = Ascent; }
00368 void UpdateLineSize( MILLIPOINT Size) { if ( Size>mLineSize ) mLineSize = Size; }
00369
00370 Justification GetJustification() { return mJustification; }
00371 MILLIPOINT GetLineSpacing() { return mLineSpacing; }
00372 FIXED16 GetLineSpaceRatio() { return mLineSpaceRatio; }
00373 MILLIPOINT GetParaLeftMargin() { return mLeftMargin; }
00374 MILLIPOINT GetParaFirstIndent() { return mFirstIndent; }
00375 MILLIPOINT GetParaRightMargin() { return mRightMargin; }
00376 const TxtRuler* GetRuler() { return mpRuler; }
00377 void SetJustification( Justification justification) { mJustification = justification; }
00378 void SetLineSpacing( MILLIPOINT Spacing) { mLineSpacing = Spacing; }
00379 void SetLineSpaceRatio( FIXED16 SpaceRatio) { mLineSpaceRatio = SpaceRatio; }
00380 void SetParaLeftMargin( MILLIPOINT Margin) { mLeftMargin = Margin; }
00381 void SetParaFirstIndent(MILLIPOINT Indent) { mFirstIndent = Indent; }
00382 void SetParaRightMargin(MILLIPOINT Margin) { mRightMargin = Margin; }
00383 void SetRuler( const TxtRuler* pRuler) { if (*mpRuler != *pRuler) *mpRuler = *pRuler; }
00384
00385 MILLIPOINT GetPosInStory() { return mPosInStory; }
00386 void SetPosInStory(MILLIPOINT pos) { mPosInStory=pos; }
00387
00388 protected:
00389 MILLIPOINT GetEffectiveLeftMargin();
00390 private:
00391 MILLIPOINT mLineDescent;
00392 MILLIPOINT mLineAscent;
00393 MILLIPOINT mLineSize;
00394
00395 Justification mJustification;
00396 MILLIPOINT mLineSpacing;
00397 FIXED16 mLineSpaceRatio;
00398 MILLIPOINT mLeftMargin;
00399 MILLIPOINT mFirstIndent;
00400 MILLIPOINT mRightMargin;
00401 TxtRuler* mpRuler;
00402
00403 MILLIPOINT mPosInStory;
00404 };
00405
00406 #endif