1 /*************************************<+>************************************* 2 ***************************************************************************** 3 ** 4 ** File: TextEdit.h 5 ** 6 ** Project: X Widgets 7 ** 8 ** Description: TextEdit widget public include file 9 ** 10 ***************************************************************************** 11 ** 12 ** Copyright (c) 1988 by Hewlett-Packard Company 13 ** Copyright (c) 1987, 1988 by Digital Equipment Corporation, Maynard, 14 ** Massachusetts, and the Massachusetts Institute of Technology, 15 ** Cambridge, Massachusetts 16 ** 17 ** Permission to use, copy, modify, and distribute this software 18 ** and its documentation for any purpose and without fee is hereby 19 ** granted, provided that the above copyright notice appear in all 20 ** copies and that both that copyright notice and this permission 21 ** notice appear in supporting documentation, and that the names of 22 ** Hewlett-Packard, Digital or M.I.T. not be used in advertising or 23 ** publicity pertaining to distribution of the software without 24 ** written prior permission. 25 ** 26 ** DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 27 ** ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 28 ** DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 29 ** ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 30 ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 31 ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 32 ** SOFTWARE. 33 ** 34 ***************************************************************************** 35 *************************************<+>*************************************/ 36 37 #ifndef _XwTextEdit_h 38 #define _XwTextEdit_h 39 40 #define XwSetArg(arg, n, v) \ 41 { Arg *_XwSetArgTmp = &(arg) ;\ 42 _XwSetArgTmp->name = (n) ;\ 43 _XwSetArgTmp->value = (XtArgVal) (v) ;} 44 45 #include <X11/StringDefs.h> 46 47 48 49 /************************************************************************* 50 * 51 * Structures used in TextEdit function calls 52 * 53 *************************************************************************/ 54 55 extern WidgetClass XwtexteditWidgetClass; 56 /* synonym added for consistent naming conventions */ 57 extern WidgetClass XwtextEditWidgetClass; 58 59 typedef struct _XwTextEditClassRec *XwTextEditWidgetClass; 60 typedef struct _XwTextEditRec *XwTextEditWidget; 61 62 typedef long XwTextPosition; 63 64 typedef enum {XwsdLeft, XwsdRight} XwScanDirection; 65 typedef enum 66 {XwstPositions, XwstWhiteSpace, XwstEOL, XwstLast} XwScanType; 67 68 typedef struct { 69 int firstPos; 70 int length; 71 unsigned char *ptr; 72 } XwTextBlock, *XwTextBlockPtr; 73 74 typedef enum {XwtextRead, XwtextAppend, XwtextEdit} XwEditType; 75 typedef enum 76 {XweditDone, XweditError, XweditPosError, XweditReject} XwEditResult; 77 78 typedef struct { 79 XtResource *resources; 80 Cardinal resource_num; 81 int (*read)(); 82 XwEditResult (*replace)(); 83 XwTextPosition (*getLastPos)(); 84 int (*setLastPos)(); 85 XwTextPosition (*scan)(); 86 XwEditType (*editType)(); 87 Boolean (*check_data)(); 88 void (*destroy)(); 89 int *data; 90 } XwTextSource, *XwTextSourcePtr; 91 92 /* this wouldn't be here if source and display (still called 93 sink here) were properly separated, classed and subclassed 94 */ 95 96 typedef short TextFit ; 97 #define tfNoFit 0x01 98 #define tfIncludeTab 0x02 99 #define tfEndText 0x04 100 #define tfNewline 0x08 101 #define tfWrapWhiteSpace 0x10 102 #define tfWrapAny 0x20 103 104 typedef struct { 105 XwTextEditWidget parent; 106 XFontStruct *font; 107 int foreground; 108 XtResource *resources; 109 Cardinal resource_num; 110 int (*display)(); 111 int (*insertCursor)(); 112 int (*clearToBackground)(); 113 int (*findPosition)(); 114 TextFit (*textFitFn)(); 115 int (*findDistance)(); 116 int (*resolve)(); 117 int (*maxLines)(); 118 int (*maxHeight)(); 119 Boolean (*check_data)(); 120 void (*destroy)(); 121 int LineLastWidth ; 122 XwTextPosition LineLastPosition ; 123 int *data; 124 } XwTextSink, *XwTextSinkPtr; 125 126 /************************************************************************* 127 * 128 * Support for Verification Callbacks 129 * 130 *************************************************************************/ 131 132 typedef enum {motionVerify, modVerify, leaveVerify} XwVerifyOpType; 133 134 typedef struct { 135 XEvent *xevent; 136 XwVerifyOpType operation; 137 Boolean doit; 138 XwTextPosition currInsert, newInsert; 139 XwTextPosition startPos, endPos; 140 XwTextBlock *text; 141 } XwTextVerifyCD, *XwTextVerifyPtr; 142 143 144 /* Class record constants */ 145 146 typedef enum {XwstringSrc, XwdiskSrc, XwprogDefinedSrc} XwSourceType; 147 148 /* other stuff */ 149 150 #define wordBreak 0x01 151 #define scrollVertical 0x02 152 #define scrollHorizontal 0x04 153 #define scrollOnOverflow 0x08 154 #define resizeWidth 0x10 155 #define resizeHeight 0x20 156 #define editable 0x40 157 158 /**************************************************************************** 159 * 160 * Display control (grow, wrap, scroll, visible cursor) 161 * 162 ****************************************************************************/ 163 164 typedef enum {XwWrapOff, XwSoftWrap, XwHardWrap} XwWrap ; 165 typedef enum {XwSourceForm, XwDisplayForm} XwWrapForm ; 166 typedef enum {XwWrapAny, XwWrapWhiteSpace} XwWrapBreak ; 167 168 /* Scroll options */ 169 typedef int XwScroll ; 170 171 /* Grow options */ 172 typedef int XwGrow ; 173 174 /************************************************************************* 175 * 176 * External functions from TextEdit 177 * 178 *************************************************************************/ 179 180 extern void XwTextClearBuffer(); 181 /* XwTextEditWidget w; */ 182 183 extern unsigned char *XwTextCopyBuffer(); 184 /* XwTextEditWidget w */ 185 186 extern unsigned char *XwTextCopySelection(); 187 /* XwTextEditWidget w */ 188 189 extern int XwTextReadSubString(); 190 /* XwTextEditWidget w; 191 XwTextPosition startpos, 192 endpos; 193 unsigned char *target; Memory to copy into 194 int targetsize, Memory size 195 targetused; Memory used by copy */ 196 197 extern void XwTextUnsetSelection(); 198 /* XwTextEditWidget w */ 199 200 extern void XwTextSetSelection(); 201 /* XwTextEditWidget w; 202 XwTextPosition left, right; */ 203 204 extern XwEditResult XwTextReplace(); 205 /* XwTextEditWidget w; 206 XwTextPosition startPos, endPos; 207 unsigned char *string; */ 208 209 extern void XwTextRedraw(); 210 /* XwTextEditWidget w */ 211 212 #define HAVE_XWTEXTRESIZE 213 extern void XwTextResize(); 214 /* XwTextEditWidget w */ 215 216 extern void XwTextUpdate(); 217 /* XwTextEditWidget w; 218 Boolean status */ 219 220 extern void XwTextInsert(); 221 /* XwTextEditWidget w */ 222 /* unsigned char *string */ 223 224 extern XwTextPosition XwTextGetLastPos(); 225 /* XwTextEditWidget w; */ 226 227 extern void XwTextGetSelectionPos(); 228 /* XwTextEditWidget w; */ 229 /* XwTextPosition *left, *right; */ 230 231 extern void XwTextSetInsertPos(); 232 /* XwTextEditWidget w; */ 233 /* XwTextPosition position */ 234 235 extern XwTextPosition XwTextGetInsertPos(); 236 /* XwTextEditWidget widget */ 237 238 extern void XwTextSetSource(); 239 /* XwTextEditWidget w; */ 240 /* XwTextSourcePtr source; */ 241 /* XwTextPosition startpos */ 242 243 /************************************************************************* 244 * 245 * Extern Source and Sink Create/Destroy functions 246 * 247 *************************************************************************/ 248 249 extern XwTextSink *XwAsciiSinkCreate(); 250 /* Widget w */ 251 /* ArgList args */ 252 /* Cardinal num_args */ 253 254 extern XwTextSource *XwStringSourceCreate(); 255 /* Widget parent; */ 256 /* ArgList args; */ 257 /* int argCount; */ 258 259 extern void XwStringSourceDestroy(); 260 /* XwTextSource *src */ 261 262 #endif 263 /* DON'T ADD STUFF AFTER THIS #endif */ 264