home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / CWASTE folder / WASTE.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-21  |  7.2 KB  |  250 lines  |  [TEXT/R*ch]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.0
  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. #if defined(powerc) || defined (__powerc)
  27. #pragma options align=mac68k
  28. #endif
  29.  
  30. /*    alignment styles */
  31.  
  32. enum {
  33.     weFlushLeft         =    -2,        /* flush left */
  34.     weFlushRight        =    -1,        /* flush right */
  35.     weFlushDefault        =     0,        /* flush according to system direction */
  36.     weCenter            =     1,        /* centered */
  37.     weJustify            =     2        /* fully justified */
  38. };
  39.  
  40. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  41.  
  42. enum {
  43.     weDoFont            =    0x0001,
  44.     weDoFace            =    0x0002,
  45.     weDoSize            =    0x0004,
  46.     weDoColor            =    0x0008,
  47.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  48.     weDoAddSize            =    0x0010,
  49.     weDoToggleFace        =    0x0020,
  50.     weDoReplaceFace        =    0x0040
  51. };
  52.  
  53. /*    values for the edge parameter in WEGetOffset etc. */
  54.  
  55. enum {
  56.     kLeadingEdge = -1,
  57.     kTrailingEdge = 0
  58. };
  59.  
  60. /*    values for WEFeatureFlag feature parameter */
  61.  
  62. enum {
  63.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  64.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  65.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  66.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  67.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  68. };
  69.  
  70. /*    values for WENew flags parameter */
  71.  
  72. enum {
  73.     weDoAutoScroll        =    1 << weFAutoScroll,
  74.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  75.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  76.     weDoUseTempMem        =    1 << weFUseTempMem,
  77.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  78. };
  79.  
  80. /*    values for WEFeatureFlag action parameter */
  81.  
  82. enum {
  83.     weBitTest = -1,                /* return the current setting of the specified feature */
  84.     weBitClear,                    /* disables the specified feature */
  85.     weBitSet                    /* enables the specified feature */
  86. };
  87.  
  88. /*    selectors for WEGetInfo and WESetInfo */
  89.  
  90. enum {
  91.     weClickLoop        =    'clik',        /* click loop callback */
  92.     wePort            =    'port',        /* graphics port */
  93.     weRefCon        =    'refc',        /* reference constant for use by application */
  94.     weScrollProc    =    'scrl',        /* auto-scroll callback */
  95.     weText            =    'text',        /* text handle */
  96.     weTSMDocumentID    =    'tsmd',        /* Text Services Manager document ID */
  97.     weTSMPreUpdate    =    'pre ',        /* Text Services Manager pre-update callback */
  98.     weTSMPostUpdate    =    'post'        /* Text Services Manager post-update callback */
  99. };
  100.  
  101. typedef struct WERunInfo {
  102.     long         runStart;
  103.     long         runEnd;
  104.     short         runHeight;
  105.     short         runAscent;
  106.     TextStyle     runStyle;
  107. } WERunInfo;
  108.  
  109. typedef Handle WEHandle;
  110.  
  111. /*    callback prototypes */
  112.  
  113. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  114. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  115. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  116. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  117.         long fixLength, long inputAreaStart, long inputAreaEnd,
  118.         long pinRangeStart, long pinRangeEnd);
  119.  
  120. /*    WASTE public calls */
  121.  
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125.  
  126. /*    creation and destruction */
  127.  
  128. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
  129. pascal void WEDispose(WEHandle hWE);
  130.  
  131. /*    getting variables */
  132.  
  133. pascal Handle WEGetText(WEHandle hWE);
  134. pascal short WEGetChar(long offset, WEHandle hWE);
  135. pascal long WEGetTextLength(WEHandle hWE);
  136. pascal long WECountLines(WEHandle hWE);
  137. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  138. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  139. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  140. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  141. pascal Boolean WEIsActive(WEHandle hWE);
  142.  
  143. /*    setting variables */
  144.  
  145. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  146. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  147. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  148.  
  149. /*    accessing style run information */
  150.  
  151. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
  152. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
  153.  
  154. /*    converting byte offsets to screen position and vice versa */
  155.  
  156. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
  157. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
  158.  
  159. /*    finding words and lines */
  160.  
  161. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  162. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  163.  
  164. /*    making a copy of a text range */
  165.  
  166. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WEHandle hWE);
  167.  
  168. /*    getting and setting the alignment style */
  169.  
  170. pascal char WEGetAlignment(WEHandle hWE);
  171. pascal void WESetAlignment(char alignment, WEHandle hWE);
  172.  
  173. /*    recalculating line breaks, drawing and scrolling */
  174.  
  175. pascal OSErr WECalText(WEHandle hWE);
  176. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  177. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  178. pascal void WESelView(WEHandle hWE);
  179.  
  180. /*    handling activate / deactivate events */
  181.  
  182. pascal void WEActivate(WEHandle hWE);
  183. pascal void WEDeactivate(WEHandle hWE);
  184.  
  185. /*     handling key-down events */
  186.  
  187. pascal void WEKey(short key, short modifiers, WEHandle hWE);
  188.  
  189. /*    handling mouse-down events and mouse tracking */
  190.  
  191. pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
  192.  
  193. /*    adjusting the cursor shape */
  194.  
  195. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  196.  
  197. /*    blinking the caret */
  198.  
  199. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  200.  
  201. /*    modifying the text and the styles */
  202.  
  203. pascal OSErr WEInsert(const void *textPtr, long textLength, StScrpHandle hStyles, WEHandle hWE);
  204. pascal OSErr WEDelete(WEHandle hWE);
  205. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
  206. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  207. pascal OSErr WEUseText(Handle hText, WEHandle hWE);
  208.  
  209. /*    clipboard operations */
  210.  
  211. pascal OSErr WECut(WEHandle hWE);
  212. pascal OSErr WECopy(WEHandle hWE);
  213. pascal OSErr WEPaste(WEHandle hWE);
  214.  
  215. /*    Script Manager utilities */
  216.  
  217. pascal short WECharByte(long offset, WEHandle hWE);
  218. pascal short WECharType(long offset, WEHandle hWE);
  219.  
  220. /*    Text Services Manager support */
  221.  
  222. pascal OSErr WEInstallTSMHandlers(void);
  223. pascal void WEStopInlineSession(WEHandle hWE);
  224.  
  225. /*    additional features */
  226.  
  227. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  228. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  229. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  230.  
  231. /*    long coordinate utilities */
  232.  
  233. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  234. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  235. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  236. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  237. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  238. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  239. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  240.  
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244.  
  245. #if defined(powerc) || defined (__powerc)
  246. #pragma options align=reset
  247. #endif
  248.  
  249. #endif
  250.