# Patch for xpaint2.1.1 to make Imagemap config files # ****** You will also need "imap.h" from this directory ***** # I'm not an X programmer, and haven't figured out how to include # what I needed in the GUI, so it appears in the shell window. # Apologies all round, but I though someone might like the functionality now # rather than waiting for me to come back from vacation and learn enough X # to fix it. Besides, someone out there might do it for me. In which case, # please mail me a copy (advax@triumf.ca) Andrew Daviel, TRIUMF, Vancouver # Canada # # How it works: # When a box, circle, or closed polygon is generated in xpaint, commands are # written to a text file in a format suitable for the httpd imagemap cgi # program. The patched program initially prompts for a filename, a default # item and a URL prefix. The default prefix typically has the form # http://machine.domain/cgi_bin/imagemap/ # When one of the 3 graphic types is generated, the program prompts for # an item name. This name is appended to the URL and written to the file, eg. # circle /examples/ow.html 382,193 383,200 # poly /examples/plant.html 117,96 116,267 172,283 192,299 # # What it's for: # Images generated for Mosaic on the Web may be imagemapped. This means that # clicking on different places in the picture will generate a link to # different documents. For this to work, a config file must be created # containing the coordinates in pixels of the 'hot' areas of the picture. # Doing this with xv and writing down pixel coordinates is tedious. *** main.c Thu Jan 13 05:17:41 1994 --- main.c.1 Thu Jun 16 23:57:47 1994 *************** *** 24,29 **** --- 24,30 ---- #define DEFINE_GLOBAL #include "xpaint.h" #include "misc.h" + #include "imap.h" #include "XPaintIcon.xpm" *************** *** 212,217 **** --- 213,228 ---- Boolean isIcon; InitTypeConverters(); + + + printf("IMAP file to create: ") ; scanf("%s",imap_filenm) ; + imap_file = fopen(imap_filenm,"w") ; + if (!imap_file) + fprintf(stderr, "ERROR: Unable to open output file '%s'\n", imap_filenm); + fprintf(imap_file,"; Imagemap co-ordinate file created by xpaint\n") ; + printf("Item prefix (URL) for IMAP items: ") ; scanf("%s",imap_URL) ; + printf("Default item for Imagemap: ") ; scanf("%s",imap_default) ; + fprintf(imap_file,"default %s%s\n",imap_URL,imap_default) ; /* ** Create the application context *** boxOp.c Mon Jun 14 03:29:30 1993 --- boxOp.c.1 Thu Jun 16 23:57:09 1994 *************** *** 17,22 **** --- 17,24 ---- #include "xpaint.h" #include "misc.h" #include "Paint.h" + #include + #include "imap.h" typedef struct { int rx, ry; *************** *** 97,103 **** l->type = (event->state & ShiftMask) ? 1 : 0; if (l->drawn = (l->startX != l->endX || l->startY != l->endY)) { MKRECT(&rect, l->startX, l->startY, l->endX, l->endY, l->type); - XDrawRectangles(XtDisplay(w), XtWindow(w), l->gcx,&rect, 1); } } --- 99,104 ---- *************** *** 108,113 **** --- 109,115 ---- XRectangle rect; int mask; GC fgc, lgc; + int minX,maxX,minY,maxY ; /* ** Check to make sure all buttons are up, before doing this *************** *** 127,132 **** --- 129,148 ---- MKRECT(&rect, l->startX, l->startY, l->endX, l->endY, l->type); XDrawRectangles(XtDisplay(w), XtWindow(w), l->gcx,&rect, 1); + + if (l->endX > l->startX) + { minX = l->startX ; maxX = l->endX ; } + else + { maxX = l->startX ; minX = l->endX ; } + if (l->endY > l->startY) + { minY = l->startY ; maxY = l->endY ; } + else + { maxY = l->startY ; minY = l->endY ; } + + printf("Rectangle item for Imagemap: ") ; scanf("%s",imap_item) ; + + fprintf(imap_file,"rect %s%s %d,%d %d,%d \n", + imap_URL,imap_item,minX,minY,maxX,maxY) ; } if (info->isFat && info->surface == opWindow) *** polyOp.c Sun May 16 07:46:32 1993 --- polyOp.c.1 Thu Jun 16 23:57:46 1994 *************** *** 18,23 **** --- 18,25 ---- #include "xpaint.h" #include "misc.h" #include "Paint.h" + #include + #include "imap.h" #define FILL 0x2 #define POLY 0x1 *************** *** 44,49 **** --- 46,52 ---- static void finish(Widget w, LocalInfo *l, Boolean flag) { + int k ; if (!l->tracking) return; *************** *** 57,62 **** --- 60,73 ---- l->points[l->npoints-1].x, l->points[l->npoints-1].y, l->endX, l->endY); + + printf("Polygon item for Imagemap: ") ; scanf("%s",imap_item) ; + fprintf(imap_file,"poly %s%s ",imap_URL,imap_item) ; + for (k=0;knpoints;k++) + fprintf(imap_file," %d,%d",l->points[k].x,l->points[k].y) ; + fprintf(imap_file,"\n") ; + + if (IsFill(l->flag)) { if (!l->isFat) *** circleOp.c Mon Jun 14 03:30:58 1993 --- circleOp.c.1 Thu Jun 16 23:57:47 1994 *************** *** 15,23 **** --- 15,25 ---- #include #include #include + #include #include "xpaint.h" #include "misc.h" #include "Paint.h" + #include "imap.h" #define FILL 0x02 #define CIRCLE 0x01 *************** *** 123,128 **** --- 125,131 ---- XRectangle *undo; int mask; GC fgc, lgc; + int centerX,centerY ; /* ** Check to make sure all buttons are up, before doing this *************** *** 138,146 **** if ((event->state & mask) != 0) return; ! if (l->drawn && info->surface == opWindow) draw(w, info->drawable, l->gcx, None, l); if (info->surface == opWindow && info->isFat) return; --- 141,156 ---- if ((event->state & mask) != 0) return; ! if (l->drawn && info->surface == opWindow) { draw(w, info->drawable, l->gcx, None, l); + centerX = (l->startX + l->endX) / 2 ; + centerY = (l->startY + l->endY) / 2 ; + printf("Circle item for Imagemap: ") ; scanf("%s",imap_item) ; + fprintf(imap_file,"circle %s%s %d,%d %d,%d\n", + imap_URL,imap_item,centerX,centerY,centerX,l->endY); + } + if (info->surface == opWindow && info->isFat) return; *************** *** 150,155 **** --- 160,166 ---- l->startY = l->ry; l->endX = event->x; l->endY = event->y; + if (l->swap) { fgc = info->first_gc;