annotate lisp/w3/w3-imap.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 9ee227acff29
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-imap.el --- Imagemap functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3 ;; Created: 1997/01/10 00:13:05
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
4 ;; Version: 1.7
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'w3-vars)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
30 (eval-and-compile
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
31 (require 'widget))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defmacro x-coord (pt) (list 'aref pt 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defmacro y-coord (pt) (list 'aref pt 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun w3-point-in-rect (point coord1 coord2 &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Return t iff POINT is within a rectangle defined by COORD1 and COORD2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 All arguments are vectors of [X Y] coordinates."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; D'uhhh, this is hard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (and (>= (x-coord point) (x-coord coord1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (<= (x-coord point) (x-coord coord2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (>= (y-coord point) (y-coord coord1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (<= (y-coord point) (y-coord coord2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun w3-point-in-circle (point coord1 coord2 &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Return t iff POINT is within a circle defined by COORD1 and COORD2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 All arguments are vectors of [X Y] coordinates."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; D'uhhh, this is (barely) slightly harder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (let (radius1 radius2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq radius1 (+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (- (y-coord coord1) (y-coord coord2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (- (y-coord coord1) (y-coord coord2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (- (x-coord coord1) (x-coord coord2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (- (x-coord coord1) (x-coord coord2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 radius2 (+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (- (y-coord coord1) (y-coord point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (- (y-coord coord1) (y-coord point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (- (x-coord coord1) (x-coord point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (- (x-coord coord1) (x-coord point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (<= radius2 radius1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; A polygon is a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; poly[0] = # of sides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; poly[1] = # of sides used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; poly[2] = vector of X coords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; poly[3] = vector of Y coords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defsubst w3-image-poly-nsegs (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (aref p 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defsubst w3-image-poly-used-segs (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (aref p 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defsubst w3-image-poly-x-coords (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (aref p 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defsubst w3-image-poly-y-coords (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (aref p 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defsubst w3-image-poly-x-coord (p n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (aref (w3-image-poly-x-coords p) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defsubst w3-image-poly-y-coord (p n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (aref (w3-image-poly-y-coords p) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defun w3-image-poly-alloc (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (< n 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (error "w3-image-poly-alloc: invalid number of sides (%d)" n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (vector n 0 (make-vector n nil) (make-vector n nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun w3-image-poly-assign (p x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if (>= (w3-image-poly-used-segs p) (w3-image-poly-nsegs p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (error "w3-image-poly-assign: out of space in the w3-image-polygon"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (aset (w3-image-poly-x-coords p) (w3-image-poly-used-segs p) x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (aset (w3-image-poly-y-coords p) (w3-image-poly-used-segs p) y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (aset p 1 (1+ (w3-image-poly-used-segs p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun w3-image-ccw (p0 p1 p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let (dx1 dx2 dy1 dy2 retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (setq dx1 (- (x-coord p1) (x-coord p0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 dy1 (- (y-coord p1) (y-coord p0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 dx2 (- (x-coord p2) (x-coord p0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 dy2 (- (y-coord p2) (y-coord p0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ((> (* dx1 dy2) (* dy1 dx2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq retval 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ((< (* dx1 dy2) (* dy1 dx2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq retval -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ((or (< (* dx1 dx2) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (< (* dy1 dy2) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq retval -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ((< (+ (* dx1 dx1) (* dy1 dy1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (+ (* dx2 dx2) (* dy2 dy2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (setq retval 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq retval 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun w3-image-line-intersect (l1 l2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (and (<= (* (w3-image-ccw (car l1) (cdr l1) (car l2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (w3-image-ccw (car l1) (cdr l1) (cdr l2))) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (<= (* (w3-image-ccw (car l2) (cdr l2) (car l1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (w3-image-ccw (car l2) (cdr l2) (cdr l1))) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun w3-point-in-poly (point &rest pgon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 "Return t iff POINT is within a polygon defined by the list of points PGON.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 All arguments are either vectors of [X Y] coordinates or lists of such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 vectors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; Right now, this fails on some points that are right on a line segment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; but it works for everything else (I think)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if (< (length pgon) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; Malformed polygon!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (let ((p (w3-image-poly-alloc (length pgon)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (hitcount 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (ip1 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (l1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (l2 (cons (vector (x-coord point) (1+ (y-coord point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (vector (x-coord point) (y-coord point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (while pgon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (w3-image-poly-assign p (x-coord (car pgon)) (y-coord (car pgon)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq pgon (cdr pgon)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (while (< i (w3-image-poly-nsegs p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Check for wraparound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq ip1 (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if (= ip1 (w3-image-poly-nsegs p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq ip1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq l1 (cons (vector (w3-image-poly-x-coord p i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (w3-image-poly-y-coord p i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (vector (w3-image-poly-x-coord p ip1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (w3-image-poly-y-coord p ip1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (w3-image-line-intersect l1 l2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (setq hitcount (1+ hitcount)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (= 1 (% hitcount 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun w3-point-in-default (point &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun w3-point-in-map (point map &optional alt-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (let (func args done cur default slot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (setq slot (if alt-text 3 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (while (and map (not done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq cur (car map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 func (intern-soft (format "w3-point-in-%s" (aref cur 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 args (aref cur 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 done (and func (fboundp func) (apply func point args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 map (cdr map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (if (equal (aref cur 0) "default")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (setq default (aref cur slot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 done nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ((and done (aref cur 2)) ; Found a link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if alt-text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (or (aref cur 3) (aref cur 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (aref cur slot)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; Regular image stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defvar w3-allowed-image-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (mapcar (function (lambda (x) (list (car x)))) w3-image-mappings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defvar w3-image-size-restriction nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defmacro w3-image-cached-p (href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "Return non-nil iff HREF is in the image cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (` (cdr-safe (assoc (, href) w3-graphics-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun w3-image-loadable-p (href force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((attribs (url-file-attributes href)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (assoc (nth 8 attribs) w3-allowed-image-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (null w3-image-size-restriction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (<= (nth 7 attribs) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (and (numberp w3-image-size-restriction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (<= (nth 7 attribs) w3-image-size-restriction)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defmacro w3-image-invalid-glyph-p (glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (` (or (null (aref (, glyph) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (null (aref (, glyph) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (equal (aref (, glyph) 2) ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; data structure in storage is a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; if (href == t) then no action should be taken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; [ type coordinates href (hopefully)descriptive-text]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (provide 'w3-imap)