]> git.saurik.com Git - wxWidgets.git/blob - src/html/mod_links.cpp
1. wxFrame doesn't show incorrect hints in the status bar for popup items
[wxWidgets.git] / src / html / mod_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: mod_links.cpp
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #include "wx/defs.h"
10 #if wxUSE_HTML
11
12 #include <wx/html/forcelink.h>
13 #include <wx/html/mod_templ.h>
14 #include <wx/wxhtml.h>
15
16 FORCE_LINK_ME(mod_links)
17
18
19 class wxHtmlAnchorCell : public wxHtmlCell
20 {
21 private:
22 wxString m_AnchorName;
23
24 public:
25 wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;}
26 virtual const wxHtmlCell* Find(int condition, const void* param) const
27 {
28 if ((condition == HTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param))))
29 return this;
30 else
31 return wxHtmlCell::Find(condition, param);
32 }
33 };
34
35
36
37 TAG_HANDLER_BEGIN(A, "A")
38
39 TAG_HANDLER_PROC(tag)
40 {
41 if (tag.HasParam("NAME")) {
42 m_WParser -> GetContainer() -> InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME")));
43 }
44
45 if (tag.HasParam("HREF")) {
46 wxString oldlnk = m_WParser -> GetLink();
47 wxColour oldclr = m_WParser -> GetActualColor();
48 int oldund = m_WParser -> GetFontUnderlined();
49
50 m_WParser -> SetActualColor(m_WParser -> GetLinkColor());
51 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(m_WParser -> GetLinkColor()));
52 m_WParser -> SetFontUnderlined(TRUE);
53 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
54 m_WParser -> SetLink(tag.GetParam("HREF"));
55
56 ParseInner(tag);
57
58 m_WParser -> SetLink(oldlnk);
59 m_WParser -> SetFontUnderlined(oldund);
60 m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
61 m_WParser -> SetActualColor(oldclr);
62 m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
63
64 return TRUE;
65 }
66 else return FALSE;
67 }
68
69 TAG_HANDLER_END(A)
70
71
72
73 TAGS_MODULE_BEGIN(Links)
74
75 TAGS_MODULE_ADD(A)
76
77 TAGS_MODULE_END(Links)
78
79
80 #endif