]> git.saurik.com Git - wxWidgets.git/blame - src/html/htmlcell.cpp
Minor compilation fixes for Borland.
[wxWidgets.git] / src / html / htmlcell.cpp
CommitLineData
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"
f6bcfd97
BP
17
18#if wxUSE_HTML && wxUSE_STREAMS
5526e819
VS
19
20#ifdef __BORDLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WXPRECOMP
4dcaf11a 25#include "wx/wx.h"
5526e819
VS
26#endif
27
4dcaf11a
RR
28#include "wx/html/htmlcell.h"
29#include "wx/html/htmlwin.h"
5526e819
VS
30#include <stdlib.h>
31
32
5526e819
VS
33//-----------------------------------------------------------------------------
34// wxHtmlCell
35//-----------------------------------------------------------------------------
36
846914d1
VS
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
5526e819 52
0b2dadd3
VS
53void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
54 const wxMouseEvent& event)
5526e819 55{
846914d1
VS
56 wxHtmlLinkInfo *lnk = GetLink(x, y);
57 if (lnk != NULL)
0b2dadd3
VS
58 {
59 wxHtmlLinkInfo lnk2(*lnk);
60 lnk2.SetEvent(&event);
9bc8fded 61 lnk2.SetHtmlCell(this);
0b2dadd3 62 ((wxHtmlWindow*)parent) -> OnLinkClicked(lnk2);
5526e819 63 // note : this overcasting is legal because parent is *always* wxHtmlWindow
0b2dadd3 64 }
5526e819
VS
65}
66
67
68
5660c520 69bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
db98870d 70{
db98870d 71 if ((!m_CanLiveOnPagebreak) &&
e52d6dbc 72 m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) {
db98870d
VS
73 *pagebreak = m_PosY;
74 if (m_Next != NULL) m_Next -> AdjustPagebreak(pagebreak);
75 return TRUE;
76 }
77
78 else {
79 if (m_Next != NULL) return m_Next -> AdjustPagebreak(pagebreak);
80 else return FALSE;
81 }
82}
83
84
85
846914d1
VS
86void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
87{
88 if (m_Link) delete m_Link;
af1ed0c1
VS
89 m_Link = NULL;
90 if (link.GetHref() != wxEmptyString)
91 m_Link = new wxHtmlLinkInfo(link);
846914d1
VS
92}
93
94
db98870d 95
721ab905
VS
96void wxHtmlCell::Layout(int w)
97{
98 SetPos(0, 0);
99 if (m_Next) m_Next -> Layout(w);
100}
101
102
103void wxHtmlCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
104{
105 if (m_Next) m_Next -> Draw(dc, x, y, view_y1, view_y2);
106}
107
108
109
110void wxHtmlCell::DrawInvisible(wxDC& dc, int x, int y)
111{
112 if (m_Next) m_Next -> DrawInvisible(dc, x, y);
113}
114
115
116
117const wxHtmlCell* wxHtmlCell::Find(int condition, const void* param) const
118{
119 if (m_Next) return m_Next -> Find(condition, param);
120 else return NULL;
121}
122
123
124
5526e819
VS
125//-----------------------------------------------------------------------------
126// wxHtmlWordCell
127//-----------------------------------------------------------------------------
128
129wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
130{
131 m_Word = word;
c181287c
VS
132
133 if (m_Word.Find(wxT('&')) != -1)
134 {
5660c520 135#define ESCSEQ(escape, subst) \
f6bcfd97 136 { _T("&") _T(escape) _T(";"), _T("&") _T(escape) _T(" "), _T(subst) }
c181287c
VS
137 static wxChar* substitutions[][3] =
138 {
5660c520
VS
139 ESCSEQ("quot", "\""),
140 ESCSEQ("lt", "<"),
141 ESCSEQ("gt", ">"),
142
143 ESCSEQ("nbsp", " "),
144 ESCSEQ("iexcl", "!"),
145