home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / WASTE 1.1 / WASTE.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-02  |  10.3 KB  |  328 lines  |  [TEXT/R*ch]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.1a2
  7.  *
  8.  *    Copyright (c) 1993-1994 Merzwaren
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __LONGCOORDINATES__
  17. #ifndef _LongCoords_
  18. #include "LongCoords.h"
  19. #endif
  20. #endif
  21.  
  22. #ifndef __TEXTEDIT__
  23. #include <TextEdit.h>
  24. #endif
  25.  
  26. #ifndef __DRAG__
  27. #include <Drag.h>
  28. #endif
  29.  
  30. #if defined(powerc) || defined (__powerc)
  31. #pragma options align=mac68k
  32. #endif
  33.  
  34. /*    result codes */
  35.  
  36. enum {
  37.     weCantUndoErr        =    -9479    /* can't undo */
  38. };
  39.  
  40. /*    alignment styles */
  41.  
  42. enum {
  43.     weFlushLeft         =    -2,        /* flush left */
  44.     weFlushRight        =    -1,        /* flush right */
  45.     weFlushDefault        =     0,        /* flush according to system direction */
  46.     weCenter            =     1,        /* centered */
  47.     weJustify            =     2        /* fully justified */
  48. };
  49.  
  50. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  51.  
  52. enum {
  53.     weDoFont            =    0x0001,
  54.     weDoFace            =    0x0002,
  55.     weDoSize            =    0x0004,
  56.     weDoColor            =    0x0008,
  57.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  58.     weDoAddSize            =    0x0010,
  59.     weDoToggleFace        =    0x0020,
  60.     weDoReplaceFace        =    0x0040
  61. };
  62.  
  63. /*    values for the edge parameter in WEGetOffset etc. */
  64.  
  65. enum {
  66.     kLeadingEdge = -1,
  67.     kTrailingEdge = 0
  68. };
  69.  
  70. /*    values for WEFeatureFlag feature parameter */
  71.  
  72. enum {
  73.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  74.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  75.     weFUndo                =    6,        /* support WEUndo() */
  76.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  77.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  78.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  79.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  80.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  81. };
  82.  
  83. /*    values for WENew flags parameter */
  84.  
  85. enum {
  86.     weDoAutoScroll        =    1 << weFAutoScroll,
  87.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  88.     weDoUndo            =    1 << weFUndo,
  89.     weDoIntCutAndPaste    =    1 << weFIntCutAndPaste,
  90.     weDoDragAndDrop        =    1 << weFDragAndDrop,
  91.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  92.     weDoUseTempMem        =    1 << weFUseTempMem,
  93.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  94. };
  95.  
  96. /*    values for WEFeatureFlag action parameter */
  97.  
  98. enum {
  99.     weBitTest = -1,                /* return the current setting of the specified feature */
  100.     weBitClear,                    /* disables the specified feature */
  101.     weBitSet                    /* enables the specified feature */
  102. };
  103.  
  104. /*    selectors for WEGetInfo and WESetInfo */
  105.  
  106. enum {
  107.     weClickLoop        =    'clik',        /* click loop callback */
  108.     weCurrentDrag    =    'drag',        /* drag currently being tracked from WEClick() */
  109.     wePort            =    'port',        /* graphics port */
  110.     weRefCon        =    'refc',        /* reference constant for use by application */
  111.     weScrollProc    =    'scrl',        /* auto-scroll callback */
  112.     weText            =    'text',        /* text handle */
  113.     weTSMDocumentID    =    'tsmd',        /* Text Services Manager document ID */
  114.     weTSMPreUpdate    =    'pre ',        /* Text Services Manager pre-update callback */
  115.     weTSMPostUpdate    =    'post'        /* Text Services Manager post-update callback */
  116. };
  117.  
  118. /*    values for WEInstallObjectHandler handlerSelector parameter */
  119.  
  120. enum {
  121.     weNewHandler        =    'new ',        /* new handler */
  122.     weDisposeHandler    =    'free',        /* dispose handler */
  123.     weDrawHandler        =    'draw',        /* draw handler */
  124.     weClickHandler        =    'clik',        /* reserved for future use */
  125.     weCursorHandler        =    'curs'        /* reserved for future use */
  126. };
  127.  
  128. /*    action kinds */
  129.  
  130. enum {
  131.     weAKNone            =    0,        /* null action */
  132.     weAKUnspecified        =    1,        /* action of unspecified nature */
  133.     weAKTyping            =    2,        /* some text has been typed in */
  134.     weAKCut                =    3,        /* the selection range has been cut */
  135.     weAKPaste            =    4,        /* something has been pasted */
  136.     weAKClear            =    5,        /* the selection range has been deleted */
  137.     weAKDrag            =    6,        /* drag and drop operation */
  138.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  139. };
  140.  
  141. typedef Handle WEHandle;
  142. typedef Handle WEObjectReference;
  143. typedef Handle WESoupHandle;
  144. typedef short WEActionKind;
  145.  
  146. typedef struct WERunInfo {
  147.     long                 runStart;    /* byte offset to first character of style run */
  148.     long                 runEnd;        /* byte offset past last character of style run */
  149.     short                 runHeight;    /* line height (ascent + descent + leading) */
  150.     short                 runAscent;    /* font ascent */
  151.     TextStyle             runStyle;    /* text attributes */
  152.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  153. } WERunInfo;
  154.  
  155. /*    callback prototypes */
  156.  
  157. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  158. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  159. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  160. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  161.         long fixLength, long inputAreaStart, long inputAreaEnd,
  162.         long pinRangeStart, long pinRangeEnd);
  163. typedef pascal OSErr (*WENewObjectProcPtr)(WEObjectReference objectRef,
  164.         Point *defaultObjectSize);
  165. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference objectRef);
  166. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  167.         WEObjectReference objectRef);
  168.  
  169. /*    WASTE public calls */
  170.  
  171. #ifdef __cplusplus
  172. extern "C" {
  173. #endif
  174.  
  175. /*    creation and destruction */
  176.  
  177. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
  178. pascal void WEDispose(WEHandle hWE);
  179.  
  180. /*    getting variables */
  181.  
  182. pascal Handle WEGetText(WEHandle hWE);
  183. pascal short WEGetChar(long offset, WEHandle hWE);
  184. pascal long WEGetTextLength(WEHandle hWE);
  185. pascal long WECountLines(WEHandle hWE);
  186. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  187. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  188. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  189. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  190. pascal Boolean WEIsActive(WEHandle hWE);
  191.  
  192. /*    setting variables */
  193.  
  194. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  195. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  196. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  197.  
  198. /*    accessing style run information */
  199.  
  200. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
  201. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
  202.  
  203. /*    converting byte offsets to screen position and vice versa */
  204.  
  205. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
  206. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
  207.  
  208. /*    finding words and lines */
  209.  
  210. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  211. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  212.  
  213. /*    making a copy of a text range */
  214.  
  215. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
  216.  
  217. /*    getting and setting the alignment style */
  218.  
  219. pascal char WEGetAlignment(WEHandle hWE);
  220. pascal void WESetAlignment(char alignment, WEHandle hWE);
  221.  
  222. /*    recalculating line breaks, drawing and scrolling */
  223.  
  224. pascal OSErr WECalText(WEHandle hWE);
  225. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  226. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  227. pascal void WESelView(WEHandle hWE);
  228.  
  229. /*    handling activate / deactivate events */
  230.  
  231. pascal void WEActivate(WEHandle hWE);
  232. pascal void WEDeactivate(WEHandle hWE);
  233.  
  234. /*     handling key-down events */
  235.  
  236. pascal void WEKey(short key, short modifiers, WEHandle hWE);
  237.  
  238. /*    handling mouse-down events and mouse tracking */
  239.  
  240. pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
  241.  
  242. /*    adjusting the cursor shape */
  243.  
  244. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  245.  
  246. /*    blinking the caret */
  247.  
  248. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  249.  
  250. /*    modifying the text and the styles */
  251.  
  252. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
  253. pascal OSErr WEDelete(WEHandle hWE);
  254. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
  255. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  256. pascal OSErr WEUseText(Handle hText, WEHandle hWE);
  257.  
  258. /*    undo */
  259.  
  260. pascal OSErr WEUndo(WEHandle hWE);
  261. pascal void WEClearUndo(WEHandle hWE);
  262. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEHandle hWE);
  263.  
  264. /*    embedded objects */
  265.  
  266. pascal OSErr WEInstallObjectHandler(OSType objectType, OSType handlerSelector, ProcPtr handler);
  267. pascal OSErr WEInsertObject(OSType objectType, Handle objectDataHandle, Point objectSize, WEHandle hWE);
  268.  
  269. /*    accessor functions for object handlers */
  270.  
  271. pascal OSType WEGetObjectType(WEObjectReference objectRef);
  272. pascal Handle WEGetObjectDataHandle(WEObjectReference objectRef);
  273. pascal Point WEGetObjectSize(WEObjectReference objectRef);
  274. pascal WEHandle WEGetObjectOwner(WEObjectReference objectRef);
  275. pascal long WEGetObjectRefCon(WEObjectReference objectRef);
  276. pascal void WESetObjectRefCon(WEObjectReference objectRef, long refCon);
  277.  
  278. /*    clipboard operations */
  279.  
  280. pascal OSErr WECut(WEHandle hWE);
  281. pascal OSErr WECopy(WEHandle hWE);
  282. pascal OSErr WEPaste(WEHandle hWE);
  283. pascal Boolean WECanPaste(void);
  284.  
  285. /*    Drag Manager support */
  286.  
  287. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEHandle hWE);
  288. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEHandle hWE);
  289. pascal OSErr WEReceiveDrag(DragReference drag, WEHandle hWE);
  290.  
  291. /*    Script Manager utilities */
  292.  
  293. pascal short WECharByte(long offset, WEHandle hWE);
  294. pascal short WECharType(long offset, WEHandle hWE);
  295.  
  296. /*    Text Services Manager support */
  297.  
  298. pascal OSErr WEInstallTSMHandlers(void);
  299. pascal void WEStopInlineSession(WEHandle hWE);
  300.  
  301. /*    additional features */
  302.  
  303. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  304. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  305. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  306.  
  307. /*    long coordinate utilities */
  308.  
  309. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  310. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  311. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  312. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  313. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  314. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  315. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  316.  
  317. pascal long WEOffsetToLine (long offset, WEHandle hWE);
  318.  
  319. #ifdef __cplusplus
  320. }
  321. #endif
  322.  
  323. #if defined(powerc) || defined (__powerc)
  324. #pragma options align=reset
  325. #endif
  326.  
  327. #endif
  328.