Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ParagraphLayout.h

Go to the documentation of this file.
00001 /*
00002  **********************************************************************
00003  *   Copyright (C) 2002-2003, International Business Machines
00004  *   Corporation and others.  All Rights Reserved.
00005  **********************************************************************
00006  */
00007 
00008 #ifndef __PARAGRAPHLAYOUT_H
00009 
00010 #define __PARAGRAPHLAYOUT_H
00011 
00012 /*
00013  * ParagraphLayout doesn't make much sense without
00014  * BreakIterator...
00015  */
00016 #include "unicode/uscript.h"
00017 #if ! UCONFIG_NO_BREAK_ITERATION
00018 
00019 #include "layout/LETypes.h"
00020 #include "layout/LEFontInstance.h"
00021 #include "layout/LayoutEngine.h"
00022 #include "unicode/ubidi.h"
00023 #include "unicode/brkiter.h"
00024 
00025 #include "layout/RunArrays.h"
00026 
00027 U_NAMESPACE_BEGIN
00028 
00039 class U_LAYOUTEX_API ParagraphLayout : public UObject
00040 {
00041 public:
00042     class VisualRun;
00043 
00055     class U_LAYOUTEX_API Line : public UObject
00056     {
00057     public:
00066         ~Line();
00067 
00075         le_int32 countRuns() const;
00076 
00085         le_int32 getAscent() const;
00086 
00095         le_int32 getDescent() const;
00096 
00105         le_int32 getLeading() const;
00106 
00116                 le_int32 getWidth() const;
00117     
00133         const VisualRun *getVisualRun(le_int32 runIndex) const;
00134 
00140         virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00141 
00147         static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00148 
00149     private:
00150 
00155         static const char fgClassID;
00156 
00157         friend class ParagraphLayout;
00158 
00159         le_int32 fAscent;
00160         le_int32 fDescent;
00161         le_int32 fLeading;
00162 
00163         le_int32 fRunCount;
00164         le_int32 fRunCapacity;
00165 
00166         VisualRun **fRuns;
00167 
00168         Line();
00169                 Line(const Line &other);
00170                 Line &operator=(const Line & /*other*/) { return *this; };
00171 
00172         void computeMetrics();
00173 
00174         void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00175                     const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00176     };
00177 
00193     class U_LAYOUTEX_API VisualRun : public UObject
00194     {
00195     public:
00208         const LEFontInstance *getFont() const;
00209 
00218         UBiDiDirection getDirection() const;
00219 
00227         le_int32 getGlyphCount() const;
00228 
00239         const LEGlyphID *getGlyphs() const;
00240 
00254         const float *getPositions() const;
00255 
00266         const le_int32 *getGlyphToCharMap() const;
00267 
00276         le_int32 getAscent() const;
00277 
00286         le_int32 getDescent() const;
00287 
00296         le_int32 getLeading() const;
00297 
00303         virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00304 
00310         static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00311 
00312     private:
00313 
00318         static const char fgClassID;
00319 
00320         const LEFontInstance *fFont;
00321         const UBiDiDirection  fDirection;
00322 
00323         const le_int32 fGlyphCount;
00324 
00325         const LEGlyphID *fGlyphs;
00326         const float     *fPositions;
00327         const le_int32  *fGlyphToCharMap;
00328 
00329         friend class Line;
00330 
00331         VisualRun();
00332                 VisualRun(const VisualRun &other);
00333                 VisualRun &operator=(const VisualRun &other) { return *this; };
00334 
00335         VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00336                   const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
00337 
00338         ~VisualRun();
00339     };
00340 
00384     ParagraphLayout(const LEUnicode chars[], le_int32 count,
00385                     const FontRuns *fontRuns,
00386                     const ValueRuns *levelRuns,
00387                     const ValueRuns *scriptRuns,
00388                     const LocaleRuns *localeRuns,
00389                     UBiDiLevel paragraphLevel, le_bool vertical,
00390                                         LEErrorCode &status);
00391 
00398     ~ParagraphLayout();
00399 
00400     // Note: the following is #if 0'd out because there's no good
00401     // way to implement it without either calling layoutEngineFactory()
00402     // or duplicating the logic there...
00403 #if 0
00404 
00419     static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
00420 #else
00421 
00433     static le_bool isComplex(const LEUnicode chars[], le_int32 count);
00434 
00435 #endif
00436 
00446     UBiDiLevel getParagraphLevel();
00447 
00457     UBiDiDirection getTextDirection();
00458 
00467     virtual le_int32 getAscent() const;
00468 
00477     virtual le_int32 getDescent() const;
00478 
00487     virtual le_int32 getLeading() const;
00488 
00495     void reflow();
00496 
00514     Line *nextLine(float width);
00515 
00521     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00522 
00528     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00529 
00530 private:
00531 
00532 
00537     static const char fgClassID;
00538 
00539     struct StyleRunInfo
00540     {
00541           LayoutEngine   *engine;
00542     const LEFontInstance *font;
00543     const Locale         *locale;
00544           LEGlyphID      *glyphs;
00545           float          *positions;
00546           UScriptCode     script;
00547           UBiDiLevel      level;
00548           le_int32        runBase;
00549           le_int32        runLimit;
00550           le_int32        glyphBase;
00551           le_int32        glyphCount;
00552     };
00553 
00554     ParagraphLayout() {};
00555     ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
00556     ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
00557 
00558     void computeLevels(UBiDiLevel paragraphLevel);
00559 
00560     Line *computeVisualRuns();
00561     void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
00562 
00563     void computeScripts();
00564 
00565     void computeLocales();
00566 
00567     void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
00568 
00569     void computeMetrics();
00570 
00571     le_int32 getLanguageCode(const Locale *locale);
00572 
00573     le_int32 getCharRun(le_int32 charIndex);
00574 
00575     static le_bool isComplex(UScriptCode script);
00576 
00577     le_int32 previousBreak(le_int32 charIndex);
00578 
00579 
00580     const LEUnicode *fChars;
00581           le_int32   fCharCount;
00582 
00583     const FontRuns   *fFontRuns;
00584     const ValueRuns  *fLevelRuns;
00585     const ValueRuns  *fScriptRuns;
00586     const LocaleRuns *fLocaleRuns;
00587 
00588           le_bool fVertical;
00589           le_bool fClientLevels;
00590           le_bool fClientScripts;
00591           le_bool fClientLocales;
00592 
00593           UBiDiLevel *fEmbeddingLevels;
00594 
00595           le_int32 fAscent;
00596           le_int32 fDescent;
00597           le_int32 fLeading;
00598 
00599           le_int32 *fGlyphToCharMap;
00600           le_int32 *fCharToMinGlyphMap;
00601                   le_int32 *fCharToMaxGlyphMap;
00602           float    *fGlyphWidths;
00603           le_int32  fGlyphCount;
00604 
00605           UBiDi *fParaBidi;
00606           UBiDi *fLineBidi;
00607 
00608           le_int32     *fStyleRunLimits;
00609           le_int32     *fStyleIndices;
00610           StyleRunInfo *fStyleRunInfo;
00611           le_int32      fStyleRunCount;
00612 
00613           BreakIterator *fBreakIterator;
00614           le_int32       fLineStart;
00615           le_int32       fLineEnd;
00616 
00617           le_int32       fFirstVisualRun;
00618           le_int32       fLastVisualRun;
00619           float          fVisualRunLastX;
00620           float          fVisualRunLastY;
00621 };
00622 
00623 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
00624 {
00625     return ubidi_getParaLevel(fParaBidi);
00626 }
00627 
00628 inline UBiDiDirection ParagraphLayout::getTextDirection()
00629 {
00630     return ubidi_getDirection(fParaBidi);
00631 }
00632 
00633 inline void ParagraphLayout::reflow()
00634 {
00635     fLineEnd = 0;
00636 }
00637 
00638 inline ParagraphLayout::Line::Line()
00639     : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00640 {
00641     // nothing else to do
00642 }
00643 
00644 inline ParagraphLayout::Line::Line(const Line & /*other*/)
00645     : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
00646 {
00647     // nothing else to do
00648 }
00649 
00650 inline le_int32 ParagraphLayout::Line::countRuns() const
00651 {
00652     return fRunCount;
00653 }
00654 
00655 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
00656 {
00657     return fFont;
00658 }
00659 
00660 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
00661 {
00662     return fDirection;
00663 }
00664 
00665 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
00666 {
00667     return fGlyphCount;
00668 }
00669 
00670 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
00671 {
00672     return fGlyphs;
00673 }
00674 
00675 inline const float *ParagraphLayout::VisualRun::getPositions() const
00676 {
00677     return fPositions;
00678 }
00679 
00680 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
00681 {
00682     return fGlyphToCharMap;
00683 }
00684 
00685 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
00686 {
00687     return fFont->getAscent();
00688 }
00689 
00690 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
00691 {
00692     return fFont->getDescent();
00693 }
00694 
00695 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
00696 {
00697     return fFont->getLeading();
00698 }
00699 
00700 inline ParagraphLayout::VisualRun::VisualRun()
00701     : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00702 {
00703     // nothing
00704 }
00705 
00706 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &other)
00707     : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
00708 {
00709     // nothing
00710 }
00711 
00712 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
00713                                              const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
00714     : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
00715       fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
00716 {
00717     // nothing else needs to be done!
00718 }
00719 
00720 U_NAMESPACE_END
00721 #endif
00722 #endif

Generated on Mon Nov 24 14:35:34 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001