]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_links.cpp
don't compile generic wxMessageDialog w/ GTK+2, it's not used (forgot to commit this)
[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
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"
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),
44 wxHtmlRenderingState& WXUNUSED(state)) {}
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 }
5526e819
VS
58};
59
60
61
62TAG_HANDLER_BEGIN(A, "A")
63
64 TAG_HANDLER_PROC(tag)
65 {
2b5f62a0 66 if (tag.HasParam( wxT("NAME") ))
04dbb646 67 {
2b5f62a0 68 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
5526e819 69 }
f42b1601 70
2b5f62a0 71 if (tag.HasParam( wxT("HREF") ))
04dbb646 72 {
4f9297b0
VS
73 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
74 wxColour oldclr = m_WParser->GetActualColor();
75 int oldund = m_WParser->GetFontUnderlined();
2b5f62a0 76 wxString name(tag.GetParam( wxT("HREF") )), target;
5526e819 77
2b5f62a0 78 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
4f9297b0
VS
79 m_WParser->SetActualColor(m_WParser->GetLinkColor());
80 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
81 m_WParser->SetFontUnderlined(TRUE);
82 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
83 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
5526e819
VS
84
85 ParseInner(tag);
86
4f9297b0
VS
87 m_WParser->SetLink(oldlnk);
88 m_WParser->SetFontUnderlined(oldund);
89 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
90 m_WParser->SetActualColor(oldclr);
91 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
5526e819
VS
92
93 return TRUE;
94 }
95 else return FALSE;
96 }
97
98TAG_HANDLER_END(A)
99
100
101
102TAGS_MODULE_BEGIN(Links)
103
104 TAGS_MODULE_ADD(A)
105
106TAGS_MODULE_END(Links)
107
108
109#endif