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