]>
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 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
14 #include "wx/wxprec.h"
17 #if wxUSE_HTML && wxUSE_STREAMS
26 #include "wx/html/forcelnk.h"
27 #include "wx/html/m_templ.h"
30 FORCE_LINK_ME(m_links
)
33 class wxHtmlAnchorCell
: public wxHtmlCell
36 wxString m_AnchorName
;
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
)) {}
46 virtual const wxHtmlCell
* Find(int condition
, const void* param
) const
48 if ((condition
== wxHTML_COND_ISANCHOR
) &&
49 (m_AnchorName
== (*((const wxString
*)param
))))
55 return wxHtmlCell::Find(condition
, param
);
62 TAG_HANDLER_BEGIN(A
, "A")
66 if (tag
.HasParam( wxT("NAME") ))
68 m_WParser
->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag
.GetParam( wxT("NAME") )));
71 if (tag
.HasParam( wxT("HREF") ))
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
;
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
));
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
));
102 TAGS_MODULE_BEGIN(Links
)
106 TAGS_MODULE_END(Links
)