1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
14 #include "wx/wxprec.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
26 #include "wx/html/forcelnk.h"
27 #include "wx/html/m_templ.h"
30 FORCE_LINK_ME(m_links
)
33 class wxHtmlAnchorCell
: public wxHtmlCell
36 wxString m_AnchorName
;
39 wxHtmlAnchorCell(const wxString
& name
) : wxHtmlCell() {m_AnchorName
= name
;}
40 virtual const wxHtmlCell
* Find(int condition
, const void* param
) const
42 if ((condition
== wxHTML_COND_ISANCHOR
) && (m_AnchorName
== (*((const wxString
*)param
))))
45 return wxHtmlCell::Find(condition
, param
);
51 TAG_HANDLER_BEGIN(A
, "A")
55 if (tag
.HasParam("NAME"))
57 m_WParser
->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag
.GetParam("NAME")));
60 if (tag
.HasParam("HREF"))
62 wxHtmlLinkInfo oldlnk
= m_WParser
->GetLink();
63 wxColour oldclr
= m_WParser
->GetActualColor();
64 int oldund
= m_WParser
->GetFontUnderlined();
65 wxString
name(tag
.GetParam("HREF")), target
;
67 if (tag
.HasParam("TARGET")) target
= tag
.GetParam("TARGET");
68 m_WParser
->SetActualColor(m_WParser
->GetLinkColor());
69 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser
->GetLinkColor()));
70 m_WParser
->SetFontUnderlined(TRUE
);
71 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
72 m_WParser
->SetLink(wxHtmlLinkInfo(name
, target
));
76 m_WParser
->SetLink(oldlnk
);
77 m_WParser
->SetFontUnderlined(oldund
);
78 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
79 m_WParser
->SetActualColor(oldclr
);
80 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr
));
91 TAGS_MODULE_BEGIN(Links
)
95 TAGS_MODULE_END(Links
)