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