home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Display.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):
-
- <3> 1/5/94 EZ fix compilation error when txtnMultiFrames is set
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _Display_
- #define _Display_
-
-
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- #ifndef _RunObject_
- #include "RunObject.h"
- #endif
-
- #ifdef txtnRulers
- #ifndef _RulersRanges_
- #include "RulersRanges.h"
- #endif
- #endif
-
- #ifndef _Frames_
- #include "Frames.h"
- #endif
-
- #ifndef _StyledText_
- #include "StyledText.h"
- #endif
-
- #ifndef _Formatter_
- #include "Formatter.h"
- #endif
-
- #ifndef _FrameFormatter_
- #include "FrameFormatter.h"
- #endif
-
- #ifndef _Line_
- #include "Line.h"
- #endif
- //***************************************************************************************************
-
- #ifdef __SC__
- class __machdl CSelection;
- class __machdl CTextension;
- #else
- class CSelection;
- class CTextension;
- #endif
-
- struct TDrawEnv {
- TDrawEnv(char nesting = 0) : savedTextEnv(nesting) {allowNesting = nesting;}
-
- char allowNesting;
- TTextEnv savedTextEnv;
- RgnHandle userClip;
- };
-
- struct TEditInfo {
- inline TEditInfo() {checkUpdateRgn = true;}
-
- Boolean checkUpdateRgn; //input to BeginEdit
- Boolean editSuccess; //input to EndEdit
-
- #ifdef txtnMultiFrames
- long oldCountFrames; //from BeginEdit to EndEdit
- #else
- long oldLinesHite;
- #endif
-
- TDrawEnv savedDrawEnv; //from BeginEdit to EndEdit
-
- char oldSelState;
- };
-
- //***************************************************************************************************
-
-
- //const for visOption to "IsSelectionVisible"
- const short kCenterSelection = 1;
- const short kNearestSelection = 2;
-
- //const for drawing routines"
- typedef ushort TDrawFlags;
-
- const TDrawFlags kNoDrawFlags = 0;
- const TDrawFlags kEraseBeforeDraw = 1 << 0;
- const TDrawFlags kFirstLineOffScreen = 1 << 1; //internal
- const TDrawFlags kDrawAllOffScreen = 1 << 2;
-
- //***************************************************************************************************
-
- void InitDisplay();
-
- void EndDisplay();
-
- //***************************************************************************************************
-
- struct TDisplayHandlers {
- CSelection* selectionHandler;
- CStyledText* styledTextHandler;
- CFormatter* formatHandler;
- CFrames* framesHandler;
-
- #ifdef txtnRulers
- CRulersRanges* rulersRanges;
- #endif
- };
- //***************************************************************************************************
-
- class CTextensionDisplay : public HandleObject {
- friend class CTextension;
- friend class CSelection;
-
- public :
- //--------
- CTextensionDisplay();
-
- void ITextensionDisplay();
-
- void SetHandlers(TDisplayHandlers* handlers, TSize sizeInfo);
-
- virtual void Free();
-
- virtual void FreeData();
-
- #ifdef txtnNever
- virtual CTextensionDisplay* CreateEmptyClone();
- #endif
-
- inline CFrames* GetFramesHandler() {return fFrames;}
-
- void HideDrawPen(); //like HidePen
- void ShowDrawPen(); //like ShowPen
-
- void GetViewRect(Rect* theRect) const;
- void SetViewRect(const Rect* theRect);
-
- virtual void Draw(const Rect *updateRect, TDrawFlags drawFlags = kEraseBeforeDraw);
- //if updateRect is nil ==> draw all
-
- void DrawChars(long firstOffset, long lastOffset, TDrawFlags drawFlags = kEraseBeforeDraw);
-
- void InvalidDraw();
-
- inline short GetLastEditAction() {return fLastEditAction;}
- //after any edit operation, the returned value is a combination of bits same as returned from DisplayChanged
-
- inline void SetLastEditAction(short action) {fLastEditAction |= action;}
-
- void Scroll(const LongPoint* scrollVals);
- void GetScrolledValues(LongPoint* scrolledVals);
-
- void Activate(Boolean activ, Boolean turnSelOn =true);
-
- Boolean IsSelectionVisible(const Rect* visRect, LongPoint* scrollVals
- , short visOption =kCenterSelection, Boolean visSelEnd = true);
-
- void SetDirection(char newDirection); // does NOT have a draw effect
- inline char GetDirection() const {return fDirection;}
-
- #ifdef txtnScal
- void SetScale(Point numer, Point denom); // does NOT have a draw effect
- inline void GetScale(Point* numer, Point* denom) {fFrames->GetScale(numer, denom);}
- #endif
-
- void LineCharsLocs(long lineNo, TOffsetRange charRange
- , TCharLocs* charLocsArr, Boolean lineBounds, char caretDir = kRunDir);
-
- Boolean Visible2BackOrder(TOffset* charOffset, char runDir);
-
- CRunObject* Point2Char(Point thePt, TOffsetRange* charRange, Boolean* outside);
- //•returns a val < 0 in charRange->rangeStart if the point is not in any frame
-
- long Point2Line(Point* thePt, Boolean* outside, Boolean* vOverflow, TOffsetRange* lineRange = nil) const;
- //•see comment on Point2Line in Frames.h
-
- void Char2Point(TOffset theChar, long* top, long* trailEdge=nil, short* hite =nil);
- // top and trailEdge are in abs coord
- //hite in output (if not nil) is set to the line hite of the line containing the char
-
- Point Char2Point(TOffset theChar, short* hite =nil);
-
- #ifdef txtnDebug
- inline char DrawEnvLevel() {return fDrawEnvLevel;}
- #endif
-
- protected :
- //-----------
- CSelection* fSelection;
- CFrames* fFrames;
- CStyledText* fStyledText;
- CFormatter* fFormatter;
- CFrameFormatter* fFrameFormatter;
-
- char fDirection;
- //------------------------------------------
-
- #ifdef txtnNever
- //bits modif notify is false by default
- inline void EnableBitsModifNotify() {++fBitsModifLevel;}
- inline void DisableBitsModifNotify() {--fBitsModifLevel;}
-
- virtual void PreRectBitsModif(const Rect* theRect);
- #endif
-
- virtual void Focus(RgnHandle* savedClip);
- virtual void UnFocus(RgnHandle savedClip);
-
-
- virtual void BeginEdit(TEditInfo* editInfo);
- virtual void EndEdit(const TEditInfo* editInfo, long firstFormatLine, long lastFormatLine
- , TOffset* selOffset=nil);
-
- private:
- //--------
- CLine* fLine;
-
- char fDrawEnvLevel;
-
- #ifdef txtnNever
- char fBitsModifLevel;
- #endif
-
- char fHasViewRect;
- Rect fViewRect;
-
- static short fLastEditAction;
- /*declared static when foot notes have been implemented. In this case it's important to remember
- the edit action in the master textension even if the context has been changed after the edit
- operation (insert foot note for instance) */
-
- static char fDrawVisLevel;
- /*
- declared global when foot notes have been implemented, in this case user may want to hide draw
- across calls which may change the context (and thus the Display)
- */
-
- //------------------------------------------
-
- void CalcLine(long lineNo);
-
- inline Boolean IsDrawHidden() {return fDrawVisLevel < 0;}
-
- void SetDrawEnv(TDrawEnv* savedDrawEnv, Boolean checkUpdateRgn =false);
-
- void RestoreDrawEnv(const TDrawEnv& savedDrawEnv);
-
- #ifdef txtnMultiFrames
- void GetViewFrames(CSectFrames* visFrames) const;
- #endif
-
- void DrawLineGroup(const TSectLines* group2Draw, RgnHandle drawClip
- , TDrawFlags drawFlags);
-
- Boolean DrawFrameText(long frameNo, TDrawFlags drawFlags, const Rect* rect2Draw =nil);
-
- Boolean ScrollRect(const Rect* rect2Scroll, long hPix, long vPix, RgnHandle invalidRgn
- , Boolean move = false);
-
- #ifdef txtnMultiFrames
- void UpdateScrolledArea(RgnHandle invalidRgn, const T1FrameEditInfo* frameEditInfo);
-
- void FrameEndEdit(const T1FrameEditInfo* editInfo, long startPix, long hite=-1);
-
- void EraseFrameBottom(long frameNo);
-
- void ScrollFrame(const T1FrameEditInfo* frameEditInfo);
- void UpdateOverflowLines(const T1FrameEditInfo* frameEditInfo);
-
- #else
- void UpdateScrolledArea(RgnHandle invalidRgn);
-
- void FrameEndEdit(const TEditInfo* editInfo, long startPix, long hite=-1);
- #endif
-
-
- void CheckScroll(Boolean doUpdate = true);
- };
- //***************************************************************************************************
-
-
- #endif
-