]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_links.cpp
Rebake after adding libs html and xml to samples using lib adv
[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 #include "wx/wxprec.h"
11
12 #include "wx/defs.h"
13 #if wxUSE_HTML && wxUSE_STREAMS
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WXPRECOMP
20 #endif
21
22 #include "wx/html/forcelnk.h"
23 #include "wx/html/m_templ.h"
24
25
26 FORCE_LINK_ME(m_links)
27
28
29 class wxHtmlAnchorCell : public wxHtmlCell
30 {
31 private:
32 wxString m_AnchorName;
33
34 public:
35 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell()
36 { m_AnchorName = name; }
37 void Draw(wxDC& WXUNUSED(dc),
38 int WXUNUSED(x), int WXUNUSED(y),
39 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
40 wxHtmlRenderingInfo& WXUNUSED(info)) {}
41
42 virtual const wxHtmlCell* Find(int condition, const void* param) const
43 {
44 if ((condition == wxHTML_COND_ISANCHOR) &&
45 (m_AnchorName == (*((const wxString*)param))))
46 {
47 return this;
48 }
49 else
50 {
51 return wxHtmlCell::Find(condition, param);
52 }
53 }
54
55 DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
56 };
57
58
59
60 TAG_HANDLER_BEGIN(A, "A")
61 TAG_HANDLER_CONSTR(A) { }
62
63 TAG_HANDLER_PROC(tag)
64 {
65 if (tag.HasParam( wxT("NAME") ))
66 {
67 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
68 }
69
70 if (tag.HasParam( wxT("HREF") ))
71 {
72 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
73 wxColour oldclr = m_WParser->GetActualColor();
74 int oldund = m_WParser->GetFontUnderlined();
75 wxString name(tag.GetParam( wxT("HREF") )), target;
76
77 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
78 m_WParser->SetActualColor(m_WParser->GetLinkColor());
79 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
80 m_WParser->SetFontUnderlined(true);
81 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
82 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
83
84 ParseInner(tag);
85
86 m_WParser->SetLink(oldlnk);
87 m_WParser->SetFontUnderlined(oldund);
88 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
89 m_WParser->SetActualColor(oldclr);
90 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
91
92 return true;
93 }
94 else return false;
95 }
96
97 TAG_HANDLER_END(A)
98
99
100
101 TAGS_MODULE_BEGIN(Links)
102
103 TAGS_MODULE_ADD(A)
104
105 TAGS_MODULE_END(Links)
106
107
108 #endif