home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LinkedFrames.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):
-
- <4> 1/5/94 EZ fix compilation problems, this file didn't compile for long time
- <3> 1/5/94 EZ don't compile if txtnMultiFrames compilation var is not defined
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifdef txtnMultiFrames
-
- #ifndef _LinkedFrames_
- #define _LinkedFrames_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- #ifndef _Array_
- #include "Array.h"
- #endif
-
- #ifndef _Pages_
- #include "Pages.h"
- #endif
-
- #ifndef _TextensionCommand_
- #include "TextensionCommand.h"
- #endif
- //***************************************************************************************************
-
-
- struct TLinkedFrameInfo {
- long top;
- long left;
- };
- typedef TLinkedFrameInfo* TLinkedFrameInfoPtr;
- //*************************************************************************************************
-
-
- //••constants for CLinkedFramesCommand command ids
-
- const short kNewFrameCommand = 5001; //works on 1 frame
- const short kDeleteFramesCommand = 5002; //works on list of frames
- const short kModifyFrameCommand = 5003; //works on 1 frame
- const short kOffsetFramesCommand = 5004; //works on list of frames
- //*************************************************************************************************
-
-
- //frameHite and frameWidth are not scaled
- struct TFrameFormatInfo {
- short frameHite;
- short frameWidth;
- };
- typedef TFrameFormatInfo* TFrameFormatInfoPtr;
-
- //*************************************************************************************************
-
- class CLongArray : public CLongTagArray {
- //Array of "long" elements
- public:
- CLongArray();
-
- inline void ILongArray(short moreElementsCount = 0)
- {this->IArray(sizeof(long), moreElementsCount);}
-
- OSErr AppendValue(long theValue);
-
- long GetValue(long index) const;
-
- void Sort(); //ascending order
-
- private:
-
- };
- //***************************************************************************************************
-
-
- class CVariableSizeFrameFormatter : public CMultiFrameFormatter {
- public:
- CVariableSizeFrameFormatter();
-
- void IVariableSizeFrameFormatter();
-
- //•override
- virtual void Free();
- virtual void FreeData();
-
- virtual void SetFrameHite(long frameNo, short newHite);
-
- virtual short GetFrameHite(long frameNo) const;
-
- virtual long GetCountFrames() const;
-
- virtual Boolean GetFrameLineRange(long frameNo, TOffsetPair* frameLines) const;
-
- virtual Boolean VariableSizeFrames() const;
-
- //•own members
- inline long GetCountFilledFrames() const {return CMultiFrameFormatter::GetCountFrames();}
- //frames containing some text
-
- short GetFrameWidth(long frameNo) const;
-
- OSErr AddUserFrame(long frameNo, short width, short hite, TOffsetPair* lines2Format =nil);
- //add at the "frameNo", returns in lines2Format the lines needing formating, -1 in lines2Format->firstOffset if none
-
- void DeleteUserFrame(long frameNo, TOffsetPair* lines2Format);
- //returns in lines2Format the lines needing formating, -1 in lines2Format->firstOffset if none
-
- void SetFrameSize(long frameNo, short width, short hite, TOffsetPair* lines2Format =nil);
-
- void DeleteAllUserFrames();
-
- protected:
- //•override
- virtual Boolean BreakFrame(long frameNo, short* pixReflow, TOffsetPair* linesReflow
- , CFormatReflowLines* formatReflowLines);
- virtual OSErr AppendFrame(short framePix, long lastLine =-1);
-
- //•own members
-
- private:
- CArray* fFrames; //array of TFrameFormatInfo
-
- void FrameChangedSize(long frameNo, TOffsetPair* lines2Format);
- };
- //*************************************************************************************************
-
-
- /*CVariableSizeFrames manages frames of variable size and with no rule of position of a frame wrt to another
- , primarily done for Linked frames in CW.
- will create a frame formatter of type "CVariableSizeFrameFormatter". CVariableSizeFrameFormatter will keep
- the non scaled width and hite for each frame which are necessary for vertical formatting of variable size frames.
- CVariableSizeFrames will keep "TLinkedFrameInfo" for each frame.
- */
-
- class CVariableSizeFrames : public CFrames {
- public:
- CVariableSizeFrames();
-
- void IVariableSizeFrames();
-
- //•override
- virtual void Free();
- virtual void FreeData();
-
- #ifdef txtnScal
- virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* absRect, Boolean scaled = true) const;
- #else
- virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* absRect) const;
- #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;
- virtual long GetTotalWidth() const;
-
- virtual short GetLineFormatWidth(long lineNo) const;
- virtual short GetLineMaxWidth(long lineNo) const;
-
- virtual long Point2Frame(const LongPoint* thePt) const; //thePt is in abs coord
- //•returns a value < 0 if the point is not in any frame
-
- virtual void SectFrames(const Rect* theRect, CSectFrames* sectedFrames) const;
- //theRect is in draw coord
-
- //•own members
-
- OSErr AddUserFrame(long frameNo, TxtnLongRect* absRect, CDisplayChanges* changes = nil);
- //add at the "frameNo", absRect is the abs text bounds
-
- void DeleteUserFrame(long frameNo, CDisplayChanges* changes);
- //delete at the "frameNo"
-
- void SetAbsTextFrame(long frameNo, const TxtnLongRect* absRect, CDisplayChanges* changes = nil);
- //•absRect is not scaled
-
- Boolean IsLastFrameOverflow() const;
-
- void DeleteAllUserFrames();
-
- protected:
-
- //•override
- virtual void CreateFrameFormatter();
-
- private:
- CVariableSizeFrameFormatter* fVSFrameFormatter; //a ref is kept to avoid type casting
- CArray* fFrames; //array of TLinkedFrameInfo
- };
- //*************************************************************************************************
-
-
-
-
-
- struct TFrameCmdData {
- long frameNo;
- TxtnLongRect textBounds;
- };
- typedef TFrameCmdData* TFrameCmdDataPtr;
- //*************************************************************************************************
-
- class CLinkedFramesCommand : public CTextensionCommand {
- public:
- CLinkedFramesCommand();
-
- void ILinkedFramesCommand(CTextension* textension, short theCmd
- , short countFrames, Boolean framesExists);
-
- //•own
- inline short GetCmdCountFrames() const {return fCountFrames;}
- inline Boolean FramesExist() const {return fFramesExist;}
-
- virtual void GetIndFrameCmdData(short frameIndex, TFrameCmdData* frameData) const = 0;
-
- protected:
- CVariableSizeFrames* fFramesHandler;
- short fCountFrames;
-
- //•override
- virtual OSErr DoIt(short* userAction);
- virtual OSErr UndoIt(short* userAction);
- virtual OSErr RedoIt(short* userAction);
-
- //•own
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges) = 0;
-
- virtual char GetFlags() const;
-
- private:
- Boolean fFramesExist;
- char fFlags;
-
- OSErr CommonAction(short* userAction);
- };
- //**************************************************************************************************
-
-
- class CMonoFrameCommand : public CLinkedFramesCommand {
- public:
- CMonoFrameCommand();
-
- void IMonoFrameCommand(CTextension* textension, short theCmd, const TFrameCmdData* frameData
- , Boolean framesExist);
-
- //•override
- virtual void GetIndFrameCmdData(short frameIndex, TFrameCmdData* frameData) const;
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges) = 0;
-
- private:
- TFrameCmdData fFrameCmdData;
- };
- //**************************************************************************************************
-
-
- class CMultiFrameCommand : public CLinkedFramesCommand {
- public:
- CMultiFrameCommand();
-
- OSErr IMultiFrameCommand(CTextension* textension, short theCmd
- , CLongArray* cmdFrames, Boolean framesExist);
-
- //•override
- virtual void Free();
-
- virtual void GetIndFrameCmdData(short frameIndex, TFrameCmdData* frameData) const;
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges) = 0;
-
- private:
- CLongArray* fFrames;
- };
- //**************************************************************************************************
-
-
- class CNewFrameCommand : public CMonoFrameCommand {
- public:
- CNewFrameCommand();
-
- void INewFrameCommand(CTextension* textension, long frameNo, TxtnLongRect* absTextRect);
- //absTextRect is not scaled
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges);
-
- virtual char GetFlags() const;
-
- private:
- };
- //**************************************************************************************************
-
-
- class CModifyFrameCommand : public CMonoFrameCommand {
- public:
- CModifyFrameCommand();
-
- void IModifyFrameCommand(CTextension* itsView, long frameNo, TxtnLongRect* newTextBounds);
- //newTextBounds is not scaled
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges);
-
- private:
- TxtnLongRect fNewTextBounds;
- };
- //**************************************************************************************************
-
-
- class CDeleteFramesCommand : public CMultiFrameCommand {
- public:
- CDeleteFramesCommand();
-
- OSErr IDeleteFramesCommand(CTextension* textension, CLongArray* cmdFrames);
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges);
-
- virtual char GetFlags() const;
-
- private:
- };
- //**************************************************************************************************
-
-
- class COffsetFramesCommand : public CMultiFrameCommand {
- public:
- COffsetFramesCommand();
-
- OSErr IOffsetFramesCommand(CTextension* textension, CLongArray* cmdFrames
- , long hOffset, long vOffset);
-
- //•own
- void SetOffsets(long hOffset, long vOffset);
-
- protected:
- //•override
- virtual OSErr DoMainAction(const TFrameCmdData* frameData, short frameIndex
- , Boolean isUndo, CDisplayChanges* displayChanges);
-
- private:
- long fHOffset;
- long fVOffset;
- };
- //**************************************************************************************************
-
-
-
- #endif //_LinkedFrames_
-
- #endif //txtnMultiFrames