]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_links.cpp
wxDataViewCtrl::Expand() only works on items whose parents are already
[wxWidgets.git] / src / html / m_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_links.cpp
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/wxprec.h"
11
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15
16 #if wxUSE_HTML && wxUSE_STREAMS
17
18 #ifndef WX_PRECOMP
19 #endif
20
21 #include "wx/html/forcelnk.h"
22 #include "wx/html/m_templ.h"
23
24
25 FORCE_LINK_ME(m_links)
26
27
28 class wxHtmlAnchorCell : public wxHtmlCell
29 {
30 private:
31 wxString m_AnchorName;
32
33 public:
34 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell()
35 { m_AnchorName = name; }
36 void Draw(wxDC& WXUNUSED(dc),
37 int WXUNUSED(x), int WXUNUSED(y),
38 int WXUNUSED(view_y1), int WXUNUSED(view_y2),
39 wxHtmlRenderingInfo& WXUNUSED(info)) {}
40
41 virtual const wxHtmlCell* Find(int condition, const void* param) const
42 {
43 if ((condition == wxHTML_COND_ISANCHOR) &&
44 (m_AnchorName == (*((const wxString*)param))))
45 {
46 return this;
47 }
48 else
49 {
50 return wxHtmlCell::Find(condition, param);
51 }
52 }
53
54 wxDECLARE_NO_COPY_CLASS(wxHtmlAnchorCell);
55 };
56
57
58
59 TAG_HANDLER_BEGIN(A, "A")
60 TAG_HANDLER_CONSTR(A) { }
61
62 TAG_HANDLER_PROC(tag)
63 {
64 if (tag.HasParam( wxT("NAME") ))
65 {
66 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
67 }
68
69 if (tag.HasParam( wxT("HREF") ))
70 {
71 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
72 wxColour oldclr = m_WParser->GetActualColor();
73 int oldund = m_WParser->GetFontUnderlined();
74 wxString name(tag.GetParam( wxT("HREF") )), target;
75
76 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
77 m_WParser->SetActualColor(m_WParser->GetLinkColor());
78 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser->GetLinkColor()));
79 m_WParser->SetFontUnderlined(true);
80 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
81 m_WParser->SetLink(wxHtmlLinkInfo(name, target));
82
83 ParseInner(tag);
84
85 m_WParser->SetLink(oldlnk);
86 m_WParser->SetFontUnderlined(oldund);
87 m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
88 m_WParser->SetActualColor(oldclr);
89 m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
90
91 return true;
92 }
93 else return false;
94 }
95
96 TAG_HANDLER_END(A)
97
98
99
100 TAGS_MODULE_BEGIN(Links)
101
102 TAGS_MODULE_ADD(A)
103
104 TAGS_MODULE_END(Links)
105
106
107 #endif