]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlcell.cpp | |
3 | // Purpose: wxHtmlCell - basic element of HTML output | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 VS |
6 | // Copyright: (c) 1999 Vaclav Slavik |
7 | // Licence: wxWindows Licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
5526e819 | 10 | #ifdef __GNUG__ |
69941f05 | 11 | #pragma implementation |
5526e819 VS |
12 | #endif |
13 | ||
4dcaf11a | 14 | #include "wx/wxprec.h" |
5526e819 | 15 | |
314260fb | 16 | #include "wx/defs.h" |
5526e819 VS |
17 | #if wxUSE_HTML |
18 | ||
19 | #ifdef __BORDLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WXPRECOMP | |
4dcaf11a | 24 | #include "wx/wx.h" |
5526e819 VS |
25 | #endif |
26 | ||
4dcaf11a RR |
27 | #include "wx/html/htmlcell.h" |
28 | #include "wx/html/htmlwin.h" | |
5526e819 VS |
29 | #include <stdlib.h> |
30 | ||
31 | ||
5526e819 VS |
32 | //----------------------------------------------------------------------------- |
33 | // wxHtmlCell | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
846914d1 VS |
36 | wxHtmlCell::wxHtmlCell() : wxObject() |
37 | { | |
38 | m_Next = NULL; | |
39 | m_Parent = NULL; | |
40 | m_Width = m_Height = m_Descent = 0; | |
41 | m_CanLiveOnPagebreak = TRUE; | |
42 | m_Link = NULL; | |
43 | } | |
44 | ||
45 | wxHtmlCell::~wxHtmlCell() | |
46 | { | |
47 | if (m_Link) delete m_Link; | |
48 | if (m_Next) delete m_Next; | |
49 | } | |
50 | ||
5526e819 | 51 | |
0b2dadd3 VS |
52 | void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, |
53 | const wxMouseEvent& event) | |
5526e819 | 54 | { |
846914d1 VS |
55 | wxHtmlLinkInfo *lnk = GetLink(x, y); |
56 | if (lnk != NULL) | |
0b2dadd3 VS |
57 | { |
58 | wxHtmlLinkInfo lnk2(*lnk); | |
59 | lnk2.SetEvent(&event); | |
9bc8fded | 60 | lnk2.SetHtmlCell(this); |
0b2dadd3 | 61 | ((wxHtmlWindow*)parent) -> OnLinkClicked(lnk2); |
5526e819 | 62 | // note : this overcasting is legal because parent is *always* wxHtmlWindow |
0b2dadd3 | 63 | } |
5526e819 VS |
64 | } |
65 | ||
66 | ||
67 | ||
5660c520 | 68 | bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const |
db98870d | 69 | { |
db98870d | 70 | if ((!m_CanLiveOnPagebreak) && |
e52d6dbc | 71 | m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) { |
db98870d VS |
72 | *pagebreak = m_PosY; |
73 | if (m_Next != NULL) m_Next -> AdjustPagebreak(pagebreak); | |
74 | return TRUE; | |
75 | } | |
76 | ||
77 | else { | |
78 | if (m_Next != NULL) return m_Next -> AdjustPagebreak(pagebreak); | |
79 | else return FALSE; | |
80 | } | |
81 | } | |
82 | ||
83 | ||
84 | ||
846914d1 VS |
85 | void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) |
86 | { | |
87 | if (m_Link) delete m_Link; | |
88 | m_Link = new wxHtmlLinkInfo(link); | |
89 | } | |
90 | ||
91 | ||
db98870d | 92 | |
5526e819 VS |
93 | //----------------------------------------------------------------------------- |
94 | // wxHtmlWordCell | |
95 | //----------------------------------------------------------------------------- | |
96 | ||
97 | wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() | |
98 | { | |
99 | m_Word = word; | |
c181287c VS |
100 | |
101 | if (m_Word.Find(wxT('&')) != -1) | |
102 | { | |
5660c520 VS |
103 | #define ESCSEQ(escape, subst) \ |
104 | { wxT("&"escape";"), wxT("&"escape" "), wxT(subst) } | |
c181287c VS |
105 | static wxChar* substitutions[][3] = |
106 | { | |
5660c520 VS |
107 | ESCSEQ("quot", "\""), |
108 | ESCSEQ("lt", "<"), | |
109 | ESCSEQ("gt", ">"), | |
110 | ||
111 | ESCSEQ("nbsp", " "), | |
112 | ESCSEQ("iexcl", "!"), | |
113 |