home *** CD-ROM | disk | FTP | other *** search
- /*
- * WASTE.h
- *
- * C/C++ interface to the WASTE text engine
- *
- * version 1.1a4 (November 1994)
- *
- * Copyright (c) 1993-1994 Merzwaren
- * All Rights Reserved
- *
- */
-
- #ifndef _WASTE_
- #define _WASTE_
-
- #ifndef __LONGCOORDINATES__
- #ifndef _LongCoords_
- #include "LongCoords.h"
- #endif
- #endif
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __DRAG__
- #include <Drag.h>
- #endif
-
- /* result codes */
-
- enum {
- weCantUndoErr = -9479, /* undo buffer is clear */
- weUnknownObjectTypeErr = -9478, /* specified object type is not registered */
- weObjectNotFoundErr = -9477
- };
-
- /* alignment styles */
-
- enum {
- 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 */
-
- enum {
- weDoFont = 0x0001,
- weDoFace = 0x0002,
- weDoSize = 0x0004,
- weDoColor = 0x0008,
- weDoAll = weDoFont + weDoFace + weDoSize + weDoColor,
- weDoAddSize = 0x0010,
- weDoToggleFace = 0x0020,
- weDoReplaceFace = 0x0040
- };
-
- /* values for the edge parameter in WEGetOffset etc. */
-
- enum {
- 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 */
-
- enum {
- 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 */
-
- enum {
- weDoAutoScroll = 1 << weFAutoScroll,
- weDoOutlineHilite = 1 << weFOutlineHilite,
- weDoUndo = 1 << weFUndo,
- weDoIntCutAndPaste = 1 << weFIntCutAndPaste,
- weDoDragAndDrop = 1 << weFDragAndDrop,
- weDoInhibitRecal = 1 << weFInhibitRecal,
- weDoUseTempMem = 1 << weFUseTempMem,
- weDoDrawOffscreen = 1 << weFDrawOffscreen
- };
-
- /* values for WEFeatureFlag action parameter */
-
- enum {
- weBitTest = -1, /* return the current setting of the specified feature */
- weBitClear, /* disables the specified feature */
- weBitSet /* enables the specified feature */
- };
-
- /* selectors for WEGetInfo and WESetInfo */
-
- enum {
- 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', /* auto-scroll callback */
- weText = 'text', /* text handle */
- 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 */
-
- enum {
- weNewHandler = 'new ', /* new handler */
- weDisposeHandler = 'free', /* dispose handler */
- weDrawHandler = 'draw', /* draw handler */
- weClickHandler = 'clik', /* click handler */
- weCursorHandler = 'curs' /* reserved for future use */
- };
-
- /* action kinds */
-
- enum {
- 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 */
- };
-
- typedef Handle WEHandle;
- typedef Handle WEObjectReference;
- typedef Handle WESoupHandle;
- typedef short WEActionKind;
-
- typedef struct WERunInfo {
- long runStart; /* byte offset to first character of style run */
- long runEnd; /* byte offset past last character of style run */
- short runHeight; /* line height (ascent + descent + leading) */
- short runAscent; /* font ascent */
- TextStyle runStyle; /* text attributes */
- WEObjectReference runObject; /* either NULL or reference to embedded object */
- } WERunInfo;
-
- /* callback prototypes */
-
- typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
- typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
- typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
- typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
- long fixLength, long inputAreaStart, long inputAreaEnd,
- long pinRangeStart, long pinRangeEnd);
- typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
- ItemReference theItem, FlavorType requestedType, Handle putDataHere);
- typedef Pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
- WEObjectReference objectRef);
- typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference objectRef);
- typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
- WEObjectReference objectRef);
-
- /* WASTE public calls */
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* creation and destruction */
-
- pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
- pascal void WEDispose(WEHandle hWE);
-
- /* getting variables */
-
- pascal Handle WEGetText(WEHandle hWE);
- pascal short WEGetChar(long offset, WEHandle hWE);
- pascal long WEGetTextLength(WEHandle hWE);
- pascal long WECountLines(WEHandle hWE);
- pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
- pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
- pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
- pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
- pascal Boolean WEIsActive(WEHandle hWE);
-
- /* setting variables */
-
- pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
- pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
- pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
-
- /* accessing style run information */
-
- pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
- pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
-
- /* converting byte offsets to screen position and vice versa */
-
- pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
- pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
-
- /* finding words and lines */
-
- pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
- pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
-
- /* making a copy of a text range */
-
- pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
-
- /* getting and setting the alignment style */
-
- pascal char WEGetAlignment(WEHandle hWE);
- pascal void WESetAlignment(char alignment, WEHandle hWE);
-
- /* recalculating line breaks, drawing and scrolling */
-
- pascal OSErr WECalText(WEHandle hWE);
- pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
- pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
- pascal void WESelView(WEHandle hWE);
-
- /* handling activate / deactivate events */
-
- pascal void WEActivate(WEHandle hWE);
- pascal void WEDeactivate(WEHandle hWE);
-
- /* handling key-down events */
-
- pascal void WEKey(short key, short modifiers, WEHandle hWE);
-
- /* handling mouse-down events and mouse tracking */
-
- pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
-
- /* adjusting the cursor shape */
-
- pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
-
- /* blinking the caret */
-
- pascal void WEIdle(long *maxSleep, WEHandle hWE);
-
- /* modifying the text and the styles */
-
- pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
- pascal OSErr WEDelete(WEHandle hWE);
- pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
- pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
- pascal OSErr WEUseText(Handle hText, WEHandle hWE);
-
- /* undo */
-
- pascal OSErr WEUndo(WEHandle hWE);
- pascal void WEClearUndo(WEHandle hWE);
- pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEHandle hWE);
- pascal Boolean WEIsTyping(WEHandle hWE);
-
- /* keeping track of changes */
-
- pascal long WEGetModCount(WEHandle hWE);
- pascal void WEResetModCount(WEHandle hWE);
-
- /* embedded objects */
-
- pascal OSErr WEInstallObjectHandler(OSType objectType, OSType handlerSelector, ProcPtr handler);
- pascal OSErr WEInsertObject(OSType objectType, Handle objectDataHandle, Point objectSize, WEHandle hWE);
- pascal OSErr WEGetSelectedObject(WEObjectReference *objectRef, WEHandle hWE);
- pascal long WEFindNextObject(long offset, WEObjectReference *objectRef, WEHandle hWE);
-
- /* accessing embedded object attributes */
-
- pascal OSType WEGetObjectType(WEObjectReference objectRef);
- pascal Handle WEGetObjectDataHandle(WEObjectReference objectRef);
- pascal Point WEGetObjectSize(WEObjectReference objectRef);
- pascal WEHandle WEGetObjectOwner(WEObjectReference objectRef);
- pascal long WEGetObjectRefCon(WEObjectReference objectRef);
- pascal void WESetObjectRefCon(WEObjectReference objectRef, long refCon);
-
- /* clipboard operations */
-
- pascal OSErr WECut(WEHandle hWE);
- pascal OSErr WECopy(WEHandle hWE);
- pascal OSErr WEPaste(WEHandle hWE);
- pascal Boolean WECanPaste(void);
-
- /* Drag Manager support */
-
- pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEHandle hWE);
- pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEHandle hWE);
- pascal OSErr WEReceiveDrag(DragReference drag, WEHandle hWE);
- pascal Boolean WECanAcceptDrag(DragReference drag, WEHandle hWE);
- pascal Boolean WEDraggedToTrash(DragReference drag);
-
- /* Script Manager utilities */
-
- pascal short WECharByte(long offset, WEHandle hWE);
- pascal short WECharType(long offset, WEHandle hWE);
-
- /* Text Services Manager support */
-
- pascal OSErr WEInstallTSMHandlers(void);
- pascal void WEStopInlineSession(WEHandle hWE);
-
- /* additional features */
-
- pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
- pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
- pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
-
- /* long coordinate utilities */
-
- pascal void WELongPointToPoint(const LongPt *lp, Point *p);
- pascal void WEPointToLongPoint(Point p, LongPt *lp);
- pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
- pascal void WELongRectToRect(const LongRect *lr, Rect *r);
- pascal void WERectToLongRect(const Rect *r, LongRect *lr);
- pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
- pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-