1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: wxHtml module for links & anchors
4
// Author: Vaclav Slavik
5
// RCS-ID: $Id: m_links.cpp,v 1.16 2004/09/27 19:15:06 ABX Exp $
6
// Copyright: (c) 1999 Vaclav Slavik
7
// Licence: wxWindows licence
8
/////////////////////////////////////////////////////////////////////////////
10
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11
#pragma implementation
14
#include "wx/wxprec.h"
17
#if wxUSE_HTML && wxUSE_STREAMS
26
#include "wx/html/forcelnk.h"
27
#include "wx/html/m_templ.h"
30
FORCE_LINK_ME(m_links)
33
class wxHtmlAnchorCell : public wxHtmlCell
36
wxString m_AnchorName;
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)) {}
46
virtual const wxHtmlCell* Find(int condition, const void* param) const
48
if ((condition == wxHTML_COND_ISANCHOR) &&
49
(m_AnchorName == (*((const wxString*)param))))
55
return wxHtmlCell::Find(condition, param);
59
DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
64
TAG_HANDLER_BEGIN(A, "A")
65
TAG_HANDLER_CONSTR(A) { }
69
if (tag.HasParam( wxT("NAME") ))
71
m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
74
if (tag.HasParam( wxT("HREF") ))
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;
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));
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));
105
TAGS_MODULE_BEGIN(Links)
109
TAGS_MODULE_END(Links)