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