]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/html/htmlcell.cpp
PageUp/PageDown scroll by 2/3 of client area height (was 1)
[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 = new wxHtmlLinkInfo(link);
89}
90
91
92
93//-----------------------------------------------------------------------------
94// wxHtmlWordCell
95//-----------------------------------------------------------------------------
96
97wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
98{
99 m_Word = word;
100
101 if (m_Word.Find(wxT('&')) != -1)
102 {
103#define ESCSEQ(escape, subst) \
104 { wxT("&"escape";"), wxT("&"escape" "), wxT(subst) }
105 static wxChar* substitutions[][3] =
106 {
107 ESCSEQ("quot", "\""),
108 ESCSEQ("lt", "<"),
109 ESCSEQ("gt", ">"),
110
111 ESCSEQ("nbsp", " "),
112 ESCSEQ("iexcl", "!"),
113