- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# ParagraphLayout.h

Go to the documentation of this file.

    00001 /*
    00002  **********************************************************************
    00003  *   Copyright (C) 2002-2010, International Business Machines
    00004  *   Corporation and others.  All Rights Reserved.
    00005  **********************************************************************
    00006  */
    00007
    00008 #ifndef __PARAGRAPHLAYOUT_H
    00009
    00010 #define __PARAGRAPHLAYOUT_H
    00011
    00017 /*
    00018  * ParagraphLayout doesn't make much sense without
    00019  * BreakIterator...
    00020  */
    00021 #include "unicode/uscript.h"
    00022 #if ! UCONFIG_NO_BREAK_ITERATION
    00023
    00024 #include "layout/LETypes.h"
    00025 #include "layout/LEFontInstance.h"
    00026 #include "layout/LayoutEngine.h"
    00027 #include "unicode/ubidi.h"
    00028 #include "unicode/brkiter.h"
    00029
    00030 #include "layout/RunArrays.h"
    00031
    00032 U_NAMESPACE_BEGIN
    00033
    00044 class U_LAYOUTEX_API ParagraphLayout : public UObject
    00045 {
    00046 public:
    00047     class VisualRun;
    00048
    00060     class U_LAYOUTEX_API Line : public UObject
    00061     {
    00062     public:
    00071         ~Line();
    00072
    00080         inline le_int32 countRuns() const;
    00081
    00090         le_int32 getAscent() const;
    00091
    00100         le_int32 getDescent() const;
    00101
    00110         le_int32 getLeading() const;
    00111
    00121         le_int32 getWidth() const;
    00122
    00138         const VisualRun *getVisualRun(le_int32 runIndex) const;
    00139
    00145         static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
    00146
    00152         virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
    00153
    00154     private:
    00155
    00160         static const char fgClassID;
    00161
    00162         friend class ParagraphLayout;
    00163
    00164         le_int32 fAscent;
    00165         le_int32 fDescent;
    00166         le_int32 fLeading;
    00167
    00168         le_int32 fRunCount;
    00169         le_int32 fRunCapacity;
    00170
    00171         VisualRun **fRuns;
    00172
    00173         inline Line();
    00174         inline Line(const Line &other);
    00175         inline Line &operator=(const Line & /*other*/) { return *this; };
    00176
    00177         void computeMetrics();
    00178
    00179         void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
    00180                     const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
    00181     };
    00182
    00198     class U_LAYOUTEX_API VisualRun : public UObject
    00199     {
    00200     public:
    00213         inline const LEFontInstance *getFont() const;
    00214
    00223         inline UBiDiDirection getDirection() const;
    00224
    00232         inline le_int32 getGlyphCount() const;
    00233
    00244         inline const LEGlyphID *getGlyphs() const;
    00245
    00259         inline const float *getPositions() const;
    00260
    00271         inline const le_int32 *getGlyphToCharMap() const;
    00272
    00281         inline le_int32 getAscent() const;
    00282
    00291         inline le_int32 getDescent() const;
    00292
    00301         inline le_int32 getLeading() const;
    00302
    00308         static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
    00309
    00315         virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
    00316
    00317     private:
    00318
    00323         static const char fgClassID;
    00324
    00325         const LEFontInstance *fFont;
    00326         const UBiDiDirection  fDirection;
    00327
    00328         const le_int32 fGlyphCount;
    00329
    00330         const LEGlyphID *fGlyphs;
    00331         const float     *fPositions;
    00332         const le_int32  *fGlyphToCharMap;
    00333
    00334         friend class Line;
    00335
    00336         inline VisualRun();
    00337         inline VisualRun(const VisualRun &other);
    00338         inline VisualRun &operator=(const VisualRun &/*other*/) { return *this; };
    00339
    00340         inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
    00341                   const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
    00342
    00343         ~VisualRun();
    00344     };
    00345
    00389     ParagraphLayout(const LEUnicode chars[], le_int32 count,
    00390                     const FontRuns *fontRuns,
    00391                     const ValueRuns *levelRuns,
    00392                     const ValueRuns *scriptRuns,
    00393                     const LocaleRuns *localeRuns,
    00394                     UBiDiLevel paragraphLevel, le_bool vertical,
    00395                     LEErrorCode &status);
    00396
    00403     ~ParagraphLayout();
    00404
    00405     // Note: the following is #if 0'd out because there's no good
    00406     // way to implement it without either calling layoutEngineFactory()
    00407     // or duplicating the logic there...
    00408 #if 0
    00409
    00424     static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
    00425 #else
    00426
    00438     static le_bool isComplex(const LEUnicode chars[], le_int32 count);
    00439
    00440 #endif
    00441
    00451     inline UBiDiLevel getParagraphLevel();
    00452
    00462     inline UBiDiDirection getTextDirection();
    00463
    00472     virtual le_int32 getAscent() const;
    00473
    00482     virtual le_int32 getDescent() const;
    00483
    00492     virtual le_int32 getLeading() const;
    00493
    00500     inline void reflow();
    00510     inline le_bool isDone() const;
    00511
    00529     Line *nextLine(float width);
    00530
    00536     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
    00537
    00543     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
    00544
    00545 private:
    00546
    00547
    00552     static const char fgClassID;
    00553
    00554     struct StyleRunInfo
    00555     {
    00556           LayoutEngine   *engine;
    00557     const LEFontInstance *font;
    00558     const Locale         *locale;
    00559           LEGlyphID      *glyphs;
    00560           float          *positions;
    00561           UScriptCode     script;
    00562           UBiDiLevel      level;
    00563           le_int32        runBase;
    00564           le_int32        runLimit;
    00565           le_int32        glyphBase;
    00566           le_int32        glyphCount;
    00567     };
    00568
    00569     ParagraphLayout() {};
    00570     ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
    00571     inline ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
    00572
    00573     void computeLevels(UBiDiLevel paragraphLevel);
    00574
    00575     Line *computeVisualRuns();
    00576     void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
    00577
    00578     void computeScripts();
    00579
    00580     void computeLocales();
    00581
    00582     void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
    00583
    00584     void computeMetrics();
    00585
    00586     le_int32 getLanguageCode(const Locale *locale);
    00587
    00588     le_int32 getCharRun(le_int32 charIndex);
    00589
    00590     static le_bool isComplex(UScriptCode script);
    00591
    00592     le_int32 previousBreak(le_int32 charIndex);
    00593
    00594
    00595     const LEUnicode *fChars;
    00596           le_int32   fCharCount;
    00597
    00598     const FontRuns   *fFontRuns;
    00599     const ValueRuns  *fLevelRuns;
    00600     const ValueRuns  *fScriptRuns;
    00601     const LocaleRuns *fLocaleRuns;
    00602
    00603           le_bool fVertical;
    00604           le_bool fClientLevels;
    00605           le_bool fClientScripts;
    00606           le_bool fClientLocales;
    00607
    00608           UBiDiLevel *fEmbeddingLevels;
    00609
    00610           le_int32 fAscent;
    00611           le_int32 fDescent;
    00612           le_int32 fLeading;
    00613
    00614           le_int32 *fGlyphToCharMap;
    00615           le_int32 *fCharToMinGlyphMap;
    00616           le_int32 *fCharToMaxGlyphMap;
    00617           float    *fGlyphWidths;
    00618           le_int32  fGlyphCount;
    00619
    00620           UBiDi *fParaBidi;
    00621           UBiDi *fLineBidi;
    00622
    00623           le_int32     *fStyleRunLimits;
    00624           le_int32     *fStyleIndices;
    00625           StyleRunInfo *fStyleRunInfo;
    00626           le_int32      fStyleRunCount;
    00627
    00628           BreakIterator *fBreakIterator;
    00629           le_int32       fLineStart;
    00630           le_int32       fLineEnd;
    00631
    00632           le_int32       fFirstVisualRun;
    00633           le_int32       fLastVisualRun;
    00634           float          fVisualRunLastX;
    00635           float          fVisualRunLastY;
    00636 };
    00637
    00638 inline UBiDiLevel ParagraphLayout::getParagraphLevel()
    00639 {
    00640     return ubidi_getParaLevel(fParaBidi);
    00641 }
    00642
    00643 inline UBiDiDirection ParagraphLayout::getTextDirection()
    00644 {
    00645     return ubidi_getDirection(fParaBidi);
    00646 }
    00647
    00648 inline void ParagraphLayout::reflow()
    00649 {
    00650     fLineEnd = 0;
    00651 }
    00652
    00653 inline ParagraphLayout::Line::Line()
    00654     : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
    00655 {
    00656     // nothing else to do
    00657 }
    00658
    00659 inline ParagraphLayout::Line::Line(const Line & /*other*/)
    00660     : UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
    00661 {
    00662     // nothing else to do
    00663 }
    00664
    00665 inline le_int32 ParagraphLayout::Line::countRuns() const
    00666 {
    00667     return fRunCount;
    00668 }
    00669
    00670 inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
    00671 {
    00672     return fFont;
    00673 }
    00674
    00675 inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
    00676 {
    00677     return fDirection;
    00678 }
    00679
    00680 inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
    00681 {
    00682     return fGlyphCount;
    00683 }
    00684
    00685 inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
    00686 {
    00687     return fGlyphs;
    00688 }
    00689
    00690 inline const float *ParagraphLayout::VisualRun::getPositions() const
    00691 {
    00692     return fPositions;
    00693 }
    00694
    00695 inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
    00696 {
    00697     return fGlyphToCharMap;
    00698 }
    00699
    00700 inline le_int32 ParagraphLayout::VisualRun::getAscent() const
    00701 {
    00702     return fFont->getAscent();
    00703 }
    00704
    00705 inline le_int32 ParagraphLayout::VisualRun::getDescent() const
    00706 {
    00707     return fFont->getDescent();
    00708 }
    00709
    00710 inline le_int32 ParagraphLayout::VisualRun::getLeading() const
    00711 {
    00712     return fFont->getLeading();
    00713 }
    00714
    00715 inline ParagraphLayout::VisualRun::VisualRun()
    00716     : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
    00717 {
    00718     // nothing
    00719 }
    00720
    00721 inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &/*other*/)
    00722     : UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
    00723 {
    00724     // nothing
    00725 }
    00726
    00727 inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
    00728                                              const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
    00729     : fFont(font), fDirection(direction), fGlyphCount(glyphCount),
    00730       fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
    00731 {
    00732     // nothing else needs to be done!
    00733 }
    00734
    00735 U_NAMESPACE_END
    00736 #endif
    00737 #endif

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines