]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_links.cpp
added wxTextCtrl::HitTest(); implemented it for MSW
[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
VS
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
3364ab79
RS
11#pragma implementation
12#endif
13
314260fb 14#include "wx/wxprec.h"
3364ab79 15
314260fb 16#include "wx/defs.h"
f6bcfd97 17#if wxUSE_HTML && wxUSE_STREAMS
5526e819 18
2b5f62a0 19#ifdef __BORLANDC__
3364ab79
RS
20#pragma hdrstop
21#endif
22
23#ifndef WXPRECOMP
3364ab79
RS
24#endif
25
69941f05
VS
26#include "wx/html/forcelnk.h"
27#include "wx/html/m_templ.h"
f42b1601 28
5526e819 29
c88293a4 30FORCE_LINK_ME(m_links)
5526e819
VS
31
32
33class wxHtmlAnchorCell : public wxHtmlCell
34{
36c4ff4d
VS
35private:
36 wxString m_AnchorName;
37
38public:
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),
e3ac6ee1 44 wxHtmlRenderingInfo& WXUNUSED(info)) {}
36c4ff4d
VS
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
5526e819 54 {
36c4ff4d 55 return wxHtmlCell::Find(condition, param);
f42b1601 56 }
36c4ff4d 57 }
fc7a2a60
VZ
58
59 DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell)
5526e819
VS
60};
61
62
63
64TAG_HANDLER_BEGIN(A, "A")
fc7a2a60 65 TAG_HANDLER_CONSTR(A) { }
5526e819
VS
66
67 TAG_HANDLER_PROC(tag)
68 {
2b5f62a0 69 if (tag.HasParam( wxT("NAME") ))
04dbb646 70 {
2b5f62a0 71 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
5526e819 72 }
f42b1601 73
2b5f62a0 74 if (tag.HasParam( wxT("HREF") ))
04dbb646 75 {
4f9297b0
VS
76 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
77 wxColour oldclr = m_WParser->GetActualColor();
78 int oldund = m_WParser->GetFontUnderlined();
2b5f62a0 79 wxString name(tag.GetParam( wxT("HREF") )), target;
5526e819 80
2b5f62a0 81 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
4f9297b0
VS
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));
5526e819
VS
87
88 ParseInner(tag);
89
4f9297b0
VS
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));
5526e819
VS
95
96 return TRUE;
97 }
98 else return FALSE;
99 }
100
101TAG_HANDLER_END(A)
102
103
104
105TAGS_MODULE_BEGIN(Links)
106
107 TAGS_MODULE_ADD(A)
108
109TAGS_MODULE_END(Links)
110
111
112#endif