]> git.saurik.com Git - wxWidgets.git/blob - src/html/m_links.cpp
In the object destructor, Disassociate the object from its Cocoa counterpart
[wxWidgets.git] / src / html / m_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include "wx/wxprec.h"
15
16 #include "wx/defs.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WXPRECOMP
24 #endif
25
26 #include "wx/html/forcelnk.h"
27 #include "wx/html/m_templ.h"
28
29
30 FORCE_LINK_ME(m_links)
31
32
33 class wxHtmlAnchorCell : public wxHtmlCell
34 {
35 private:
36 wxString m_AnchorName;
37
38 public:
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
54 {
55 return wxHtmlCell::Find(condition, param);
56 }
57 }
58 };
59
60
61
62 TAG_HANDLER_BEGIN(A, "A")
63
64 TAG_HANDLER_PROC(tag)
65 {
66 if (tag.HasParam( wxT("NAME") ))
67 {
68 m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam( wxT("NAME") )));
69 }
70
71 if (tag.HasParam( wxT("HREF") ))
72 {
73 wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
74 wxColour oldclr = m_WParser->GetActualColor();
75 int oldund = m_WParser->GetFontUnderlined();
76 wxString name(tag.GetParam( wxT("HREF") )), target;
77
78 if (tag.HasParam( wxT("TARGET") )) target = tag.GetParam( wxT("TARGET") );
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));
84
85 ParseInner(tag);
86
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));
92
93 return TRUE;
94 }
95 else return FALSE;
96 }
97
98 TAG_HANDLER_END(A)
99
100
101
102 TAGS_MODULE_BEGIN(Links)
103
104 TAGS_MODULE_ADD(A)
105
106 TAGS_MODULE_END(Links)
107
108
109 #endif