home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StyledText.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _StyledText_
- #define _StyledText_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _AttrObject_
- #include "AttrObject.h"
- #endif
-
- #ifndef _RunObject_
- #include "RunObject.h"
- #endif
-
- #ifndef _RunsRanges_
- #include "RunsRanges.h"
- #endif
-
- //***************************************************************************************************
-
- struct TTextEnv {
- TTextEnv(char nesting = 0) {allowNesting = nesting;}
-
- char allowNesting;
- GrafPtr savedPort;
- short savedSysJust;
- long savedFontForce;
- };
-
- class CStyledText : public HandleObject {
- public:
- //-------
- CStyledText();
-
- void IStyledText(GrafPtr textPort, CRunObject* protoObj, TSize sizeInfo = kLargeSize);
- virtual void Free();
-
- inline CRunsRanges* GetRunsRanges() {return fRunsRanges;}
-
- virtual void SetTextPort(GrafPtr newPort);
- GrafPtr GetTextPort() const;
-
- virtual void SetTextEnv(TTextEnv* savedTextEnv);
- virtual void RestoreTextEnv(const TTextEnv& savedTextEnv);
-
- inline void* LockChars(Boolean moveHi = false) {return fTextChars->LockArray(moveHi);}
- inline void UnlockChars() {fTextChars->UnlockArray();}
-
- #ifdef txtnNever
- inline OSErr SetCharsSize(long newCharsCount, Boolean compact =false)
- {return fTextChars->SetElementsCount(newCharsCount, compact);}
- #endif
-
- inline uPtr GetCharPtr(long charOffset) const
- {return (uPtr(fTextChars->GetElementPtr(charOffset)));}
-
- inline long CountChars() const {return (fTextChars->CountElements());}
-
- virtual void WordBoundaries(TOffsetRange* wordRange);
-
- short AdvanceOffset(long charOffset, Boolean forward);
-
- inline CRunObject* Char2Run(TOffset charOffset) //returns nil if text is empty
- {return (CRunObject*)(fRunsRanges->Offset2Object(charOffset));}
-
- inline CRunObject* Char2TextRun(TOffset charOffset) const
- {return fRunsRanges->Char2TextRun(charOffset);}
-
- #ifdef txtnDebug
- inline char TextEnvLevel() {return fTextEnvLevel;}
- #endif
-
- protected:
- //----------
- GrafPtr fTextPort;
-
- CArray* fTextChars;
- CRunsRanges* fRunsRanges;
-
-
- char CalcNextScriptRun(long offset, long len, long* scriptRunLen); //call FindScriptRun
- OSErr Run2ScriptRuns(long runOffset, long runLen, const CRunObject* defaultRun);
-
- OSErr CalcScriptRuns(const CRunObject* defaultRun, char* majorDirection);
- //defaultRun may be nil
-
- short GetByteOrder(uPtr chars, short offset, short charScript);
- //returns the same result as CharByte
-
- private:
- //--------
- CRunObject* fSavedObj;
-
- char fTextEnvLevel; //allow nested calls to SaveTextEnv and RestoreTextEnv
- };
- //***************************************************************************************************
-
- #endif
-