1 /**************************************************************************** 2 * NCSA Mosaic for the X Window System * 3 * Software Development Group * 4 * National Center for Supercomputing Applications * 5 * University of Illinois at Urbana-Champaign * 6 * 605 E. Springfield, Champaign IL 61820 * 7 * mosaic@ncsa.uiuc.edu * 8 * * 9 * Copyright (C) 1993, Board of Trustees of the University of Illinois * 10 * * 11 * NCSA Mosaic software, both binary and source (hereafter, Software) is * 12 * copyrighted by The Board of Trustees of the University of Illinois * 13 * (UI), and ownership remains with the UI. * 14 * * 15 * The UI grants you (hereafter, Licensee) a license to use the Software * 16 * for academic, research and internal business purposes only, without a * 17 * fee. Licensee may distribute the binary and source code (if released) * 18 * to third parties provided that the copyright notice and this statement * 19 * appears on all copies and that no charge is associated with such * 20 * copies. * 21 * * 22 * Licensee may make derivative works. However, if Licensee distributes * 23 * any derivative work based on or derived from the Software, then * 24 * Licensee will (1) notify NCSA regarding its distribution of the * 25 * derivative work, and (2) clearly notify users that such derivative * 26 * work is a modified version and not the original NCSA Mosaic * 27 * distributed by the UI. * 28 * * 29 * Any Licensee wishing to make commercial use of the Software should * 30 * contact the UI, c/o NCSA, to negotiate an appropriate license for such * 31 * commercial use. Commercial use includes (1) integration of all or * 32 * part of the source code into a product for sale or license by or on * 33 * behalf of Licensee to third parties, or (2) distribution of the binary * 34 * code or source code to third parties that need it to utilize a * 35 * commercial product sold or licensed by or on behalf of Licensee. * 36 * * 37 * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * 38 * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * 39 * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * 40 * USERS OF THIS SOFTWARE. * 41 * * 42 * By using or copying this Software, Licensee agrees to abide by the * 43 * copyright law and all other applicable laws of the U.S. including, but * 44 * not limited to, export control laws, and the terms of this license. * 45 * UI shall have the right to terminate this license immediately by * 46 * written notice upon Licensee's breach of, or non-compliance with, any * 47 * of its terms. Licensee may be held legally responsible for any * 48 * copyright infringement that is caused or encouraged by Licensee's * 49 * failure to abide by the terms of this license. * 50 * * 51 * Comments and questions are welcome and can be sent to * 52 * mosaic-x@ncsa.uiuc.edu. * 53 ****************************************************************************/ 54 55 #ifndef HTML_H 56 #define HTML_H 57 58 #if 0 59 /* define via the Imakefile -elf*/ 60 #ifndef MOTIF 61 #define MOTIF 62 #endif 63 #endif 64 65 #ifdef MOTIF 66 #include <Xm/Xm.h> 67 #if (XmVERSION == 1)&&(XmREVISION >= 2) 68 #undef MOTIF1_2 69 #define MOTIF1_2 70 #endif 71 #else 72 #include <X11/Intrinsic.h> 73 #include <X11/Constraint.h> 74 #endif /* MOTIF */ 75 #include <X11/StringDefs.h> 76 77 78 79 typedef int (*visitTestProc)(); 80 typedef void (*pointerTrackProc)(); 81 82 typedef struct ele_ref_rec { 83 int id, pos; 84 } ElementRef; 85 86 typedef struct link_rec { 87 char *href; 88 char *role; 89 } LinkInfo; 90 91 /* 92 * Public functions 93 */ 94 #ifdef _NO_PROTO 95 extern char *HTMLGetText (); 96 extern char *HTMLGetTextAndSelection (); 97 extern char **HTMLGetHRefs (); 98 extern char **HTMLGetImageSrcs (); 99 extern void *HTMLGetWidgetInfo (); 100 extern void HTMLFreeWidgetInfo (); 101 extern void HTMLFreeImageInfo (); 102 extern LinkInfo *HTMLGetLinks (); 103 extern int HTMLPositionToId (); 104 extern int HTMLIdToPosition (); 105 extern int HTMLAnchorToPosition (); 106 extern int HTMLAnchorToId (); 107 extern void HTMLGotoId (); 108 extern void HTMLRetestAnchors (); 109 extern void HTMLClearSelection (); 110 extern void HTMLSetSelection (); 111 extern void HTMLSetText (); 112 extern int HTMLSearchText (); 113 #else 114 extern char *HTMLGetText (Widget w, int pretty); 115 extern char *HTMLGetTextAndSelection (Widget w, char **startp, char **endp, 116 char **insertp); 117 extern char **HTMLGetHRefs (Widget w, int *num_hrefs); 118 extern char **HTMLGetImageSrcs (Widget w, int *num_srcs); 119 extern void *HTMLGetWidgetInfo (Widget w); 120 extern void HTMLFreeWidgetInfo (void *ptr); 121 extern void HTMLFreeImageInfo (Widget w); 122 extern LinkInfo *HTMLGetLinks (Widget w, int *num_links); 123 extern int HTMLPositionToId(Widget w, int x, int y); 124 extern int HTMLIdToPosition(Widget w, int element_id, int *x, int *y); 125 extern int HTMLAnchorToPosition(Widget w, char *name, int *x, int *y); 126 extern int HTMLAnchorToId(Widget w, char *name); 127 extern void HTMLGotoId(Widget w, int element_id); 128 extern void HTMLRetestAnchors(Widget w, visitTestProc testFunc); 129 extern void HTMLClearSelection (Widget w); 130 extern void HTMLSetSelection (Widget w, ElementRef *start, ElementRef *end); 131 extern void HTMLSetText (Widget w, char *text, char *header_text, 132 char *footer_text, int element_id, 133 char *target_anchor, void *ptr); 134 extern int HTMLSearchText (Widget w, char *pattern, 135 ElementRef *m_start, ElementRef *m_end, int backward, int caseless); 136 #endif /* _NO_PROTO */ 137 138 139 /* 140 * Public Structures 141 */ 142 typedef struct acall_rec { 143 XEvent *event; 144 int element_id; 145 char *text; 146 char *href; 147 } WbAnchorCallbackData; 148 149 150 typedef struct fcall_rec { 151 XEvent *event; 152 char *href; 153 char *method; 154 char *enctype; 155 char *enc_entity; 156 int attribute_count; 157 char **attribute_names; 158 char **attribute_values; 159 } WbFormCallbackData; 160 161 162 typedef struct form_rec { 163 Widget hw; 164 char *action; 165 char *method; 166 char *enctype; 167 char *enc_entity; 168 int start, end; 169 Widget button_pressed; /* match button pressed to one of submits */ 170 struct form_rec *next; 171 } FormInfo; 172 173 174 typedef struct image_rec { 175 int ismap; 176 FormInfo *fptr; 177 int internal; 178 int delayed; 179 int fetched; 180 int width, height; 181 int num_colors; 182 int *reds; 183 int *greens; 184 int *blues; 185 unsigned char *image_data; 186 Pixmap image; 187 char *text; 188 } ImageInfo; 189 190 191 typedef struct wid_rec { 192 Widget w; 193 int type; 194 int id; 195 int x, y; 196 int width, height; 197 char *name; 198 char *value; 199 char *password; 200 char **mapping; 201 Boolean checked; 202 Boolean mapped; 203 struct wid_rec *next; 204 } WidgetInfo; 205 206 207 typedef enum { F_NONE, F_TEXT, F_IMAGE, F_WIDGET} FieldType; 208 209 typedef struct table_field { 210 int colSpan; /* number of cells this spans vertically */ 211 int rowSpan; /* number of cells this spans horizontally */ 212 Boolean contVert; /* does this cell continue from previous */ 213 Boolean contHoriz; /* does this cell continue from previous */ 214 int alignment; /* contents alignment */ 215 int maxWidth; 216 int minWidth; 217 int maxHeight; 218 int minHeight; 219 int colWidth; /* uniform width for all element in this col*/ 220 int rowHeight; /* uniform hieght for all element in the row*/ 221 Boolean header; /* is this field created with <TH> or <TD> */ 222 223 /* contents */ 224 FieldType type; 225 char *text; 226 XFontStruct *font; 227 char **formattedText; 228 int numLines; /* for formatted text */ 229 230 ImageInfo *image; 231 WidgetInfo *winfo; 232 } TableField; 233 234 typedef struct table_rec { 235 Boolean borders; 236 char *caption; 237 int captionAlignment; 238 struct mark_up *mptr; 239 int width,height; 240 int numColumns; 241 int numRows; 242 TableField *table; 243 } TableInfo; 244 245 typedef struct sel_rec { 246 Widget hw; 247 struct mark_up *mptr; 248 int is_value; 249 char *retval_buf; 250 char *option_buf; 251 char **returns; 252 char **options; 253 int option_cnt; 254 char **value; 255 int value_cnt; 256 } SelectInfo; 257 258 259 typedef ImageInfo *(*resolveImageProc)(); 260 261 262 /* 263 * defines and structures used for the formatted element list 264 */ 265 266 #define E_TEXT 1 267 #define E_BULLET 2 268 #define E_LINEFEED 3 269 #define E_IMAGE 4 270 #define E_WIDGET 5 271 #define E_HRULE 6 272 #define E_TABLE 7 273 274 /* define alignment values */ 275 #define ALIGN_BOTTOM 0 276 #define ALIGN_MIDDLE 1 277 #define ALIGN_TOP 2 278 279 #define ALIGN_LEFT 3 280 #define ALIGN_CENTER 4 281 #define ALIGN_RIGHT 5 282 283 284 struct ele_rec { 285 int type; 286 ImageInfo *pic_data; 287 WidgetInfo *widget_data; 288 TableInfo *table_data; 289 XFontStruct *font; 290 int alignment; 291 Boolean internal; 292 Boolean selected; 293 int indent_level; 294 int start_pos, end_pos; 295 int x, y; 296 int y_offset; 297 int width; 298 int line_number; 299 int line_height; 300 int ele_id; 301 int underline_number; 302 Boolean dashed_underline; 303 Boolean strikeout; 304 unsigned long fg; 305 unsigned long bg; 306 char *anchorName; 307 char *anchorHRef; 308 char *edata; 309 int edata_len; 310 struct ele_rec *next; 311 struct ele_rec *prev; 312 }; 313 314 struct ref_rec { 315 char *anchorHRef; 316 struct ref_rec *next; 317 }; 318 319 struct delay_rec { 320 char *src; 321 struct delay_rec *next; 322 }; 323 324 325 /* 326 * defines and structures used for the HTML parser, and the 327 * parsed object list. 328 */ 329 330 /* Mark types */ 331 #define M_UNKNOWN -1 332 #define M_NONE 0 333 #define M_TITLE 1 334 #define M_HEADER_1 2 335 #define M_HEADER_2 3 336 #define M_HEADER_3 4 337 #define M_HEADER_4 5 338 #define M_HEADER_5 6 339 #define M_HEADER_6 7 340 #define M_ANCHOR 8 341 #define M_PARAGRAPH 9 342 #define M_ADDRESS 10 343 #define M_PLAIN_TEXT 11 344 #define M_UNUM_LIST 12 345 #define M_NUM_LIST 13 346 #define M_LIST_ITEM 14 347 #define M_DESC_LIST 15 348 #define M_DESC_TITLE 16 349 #define M_DESC_TEXT 17 350 #define M_PREFORMAT 18 351 #define M_PLAIN_FILE 19 352 #define M_LISTING_TEXT 20 353 #define M_INDEX 21 354 #define M_MENU 22 355 #define M_DIRECTORY 23 356 #define M_IMAGE 24 357 #define M_FIXED 25 358 #define M_BOLD 26 359 #define M_ITALIC 27 360 #define M_EMPHASIZED 28 361 #define M_STRONG 29 362 #define M_CODE 30 363 #define M_SAMPLE 31 364 #define M_KEYBOARD 32 365 #define M_VARIABLE 33 366 #define M_CITATION 34 367 #define M_BLOCKQUOTE 35 368 #define M_STRIKEOUT 36 369 #define M_INPUT 37 370 #define M_FORM 38 371 #define M_HRULE 39 372 #define M_LINEBREAK 40 373 #define M_BASE 41 374 #define M_SELECT 42 375 #define M_OPTION 43 376 #define M_TEXTAREA 44 377 #define M_TABLE 45 378 #define M_CAPTION 46 379 #define M_TABLE_HEADER 47 380 #define M_TABLE_ROW 48 381 #define M_TABLE_DATA 49 382 #define M_SUP 50 383 #define M_SUB 51 384 #define M_FIGURE 52 385 #define M_COMMENT 53 386 #define M_DOC_HEAD 54 /* amb 2 */ 387 #define M_UNDERLINED 55 /* amb 2 */ 388 #define M_DOC_BODY 56 /* amb 2 */ 389 390 /* syntax of Mark types */ 391 #define MT_TITLE "title" 392 #define MT_HEADER_1 "h1" 393 #define MT_HEADER_2 "h2" 394 #define MT_HEADER_3 "h3" 395 #define MT_HEADER_4 "h4" 396 #define MT_HEADER_5 "h5" 397 #define MT_HEADER_6 "h6" 398 #define MT_ANCHOR "a" 399 #define MT_PARAGRAPH "p" 400 #define MT_ADDRESS "address" 401 #define MT_PLAIN_TEXT "xmp" 402 #define MT_UNUM_LIST "ul" 403 #define MT_NUM_LIST "ol" 404 #define MT_LIST_ITEM "li" 405 #define MT_DESC_LIST "dl" 406 #define MT_DESC_TITLE "dt" 407 #define MT_DESC_TEXT "dd" 408 #define MT_PREFORMAT "pre" 409 #define MT_PLAIN_FILE "plaintext" 410 #define MT_LISTING_TEXT "listing" 411 #define MT_INDEX "isindex" 412 #define MT_MENU "menu" 413 #define MT_DIRECTORY "dir" 414 #define MT_IMAGE "img" 415 #define MT_FIGURE "fig" 416 #define MT_FIXED "tt" 417 #define MT_BOLD "b" 418 #define MT_ITALIC "i" 419 #define MT_EMPHASIZED "em" 420 #define MT_STRONG "strong" 421 #define MT_CODE "code" 422 #define MT_SAMPLE "samp" 423 #define MT_KEYBOARD "kbd" 424 #define MT_VARIABLE "var" 425 #define MT_CITATION "cite" 426 #define MT_BLOCKQUOTE "blockquote" 427 #define MT_STRIKEOUT "strike" 428 #define MT_INPUT "input" 429 #define MT_FORM "form" 430 #define MT_HRULE "hr" 431 #define MT_LINEBREAK "br" 432 #define MT_BASE "base" 433 #define MT_SELECT "select" 434 #define MT_OPTION "option" 435 #define MT_TEXTAREA "textarea" 436 #define MT_TABLE "table" 437 #define MT_CAPTION "caption" 438 #define MT_TABLE_ROW "tr" 439 #define MT_TABLE_HEADER "th" 440 #define MT_TABLE_DATA "td" 441 #define MT_SUP "sup" 442 #define MT_SUB "sub" 443 #define MT_DOC_HEAD "head" /* amb 2 */ 444 #define MT_UNDERLINED "u" /* amb 2 */ 445 #define MT_DOC_BODY "body" 446 447 /* anchor tags */ 448 #define AT_NAME "name" 449 #define AT_HREF "href" 450 451 452 struct mark_up { 453 int type; 454 int is_end; 455 char *start; 456 char *text; 457 char *end; 458 struct mark_up *next; 459 }; 460 461 462 /* 463 * New resource names 464 */ 465 #define WbNmarginWidth "marginWidth" 466 #define WbNmarginHeight "marginHeight" 467 #define WbNtext "text" 468 #define WbNheaderText "headerText" 469 #define WbNfooterText "footerText" 470 #define WbNtitleText "titleText" 471 #define WbNanchorUnderlines "anchorUnderlines" 472 #define WbNvisitedAnchorUnderlines "visitedAnchorUnderlines" 473 #define WbNdashedAnchorUnderlines "dashedAnchorUnderlines" 474 #define WbNdashedVisitedAnchorUnderlines "dashedVisitedAnchorUnderlines" 475 #define WbNanchorColor "anchorColor" 476 #define WbNvisitedAnchorColor "visitedAnchorColor" 477 #define WbNactiveAnchorFG "activeAnchorFG" 478 #define WbNactiveAnchorBG "activeAnchorBG" 479 #define WbNfancySelections "fancySelections" 480 #define WbNimageBorders "imageBorders" 481 #define WbNdelayImageLoads "delayImageLoads" 482 #define WbNisIndex "isIndex" 483 #define WbNitalicFont "italicFont" 484 #define WbNboldFont "boldFont" 485 #define WbNfixedFont "fixedFont" 486 #define WbNfixedboldFont "fixedboldFont" 487 #define WbNfixeditalicFont "fixeditalicFont" 488 #define WbNheader1Font "header1Font" 489 #define WbNheader2Font "header2Font" 490 #define WbNheader3Font "header3Font" 491 #define WbNheader4Font "header4Font" 492 #define WbNheader5Font "header5Font" 493 #define WbNheader6Font "header6Font" 494 #define WbNaddressFont "addressFont" 495 #define WbNplainFont "plainFont" 496 #define WbNplainboldFont "plainboldFont" 497 #define WbNplainitalicFont "plainitalicFont" 498 #define WbNlistingFont "listingFont" 499 #define WbNanchorCallback "anchorCallback" 500 #define WbNlinkCallback "linkCallback" 501 #define WbNsubmitFormCallback "submitFormCallback" 502 #define WbNpreviouslyVisitedTestFunction "previouslyVisitedTestFunction" 503 #define WbNresolveImageFunction "resolveImageFunction" 504 #define WbNresolveDelayedImage "resolveDelayedImage" 505 #define WbNpercentVerticalSpace "percentVerticalSpace" 506 #define WbNpointerMotionCallback "pointerMotionCallback" 507 #define WbNverticalScrollOnRight "verticalScrollOnRight" 508 #define WbNhorizontalScrollOnTop "horizontalScrollOnTop" 509 #define WbNview "view" 510 #define WbNverticalScrollBar "verticalScrollBar" 511 #define WbNhorizontalScrollBar "horizontalScrollBar" 512 #define WbNsupSubFont "supSubFont" /* amb */ 513 514 /* 515 * New resource classes 516 */ 517 #define WbCMarginWidth "MarginWidth" 518 #define WbCMarginHeight "MarginHeight" 519 #define WbCText "Text" 520 #define WbCHeaderText "HeaderText" 521 #define WbCFooterText "FooterText" 522 #define WbCTitleText "TitleText" 523 #define WbCAnchorUnderlines "AnchorUnderlines" 524 #define WbCVisitedAnchorUnderlines "VisitedAnchorUnderlines" 525 #define WbCDashedAnchorUnderlines "DashedAnchorUnderlines" 526 #define WbCDashedVisitedAnchorUnderlines "DashedVisitedAnchorUnderlines" 527 #define WbCAnchorColor "AnchorColor" 528 #define WbCVisitedAnchorColor "VisitedAnchorColor" 529 #define WbCActiveAnchorFG "ActiveAnchorFG" 530 #define WbCActiveAnchorBG "ActiveAnchorBG" 531 #define WbCFancySelections "FancySelections" 532 #define WbCImageBorders "ImageBorders" 533 #define WbCDelayImageLoads "DelayImageLoads" 534 #define WbCIsIndex "IsIndex" 535 #define WbCItalicFont "ItalicFont" 536 #define WbCBoldFont "BoldFont" 537 #define WbCFixedFont "FixedFont" 538 #define WbCFixedboldFont "FixedboldFont" 539 #define WbCFixeditalicFont "FixeditalicFont" 540 #define WbCHeader1Font "Header1Font" 541 #define WbCHeader2Font "Header2Font" 542 #define WbCHeader3Font "Header3Font" 543 #define WbCHeader4Font "Header4Font" 544 #define WbCHeader5Font "Header5Font" 545 #define WbCHeader6Font "Header6Font" 546 #define WbCAddressFont "AddressFont" 547 #define WbCPlainFont "PlainFont" 548 #define WbCPlainboldFont "PlainboldFont" 549 #define WbCPlainitalicFont "PlainitalicFont" 550 #define WbCListingFont "ListingFont" 551 #define WbCPreviouslyVisitedTestFunction "PreviouslyVisitedTestFunction" 552 #define WbCResolveImageFunction "ResolveImageFunction" 553 #define WbCResolveDelayedImage "ResolveDelayedImage" 554 #define WbCPercentVerticalSpace "PercentVerticalSpace" 555 #define WbCPointerMotionCallback "PointerMotionCallback" 556 #define WbCVerticalScrollOnRight "VerticalScrollOnRight" 557 #define WbCHorizontalScrollOnTop "HorizontalScrollOnTop" 558 #define WbCView "View" 559 #define WbCVerticalScrollBar "VerticalScrollBar" 560 #define WbCHorizontalScrollBar "HorizontalScrollBar" 561 #define WbCSupSubFont "SupSubFont" /* amb */ 562 563 564 typedef struct _HTMLClassRec *HTMLWidgetClass; 565 typedef struct _HTMLRec *HTMLWidget; 566 567 extern WidgetClass htmlWidgetClass; 568 569 570 #endif /* HTML_H */ 571 572