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