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