1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_links.cpp
3 // Purpose: wxHtml module for links & anchors
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
15 #if wxUSE_HTML && wxUSE_STREAMS
20 #include "wx/html/forcelnk.h"
21 #include "wx/html/m_templ.h"
22 #include "wx/html/styleparams.h"
25 FORCE_LINK_ME(m_links
)
28 class wxHtmlAnchorCell
: public wxHtmlCell
31 wxString m_AnchorName
;
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
)) {}
41 virtual const wxHtmlCell
* Find(int condition
, const void* param
) const
43 if ((condition
== wxHTML_COND_ISANCHOR
) &&
44 (m_AnchorName
== (*((const wxString
*)param
))))
50 return wxHtmlCell::Find(condition
, param
);
54 wxDECLARE_NO_COPY_CLASS(wxHtmlAnchorCell
);
59 TAG_HANDLER_BEGIN(A
, "A")
60 TAG_HANDLER_CONSTR(A
) { }
65 if (tag
.GetParamAsString(wxT("NAME"), &name
))
67 m_WParser
->GetContainer()->InsertCell(new wxHtmlAnchorCell(name
));
71 if (tag
.GetParamAsString(wxT("HREF"), &href
))
73 wxHtmlLinkInfo oldlnk
= m_WParser
->GetLink();
74 wxColour oldclr
= m_WParser
->GetActualColor();
75 wxColour oldbackclr
= m_WParser
->GetActualBackgroundColor();
76 int oldbackmode
= m_WParser
->GetActualBackgroundMode();
77 int oldsize
= m_WParser
->GetFontSize();
78 int oldbold
= m_WParser
->GetFontBold();
79 int olditalic
= m_WParser
->GetFontItalic();
80 int oldund
= m_WParser
->GetFontUnderlined();
81 wxString oldfontface
= m_WParser
->GetFontFace();
82 wxString target
= tag
.GetParam( wxT("TARGET") );
84 // set default styles, might get overridden by ApplyStyle
85 m_WParser
->SetActualColor(m_WParser
->GetLinkColor());
86 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser
->GetLinkColor()));
87 m_WParser
->SetFontUnderlined(true);
88 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
89 m_WParser
->SetLink(wxHtmlLinkInfo(href
, target
));
91 // Load any style parameters
92 wxHtmlStyleParams
styleParams(tag
);
93 ApplyStyle(styleParams
);
97 m_WParser
->SetLink(oldlnk
);
98 m_WParser
->SetFontSize(oldsize
);
99 m_WParser
->SetFontBold(oldbold
);
100 m_WParser
->SetFontFace(oldfontface
);
101 m_WParser
->SetFontItalic(olditalic
);
102 m_WParser
->SetFontUnderlined(oldund
);
103 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
104 m_WParser
->SetActualColor(oldclr
);
105 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr
));
107 if (oldbackmode
!= m_WParser
->GetActualBackgroundMode() ||
108 oldbackclr
!= m_WParser
->GetActualBackgroundColor())
110 m_WParser
->SetActualBackgroundMode(oldbackmode
);
111 m_WParser
->SetActualBackgroundColor(oldbackclr
);
112 m_WParser
->GetContainer()->InsertCell(
113 new wxHtmlColourCell(oldbackclr
, oldbackmode
== wxTRANSPARENT
? wxHTML_CLR_TRANSPARENT_BACKGROUND
: wxHTML_CLR_BACKGROUND
));
125 TAGS_MODULE_BEGIN(Links
)
129 TAGS_MODULE_END(Links
)