]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_links.cpp
removed #errors in 2.7 compilation
[wxWidgets.git] / src / html / m_links.cpp
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
c88293a4 2// Name: m_links.cpp
5526e819
VS
3// Purpose: wxHtml module for links & anchors
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819 6// Copyright: (c) 1999 Vaclav Slavik
65571936 7// Licence: wxWindows licence
5526e819
VS
8/////////////////////////////////////////////////////////////////////////////
9
314260fb 10#include "wx/wxprec.h"
3364ab79 11
314260fb 12#include "wx/defs.h"
f6bcfd97 13#if wxUSE_HTML && wxUSE_STREAMS
5526e819 14
2b5f62a0 15#ifdef __BORLANDC__
3364ab79
RS
16#pragma hdrstop
17#endif
18
19#ifndef WXPRECOMP
3364ab79
RS
20#endif
21
69941f05
VS
22#include "wx/html/forcelnk.h"
23#include "wx/html/m_templ.h"
f42b1601 24
5526e819 25
c88293a4 26FORCE_LINK_ME(m_links)
5526e819
VS
27
28
29class wxHtmlAnchorCell : public wxHtmlCell
30{
36c4ff4d
VS
31private:
32 wxString m_AnchorName;
33
34public:
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),
e3ac6ee1 40 wxHtmlRenderingInfo& WXUNUSED(info)) {}
36c4ff4d
VS
41
42 virtual const wxHtmlCell* Find(int condition, const void* param) const
43 {
d1da8872 44 if ((condition == wxHTML_COND_ISANCHOR) &&
36c4ff4d
VS
45 (m_AnchorName == (*((const wxString*)param))))
46 {
47 return this;
48 }
49 else
5526e819 50 {
36c4ff4d 51 return wxHtmlCell::Find(condition, param);
f42b1601 52 }
36c4ff4d 53 }
fc7a2a60
VZ
54
55 DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
5526e819
VS
56};
57
58
59
60TAG_HANDLER_BEGIN(A, "A")
fc7a2a60 61 TAG_HANDLER_CONSTR(A) { }
5526e819
VS
62
63 TAG_HANDLER_PROC(tag)
64 {
2b5f62a0 65 if (tag.HasParam( wxT("NAME") ))
04dbb646 66 {
2b5f62a0 67 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
5526e819 68 }
f42b1601 69
2b5f62a0 70 if (tag.HasParam( wxT("HREF") ))
04dbb646 71 {
4f9297b0
VS
72 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
73 wxColour oldclr = m_WParser->GetActualColor();
74 int oldund = m_WParser->GetFontUnderlined();
2b5f62a0 75 wxString name(tag.GetParam( wxT("HREF") )), target;
5526e819 76
2b5f62a0 77 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
4f9297b0
VS
78 m_WParser->SetActualColor(m_WParser->GetLinkColor());
79 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
d1da8872 80 m_WParser->SetFontUnderlined(true);
4f9297b0
VS
81 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
82 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
5526e819
VS
83
84 ParseInner(tag);
85
4f9297b0
VS
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));
5526e819 91
d1da8872 92 return true;
5526e819 93 }
d1da8872 94 else return false;
5526e819
VS
95 }
96
97TAG_HANDLER_END(A)
98
99
100
101TAGS_MODULE_BEGIN(Links)
102
103 TAGS_MODULE_ADD(A)
104
105TAGS_MODULE_END(Links)
106
107
108#endif