home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Frames.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 _Frames_
- #define _Frames_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- #ifndef _Array_
- #include "Array.h"
- #endif
-
- #ifndef _FrameFormatter_
- #include "FrameFormatter.h"
- #endif
-
- //***************************************************************************************************
-
- /*TSectLines is the element type of the array filled by CFrames::SectLines.
- an element with countLines == 0 ===> firstLineRect is a rect with no lines
- (probably should be erased by the caller), in this case firstLine and lineAscent are undefined.
- */
- struct TSectLines {
- long firstLine;
- Rect firstLineRect; //rect hite = lineHite
- short countLines;
- short lineAscent;
- };
- typedef TSectLines* TSectLinesPtr;
- //*************************************************************************************************
-
-
- #ifdef txtnMultiFrames
- struct TUniformSectFrames {
- long fFirstFrame;
- short fCountAcross;
- long fLastFrame;
- short fRowFrames;
-
- short fCurrentAcross;
- };
-
- const short kMaxSectedFrames = 64;
- struct TMultiformFrames {
- short fCountSected;
- long fSectedFrames[kMaxSectedFrames];
- };
-
- /*CSectFrames is returned from CFrames::SectFrames, the caller will loop on each frame by calling
- CSectFrames::GetNextFrame , GetNextFrame returns a val < 0 if no next.*/
-
- class CSectFrames : private SingleObject {
- public:
- TUniformSectFrames fUniformFrames;
-
- CSectFrames() {
- fCurrentFrame = -2;
- fMultiformFrames.fCountSected = 0;
- }
-
- void SetUniform(long firstFrame, short countAcross, long lastFrame, short rowFrames);
- void AppendMultiform(long frameNo);
-
- inline Boolean IsEmpty() const {return fCurrentFrame == -2;}
-
- long GetFirstFrame() const;
- long GetLastFrame() const;
-
- long GetNextFrame(); //returns < 0 if no next
-
- private:
- TMultiformFrames fMultiformFrames;
-
- long fCurrentFrame;
-
- inline IsUniform() const {return fMultiformFrames.fCountSected < 0;}
- };
- //*************************************************************************************************
- #endif
-
-
- //constants for CDisplayChanges::fKind
- const short kNoChanges = 0;
-
- const short kNeedHReformat = 1;
- const short kNeedVReformat = 2;
- const short kNeedPartialReformat = 4;
-
- const short kRedrawAll = 8;
- const short kCheckSize = 16;
-
- const short kCheckUpdate = 32;
-
- const short kScrollSelection = 64;
-
- //*************************************************************************************************
-
- class CDisplayChanges : private SingleObject {
- public :
- CDisplayChanges();
-
- inline void SetChangesKind(short result) {fKind |= result;}
- inline short GetChangesKind() const {return fKind;}
-
- void SetFormatRange(const TOffsetPair* formatRange);
- void GetFormatRange(TOffsetPair* formatRange) const;
-
- private:
- short fKind;
-
- TOffsetPair fFormatRange;
- };
- //*************************************************************************************************
-
- struct TCell {
- long row;
- short column;
- };
- //*************************************************************************************************
-
- #ifdef txtnNever
- //constants for SyncTextFrameHite
- const short kNoShrink = 1;
- const short kNoExpand = 2;
- #endif
- //*************************************************************************************************
-
-
-
- inline void InitFrames() {} //should be called atr the start
- inline void EndFrames() {} //should be called atr the end
-
- //*************************************************************************************************
-
-
- class CFrames : public HandleObject {
- public:
- CFrames();
-
- void IFrames();
-
- virtual void Free();
- virtual void FreeData();
-
- inline CFrameFormatter* GetFrameFormatter() {return fFrameFormatter;}
-
- inline long GetCountFrames() const {return fFrameFormatter->GetCountFrames();}
-
- #ifdef txtnScal
- virtual void SetScale(Point numer, Point denom);
- void GetScale(Point* numer, Point* denom) const;
- #endif
-
- inline void SetDirection(char newDirection) {fDirection = newDirection;}
-
- #ifdef txtnScal
- virtual void GetTextFrameSize(LongPoint* theSize, Boolean scaled = true, long frameNo = 0) const = 0;
- #else
- virtual void GetTextFrameSize(LongPoint* theSize, long frameNo = 0) const = 0;
- #endif
-
- virtual void SetTextFrameSize(const LongPoint* newSize, CDisplayChanges* changes = nil, long frameNo = 0) = 0;
- //•newSize is not scaled
-
- #ifdef txtnNever
- virtual Boolean SyncTextFrameHite(Rect* rect2Update = nil, short flags = 0, long frameNo = 0);
- #endif
-
- #ifdef txtnScal
- virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* absRect, Boolean scaled = true) const;
-
- virtual void GetAbsTextFrame(long frameNo, TxtnLongRect* absRect, Boolean scaled = true) const;
-
- void GetTextFrame(long frameNo, Rect* theRect, Boolean scaled = true) const;
- //in draw coord
-
- void GetFrameRect(long frameNo, Rect* theRect, Boolean scaled = true) const;
- //in draw coord
-
- #else
- virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* absRect) const;
-
- virtual void GetAbsTextFrame(long frameNo, TxtnLongRect* absRect) const;
-
- void GetTextFrame(long frameNo, Rect* theRect) const;
- //in draw coord
-
- void GetFrameRect(long frameNo, Rect* theRect) const;
- //in draw coord
- #endif
-
- virtual void SetMargins(const Rect* newMargins, CDisplayChanges* changes = nil); //newMargins not scaled
-
- #ifdef txtnScal
- virtual void GetMargins(Rect* margins, Boolean scaled = true) const;
- #else
- virtual void GetMargins(Rect* margins) const;
- #endif
-
- virtual long GetTotalHite() const = 0;
- virtual long GetTotalWidth() const = 0;
-
- #ifdef txtnMultiFrames
- virtual void InvalFramePart(long frameNo, TFrameEditFlags invalFlags, long invalMessage = 0
- , RgnHandle theClip = nil);
- #endif
-
- //••• formatter can optimize for non variable size Frames
- virtual short GetLineFormatWidth(long lineNo) const = 0;
- virtual short GetLineMaxWidth(long lineNo) const = 0;
-
- long HDraw2Abs(long hCoord) const;
- long VDraw2Abs(long vCoord) const;
- short HAbs2Draw(long hCoord) const;
- short VAbs2Draw(long vCoord) const;
- void Abs2Draw(const TxtnLongRect* absRect, Rect* drawRect) const;
- void Draw2Abs(const Rect* drawRect, TxtnLongRect* absRect) const;
- Point Abs2Draw(const LongPoint* absPoint) const;
- void Draw2Abs(Point thePoint, LongPoint* absPoint) const;
-
- void FramesScrolled(long hPix, long vPix);
- inline long GetVScrolledPix() const {return fVScrolledPix;}
- inline long GetHScrolledPix() const {return fHScrolledPix;}
-
- void SetDrawOrigin(long h, long v);
- void GetDrawOrigin(long* h, long* v) const;
-
- void SetFramesOrigin(long h, long v);
- void GetFramesOrigin(long* h, long* v) const;
-
- long Point2Line(Point* thePt, Boolean* outside, Boolean* vOverflow) const;
- /* -•returns a val < 0 if thePt is not in any frame
- -thePt (in and out) is in draw coord
- -in output thePt is set to the topLeft of the line in Draw coord (except if outside is true).
- -outside is true if thePt is outside the text frame
- -vOverflow is true if thePt->v is > frame last line (in this case the fn result is the last line in the frame)
- */
-
- void Line2Point(long lineNo, LongPoint* absPt) const;
- Point Line2Point(long lineNo) const;
-
- virtual long Point2Frame(const LongPoint* thePt) const = 0; //thePt is in abs coord
- //•returns a value < 0 if the point is not in any frame
-
- long Point2Frame(Point thePt) const;
- //thePt is in draw coord
-
- #ifdef txtnMultiFrames
- virtual void SectFrames(const Rect* theRect, CSectFrames* sectedFrames) const = 0;
- //theRect is in draw coord
- #endif
-
- Boolean SectLines(Rect* theRect, long frameNo, short* countLines, CArray* sectedLines) const;
-
- protected:
- CFrameFormatter* fFrameFormatter;
-
- #ifdef txtnScal
- Point fNumer;
- Point fDenom;
- #endif
-
- char fDirection;
-
- long fVScrolledPix;
- long fHScrolledPix;
-
- LongPoint fDrawOrigin;
- LongPoint fFramesOrigin;
-
- virtual void CreateFrameFormatter() = 0;
-
- private:
- Rect fMargins;
-
- #ifdef txtnScal
- Rect fScaledMargins;
- #endif
-
- #ifdef txtnScal
- void RecalcScaledMargins();
- #endif
- };
- //*************************************************************************************************
-
- class CMonoSizeFrames : public CFrames {
- public:
- CMonoSizeFrames();
-
- void IMonoSizeFrames();
-
- //•override
-
- #ifdef txtnScal
- virtual void SetScale(Point numer, Point denom);
- #endif
-
- virtual void SetTextFrameSize(const LongPoint* newSize, CDisplayChanges* changes = nil, long frameNo = 0);
-
- #ifdef txtnScal
- virtual void GetTextFrameSize(LongPoint* theSize, Boolean scaled = true, long frameNo = 0) const;
- #else
- virtual void GetTextFrameSize(LongPoint* theSize, long frameNo = 0) const;
- #endif
-
- virtual long GetTotalHite() const = 0;
- virtual long GetTotalWidth() const = 0;
-
- virtual short GetLineFormatWidth(long lineNo) const;
- virtual short GetLineMaxWidth(long lineNo) const;
-
- virtual long Point2Frame(const LongPoint* thePt) const = 0; //thePt is in abs coord
-
- #ifdef txtnMultiFrames
- virtual void SectFrames(const Rect* theRect, CSectFrames* sectedFrames) const = 0;
- //theRect is in draw coord
- #endif
-
- protected:
- LongPoint fTextFrameSize;
-
- #ifdef txtnScal
- LongPoint fScaledTextFrameSize;
- #endif
-
- //•override
- virtual void CreateFrameFormatter() = 0;
-
- private:
- #ifdef txtnScal
- void RecalcScaledSize();
- #endif
- };
- //*************************************************************************************************
-
- /*
- -CMonoFrameFrames may be called with 0 vertical in SetTextFrameSize ==> unlimited hite
- */
- class CMonoFrame : public CMonoSizeFrames {
- public:
- CMonoFrame();
-
- inline void IMonoFrame() {this->IMonoSizeFrames();}
-
- //•override
-
- virtual void SetTextFrameSize(const LongPoint* newSize, CDisplayChanges* changes = nil, long frameNo = 0);
-
- virtual long GetTotalHite() const;
- virtual long GetTotalWidth() const;
-
- #ifdef txtnMultiFrames
- virtual void SectFrames(const Rect* theRect, CSectFrames* sectedFrames) const;
- #endif
-
- virtual long Point2Frame(const LongPoint* thePt) const;
- //•returns a value < 0 if the point is not in the frame
-
- //•own members
-
- protected:
- virtual void CreateFrameFormatter();
-
- private:
- };
- //*************************************************************************************************
-
-
- #endif
-