1 /*****
2 * XmHTML.h : XmHTML Widget public header file
3 *
4 * This file Version	$Revision$
5 *
6 * Creation date:		Tue Nov 19 23:18:37 GMT+0100 1996
7 * Last modification: 	$Date$
8 * By:					$Author$
9 * Current State:		$State$
10 *
11 * Author:				newt
12 * (C)Copyright 1995-1996 Ripley Software Development
13 * All Rights Reserved
14 *
15 * This file is part of the XmHTML Widget Library.
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Library General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25 * Library General Public License for more details.
26 *
27 * You should have received a copy of the GNU Library General Public
28 * License along with this library; if not, write to the Free
29 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 *
31 *****/
32 /*****
33 * $Source$
34 *****/
35 /*****
36 * ChangeLog
37 * $Log$
38 * Revision 1.2  2012/03/01 17:56:31  ziad
39 * Cput
40 *
41 * Revision 1.1  2011/06/30 16:08:41  rwcox
42 * Cadd
43 *
44 * Revision 1.21  1998/04/27 06:56:31  newt
45 * Updated version number
46 *
47 * Revision 1.20  1998/04/04 06:27:53  newt
48 * XmHTML Beta 1.1.3
49 *
50 * Revision 1.19  1997/10/26 23:49:52  newt
51 * Moved internal symbol defines to XmHTMLP.h
52 *
53 * Revision 1.18  1997/10/23 00:24:44  newt
54 * XmHTML Beta 1.1.0 release
55 *
56 * Revision 1.17  1997/08/31 17:32:43  newt
57 * log edit
58 *
59 * Revision 1.16  1997/08/30 00:40:16  newt
60 * Changed proto's for XmHTMLImageReplace and XmHTMLImageUpdate. They now
61 * return an XmImageStatus instead of void.
62 *
63 * Revision 1.15  1997/08/01 12:54:55  newt
64 * Progressive image loading changes.
65 *
66 * Revision 1.14  1997/05/28 01:41:04  newt
67 * Added the XmHTMLImageGZFSupported, XmHTMLGIFtoGZF, XmHTMLGifReadOK and
68 * XmHTMLGifGetDataBlock convienience routines to convert GIF images to an
69 * alternate format. Added the XmHTMLAllocColor and XmHTMLFreeColor protos for
70 * easy color allocation. Modified the XmImageCreate routines to use a
71 * XmImageConfig structure.
72 *
73 * Revision 1.13  1997/04/29 14:22:35  newt
74 * Completely revised due to XmHTMLParserObject integration
75 *
76 * Revision 1.12  1997/04/03 05:31:30  newt
77 * XmHTMLFrameGetChild proto. XmIMAGE_SHARED_DATA option bit added.
78 *
79 * Revision 1.11  1997/03/28 07:06:14  newt
80 * XmNframeCallback, XmHTMLFrameCallbackStruct. XmHTMLParserCallback changes.
81 *
82 * Revision 1.10  1997/03/20 08:05:02  newt
83 * XmHTMLImageFreeImageInfo, XmNrepeatDelay
84 *
85 * Revision 1.9  1997/03/11 19:50:27  newt
86 * Changes in XmImageInfo; grouped and renamed convenience functions
87 *
88 * Revision 1.8  1997/03/04 18:45:55  newt
89 * XmNimagemapBoundingBoxForeground and XmCImagemapDrawBoundingBoxes
90 * resources added
91 *
92 * Revision 1.7  1997/03/04 00:56:30  newt
93 * Delayed Image Loading: added the delayed field to the XmImageInfo structure.
94 * Removed a number of obsolete defines
95 *
96 * Revision 1.6  1997/03/02 23:07:10  newt
97 * Image/Imagemap related changes. XmHTMLAnchorCallbackStruct changed
98 *
99 * Revision 1.5  1997/02/11 02:01:26  newt
100 * Added the XmNhandleShortTags resource
101 *
102 * Revision 1.4  1997/02/04 02:55:57  newt
103 * added the basefont element
104 *
105 * Revision 1.3  1997/01/09 06:55:53  newt
106 * expanded copyright marker
107 *
108 * Revision 1.2  1997/01/09 06:47:58  newt
109 * New resource: XmNparserCallback and corresponding error structure/defines
110 *
111 * Revision 1.1  1996/12/19 02:17:14  newt
112 * Initial Revision
113 *
114 *****/
115 /*****
116 * Public interfaces are listed at the end of this file
117 *****/
118 
119 #ifndef _XmHTML_h_
120 #define _XmHTML_h_
121 
122 #define XmHTMLVERSION	1
123 #define XmHTMLREVISION	1
124 #define XmHTMLUPDATE_LEVEL 7
125 #define XmHTMLVersion \
126 	(XmHTMLVERSION * 1000 + XmHTMLREVISION * 100 + XmHTMLUPDATE_LEVEL)
127 
128 /* used by Imake to get Shared library version numbering */
129 #ifndef _LIBRARY
130 
131 #define XmHTMLVERSION_STRING \
132 	"XmHTML Beta Version 1.1.7 (C)Ripley Software Development"
133 
134 /* Required includes */
135 #include <X11/Intrinsic.h>
136 #include <Xm/Xm.h>
137 #include <XmHTML/HTML.h>
138 
139 #ifndef XmHTML_LIBEXPORT
140 #define XmHTML_LIBEXPORT extern
141 #endif
142 
143 _XFUNCPROTOBEGIN
144 
145 /* XmHTML type defines */
146 typedef struct _XmHTMLClassRec *XmHTMLWidgetClass;
147 typedef struct _XmHTMLRec *XmHTMLWidget;
148 
149 /*****
150 * VMS works differently here: it defines externalref to globalref,
151 * so guard against incorrectly overriding the externaldef define.
152 *****/
153 #ifdef VMS
154 externalref WidgetClass xmHTMLWidgetClass;
155 #else
156 XmHTML_LIBEXPORT WidgetClass xmHTMLWidgetClass;
157 #endif
158 
159 /* XmHTML Widget subclassing macro */
160 #ifndef XmIsHTML
161 #define XmIsHTML(w)	XtIsSubclass(w, xmHTMLWidgetClass)
162 #endif /* XmIsHTML */
163 
164 /********    Public Function Declarations    ********/
165 
166 /*****
167 * Convenience/public functions
168 * There are six categories:
169 * - image related
170 * - anchor related
171 * - text related
172 * - tag analyzers
173 * - object related
174 * - functions that don't fit in any of the above three
175 *****/
176 
177 /*****
178 * Image related convenience functions
179 *****/
180 XmHTML_LIBEXPORT XmImageInfo *XmHTMLImageDefaultProc(Widget w, String file,
181 	unsigned char *buf, int size);
182 
183 /* Return image type */
184 XmHTML_LIBEXPORT unsigned char XmHTMLImageGetType(String file,
185 	unsigned char *buf, int size);
186 
187 /* returns True if XmHTMLImageDefaultProc supports JPEG images */
188 XmHTML_LIBEXPORT Boolean XmHTMLImageJPEGSupported(void);
189 
190 /* returns True if XmHTMLImageDefaultProc supports PNG images */
191 XmHTML_LIBEXPORT Boolean XmHTMLImagePNGSupported(void);
192 
193 /* returns True if XmHTMLImageDefaultProc supports GZF images */
194 XmHTML_LIBEXPORT Boolean XmHTMLImageGZFSupported(void);
195 
196 /* Replace image with new_image */
197 XmHTML_LIBEXPORT XmImageStatus XmHTMLImageReplace(Widget w, XmImageInfo *image,
198 		XmImageInfo *new_image);
199 
200 /* update image */
201 XmHTML_LIBEXPORT XmImageStatus XmHTMLImageUpdate(Widget w, XmImageInfo *image);
202 
203 /* release all memory occupied by the images */
204 XmHTML_LIBEXPORT void XmHTMLImageFreeAllImages(Widget w);
205 
206 /* add an imagemap to a HTML widget. */
207 XmHTML_LIBEXPORT void XmHTMLImageAddImageMap(Widget w, String image_map);
208 
209 /* free an XmImageInfo structure */
210 XmHTML_LIBEXPORT void	XmHTMLImageFreeImageInfo(Widget w, XmImageInfo *info);
211 
212 /* return the total size of a given XmImageInfo structure */
213 XmHTML_LIBEXPORT int XmHTMLImageGetImageInfoSize(XmImageInfo *info);
214 
215 /* suspend progressive image loading */
216 XmHTML_LIBEXPORT void XmHTMLImageProgressiveSuspend(Widget w);
217 
218 /* reactivate progressive image loading */
219 XmHTML_LIBEXPORT void XmHTMLImageProgressiveContinue(Widget w);
220 
221 /* terminate progressive image loading */
222 XmHTML_LIBEXPORT void XmHTMLImageProgressiveKill(Widget w);
223 
224 /*****
225 * Special image functions
226 *****/
227 /*****
228 * Create and return a XmImage for use other than with XmHTML.
229 * When width and height are non-zero, the image read is scaled to the specified
230 * dimensions.
231 *****/
232 XmHTML_LIBEXPORT XmImage *XmImageCreate(Widget w, String file,
233 	Dimension width, Dimension height, XmImageConfig *config);
234 
235 /*****
236 * Create an XmImage from the given XmImageInfo. When the image type is
237 * IMAGE_UNKNOWN, but the url field represents a local file, this routine
238 * calls XmImageCreate with the url field as the file argument.
239 * Only honors the ImageFrameSelect, ImageCreateGC and ImageBackground
240 * XmImageConfig flag and appropriate fields of that structure.
241 *****/
242 XmHTML_LIBEXPORT XmImage *XmImageCreateFromInfo(Widget w, XmImageInfo *info,
243 	Dimension width, Dimension height, XmImageConfig *config);
244 
245 /* destroy a XmImage */
246 XmHTML_LIBEXPORT void XmImageDestroy(XmImage *image);
247 
248 /*****
249 * Tiles "dest" with the given XmImage. Please note that "src" *must* have been
250 * created with the ImageCreateGC flag, otherwise this function does nothing and
251 * returns -1. Returns 0 upon success.
252 * Internally, this routine is more or less a combination of XSetTile,
253 * XSetTSOrigin and XFillRectangle in one.
254 *
255 * (UNTESTED)
256 *****/
257 XmHTML_LIBEXPORT int XmImageSetBackgroundImage(XmImage *src, Drawable dest,
258 	int src_x, int src_y, int width, int height, int dest_x, int dest_y);
259 
260 /*****
261 * XCopyArea for an XmImage which also takes a possible clipmask into account.
262 * Please note that "image" *must* have been created with the ImageCreateGC
263 * flag, otherwise this function does nothing and returns -1.
264 * Returns 0 upon success.
265 *
266 * (UNTESTED)
267 *****/
268 XmHTML_LIBEXPORT int XmImageDrawImage(XmImage *image, Drawable dest, int src_x,
269 	int src_y, int dest_x, int dest_y);
270 
271 /*****
272 * Write an image to file. Returns False upon failure.
273 * Saving an image in the GIF format is *not* possible due to Unisys's
274 * stupid LZW licensing policy. Exporting an image as PNG, JPEG or GZF is only
275 * possible if support for the required libraries has been compiled in.
276 *
277 * (UNIMPLEMENTED, always returns False)
278 *****/
279 XmHTML_LIBEXPORT Boolean XmImageExport(XmImageInfo *info, String file,
280 	Dimension width, Dimension height, unsigned char type);
281 
282 /* convert a GIF image to a GZF image */
283 XmHTML_LIBEXPORT Boolean XmHTMLGIFtoGZF(String infile, unsigned char *buf,
284 	int size, String outfile);
285 
286 /*****
287 * Anchor related convenience functions
288 * These routines can be used to jump to named anchors.
289 *****/
290 /* return the internal id of a named anchor given it's name or -1. */
291 XmHTML_LIBEXPORT int XmHTMLAnchorGetId(Widget w, String anchor);
292 
293 /* scroll to a named anchor, given it's id */
294 XmHTML_LIBEXPORT void XmHTMLAnchorScrollToId(Widget w, int anchor_id);
295 
296 /* scroll to a named anchor, given it's name */
297 XmHTML_LIBEXPORT void XmHTMLAnchorScrollToName(Widget w, String anchor);
298 
299 /* return True if a named anchor is currently visible, given it's id */
300 XmHTML_LIBEXPORT Boolean XmHTMLAnchorVisibleByName(Widget w, String anchor);
301 
302 /* return True if a named anchor is currently visible, given it's name */
303 XmHTML_LIBEXPORT Boolean XmHTMLAnchorVisibleById(Widget w, int anchor_id);
304 
305 /*****
306 * Checks a HTML instance against a current href name and alters any
307 * matching anchors to visited and causes a refesh.
308 * If visited is True, the matching anchor is rendered as visited. If it's
309 * False, it will be rendered as not visited.
310 *****/
311 XmHTML_LIBEXPORT void XmHTMLAnchorReEval(Widget w, String href,
312 	Boolean visited);
313 
314 /*****
315 * Text related convenience functions
316 *****/
317 /* This macro sets the given text into a HTML widget */
318 #define XmHTMLTextSet(WIDGET,TEXT) XtVaSetValues((WIDGET), \
319 		XmNvalue, (TEXT), NULL)
320 
321 /* scroll to the requested line number */
322 XmHTML_LIBEXPORT void XmHTMLTextScrollToLine(Widget w, int line);
323 
324 /* set text into a html widget */
325 XmHTML_LIBEXPORT void XmHTMLTextSetString(Widget w, String text);
326 
327 /*****
328 * same as XmHTMLTextSetString with one fundamental difference: text doesn't
329 * have to be NULL terminated. The size of the input string is instead
330 * given by len. If text is NULL or len is 0, the current contents are
331 * cleared.
332 *****/
333 XmHTML_LIBEXPORT void XmHTMLTextSetStringWithLength(Widget w, String text,
334 	size_t len);
335 
336 /* return a *pointer* to the original text */
337 XmHTML_LIBEXPORT String XmHTMLTextGetSource(Widget w);
338 
339 /* return a copy of the current parser output */
340 XmHTML_LIBEXPORT String XmHTMLTextGetString(Widget w);
341 
342 /*****
343 * Return a formatted copy of the current widget contents
344 * (UNIMPLEMENTED, always returns NULL)
345 *****/
346 XmHTML_LIBEXPORT String XmHTMLTextGetFormatted(Widget w,
347 	unsigned char papertype, XmHTMLPaperSize *paperdef, unsigned char type,
348 	unsigned long PSoptions);
349 
350 XmHTML_LIBEXPORT String XmHTMLTextGetSelection(Widget w);
351 
352 XmHTML_LIBEXPORT void XmHTMLTextClearSelection(Widget w, Time time);
353 
354 XmHTML_LIBEXPORT Boolean XmHTMLTextSetSelection(Widget w,
355 	XmHTMLTextPosition first, XmHTMLTextPosition last, Time time);
356 
357 XmHTML_LIBEXPORT void XmHTMLTextSetHighlight(Widget w, XmHTMLTextPosition first,
358 	XmHTMLTextPosition last, XmHighlightMode mode);
359 
360 XmHTML_LIBEXPORT Boolean XmHTMLTextCopy(Widget w, Time time);
361 
362 XmHTML_LIBEXPORT Boolean XmHTMLTextShowPosition(Widget w,
363 	XmHTMLTextPosition position);
364 
365 /* text search functions */
366 XmHTML_LIBEXPORT XmHTMLTextFinder XmHTMLTextFinderCreate(Widget w);
367 
368 XmHTML_LIBEXPORT void XmHTMLTextFinderDestroy(XmHTMLTextFinder finder);
369 
370 XmHTML_LIBEXPORT Boolean XmHTMLTextFinderSetPattern(XmHTMLTextFinder finder,
371 	String to_find);
372 
373 XmHTML_LIBEXPORT Boolean
374 	XmHTMLTextFinderSetPatternFlags(XmHTMLTextFinder finder, int flags,
375 		Boolean ignore_case, XmHTMLDirection direction);
376 
377 /* return the id of the last known regex error */
378 XmHTML_LIBEXPORT int XmHTMLTextFinderGetError(XmHTMLTextFinder finder);
379 
380 /* same as above but now returns a string which must be freed by caller */
381 XmHTML_LIBEXPORT String XmHTMLTextFinderGetErrorString(XmHTMLTextFinder finder);
382 
383 XmHTML_LIBEXPORT XmHTMLRegexStatus XmHTMLTextFindString(Widget w,
384 	XmHTMLTextFinder finder);
385 
386 XmHTML_LIBEXPORT void XmHTMLTextFinderReset(XmHTMLTextFinder finder);
387 
388 XmHTML_LIBEXPORT Boolean XmHTMLTextFindToPosition(Widget w,
389 	XmHTMLTextFinder finder, XmHTMLTextPosition *start,
390 	XmHTMLTextPosition *end);
391 
392 /*****
393 * Tag analyzers.
394 * These routines allow you to filter values out of the attributes
395 * attached to a HTML element.
396 *****/
397 XmHTML_LIBEXPORT int XmHTMLTagGetNumber(String attributes, String tag,
398 	int default_value);
399 
400 XmHTML_LIBEXPORT int XmHTMLTagCheckNumber(String attributes, String tag,
401 	int default_value);
402 
403 XmHTML_LIBEXPORT String XmHTMLTagGetValue(String attributes, String tag);
404 
405 XmHTML_LIBEXPORT Boolean XmHTMLTagCheck(String attributes, String tag);
406 
407 XmHTML_LIBEXPORT Boolean XmHTMLTagCheckValue(String attributes, String tag,
408 	String check);
409 
410 /*****
411 * Object related convenience functions.
412 * These functions allow one to define custom HTML elements to XmHTML.
413 *****/
414 
415 /* define a new element to the HTML parser */
416 XmHTML_LIBEXPORT XmHTMLElementId XmHTMLObjectDefine(String element,
417 	Boolean terminated, unsigned long attribute_flags, XtPointer user_data);
418 
419 /* undefine a previously defined element */
420 XmHTML_LIBEXPORT XmHTMLObjectStatus
421 	XmHTMLObjectUndefine(XmHTMLElementId element_id);
422 
423 /* reconfigure the given object (change position and/or size) */
424 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectReconfigure(Widget w,
425 	XmHTMLObjectId object_id, int x, int y, Dimension width, Dimension height);
426 
427 /* show/hide the given object */
428 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectShow(Widget w,
429 	XmHTMLObjectId object_id, Boolean show);
430 
431 /* raise the given object from the currently displayed document */
432 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectRaise(Widget w,
433 	XmHTMLObjectId object_id);
434 
435 /* lower the given object into the currently displayed document */
436 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectLower(Widget w,
437 	XmHTMLObjectId object_id);
438 
439 /* Create an external object corresponding to a previously defined element */
440 XmHTML_LIBEXPORT XmHTMLObjectId XmHTMLObjectCreate(XmHTMLElementId element_id);
441 
442 /* Destroy an external object */
443 XmHTML_LIBEXPORT void XmHTMLObjectDestroy(XmHTMLObjectId object_id);
444 
445 /* register an external object for use with XmHTML */
446 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectRegister(Widget w,
447 	XmHTMLObjectId object_id);
448 
449 /* unregister a previously registered object from XmHTML */
450 XmHTML_LIBEXPORT XmHTMLObjectStatus XmHTMLObjectUnregister(Widget w,
451 	XmHTMLObjectId object_id);
452 
453 /* fetch the element data from the given object */
454 XmHTML_LIBEXPORT XmHTMLElementId XmHTMLObjectGetElement(Widget w,
455 	XmHTMLObjectId object_id);
456 
457 /*****
458 * Miscelleneous convenience functions
459 *****/
460 /* return the library version number */
461 XmHTML_LIBEXPORT int XmHTMLGetVersion(void);
462 
463 /* return version string */
464 XmHTML_LIBEXPORT char *XmHTMLGetVersionString(void);
465 
466 /* return the URL type of the given href */
467 XmHTML_LIBEXPORT URLType XmHTMLGetURLType(String href);
468 
469 /* return the value of the <TITLE></TITLE> element */
470 XmHTML_LIBEXPORT String XmHTMLGetTitle(Widget w);
471 
472 /* return an info structure for the specified location */
473 XmHTML_LIBEXPORT XmHTMLInfoStructure *XmHTMLXYToInfo(Widget w, int x, int y);
474 
475 /* return document structure (list of images & hyperlinks) */
476 XmHTML_LIBEXPORT XmHTMLDocumentInfo *XmHTMLGetDocumentInfo(Widget w);
477 
478 /* free a document structure */
479 XmHTML_LIBEXPORT void XmHTMLFreeDocumentInfo(XmHTMLDocumentInfo *doc_info);
480 
481 /****
482 * Return the contents of the document head. Returns True when a <head></head>
483 * section is present in the current document, False if not. When mask_bits
484 * only contains HeadClear, the given attribute structure is wiped clean and
485 * this function will return False immediatly.
486 * The only exception concerns the <!DOCTYPE> tag and the HeadDocType mask bit:
487 * if this bit is set, the value of this tag is returned whether or not a
488 * head is present.
489 ****/
490 XmHTML_LIBEXPORT Boolean XmHTMLGetHeadAttributes(Widget w,
491 	XmHTMLHeadAttributes *head, unsigned char mask_bits);
492 
493 /* return the widget id of a framechild given its name */
494 XmHTML_LIBEXPORT Widget XmHTMLFrameGetChild(Widget w, String name);
495 
496 /* Create a HTML widget if parent is not null and no subclass of XmGadget */
497 XmHTML_LIBEXPORT Widget XmCreateHTML(Widget parent, String name,
498 	ArgList arglist,
499 	Cardinal argcount);
500 
501 /* force a recomputation of screen layout and trigger a redisplay */
502 XmHTML_LIBEXPORT void XmHTMLRedisplay(Widget w);
503 XmHTML_LIBEXPORT void XmHTMLRefresh(Widget w);
504 
505 /* return info about the font cache for display of the given widget */
506 XmHTML_LIBEXPORT XmHTMLFontCacheInfo *XmHTMLGetFontCacheInfo(Widget w);
507 
508 /* free the given font cache info */
509 XmHTML_LIBEXPORT void XmHTMLFreeFontCacheInfo(XmHTMLFontCacheInfo *info);
510 
511 /*
512 * Allocate given color (symbolic name of rgb triplet) using the widget's
513 * colormap. Works with the XmNmaxImageColors resource.
514 */
515 XmHTML_LIBEXPORT Pixel XmHTMLAllocColor(Widget w, String color,
516 	Pixel def_pixel);
517 
518 /* free a color allocated with XmHTMLAllocColor */
519 XmHTML_LIBEXPORT void XmHTMLFreeColor(Widget w, Pixel pixel);
520 
521 _XFUNCPROTOEND
522 
523 #endif /* _LIBRARY */
524 
525 /* Don't add anything after this endif! */
526 #endif /* _XmHTML_h_ */
527