]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/html/htmlcell.cpp
Found bug that skrewed up display wrt horizontal
[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#if wxUSE_HTML
18
19#ifdef __BORDLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WXPRECOMP
24#include "wx/wx.h"
25#endif
26
27#include "wx/html/htmlcell.h"
28#include "wx/html/htmlwin.h"
29#include <stdlib.h>
30
31
32//-----------------------------------------------------------------------------
33// wxHtmlCell
34//-----------------------------------------------------------------------------
35
36wxHtmlCell::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
45wxHtmlCell::~wxHtmlCell()
46{
47 if (m_Link) delete m_Link;
48 if (m_Next) delete m_Next;
49}
50
51
52void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
53 const wxMouseEvent& event)
54{
55 wxHtmlLinkInfo *lnk = GetLink(x, y);
56 if (lnk != NULL)
57 {
58 wxHtmlLinkInfo lnk2(*lnk);
59 lnk2.SetEvent(&event);
60 lnk2.SetHtmlCell(this);
61 ((wxHtmlWindow*)parent) -> OnLinkClicked(lnk2);
62 // note : this overcasting is legal because parent is *always* wxHtmlWindow
63 }
64}
65
66
67
68bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
69{
70 if ((!m_CanLiveOnPagebreak) &&
71 m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) {
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
85void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
86{
87 if (m_Link) delete m_Link;
88 m_Link = NULL;
89 if (link.GetHref() != wxEmptyString)
90 m_Link = new wxHtmlLinkInfo(link);
91}
92
93
94
95void wxHtmlCell::Layout(int w)
96{
97 SetPos(0, 0);
98 if (m_Next) m_Next -> Layout(w);
99}
100
101
102void wxHtmlCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
103{
104 if (m_Next) m_Next -> Draw(dc, x, y, view_y1, view_y2);
105}
106
107
108
109void wxHtmlCell::DrawInvisible(wxDC& dc, int x, int y)
110{
111 if (m_Next) m_Next -> DrawInvisible(dc, x, y);
112}
113
114
115
116const wxHtmlCell* wxHtmlCell::Find(int condition, const void* param) const
117{
118 if (m_Next) return m_Next -> Find(condition, param);
119 else return NULL;
120}
121
122
123
124//-----------------------------------------------------------------------------
125// wxHtmlWordCell
126//-----------------------------------------------------------------------------
127
128wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
129{
130 m_Word = word;
131
132 if (m_Word.Find(wxT('&')) != -1)
133 {
134#define ESCSEQ(escape, subst) \
135 { wxT("&"escape";"), wxT("&"escape" "), wxT(subst) }
136 static wxChar* substitutions[][3] =
137 {
138 ESCSEQ("quot", "\""),
139 ESCSEQ("lt", "<"),
140 ESCSEQ("gt", ">"),
141
142 ESCSEQ("nbsp", " "),
143 ESCSEQ("iexcl", "!"),
144