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