1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/m_links.cpp
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"
16 #if wxUSE_HTML && wxUSE_STREAMS
21 #include "wx/html/forcelnk.h"
22 #include "wx/html/m_templ.h"
23 #include "wx/html/styleparams.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 wxDECLARE_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 wxColour oldbackclr
= m_WParser
->GetActualBackgroundColor();
75 int oldbackmode
= m_WParser
->GetActualBackgroundMode();
76 int oldsize
= m_WParser
->GetFontSize();
77 int oldbold
= m_WParser
->GetFontBold();
78 int olditalic
= m_WParser
->GetFontItalic();
79 int oldund
= m_WParser
->GetFontUnderlined();
80 wxString oldfontface
= m_WParser
->GetFontFace();
81 wxString
name(tag
.GetParam( wxT("HREF") )), target
;
83 if (tag
.HasParam( wxT("TARGET") )) target
= tag
.GetParam( wxT("TARGET") );
85 // set default styles, might get overridden by ApplyStyle
86 m_WParser
->SetActualColor(m_WParser
->GetLinkColor());
87 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(m_WParser
->GetLinkColor()));
88 m_WParser
->SetFontUnderlined(true);
89 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
90 m_WParser
->SetLink(wxHtmlLinkInfo(name
, target
));
92 // Load any style parameters
93 wxHtmlStyleParams
styleParams(tag
);
94 ApplyStyle(styleParams
);
98 m_WParser
->SetLink(oldlnk
);
99 m_WParser
->SetFontSize(oldsize
);
100 m_WParser
->SetFontBold(oldbold
);
101 m_WParser
->SetFontFace(oldfontface
);
102 m_WParser
->SetFontItalic(olditalic
);
103 m_WParser
->SetFontUnderlined(oldund
);
104 m_WParser
->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser
->CreateCurrentFont()));
105 m_WParser
->SetActualColor(oldclr
);
106 m_WParser
->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr
));
108 if (oldbackmode
!= m_WParser
->GetActualBackgroundMode() ||
109 oldbackclr
!= m_WParser
->GetActualBackgroundColor())
111 m_WParser
->SetActualBackgroundMode(oldbackmode
);
112 m_WParser
->SetActualBackgroundColor(oldbackclr
);
113 m_WParser
->GetContainer()->InsertCell(
114 new wxHtmlColourCell(oldbackclr
, oldbackmode
== wxTRANSPARENT
? wxHTML_CLR_TRANSPARENT_BACKGROUND
: wxHTML_CLR_BACKGROUND
));
126 TAGS_MODULE_BEGIN(Links
)
130 TAGS_MODULE_END(Links
)