KHtml

html_image.cpp
1 /**
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 // --------------------------------------------------------------------------
23 
24 #include "html_image.h"
25 #include "dom_doc.h"
26 #include "html_misc.h"
27 
28 #include <html/html_imageimpl.h>
29 #include <html/html_miscimpl.h>
30 #include <xml/dom_docimpl.h>
31 
32 using namespace DOM;
33 
34 HTMLAreaElement::HTMLAreaElement() : HTMLElement()
35 {
36 }
37 
38 HTMLAreaElement::HTMLAreaElement(const HTMLAreaElement &other) : HTMLElement(other)
39 {
40 }
41 
42 HTMLAreaElement::HTMLAreaElement(HTMLAreaElementImpl *impl) : HTMLElement(impl)
43 {
44 }
45 
46 HTMLAreaElement &HTMLAreaElement::operator = (const Node &other)
47 {
48  assignOther(other, ID_AREA);
49  return *this;
50 }
51 
52 HTMLAreaElement &HTMLAreaElement::operator = (const HTMLAreaElement &other)
53 {
54  HTMLElement::operator = (other);
55  return *this;
56 }
57 
58 HTMLAreaElement::~HTMLAreaElement()
59 {
60 }
61 
63 {
64  if (!impl) {
65  return DOMString();
66  }
67  return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY);
68 }
69 
71 {
72  if (impl) {
73  ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value);
74  }
75 }
76 
78 {
79  if (!impl) {
80  return DOMString();
81  }
82  return ((ElementImpl *)impl)->getAttribute(ATTR_ALT);
83 }
84 
86 {
87  if (impl) {
88  ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value);
89  }
90 }
91 
93 {
94  if (!impl) {
95  return DOMString();
96  }
97  return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS);
98 }
99 
101 {
102  if (impl) {
103  ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value);
104  }
105 }
106 
108 {
109  if (!impl) {
110  return DOMString();
111  }
112  const DOMString href = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_HREF).trimSpaces();
113  return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
114 }
115 
117 {
118  if (impl) {
119  ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value);
120  }
121 }
122 
124 {
125  if (!impl) {
126  return 0;
127  }
128  return !((ElementImpl *)impl)->getAttribute(ATTR_NOHREF).isNull();
129 }
130 
131 void HTMLAreaElement::setNoHref(bool _noHref)
132 {
133  if (impl) {
134  DOMString str;
135  if (_noHref) {
136  str = "";
137  }
138  ((ElementImpl *)impl)->setAttribute(ATTR_NOHREF, str);
139  }
140 }
141 
143 {
144  if (!impl) {
145  return DOMString();
146  }
147  return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE);
148 }
149 
151 {
152  if (impl) {
153  ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value);
154  }
155 }
156 
158 {
159  if (!impl) {
160  return 0;
161  }
162  return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt();
163 }
164 
165 void HTMLAreaElement::setTabIndex(long _tabIndex)
166 {
167  if (impl) {
168  DOMString value(QString::number(_tabIndex));
169  ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX, value);
170  }
171 }
172 
174 {
175  if (!impl) {
176  return DOMString();
177  }
178  return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET);
179 }
180 
182 {
183  if (impl) {
184  ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value);
185  }
186 }
187 
188 // --------------------------------------------------------------------------
189 
190 HTMLImageElement::HTMLImageElement() : HTMLElement()
191 {
192 }
193 
194 HTMLImageElement::HTMLImageElement(const HTMLImageElement &other) : HTMLElement(other)
195 {
196 }
197 
198 HTMLImageElement::HTMLImageElement(HTMLImageElementImpl *impl) : HTMLElement(impl)
199 {
200 }
201 
202 HTMLImageElement &HTMLImageElement::operator = (const Node &other)
203 {
204  assignOther(other, ID_IMG);
205  return *this;
206 }
207 
208 HTMLImageElement &HTMLImageElement::operator = (const HTMLImageElement &other)
209 {
210  HTMLElement::operator = (other);
211  return *this;
212 }
213 
214 HTMLImageElement::~HTMLImageElement()
215 {
216 }
217 
219 {
220  if (!impl) {
221  return DOMString();
222  }
223  return ((ElementImpl *)impl)->getAttribute(ATTR_NAME);
224 }
225 
227 {
228  if (impl) {
229  ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value);
230  }
231 }
232 
234 {
235  if (!impl) {
236  return DOMString();
237  }
238  return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN);
239 }
240 
242 {
243  if (impl) {
244  ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value);
245  }
246 }
247 
249 {
250  if (!impl) {
251  return DOMString();
252  }
253  return ((ElementImpl *)impl)->getAttribute(ATTR_ALT);
254 }
255 
257 {
258  if (impl) {
259  ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value);
260  }
261 }
262 
263 #ifndef KHTML_NO_DEPRECATED
265 {
266  if (!impl) {
267  return 0;
268  }
269  // ### return value in pixels
270  return static_cast<HTMLImageElementImpl *>(impl)->getAttribute(ATTR_BORDER).toInt();
271 }
272 #endif
273 
274 #ifndef KHTML_NO_DEPRECATED
276 {
277  if (impl) {
278  static_cast<HTMLImageElementImpl *>(impl)->setAttribute(ATTR_BORDER, QString::number(value));
279  }
280 }
281 #endif
282 
284 {
285  if (!impl) {
286  return DOMString();
287  }
288  return static_cast<HTMLImageElementImpl *>(impl)->getAttribute(ATTR_BORDER);
289 }
290 
292 {
293  if (impl) {
294  static_cast<HTMLImageElementImpl *>(impl)->setAttribute(ATTR_BORDER, value);
295  }
296 }
297 
299 {
300  if (!impl) {
301  return 0;
302  }
303  return static_cast<HTMLImageElementImpl *>(impl)->height();
304 }
305 
307 {
308  if (impl) {
309  ((HTMLImageElementImpl *)impl)->setHeight(value);
310  }
311 }
312 
314 {
315  if (!impl) {
316  return 0;
317  }
318  // ### return actual value
319  return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE).toInt();
320 }
321 
323 {
324  if (impl) {
325  ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, QString::number(value));
326  }
327 }
328 
330 {
331  if (!impl) {
332  return 0;
333  }
334  return !((ElementImpl *)impl)->getAttribute(ATTR_ISMAP).isNull();
335 }
336 
337 void HTMLImageElement::setIsMap(bool _isMap)
338 {
339  if (impl) {
340  DOMString str;
341  if (_isMap) {
342  str = "";
343  }
344  ((ElementImpl *)impl)->setAttribute(ATTR_ISMAP, str);
345  }
346 }
347 
349 {
350  if (!impl) {
351  return DOMString();
352  }
353  return ((ElementImpl *)impl)->getAttribute(ATTR_LONGDESC);
354 }
355 
357 {
358  if (impl) {
359  ((ElementImpl *)impl)->setAttribute(ATTR_LONGDESC, value);
360  }
361 }
362 
364 {
365  if (!impl) {
366  return DOMString();
367  }
368  const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
369  return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
370 }
371 
373 {
374  if (impl) {
375  ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value);
376  }
377 }
378 
380 {
381  if (!impl) {
382  return DOMString();
383  }
384  return ((ElementImpl *)impl)->getAttribute(ATTR_USEMAP);
385 }
386 
388 {
389  if (impl) {
390  ((ElementImpl *)impl)->setAttribute(ATTR_USEMAP, value);
391  }
392 }
393 
395 {
396  if (!impl) {
397  return 0;
398  }
399  // ### return actual vspace
400  return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE).toInt();
401 }
402 
404 {
405  if (impl) {
406  static_cast<ElementImpl *>(impl)->setAttribute(ATTR_VSPACE, QString::number(value));
407  }
408 }
409 
411 {
412  if (!impl) {
413  return 0;
414  }
415  return static_cast<HTMLImageElementImpl *>(impl)->width();
416 }
417 
419 {
420  if (impl) {
421  ((HTMLImageElementImpl *)impl)->setWidth(value);
422  }
423 }
424 
426 {
427  if (impl) {
428  return static_cast<const HTMLImageElementImpl *>(impl)->x();
429  }
430  return 0;
431 }
432 
433 long HTMLImageElement::y() const
434 {
435  if (impl) {
436  return static_cast<const HTMLImageElementImpl *>(impl)->y();
437  }
438  return 0;
439 }
440 
441 // --------------------------------------------------------------------------
442 
443 HTMLMapElement::HTMLMapElement() : HTMLElement()
444 {
445 }
446 
447 HTMLMapElement::HTMLMapElement(const HTMLMapElement &other) : HTMLElement(other)
448 {
449 }
450 
451 HTMLMapElement::HTMLMapElement(HTMLMapElementImpl *impl) : HTMLElement(impl)
452 {
453 }
454 
455 HTMLMapElement &HTMLMapElement::operator = (const Node &other)
456 {
457  assignOther(other, ID_MAP);
458  return *this;
459 }
460 
461 HTMLMapElement &HTMLMapElement::operator = (const HTMLMapElement &other)
462 {
463  HTMLElement::operator = (other);
464  return *this;
465 }
466 
467 HTMLMapElement::~HTMLMapElement()
468 {
469 }
470 
472 {
473  if (!impl) {
474  return HTMLCollection();
475  }
476  return HTMLCollection(((HTMLMapElementImpl *)impl)->areas());
477 }
478 
480 {
481  if (!impl) {
482  return DOMString();
483  }
484  return ((ElementImpl *)impl)->getAttribute(ATTR_NAME);
485 }
486 
488 {
489  if (impl) {
490  ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value);
491  }
492 }
493 
void setSrc(const DOMString &)
see src
Definition: html_image.cpp:372
void setWidth(long)
see width
Definition: html_image.cpp:418
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
DOMString getBorder() const
Width of border around image.
Definition: html_image.cpp:283
long vspace() const
Vertical space above and below this image.
Definition: html_image.cpp:394
Client-side image map area definition.
Definition: html_image.h:46
void setAccessKey(const DOMString &)
see accessKey
Definition: html_image.cpp:70
void setHeight(long)
see height
Definition: html_image.cpp:306
bool isMap() const
Use server-side image map.
Definition: html_image.cpp:329
void setLongDesc(const DOMString &)
see longDesc
Definition: html_image.cpp:356
void setName(const DOMString &)
see name
Definition: html_image.cpp:487
DOMString align() const
Aligns this object (vertically or horizontally) with respect to its surrounding text.
Definition: html_image.cpp:233
void setCoords(const DOMString &)
see coords
Definition: html_image.cpp:100
void setAttribute(const DOMString &name, const DOMString &value)
Adds a new attribute.
DOMString alt() const
Alternate text for user agents not rendering the normal content of this element.
Definition: html_image.cpp:248
QString number(int n, int base)
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
long x() const
Nonstandard extension to DOM::ImgElement.
Definition: html_image.cpp:425
void setHref(const DOMString &)
see href
Definition: html_image.cpp:116
void setAlt(const DOMString &)
see alt
Definition: html_image.cpp:256
DOMString src() const
URI designating the source of this image.
Definition: html_image.cpp:363
long hspace() const
Horizontal space to the left and right of this image.
Definition: html_image.cpp:313
void setUseMap(const DOMString &)
see useMap
Definition: html_image.cpp:387
void setName(const DOMString &)
see name
Definition: html_image.cpp:226
DOMString name() const
Names the map (for use with usemap ).
Definition: html_image.cpp:479
DOMString target() const
Frame to render the resource in.
Definition: html_image.cpp:173
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
long tabIndex() const
Index that represents the element&#39;s position in the tabbing order.
Definition: html_image.cpp:157
Embedded image.
Definition: html_image.h:186
void setShape(const DOMString &)
see shape
Definition: html_image.cpp:150
DOMString longDesc() const
URI designating a long description of this image or frame.
Definition: html_image.cpp:348
DOMString coords() const
Comma-separated list of lengths, defining an active region geometry.
Definition: html_image.cpp:92
void setTabIndex(long)
see tabIndex
Definition: html_image.cpp:165
void setHspace(long)
see hspace
Definition: html_image.cpp:322
DOMString useMap() const
Use client-side image map.
Definition: html_image.cpp:379
long height() const
Override height.
Definition: html_image.cpp:298
This library provides a full-featured HTML parser and widget.
DOMString accessKey() const
A single character access key to give access to the form control.
Definition: html_image.cpp:62
DOMString href() const
The URI of the linked resource.
Definition: html_image.cpp:107
void setNoHref(bool)
see noHref
Definition: html_image.cpp:131
HTMLCollection areas() const
The list of areas defined for the image map.
Definition: html_image.cpp:471
void setAlign(const DOMString &)
see align
Definition: html_image.cpp:241
DOMString getAttribute(const DOMString &name)
Retrieves an attribute value by name.
DOMString name() const
The name of the element (for backwards compatibility).
Definition: html_image.cpp:218
bool noHref() const
Specifies that this area is inactive, i.e., has no associated action.
Definition: html_image.cpp:123
DOMString shape() const
The shape of the active area.
Definition: html_image.cpp:142
void setVspace(long)
see vspace
Definition: html_image.cpp:403
Client-side image map.
Definition: html_image.h:399
void setBorder(const DOMString &)
see border
Definition: html_image.cpp:291
KHTML_DEPRECATED long border() const
Definition: html_image.cpp:264
void setAlt(const DOMString &)
see alt
Definition: html_image.cpp:85
void setIsMap(bool)
see isMap
Definition: html_image.cpp:337
void setTarget(const DOMString &)
see target
Definition: html_image.cpp:181
All HTML element interfaces derive from this class.
Definition: html_element.h:70
DOMString alt() const
Alternate text for user agents not rendering the normal content of this element.
Definition: html_image.cpp:77
long width() const
Override width.
Definition: html_image.cpp:410
DOMString trimSpaces() const
Returns a string with Space Characters removed from the start and the end.
Definition: dom_string.cpp:345
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.