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