HTML_xxxx constants changed to wxHTML_xxxx (with backward compatibility through WXWIN...
[wxWidgets.git] / src / html / m_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_links.cpp
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <wx/wxprec.h>
15
16 #if wxUSE_HTML
17
18 #ifdef __BORDLANDC__
19 #pragma hdrstop
20 #endif
21
22 #ifndef WXPRECOMP
23 #include <wx/wx.h>
24 #endif
25
26
27 #include "wx/html/forcelnk.h"
28 #include "wx/html/m_templ.h"
29
30
31 FORCE_LINK_ME(mod_links)
32
33
34 class wxHtmlAnchorCell : public wxHtmlCell
35 {
36 private:
37 wxString m_AnchorName;
38
39 public:
40 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;}
41 virtual const wxHtmlCell* Find(int condition, const void* param) const
42 {
43 if ((condition == wxHTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param))))
44 return this;
45 else
46 return wxHtmlCell::Find(condition, param);
47 }
48 };
49
50
51
52 TAG_HANDLER_BEGIN(A, "A")
53
54 TAG_HANDLER_PROC(tag)
55 {
56 if (tag.HasParam("NAME")) {
57 m_WParser -> GetContainer() -> InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME")));
58 }
59
60 if (tag.HasParam("HREF")) {
61 wxString oldlnk = m_WParser -> GetLink();
62 wxColour oldclr = m_WParser -> GetActualColor();
63 int oldund = m_WParser -> GetFontUnderlined();
64
65 m_WParser -> SetActualColor(m_WParser -> GetLinkColor());
66 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(m_WParser -> GetLinkColor()));
67 m_WParser -> SetFontUnderlined(TRUE);
68 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
69 m_WParser -> SetLink(tag.GetParam("HREF"));
70
71 ParseInner(tag);
72
73 m_WParser -> SetLink(oldlnk);
74 m_WParser -> SetFontUnderlined(oldund);
75 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
76 m_WParser -> SetActualColor(oldclr);
77 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
78
79 return TRUE;
80 }
81 else return FALSE;
82 }
83
84 TAG_HANDLER_END(A)
85
86
87
88 TAGS_MODULE_BEGIN(Links)
89
90 TAGS_MODULE_ADD(A)
91
92 TAGS_MODULE_END(Links)
93
94
95 #endif