]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_links.cpp
added lowercase functionality to wxHexToDec
[wxWidgets.git] / src / html / m_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: m_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 #include "wx/defs.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
18
19 #ifdef __BORDLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WXPRECOMP
24 #include "wx/wx.h"
25 #endif
26
27
28 #include "wx/html/forcelnk.h"
29 #include "wx/html/m_templ.h"
30
31
32 FORCE_LINK_ME(m_links)
33
34
35 class wxHtmlAnchorCell : public wxHtmlCell
36 {
37 private:
38 wxString m_AnchorName;
39
40 public:
41 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;}
42 virtual const wxHtmlCell* Find(int condition, const void* param) const
43 {
44 if ((condition == wxHTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param))))
45 return this;
46 else
47 return wxHtmlCell::Find(condition, param);
48 }
49 };
50
51
52
53 TAG_HANDLER_BEGIN(A, "A")
54
55 TAG_HANDLER_PROC(tag)
56 {
57 if (tag.HasParam("NAME"))
58 {
59 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME")));
60 }
61
62 if (tag.HasParam("HREF"))
63 {
64 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
65 wxColour oldclr = m_WParser->GetActualColor();
66 int oldund = m_WParser->GetFontUnderlined();
67 wxString name(tag.GetParam("HREF")), target;
68
69 if (tag.HasParam("TARGET")) target = tag.GetParam("TARGET");
70 m_WParser->SetActualColor(m_WParser->GetLinkColor());
71 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
72 m_WParser->SetFontUnderlined(TRUE);
73 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
74 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
75
76 ParseInner(tag);
77
78 m_WParser->SetLink(oldlnk);
79 m_WParser->SetFontUnderlined(oldund);
80 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
81 m_WParser->SetActualColor(oldclr);
82 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
83
84 return TRUE;
85 }
86 else return FALSE;
87 }
88
89 TAG_HANDLER_END(A)
90
91
92
93 TAGS_MODULE_BEGIN(Links)
94
95 TAGS_MODULE_ADD(A)
96
97 TAGS_MODULE_END(Links)
98
99
100 #endif