]>
git.saurik.com Git - wxWidgets.git/blob - src/html/m_links.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
13 #if wxUSE_HTML && wxUSE_STREAMS
22 #include "wx/html/forcelnk.h"
23 #include "wx/html/m_templ.h"
26 FORCE_LINK_ME(m_links
)
29 class wxHtmlAnchorCell
: public wxHtmlCell
32 wxString m_AnchorName
;
35 wxHtmlAnchorCell(const wxString
& name
) : wxHtmlCell()
36 { m_AnchorName
= name
; }
37 void Draw(wxDC
& WXUNUSED(dc
),
38 int WXUNUSED(x
), int WXUNUSED(y
),
39 int WXUNUSED(view_y1
), int WXUNUSED(view_y2
),
40 wxHtmlRenderingInfo
& WXUNUSED(info
)) {}
42 virtual const wxHtmlCell
* Find(int condition
, const void* param
) const
44 if ((condition
== wxHTML_COND_ISANCHOR
) &&
45 (m_AnchorName
== (*((const wxString
*)param
))))
51 return wxHtmlCell::Find(condition
, param
);
55 DECLARE_NO_COPY_CLASS(wxHtmlAnchorCell
)
60 TAG_HANDLER_BEGIN(A
, "A")
61 TAG_HANDLER_CONSTR(A
) { }
65 if (tag
.HasParam( wxT("NAME") ))
67 m_WParser
->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag
.GetParam( wxT("NAME") )));
70 if (tag
.HasParam( wxT("HREF") ))
72 wxHtmlLinkInfo oldlnk
= m_WParser
->GetLink();
73 wxColour oldclr
= m_WParser
->GetActualColor();
74 int oldund
= m_WParser
->GetFontUnderlined();
75 wxString
name(tag
.GetParam( wxT("HREF") )), target
;
77 if (tag
.HasParam( wxT("TARGET") )) target
= tag
.GetParam( wxT("TARGET") );
78 m_WParser
->SetActualColor(m_WParser
->GetLinkColor());
79 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser
->GetLinkColor()));
80 m_WParser
->SetFontUnderlined(true);
81 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
82 m_WParser
->SetLink(wxHtmlLinkInfo(name
, target
));
86 m_WParser
->SetLink(oldlnk
);
87 m_WParser
->SetFontUnderlined(oldund
);
88 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
89 m_WParser
->SetActualColor(oldclr
);
90 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr
));
101 TAGS_MODULE_BEGIN(Links
)
105 TAGS_MODULE_END(Links
)