home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-12 | 12.1 KB | 364 lines | [TEXT/PJMM] |
- unit WASTE;
-
- { Pascal interface to the WASTE text engine }
-
- { version 1.1a4 (November 1994) }
-
- { Copyright © 1993-1994 Merzwaren }
- { All Rights Reserved }
-
- interface
- uses
- Drag, LongCoords;
-
- const
-
- { result codes }
-
- weCantUndoErr = -9479; { undo buffer is clear }
- weUnknownObjectTypeErr = -9478; { specified object type is not registered }
- weObjectNotFoundErr = -9477; { no object found at specified offset }
-
- { alignment styles }
-
- weFlushLeft = -2; { flush left }
- weFlushRight = -1; { flush right }
- weFlushDefault = 0; { flush according to system direction }
- weCenter = 1; { centered }
- weJustify = 2; { fully justified }
-
- { values for the mode parameter in WESetStyle and WEContinuousStyle }
-
- weDoFont = $0001; { set font family number }
- weDoFace = $0002; { turn on the styles specified in tsFace }
- weDoSize = $0004; { set type size }
- weDoColor = $0008; { set color }
- weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
- weDoAddSize = $0010; { adjust type size }
- weDoToggleFace = $0020; { turn a style off if it's continuous over the selection }
- weDoReplaceFace = $0040; { replace existing styles outright }
-
- { values for the edge parameter in WEGetOffset etc. }
-
- kLeadingEdge = -1; { point is on the leading edge of a glyph }
- kTrailingEdge = 0; { point is on the trailing edge of a glyph }
- kObjectEdge = 2; { point is in the middle of an embedded object }
-
- { values for WEFeatureFlag feature parameter }
-
- weFAutoScroll = 0; { automatically scroll the selection range into view }
- weFOutlineHilite = 2; { frame selection when deactivated }
- weFUndo = 6; { support WEUndo }
- weFIntCutAndPaste = 7; { use intelligent cut-and-paste rules }
- weFDragAndDrop = 8; { support drag-and-drop text editing }
- weFInhibitRecal = 9; { don't recalculate line starts and don't redraw text }
- weFUseTempMem = 10; { use temporary memory for main data structures }
- weFDrawOffscreen = 11; { draw text offscreen for smoother visual results }
-
- { values for WENew flags parameter }
-
- weDoAutoScroll = $0001;
- weDoOutlineHilite = $0004;
- weDoUndo = $0040;
- weDoIntCutAndPaste = $0080;
- weDoDragAndDrop = $0100;
- weDoInhibitRecal = $0200;
- weDoUseTempMem = $0400;
- weDoDrawOffscreen = $0800;
-
- { values for WEFeatureFlag action parameter }
-
- weBitClear = 0; { disables the specified feature }
- weBitSet = 1; { enables the specified feature }
- weBitTest = -1; { returns the current setting of the specified feature }
-
- { values for WEGetInfo and WESetInfo selector parameter }
-
- weClickLoop = 'clik'; { click loop callback }
- weCurrentDrag = 'drag'; { drag currently being tracked from WEClick }
- wePort = 'port'; { graphics port }
- weRefCon = 'refc'; { reference constant for use by application }
- weScrollProc = 'scrl'; { scroll callback }
- weText = 'text'; { handle to the raw text }
- weTranslateDragHook = 'xdrg'; { drag translation callback }
- weTSMDocumentID = 'tsmd'; { Text Services Manager document ID }
- weTSMPreUpdate = 'pre '; { Text Services Manager pre-update callback }
- weTSMPostUpdate = 'post'; { Text Services Manager post-update callback }
-
- { values for WEInstallObjectHandler handlerSelector parameter }
-
- weNewHandler = 'new '; { new handler }
- weDisposeHandler = 'free'; { dispose handler }
- weDrawHandler = 'draw'; { draw handler }
- weClickHandler = 'clik'; { click handler }
- weCursorHandler = 'curs'; { reserved for future use }
-
- { action kinds }
-
- weAKNone = 0; { null action }
- weAKUnspecified = 1; { action of unspecified nature }
- weAKTyping = 2; { some text has been typed in }
- weAKCut = 3; { the selection range has been cut }
- weAKPaste = 4; { something has been pasted }
- weAKClear = 5; { the selection range has been deleted }
- weAKDrag = 6; { drag and drop operation }
- weAKSetStyle = 7; { some style has been applied to a text range }
-
- type
-
- { WASTE data types }
-
- WEHandle = Handle;
- WEObjectReference = Handle;
- WESoupHandle = Handle;
- WEActionKind = Integer;
-
- WERunInfo = record
- runStart: LongInt; { byte offset to first character of style run }
- runEnd: LongInt; { byte offset past last character of style run }
- runHeight: Integer; { line height (ascent + descent + leading) }
- runAscent: Integer; { font ascent }
- runStyle: TextStyle; { text attributes }
- runObject: WEObjectReference; { either NIL or reference to embedded object }
- end; { WERunInfo }
-
- { callback prototypes }
-
- { FUNCTION MyClickLoop(hWE: WEHandle): Boolean; }
- WEClickLoopProcPtr = ProcPtr;
-
- { PROCEDURE MyScrollProc(hWE: WEHandle); }
- WEScrollProcPtr = ProcPtr;
-
- { PROCEDURE MyTSMPreUpdate(hWE: WEHandle); }
- WETSMPreUpdateProcPtr = ProcPtr;
-
- { PROCEDURE MyTSMPostUpdate(hWE: WEHandle; fixLength: LongInt; }
- { inputAreaStart, inputAreaEnd:LongInt; }
- { pinRangeStart, pinRangeEnd: LongInt); }
- WETSMPostUpdateProcPtr = ProcPtr;
-
- { FUNCTION MyTranslateDrag (theDrag: DragReference; theItem: ItemReference; }
- { requestedType: FlavorType; putDataHere: Handle): OSErr; }
- WETranslateDragProcPtr = ProcPtr;
-
- { FUNCTION MyNewObject(VAR defaultObjectSize: Point; }
- { objectRef: WEObjectReference): OSErr; }
- WENewObjectProcPtr = ProcPtr;
-
- { FUNCTION MyDisposeObject (objectRef: WEObjectReference): OSErr; }
- WEDisposeObjectProcPtr = ProcPtr;
-
- { FUNCTION MyDrawObject (destRect: Rect; }
- { objectRef: WEObjectReference): OSErr }
- WEDrawObjectProcPtr = ProcPtr;
-
- { WASTE Public Calls }
-
- { creation and destruction }
- function WENew (destRect, viewRect: LongRect;
- flags: Integer;
- var hWE: WEHandle): OSErr;
- procedure WEDispose (hWE: WEHandle);
-
- { getting variables }
- function WEGetText (hWE: WEHandle): Handle;
- function WEGetChar (offset: LongInt;
- hWE: WEHandle): Char;
- function WEGetTextLength (hWE: WEHandle): LongInt;
- function WECountLines (hWE: WEHandle): LongInt;
- function WEGetHeight (startLine, endLine: LongInt;
- hWE: WEHandle): LongInt;
- procedure WEGetSelection (var selStart, selEnd: LongInt;
- hWE: WEHandle);
- procedure WEGetDestRect (var destRect: LongRect;
- hWE: WEHandle);
- procedure WEGetViewRect (var viewRect: LongRect;
- hWE: WEHandle);
- function WEIsActive (hWE: WEHandle): Boolean;
-
- { setting variables }
- procedure WESetSelection (selStart, selEnd: LongInt;
- hWE: WEHandle);
- procedure WESetDestRect (destRect: LongRect;
- hWE: WEHandle);
- procedure WESetViewRect (viewRect: LongRect;
- hWE: WEHandle);
-
- { accessing style run information }
- function WEContinuousStyle (var mode: Integer;
- var ts: TextStyle;
- hWE: WEHandle): Boolean;
- procedure WEGetRunInfo (offset: LongInt;
- var info: WERunInfo;
- hWE: Handle);
-
- { converting byte offsets to screen positions and vice versa }
- function WEGetOffset (thePoint: LongPt;
- var edge: SignedByte;
- hWE: Handle): LongInt;
- procedure WEGetPoint (offset: LongInt;
- var thePoint: LongPt;
- var lineHeight: Integer;
- hWE: Handle);
-
- { finding words and lines }
- procedure WEFindWord (offset: LongInt;
- edge: SignedByte;
- var wordStart, wordEnd: LongInt;
- hWE: WEHandle);
- procedure WEFindLine (offset: LongInt;
- edge: SignedByte;
- var lineStart, lineEnd: LongInt;
- hWE: WEHandle);
-
- { making a copy of a text range }
- function WECopyRange (rangeStart, rangeEnd: LongInt;
- hText: Handle;
- hStyles: StScrpHandle;
- hSoup: WESoupHandle;
- hWE: WEHandle): OSErr;
-
- { getting and setting the alignment style }
- function WEGetAlignment (hWE: WEHandle): SignedByte;
- procedure WESetAlignment (alignment: SignedByte;
- hWE: WEHandle);
-
- { recalculating line breaks, drawing and scrolling }
- function WECalText (hWE: WEHandle): OSErr;
- procedure WEUpdate (updateRgn: RgnHandle;
- hWE: WEHandle);
- procedure WEScroll (hOffset, vOffset: LongInt;
- hWE: WEHandle);
- procedure WESelView (hWE: WEHandle);
-
- { handling activate/deactivate events }
- procedure WEActivate (hWE: WEHandle);
- procedure WEDeactivate (hWE: WEHandle);
-
- { handling key-down events }
- procedure WEKey (key: Char;
- modifiers: Integer;
- hWE: WEHandle);
-
- { handling mouse-down events and mouse tracking }
- procedure WEClick (hitPt: Point;
- modifiers: Integer;
- clickTime: LongInt;
- hWE: WEHandle);
-
- { adjusting the cursor shape }
- function WEAdjustCursor (mouseLoc: Point;
- mouseRgn: RgnHandle;
- hWE: WEHandle): Boolean;
-
- { blinking the caret }
- procedure WEIdle (var maxSleep: LongInt;
- hWE: WEHandle);
-
- { modifying the text and the styles }
- function WEInsert (pText: Ptr;
- textLength: LongInt;
- hStyles: StScrpHandle;
- hSoup: WESoupHandle;
- hWE: WEHandle): OSErr;
- function WEDelete (hWE: WEHandle): OSErr;
- function WESetStyle (mode: Integer;
- ts: TextStyle;
- hWE: WEHandle): OSErr;
- function WEUseText (hText: Handle;
- hWE: WEHandle): OSErr;
- function WEUseStyleScrap (hStyles: StScrpHandle;
- hWE: WEHandle): OSErr;
-
- { undo }
- function WEUndo (hWE: WEHandle): OSErr;
- procedure WEClearUndo (hWE: WEHandle);
- function WEGetUndoInfo (var redoFlag: Boolean;
- hWE: WEHandle): WEActionKind;
- function WEIsTyping (hWE: WEHandle): Boolean;
-
- { keeping track of changes }
- function WEGetModCount (hWE: WEHandle): LongInt;
- procedure WEResetModCount (hWE: WEHandle);
-
- { embedded objects }
- function WEInstallObjectHandler (objectType: OSType;
- handlerSelector: OSType;
- handler: ProcPtr): OSErr;
- function WEInsertObject (objectType: OSType;
- objectDataHandle: Handle;
- objectSize: Point; { (0, 0) means default size }
- hWE: WEHandle): OSErr;
- function WEGetSelectedObject (var objectRef: WEObjectReference;
- hWE: WEHandle): OSErr;
- function WEFindNextObject (offset: LongInt;
- var objectRef: WEObjectReference;
- hWE: WEHandle): LongInt;
-
- { accessing embedded object attributes }
- function WEGetObjectType (objectRef: WEObjectReference): OSType;
- function WEGetObjectDataHandle (objectRef: WEObjectReference): Handle;
- function WEGetObjectSize (objectRef: WEObjectReference): Point;
- function WEGetObjectOwner (objectRef: WEObjectReference): WEHandle;
- function WEGetObjectRefCon (objectRef: WEObjectReference): LongInt;
- procedure WESetObjectRefCon (objectRef: WEObjectReference;
- refCon: LongInt);
-
- { Clipboard operations }
- function WECut (hWE: WEHandle): OSErr;
- function WECopy (hWE: WEHandle): OSErr;
- function WEPaste (hWE: WEHandle): OSErr;
- function WECanPaste: Boolean;
-
- { Drag Manager support }
- function WEGetHiliteRgn (rangeStart, rangeEnd: LongInt;
- hWE: WEHandle): RgnHandle;
- function WETrackDrag (message: DragTrackingMessage;
- drag: DragReference;
- hWE: WEHandle): OSErr;
- function WEReceiveDrag (drag: DragReference;
- hWE: WEHandle): OSErr;
- function WECanAcceptDrag (drag: DragReference;
- hWE: WEHandle): Boolean;
- function WEDraggedToTrash (drag: DragReference): Boolean;
-
- { Script Manager utilities }
- function WECharByte (offset: LongInt;
- hWE: WEHandle): Integer;
- function WECharType (offset: LongInt;
- hWE: WEHandle): Integer;
-
- { Text Services Manager support }
- function WEInstallTSMHandlers: OSErr;
- procedure WEStopInlineSession (hWE: WEHandle);
-
- { additional features }
- function WEFeatureFlag (feature: Integer;
- action: Integer;
- hWE: WEHandle): Integer;
- function WEGetInfo (selector: OSType;
- info: univ Ptr;
- hWE: WEHandle): OSErr;
- function WESetInfo (selector: OSType;
- info: univ Ptr;
- hWE: WEHandle): OSErr;
-
- { long coordinates utility routines }
- procedure WELongPointToPoint (lp: LongPt;
- var p: Point);
- procedure WEPointToLongPoint (p: Point;
- var lp: LongPt);
- procedure WESetLongRect (var lr: LongRect;
- left, top, right, bottom: LongInt);
- procedure WELongRectToRect (lr: LongRect;
- var r: Rect);
- procedure WERectToLongRect (r: Rect;
- var lr: LongRect);
- procedure WEOffsetLongRect (var lr: LongRect;
- hOffset, vOffset: LongInt);
- function WELongPointInLongRect (lp: LongPt;
- lr: LongRect): Boolean;
-
- implementation
- end.