No changes, just remove an extra pair of braces in wxHTML code.
[wxWidgets.git] / src / html / m_image.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_image.cpp
3 // Purpose: wxHtml module for displaying images
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik, Joel Lucsy
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/wxprec.h"
11
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15
16 #if wxUSE_HTML && wxUSE_STREAMS
17
18 #ifndef WX_PRECOMP
19 #include "wx/dynarray.h"
20 #include "wx/dc.h"
21 #include "wx/scrolwin.h"
22 #include "wx/timer.h"
23 #include "wx/dcmemory.h"
24 #include "wx/log.h"
25 #include "wx/math.h"
26 #include "wx/image.h"
27 #include "wx/wxcrtvararg.h"
28 #endif
29
30 #include "wx/html/forcelnk.h"
31 #include "wx/html/m_templ.h"
32 #include "wx/html/htmlwin.h"
33
34 #include "wx/gifdecod.h"
35 #include "wx/artprov.h"
36
37 #include <float.h>
38
39 FORCE_LINK_ME(m_image)
40
41
42
43
44 WX_DECLARE_OBJARRAY(int, CoordArray);
45 #include "wx/arrimpl.cpp" // this is a magic incantation which must be done!
46 WX_DEFINE_OBJARRAY(CoordArray)
47
48
49 // ---------------------------------------------------------------------------
50 // wxHtmlImageMapAreaCell
51 // 0-width, 0-height cell that represents single area in
52 // imagemap (it's GetLink is called from wxHtmlImageCell's)
53 // ---------------------------------------------------------------------------
54
55 class wxHtmlImageMapAreaCell : public wxHtmlCell
56 {
57 public:
58 enum celltype { CIRCLE, RECT, POLY };
59 protected:
60 CoordArray coords;
61 celltype type;
62 int radius;
63 public:
64 wxHtmlImageMapAreaCell( celltype t, wxString &coords, double pixel_scale = 1.0);
65 virtual wxHtmlLinkInfo *GetLink( int x = 0, int y = 0 ) const;
66 void Draw(wxDC& WXUNUSED(dc),
67 int WXUNUSED(x), int WXUNUSED(y),
68 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
69 wxHtmlRenderingInfo& WXUNUSED(info)) {}
70
71
72 wxDECLARE_NO_COPY_CLASS(wxHtmlImageMapAreaCell);
73 };
74
75
76
77
78
79 wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype t, wxString &incoords, double pixel_scale )
80 {
81 int i;
82 wxString x = incoords, y;
83
84 type = t;
85 while ((i = x.Find( ',' )) != wxNOT_FOUND)
86 {
87 coords.Add( (int)(pixel_scale * (double)wxAtoi( x.Left( i ).c_str())) );
88 x = x.Mid( i + 1 );
89 }
90 coords.Add( (int)(pixel_scale * (double)wxAtoi( x.c_str())) );
91 }
92
93 wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
94 {
95 switch (type)
96 {
97 case RECT:
98 {
99 int l, t, r, b;
100
101 l = coords[ 0 ];
102 t = coords[ 1 ];
103 r = coords[ 2 ];
104 b = coords[ 3 ];
105 if (x >= l && x <= r && y >= t && y <= b)
106 {
107 return m_Link;
108 }
109 break;
110 }
111 case CIRCLE:
112 {
113 int l, t, r;
114 double d;
115
116 l = coords[ 0 ];
117 t = coords[ 1 ];
118 r = coords[ 2 ];
119 d = sqrt( (double) (((x - l) * (x - l)) + ((y - t) * (y - t))) );
120 if (d < (double)r)
121 {
122 return m_Link;
123 }
124 }
125 break;
126 case POLY:
127 if (coords.GetCount() >= 6)
128 {
129 int intersects = 0;
130 int wherex = x;
131 int wherey = y;
132 int totalv = coords.GetCount() / 2;
133 int totalc = totalv * 2;
134 int xval = coords[totalc - 2];
135 int yval = coords[totalc - 1];
136 int end = totalc;
137 int pointer = 1;
138
139 if ((yval >= wherey) != (coords[pointer] >= wherey))
140 {
141 if ((xval >= wherex) == (coords[0] >= wherex))
142 {
143 intersects += (xval >= wherex) ? 1 : 0;
144 }
145 else
146 {
147 intersects += ((xval - (yval - wherey) *
148 (coords[0] - xval) /
149 (coords[pointer] - yval)) >= wherex) ? 1 : 0;
150 }
151 }
152
153 while (pointer < end)
154 {
155 yval = coords[pointer];
156 pointer += 2;
157 if (yval >= wherey)
158 {
159 while ((pointer < end) && (coords[pointer] >= wherey))
160 {
161 pointer += 2;
162 }
163 if (pointer >= end)
164 {
165 break;
166 }
167 if ((coords[pointer - 3] >= wherex) ==
168 (coords[pointer - 1] >= wherex)) {
169 intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
170 }
171 else
172 {
173 intersects +=
174 ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
175 (coords[pointer - 1] - coords[pointer - 3]) /
176 (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
177 }
178 }
179 else
180 {
181 while ((pointer < end) && (coords[pointer] < wherey))
182 {
183 pointer += 2;
184 }
185 if (pointer >= end)
186 {
187 break;
188 }
189 if ((coords[pointer - 3] >= wherex) ==
190 (coords[pointer - 1] >= wherex))
191 {
192 intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
193 }
194 else
195 {
196 intersects +=
197 ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
198 (coords[pointer - 1] - coords[pointer - 3]) /
199 (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
200 }
201 }
202 }
203 if ((intersects & 1) != 0)
204 {
205 return m_Link;
206 }
207 }
208 break;
209 }
210
211 if (m_Next)
212 {
213 wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next;
214 return a->GetLink( x, y );
215 }
216 return NULL;
217 }
218
219
220
221
222
223
224
225
226 //--------------------------------------------------------------------------------
227 // wxHtmlImageMapCell
228 // 0-width, 0-height cell that represents map from imagemaps
229 // it is always placed before wxHtmlImageMapAreaCells
230 // It responds to Find(wxHTML_COND_ISIMAGEMAP)
231 //--------------------------------------------------------------------------------
232
233
234 class wxHtmlImageMapCell : public wxHtmlCell
235 {
236 public:
237 wxHtmlImageMapCell( wxString &name );
238 protected:
239 wxString m_Name;
240 public:
241 virtual wxHtmlLinkInfo *GetLink( int x = 0, int y = 0 ) const;
242 virtual const wxHtmlCell *Find( int cond, const void *param ) const;
243 void Draw(wxDC& WXUNUSED(dc),
244 int WXUNUSED(x), int WXUNUSED(y),
245 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
246 wxHtmlRenderingInfo& WXUNUSED(info)) {}
247
248 wxDECLARE_NO_COPY_CLASS(wxHtmlImageMapCell);
249 };
250
251
252 wxHtmlImageMapCell::wxHtmlImageMapCell( wxString &name )
253 {
254 m_Name = name ;
255 }
256
257 wxHtmlLinkInfo *wxHtmlImageMapCell::GetLink( int x, int y ) const
258 {
259 wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next;
260 if (a)
261 return a->GetLink( x, y );
262 return wxHtmlCell::GetLink( x, y );
263 }
264
265 const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const
266 {
267 if (cond == wxHTML_COND_ISIMAGEMAP)
268 {
269 if (m_Name == *((wxString*)(param)))
270 return this;
271 }
272 return wxHtmlCell::Find(cond, param);
273 }
274
275
276
277
278
279 //--------------------------------------------------------------------------------
280 // wxHtmlImageCell
281 // Image/bitmap
282 //--------------------------------------------------------------------------------
283
284 class wxHtmlImageCell : public wxHtmlCell
285 {
286 public:
287 wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
288 wxFSFile *input,
289 int w = wxDefaultCoord, bool wpercent = false,
290 int h = wxDefaultCoord, bool hpresent = false,
291 double scale = 1.0, int align = wxHTML_ALIGN_BOTTOM,
292 const wxString& mapname = wxEmptyString);
293 virtual ~wxHtmlImageCell();
294 void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
295 wxHtmlRenderingInfo& info);
296 virtual wxHtmlLinkInfo *GetLink(int x = 0, int y = 0) const;
297
298 void SetImage(const wxImage& img);
299
300 // If "alt" text is set, it will be used when converting this cell to text.
301 void SetAlt(const wxString& alt);
302 virtual wxString ConvertToText(wxHtmlSelection *sel) const;
303
304 #if wxUSE_GIF && wxUSE_TIMER
305 void AdvanceAnimation(wxTimer *timer);
306 virtual void Layout(int w);
307 #endif
308
309 private:
310 wxBitmap *m_bitmap;
311 int m_align;
312 int m_bmpW, m_bmpH;
313 bool m_bmpWpercent:1;
314 bool m_bmpHpresent:1;
315 bool m_showFrame:1;
316 wxHtmlWindowInterface *m_windowIface;
317 #if wxUSE_GIF && wxUSE_TIMER
318 wxGIFDecoder *m_gifDecoder;
319 wxTimer *m_gifTimer;
320 int m_physX, m_physY;
321 size_t m_nCurrFrame;
322 #endif
323 double m_scale;
324 wxHtmlImageMapCell *m_imageMap;
325 wxString m_mapName;
326 wxString m_alt;
327
328 wxDECLARE_NO_COPY_CLASS(wxHtmlImageCell);
329 };
330
331 #if wxUSE_GIF && wxUSE_TIMER
332 class wxGIFTimer : public wxTimer
333 {
334 public:
335 wxGIFTimer(wxHtmlImageCell *cell) : m_cell(cell) {}
336 virtual void Notify()
337 {
338 m_cell->AdvanceAnimation(this);
339 }
340
341 private:
342 wxHtmlImageCell *m_cell;
343
344 wxDECLARE_NO_COPY_CLASS(wxGIFTimer);
345 };
346 #endif
347
348
349 //----------------------------------------------------------------------------
350 // wxHtmlImageCell
351 //----------------------------------------------------------------------------
352
353
354 wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
355 wxFSFile *input,
356 int w, bool wpercent, int h, bool hpresent, double scale, int align,
357 const wxString& mapname) : wxHtmlCell()
358 {
359 m_windowIface = windowIface;
360 m_scale = scale;
361 m_showFrame = false;
362 m_bitmap = NULL;
363 m_bmpW = w;
364 m_bmpH = h;
365 m_align = align;
366 m_bmpWpercent = wpercent;
367 m_bmpHpresent = hpresent;
368 m_imageMap = NULL;
369 m_mapName = mapname;
370 SetCanLiveOnPagebreak(false);
371 #if wxUSE_GIF && wxUSE_TIMER
372 m_gifDecoder = NULL;
373 m_gifTimer = NULL;
374 m_physX = m_physY = wxDefaultCoord;
375 m_nCurrFrame = 0;
376 #endif
377
378 if ( m_bmpW && m_bmpH )
379 {
380 if ( input )
381 {
382 wxInputStream *s = input->GetStream();
383
384 if ( s )
385 {
386 #if wxUSE_GIF && wxUSE_TIMER
387 bool readImg = true;
388 if ( m_windowIface &&
389 (input->GetLocation().Matches(wxT("*.gif")) ||
390 input->GetLocation().Matches(wxT("*.GIF"))) )
391 {
392 m_gifDecoder = new wxGIFDecoder();
393 if ( m_gifDecoder->LoadGIF(*s) == wxGIF_OK )
394 {
395 wxImage img;
396 if ( m_gifDecoder->ConvertToImage(0, &img) )
397 SetImage(img);
398
399 readImg = false;
400
401 if ( m_gifDecoder->IsAnimation() )
402 {
403 m_gifTimer = new wxGIFTimer(this);
404 long delay = m_gifDecoder->GetDelay(0);
405 if ( delay == 0 )
406 delay = 1;
407 m_gifTimer->Start(delay, true);
408 }
409 else
410 {
411 wxDELETE(m_gifDecoder);
412 }
413 }
414 else
415 {
416 wxDELETE(m_gifDecoder);
417 }
418 }
419
420 if ( readImg )
421 #endif // wxUSE_GIF && wxUSE_TIMER
422 {
423 wxImage image(*s, wxBITMAP_TYPE_ANY);
424 if ( image.IsOk() )
425 SetImage(image);
426 }
427 }
428 }
429 else // input==NULL, use "broken image" bitmap
430 {
431 if ( m_bmpW == wxDefaultCoord && m_bmpH == wxDefaultCoord )
432 {
433 m_bmpW = 29;
434 m_bmpH = 31;
435 }
436 else
437 {
438 m_showFrame = true;
439 if ( m_bmpW == wxDefaultCoord ) m_bmpW = 31;
440 if ( m_bmpH == wxDefaultCoord ) m_bmpH = 33;
441 }
442 m_bitmap =
443 new wxBitmap(wxArtProvider::GetBitmap(wxART_MISSING_IMAGE));
444 }
445 }
446 //else: ignore the 0-sized images used sometimes on the Web pages
447
448 }
449
450 void wxHtmlImageCell::SetImage(const wxImage& img)
451 {
452 #if !defined(__WXMSW__) || wxUSE_WXDIB
453 if ( img.IsOk() )
454 {
455 delete m_bitmap;
456
457 int ww, hh;
458 ww = img.GetWidth();
459 hh = img.GetHeight();
460
461 if ( m_bmpW == wxDefaultCoord)
462 m_bmpW = ww;
463 if ( m_bmpH == wxDefaultCoord)
464 m_bmpH = hh;
465
466 // Only scale the bitmap at the rendering stage,
467 // so we don't lose quality twice
468 /*
469 if ((m_bmpW != ww) || (m_bmpH != hh))
470 {
471 wxImage img2 = img.Scale(m_bmpW, m_bmpH);
472 m_bitmap = new wxBitmap(img2);
473 }
474 else
475 */
476 m_bitmap = new wxBitmap(img);
477 }
478 #endif
479 }
480
481 void wxHtmlImageCell::SetAlt(const wxString& alt)
482 {
483 m_alt = alt;
484 }
485
486 wxString wxHtmlImageCell::ConvertToText(wxHtmlSelection* WXUNUSED(sel)) const
487 {
488 return m_alt;
489 }
490
491 #if wxUSE_GIF && wxUSE_TIMER
492 void wxHtmlImageCell::AdvanceAnimation(wxTimer *timer)
493 {
494 wxImage img;
495
496 // advance current frame
497 m_nCurrFrame++;
498 if (m_nCurrFrame == m_gifDecoder->GetFrameCount())
499 m_nCurrFrame = 0;
500
501 if ( m_physX == wxDefaultCoord )
502 {
503 m_physX = m_physY = 0;
504 for (wxHtmlCell *cell = this; cell; cell = cell->GetParent())
505 {
506 m_physX += cell->GetPosX();
507 m_physY += cell->GetPosY();
508 }
509 }
510
511 wxWindow *win = m_windowIface->GetHTMLWindow();
512 wxPoint pos =
513 m_windowIface->HTMLCoordsToWindow(this, wxPoint(m_physX, m_physY));
514 wxRect rect(pos, wxSize(m_Width, m_Height));
515
516 if ( win->GetClientRect().Intersects(rect) &&
517 m_gifDecoder->ConvertToImage(m_nCurrFrame, &img) )
518 {
519 #if !defined(__WXMSW__) || wxUSE_WXDIB
520 if ( m_gifDecoder->GetFrameSize(m_nCurrFrame) != wxSize(m_Width, m_Height) ||
521 m_gifDecoder->GetFramePosition(m_nCurrFrame) != wxPoint(0, 0) )
522 {
523 wxBitmap bmp(img);
524 wxMemoryDC dc;
525 dc.SelectObject(*m_bitmap);
526 dc.DrawBitmap(bmp, m_gifDecoder->GetFramePosition(m_nCurrFrame),
527 true /* use mask */);
528 }
529 else
530 #endif
531 SetImage(img);
532 win->Refresh(img.HasMask(), &rect);
533 }
534
535 long delay = m_gifDecoder->GetDelay(m_nCurrFrame);
536 if ( delay == 0 )
537 delay = 1;
538 timer->Start(delay, true);
539 }
540
541 void wxHtmlImageCell::Layout(int w)
542 {
543 if (m_bmpWpercent)
544 {
545
546 m_Width = w*m_bmpW/100;
547
548 if (!m_bmpHpresent && m_bitmap != NULL)
549 m_Height = m_bitmap->GetHeight()*m_Width/m_bitmap->GetWidth();
550 else
551 m_Height = static_cast<int>(m_scale*m_bmpH);
552 } else
553 {
554 m_Width = static_cast<int>(m_scale*m_bmpW);
555 m_Height = static_cast<int>(m_scale*m_bmpH);
556 }
557
558 switch (m_align)
559 {
560 case wxHTML_ALIGN_TOP :
561 m_Descent = m_Height;
562 break;
563 case wxHTML_ALIGN_CENTER :
564 m_Descent = m_Height / 2;
565 break;
566 case wxHTML_ALIGN_BOTTOM :
567 default :
568 m_Descent = 0;
569 break;
570 }
571
572 wxHtmlCell::Layout(w);
573 m_physX = m_physY = wxDefaultCoord;
574 }
575
576 #endif
577
578 wxHtmlImageCell::~wxHtmlImageCell()
579 {
580 delete m_bitmap;
581 #if wxUSE_GIF && wxUSE_TIMER
582 delete m_gifTimer;
583 delete m_gifDecoder;
584 #endif
585 }
586
587
588 void wxHtmlImageCell::Draw(wxDC& dc, int x, int y,
589 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
590 wxHtmlRenderingInfo& WXUNUSED(info))
591 {
592 if ( m_showFrame )
593 {
594 dc.SetBrush(*wxTRANSPARENT_BRUSH);
595 dc.SetPen(*wxBLACK_PEN);
596 dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height);
597 x++, y++;
598 }
599 if ( m_bitmap )
600 {
601 // We add in the scaling from the desired bitmap width
602 // and height, so we only do the scaling once.
603 double imageScaleX = 1.0;
604 double imageScaleY = 1.0;
605 if (m_Width != m_bitmap->GetWidth())
606 imageScaleX = (double) m_Width / (double) m_bitmap->GetWidth();
607 if (m_Height != m_bitmap->GetHeight())
608 imageScaleY = (double) m_Height / (double) m_bitmap->GetHeight();
609
610 double us_x, us_y;
611 dc.GetUserScale(&us_x, &us_y);
612 dc.SetUserScale(us_x * imageScaleX, us_y * imageScaleY);
613
614 dc.DrawBitmap(*m_bitmap, (int) ((x + m_PosX) / (imageScaleX)),
615 (int) ((y + m_PosY) / (imageScaleY)), true);
616 dc.SetUserScale(us_x, us_y);
617 }
618 }
619
620 wxHtmlLinkInfo *wxHtmlImageCell::GetLink( int x, int y ) const
621 {
622 if (m_mapName.empty())
623 return wxHtmlCell::GetLink( x, y );
624 if (!m_imageMap)
625 {
626 wxHtmlContainerCell *p, *op;
627 op = p = GetParent();
628 while (p)
629 {
630 op = p;
631 p = p->GetParent();
632 }
633 p = op;
634 wxHtmlCell *cell = (wxHtmlCell*)p->Find(wxHTML_COND_ISIMAGEMAP,
635 (const void*)(&m_mapName));
636 if (!cell)
637 {
638 ((wxString&)m_mapName).Clear();
639 return wxHtmlCell::GetLink( x, y );
640 }
641 { // dirty hack, ask Joel why he fills m_ImageMap in this place
642 // THE problem is that we're in const method and we can't modify m_ImageMap
643 wxHtmlImageMapCell **cx = (wxHtmlImageMapCell**)(&m_imageMap);
644 *cx = (wxHtmlImageMapCell*)cell;
645 }
646 }
647 return m_imageMap->GetLink(x, y);
648 }
649
650
651
652 //--------------------------------------------------------------------------------
653 // tag handler
654 //--------------------------------------------------------------------------------
655
656 TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
657 TAG_HANDLER_CONSTR(IMG) { }
658
659 TAG_HANDLER_PROC(tag)
660 {
661 if (tag.GetName() == wxT("IMG"))
662 {
663 if (tag.HasParam(wxT("SRC")))
664 {
665 int w = wxDefaultCoord, h = wxDefaultCoord;
666 bool wpercent = false;
667 bool hpresent = false;
668 int al;
669 wxFSFile *str;
670 wxString tmp = tag.GetParam(wxT("SRC"));
671 wxString mn = wxEmptyString;
672
673 str = m_WParser->OpenURL(wxHTML_URL_IMAGE, tmp);
674
675 if (tag.HasParam(wxT("WIDTH")))
676 {
677 if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &w, wpercent))
678 {
679 if (wpercent)
680 {
681 if (w < 0)
682 w = 0;
683 else if (w > 100)
684 w = 100;
685 }
686 }
687 }
688
689 if (tag.HasParam(wxT("HEIGHT")))
690 {
691 tag.GetParamAsInt(wxT("HEIGHT"), &h);
692 hpresent = true;
693 }
694
695 al = wxHTML_ALIGN_BOTTOM;
696 if (tag.HasParam(wxT("ALIGN")))
697 {
698 wxString alstr = tag.GetParam(wxT("ALIGN"));
699 alstr.MakeUpper(); // for the case alignment was in ".."
700 if (alstr == wxT("TEXTTOP"))
701 al = wxHTML_ALIGN_TOP;
702 else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))
703 al = wxHTML_ALIGN_CENTER;
704 }
705 if (tag.HasParam(wxT("USEMAP")))
706 {
707 mn = tag.GetParam( wxT("USEMAP") );
708 if ( !mn.empty() && *mn.begin() == '#' )
709 {
710 mn = mn.Mid( 1 );
711 }
712 }
713 wxHtmlImageCell *cel = new wxHtmlImageCell(
714 m_WParser->GetWindowInterface(),
715 str, w, wpercent, h, hpresent,
716 m_WParser->GetPixelScale(),
717 al, mn);
718 m_WParser->ApplyStateToCell(cel);
719 m_WParser->StopCollapsingSpaces();
720 cel->SetId(tag.GetParam(wxT("id"))); // may be empty
721 cel->SetAlt(tag.GetParam(wxT("alt")));
722 m_WParser->GetContainer()->InsertCell(cel);
723 if (str)
724 delete str;
725 }
726 }
727 if (tag.GetName() == wxT("MAP"))
728 {
729 m_WParser->CloseContainer();
730 m_WParser->OpenContainer();
731 if (tag.HasParam(wxT("NAME")))
732 {
733 wxString tmp = tag.GetParam(wxT("NAME"));
734 wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp );
735 m_WParser->GetContainer()->InsertCell( cel );
736 }
737 ParseInner( tag );
738 m_WParser->CloseContainer();
739 m_WParser->OpenContainer();
740 }
741 if (tag.GetName() == wxT("AREA"))
742 {
743 if (tag.HasParam(wxT("SHAPE")))
744 {
745 wxString tmp = tag.GetParam(wxT("SHAPE"));
746 wxString coords = wxEmptyString;
747 tmp.MakeUpper();
748 wxHtmlImageMapAreaCell *cel = NULL;
749 if (tag.HasParam(wxT("COORDS")))
750 {
751 coords = tag.GetParam(wxT("COORDS"));
752 }
753 if (tmp == wxT("POLY"))
754 {
755 cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords, m_WParser->GetPixelScale() );
756 }
757 else if (tmp == wxT("CIRCLE"))
758 {
759 cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords, m_WParser->GetPixelScale() );
760 }
761 else if (tmp == wxT("RECT"))
762 {
763 cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords, m_WParser->GetPixelScale() );
764 }
765 if (cel != NULL && tag.HasParam(wxT("HREF")))
766 {
767 wxString target;
768 if (tag.HasParam(wxT("TARGET")))
769 target = tag.GetParam(wxT("TARGET"));
770 cel->SetLink(wxHtmlLinkInfo(tag.GetParam(wxT("HREF")), target));
771 }
772 if (cel != NULL)
773 m_WParser->GetContainer()->InsertCell( cel );
774 }
775 }
776
777 return false;
778 }
779
780 TAG_HANDLER_END(IMG)
781
782
783
784 TAGS_MODULE_BEGIN(Image)
785
786 TAGS_MODULE_ADD(IMG)
787
788 TAGS_MODULE_END(Image)
789
790
791 #endif