]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_links.cpp
fix leak introduced by r53753
[wxWidgets.git] / src / html / m_links.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
93763ad5 2// Name: src/html/m_links.cpp
5526e819
VS
3// Purpose: wxHtml module for links & anchors
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819 6// Copyright: (c) 1999 Vaclav Slavik
65571936 7// Licence: wxWindows licence
5526e819
VS
8/////////////////////////////////////////////////////////////////////////////
9
314260fb 10#include "wx/wxprec.h"
3364ab79 11
2b5f62a0 12#ifdef __BORLANDC__
93763ad5 13 #pragma hdrstop
3364ab79
RS
14#endif
15
93763ad5
WS
16#if wxUSE_HTML && wxUSE_STREAMS
17
b4f4d3dd 18#ifndef WX_PRECOMP
3364ab79
RS
19#endif
20
69941f05
VS
21#include "wx/html/forcelnk.h"
22#include "wx/html/m_templ.h"
f42b1601 23
5526e819 24
c88293a4 25FORCE_LINK_ME(m_links)
5526e819
VS
26
27
28class wxHtmlAnchorCell : public wxHtmlCell
29{
36c4ff4d
VS
30private:
31 wxString m_AnchorName;
32
33public:
34 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell()
35 { m_AnchorName = name; }
36 void Draw(wxDC& WXUNUSED(dc),
37 int WXUNUSED(x), int WXUNUSED(y),
38 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
e3ac6ee1 39 wxHtmlRenderingInfo& WXUNUSED(info)) {}
36c4ff4d
VS
40
41 virtual const wxHtmlCell* Find(int condition, const void* param) const
42 {
d1da8872 43 if ((condition == wxHTML_COND_ISANCHOR) &&
36c4ff4d
VS
44 (m_AnchorName == (*((const wxString*)param))))
45 {
46 return this;
47 }
48 else
5526e819 49 {
36c4ff4d 50 return wxHtmlCell::Find(condition, param);
f42b1601 51 }
36c4ff4d 52 }
fc7a2a60
VZ
53
54 DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
5526e819
VS
55};
56
57
58
59TAG_HANDLER_BEGIN(A, "A")
fc7a2a60 60 TAG_HANDLER_CONSTR(A) { }
5526e819
VS
61
62 TAG_HANDLER_PROC(tag)
63 {
2b5f62a0 64 if (tag.HasParam( wxT("NAME") ))
04dbb646 65 {
2b5f62a0 66 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
5526e819 67 }
f42b1601 68
2b5f62a0 69 if (tag.HasParam( wxT("HREF") ))
04dbb646 70 {
4f9297b0
VS
71 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
72 wxColour oldclr = m_WParser->GetActualColor();
73 int oldund = m_WParser->GetFontUnderlined();
2b5f62a0 74 wxString name(tag.GetParam( wxT("HREF") )), target;
5526e819 75
2b5f62a0 76 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
4f9297b0
VS
77 m_WParser->SetActualColor(m_WParser->GetLinkColor());
78 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
d1da8872 79 m_WParser->SetFontUnderlined(true);
4f9297b0
VS
80 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
81 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
5526e819
VS
82
83 ParseInner(tag);
84
4f9297b0
VS
85 m_WParser->SetLink(oldlnk);
86 m_WParser->SetFontUnderlined(oldund);
87 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
88 m_WParser->SetActualColor(oldclr);
89 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
5526e819 90
d1da8872 91 return true;
5526e819 92 }
d1da8872 93 else return false;
5526e819
VS
94 }
95
96TAG_HANDLER_END(A)
97
98
99
100TAGS_MODULE_BEGIN(Links)
101
102 TAGS_MODULE_ADD(A)
103
104TAGS_MODULE_END(Links)
105
106
107#endif