home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------------------
-
- Program: CPlusTESample 2.0
- File: TEDocument.h
- Uses: Document.h
-
- by Andrew Shebanow
- of Apple Macintosh Developer Technical Support
- with modifications by Eric Berdahl
-
- Copyright © 1989-1990 Apple Computer, Inc.
- Copyright © 1992 Eric Berdahl
- All rights reserved.
-
- ------------------------------------------------------------------------------------------*/
-
- #ifndef __TEDOCUMENT__
- #define __TEDOCUMENT__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
- #ifndef __CONTROLS__
- #include <Controls.h>
- #endif
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __DOCUMENT__
- #include "Document.h"
- #endif
-
- #ifndef _UAPPLEOBJECT_
- #include "UAppleObject.h"
- #endif
-
- // kTEFileType is the type of our files - in this case, TEXT
- const OSType kTEFileType = 'TEXT';
-
-
- class TEDocument : public TDocument, public MAppleObject {
- private:
- Boolean fSelFontContinuous; // does the selection have a continous style
- Boolean fSelFaceContinuous;
- Boolean fSelSizeContinuous;
- TextStyle fTxStyle; // the style of the selection text
- TEHandle fDocTE; // our text
- ControlHandle fDocVScroll; // vertical scrollbar
- ControlHandle fDocHScroll; // horizontal scrollbar
- ClikLoopProcPtr fDocClik; // our clik loop
-
- public:
- // methods not intended for use outside of this class
- // They aren't virtual since private routines can
- // never be overridden, and non-virtual calls are
- // faster than virtual calls.
- // EMB Note: except for the fact that scriptability requires that some
- // of them are callable from the scripting temp classes
- void GetTERect(Rect* teRect);
- void AdjustTE();
- void DrawWindow();
- void AdjustViewRect();
- void ResizeWindow();
- void AdjustHV(Boolean isVert,Boolean mustRedraw);
- void AdjustScrollSizes();
- void AdjustScrollbars(Boolean needsResize);
-
- private:
- static pascal void VActionProc(ControlHandle control,short part);
- static pascal void HActionProc(ControlHandle control,short part);
-
- // Object Model support
- virtual DescType GetAppleClass() const;
- virtual long CountContainedObjects(DescType ofType);
- virtual void DoAppleEvent(const AppleEvent& message,
- AppleEvent& reply,
- long refCon);
- virtual MAppleObject* GetContainedObject(DescType desiredType,
- DescType keyForm,
- const AEDesc& keyData,
- Boolean& needDisposal);
- virtual Boolean CompareAppleObjects(DescType operation,
- const MAppleObject& toWhat);
-
- // Methods to implement the AppleEvent protocols
- virtual void DoAppleSave(const AppleEvent& message, AppleEvent& reply);
- virtual void DoAppleClose(const AppleEvent& message, AppleEvent& reply);
-
- virtual MAppleObject* GetAppleProperty(DescType keyFrom, const AEDesc& keyData,
- Boolean& needDisposal);
- protected:
- // i/o routines
- virtual void ReadFromFile(short refNum);
- virtual void WriteToFile(short refNum);
-
- TEHandle GetTEHandle();
- public:
- TEDocument(short resID);
- virtual ~TEDocument();
-
- // methods from TDocument we override
- virtual void DoZoom(short partCode);
- virtual void DoGrow(EventRecord* theEvent);
- virtual void DoContent(EventRecord* theEvent);
- virtual void DoKeyDown(EventRecord* theEvent);
- virtual void DoActivate(Boolean becomingActive);
- virtual void DoIdle();
- virtual void DoUpdate();
- virtual void DoCut();
- virtual void DoCopy();
- virtual void DoPaste();
- virtual void DoClear();
- virtual unsigned long CalcIdle();
- virtual Boolean HaveSelection();
- virtual void DoSelectAll();
-
- // methods added to support changing text attributes
- virtual void SetFontName(Str255 fontName);
- virtual void SetFont(short fontID);
- virtual void SetFontSize(short fontSize);
-
- virtual short GetSelectionFontSize();
- virtual short GetSelectionFont();
-
- virtual Boolean SelectionIsPlain();
- virtual Boolean SelectionIsBold();
- virtual Boolean SelectionIsItalic();
- virtual Boolean SelectionIsUnderline();
- virtual Boolean SelectionIsOutline();
- virtual Boolean SelectionIsShadow();
-
- virtual void SetPlain();
- virtual void SetBold(Boolean on = true);
- virtual void SetItalic(Boolean on = true);
- virtual void SetUnderline(Boolean on = true);
- virtual void SetOutline(Boolean on = true);
- virtual void SetShadow(Boolean on = true);
-
- // new public methods
- void AdjustScrollValues(Boolean mustRedraw);
- ClikLoopProcPtr GetClikLoop();
- void GetVisTERgn(RgnHandle rgn);
-
- // base TextEdit accessor functions
- virtual void SetFaceAttributes(short attributes, Boolean on = true);
- virtual Boolean GetFaceAttributes(short attributes);
-
- virtual void UpdateForNewSelection();
- };
-
- #endif
-