]> git.saurik.com Git - wxWidgets.git/blame - src/html/m_links.cpp
Buttons need to be small on PDAs.
[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
3364ab79
RS
19#ifdef __BORDLANDC__
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{
35 private:
36 wxString m_AnchorName;
f42b1601 37
5526e819
VS
38 public:
39 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;}
40 virtual const wxHtmlCell* Find(int condition, const void* param) const
41 {
efba2b89 42 if ((condition == wxHTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param))))
5526e819 43 return this;
f42b1601 44 else
5526e819 45 return wxHtmlCell::Find(condition, param);
f42b1601 46 }
5526e819
VS
47};
48
49
50
51TAG_HANDLER_BEGIN(A, "A")
52
53 TAG_HANDLER_PROC(tag)
54 {
4f9297b0 55 if (tag.HasParam("NAME"))
04dbb646 56 {
4f9297b0 57 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME")));
5526e819 58 }
f42b1601 59
04dbb646
VZ
60 if (tag.HasParam("HREF"))
61 {
4f9297b0
VS
62 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
63 wxColour oldclr = m_WParser->GetActualColor();
64 int oldund = m_WParser->GetFontUnderlined();
846914d1 65 wxString name(tag.GetParam("HREF")), target;
5526e819 66
846914d1 67 if (tag.HasParam("TARGET")) target = tag.GetParam("TARGET");
4f9297b0
VS
68 m_WParser->SetActualColor(m_WParser->GetLinkColor());
69 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
70 m_WParser->SetFontUnderlined(TRUE);
71 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
72 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
5526e819
VS
73
74 ParseInner(tag);
75
4f9297b0
VS
76 m_WParser->SetLink(oldlnk);
77 m_WParser->SetFontUnderlined(oldund);
78 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
79 m_WParser->SetActualColor(oldclr);
80 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
5526e819
VS
81
82 return TRUE;
83 }
84 else return FALSE;
85 }
86
87TAG_HANDLER_END(A)
88
89
90
91TAGS_MODULE_BEGIN(Links)
92
93 TAGS_MODULE_ADD(A)
94
95TAGS_MODULE_END(Links)
96
97
98#endif