]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/html/htmlcell.cpp
forgot to check in wxHtmlProcessor::IsEnabled test in wxHtmlWindow::SetPage
[wxWidgets.git] / src / html / htmlcell.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: htmlcell.cpp
3// Purpose: wxHtmlCell - basic element of HTML output
4// Author: Vaclav Slavik
5// RCS-ID: $Id$
6// Copyright: (c) 1999 Vaclav Slavik
7// Licence: wxWindows Licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation
12#endif
13
14#include "wx/wxprec.h"
15
16#include "wx/defs.h"
17
18#if wxUSE_HTML && wxUSE_STREAMS
19
20#ifdef __BORDLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WXPRECOMP
25#include "wx/wx.h"
26#endif
27
28#include "wx/html/htmlcell.h"
29#include "wx/html/htmlwin.h"
30#include <stdlib.h>
31
32
33//-----------------------------------------------------------------------------
34// wxHtmlCell
35//-----------------------------------------------------------------------------
36
37wxHtmlCell::wxHtmlCell() : wxObject()
38{
39 m_Next = NULL;
40 m_Parent = NULL;
41 m_Width = m_Height = m_Descent = 0;
42 m_CanLiveOnPagebreak = TRUE;
43 m_Link = NULL;
44}
45
46wxHtmlCell::~wxHtmlCell()
47{
48 if (m_Link) delete m_Link;
49 if (m_Next) delete m_Next;
50}
51
52
53void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
54 const wxMouseEvent& event)
55{
56 wxHtmlLinkInfo *lnk = GetLink(x, y);
57 if (lnk != NULL)
58 {
59 wxHtmlLinkInfo lnk2(*lnk);
60 lnk2.SetEvent(&event);
61 lnk2.SetHtmlCell(this);
62 ((wxHtmlWindow*)parent)->OnLinkClicked(lnk2);
63 // note : this overcasting is legal because parent is *always* wxHtmlWindow
64 }
65}
66
67
68
69bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
70{
71 if ((!m_CanLiveOnPagebreak) &&
72 m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak)
73 {
74 *pagebreak = m_PosY;
75 if (m_Next != NULL) m_Next->AdjustPagebreak(pagebreak);
76 return TRUE;
77 }
78
79 else
80 {
81 if (m_Next != NULL) return m_Next->AdjustPagebreak(pagebreak);
82 else return FALSE;
83 }
84}
85
86
87
88void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
89{
90 if (m_Link) delete m_Link;
91 m_Link = NULL;
92 if (link.GetHref() != wxEmptyString)
93 m_Link = new wxHtmlLinkInfo(link);
94}
95
96
97
98void wxHtmlCell::Layout(int w)
99{
100 SetPos(0, 0);
101 if (m_Next) m_Next->Layout(w);
102}
103
104
105void wxHtmlCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
106{
107 if (m_Next) m_Next->Draw(dc, x, y, view_y1, view_y2);
108}
109
110
111
112void wxHtmlCell::DrawInvisible(wxDC& dc, int x, int y)
113{
114 if (m_Next) m_Next->DrawInvisible(dc, x, y);
115}
116
117
118
119const wxHtmlCell* wxHtmlCell::Find(int condition, const void* param) const
120{
121 if (m_Next) return m_Next->Find(condition, param);
122 else return NULL;
123}
124
125
126
127//-----------------------------------------------------------------------------
128// wxHtmlWordCell
129//-----------------------------------------------------------------------------
130
131wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
132{
133 m_Word = word;
134
135 if (m_Word.Find(wxT('&')) != -1)
136 {
137#define ESCSEQ(escape, subst) \
138 { _T("&") _T(escape) _T(";"), _T("&") _T(escape) _T(" "), _T("&") _T(escape), _T(subst) }
139 static wxChar* substitutions[][4] =
140 {
141 ESCSEQ("quot", "\""),
142 ESCSEQ("#34", "\""),
143 ESCSEQ("lt", "<"),
144 ESCSEQ("#60", "<"),
145 ESCSEQ("gt", ">"),
146 ESCSEQ("#62", ">"),
147
148 ESCSEQ("#94", "^"), /* ^ */
149
150 ESCSEQ("nbsp", " "),
151 ESCSEQ("#32", " "),
152 ESCSEQ("iexcl", "!"),
153 ESCSEQ("#33", "!"),
154