]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/html/htmlcell.cpp
fix for assert when setting tooltip for a readonly combo
[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 *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
86void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
87{
88 if (m_Link) delete m_Link;
89 m_Link = NULL;
90 if (link.GetHref() != wxEmptyString)
91 m_Link = new wxHtmlLinkInfo(link);
92}
93
94
95
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
125//-----------------------------------------------------------------------------
126// wxHtmlWordCell
127//-----------------------------------------------------------------------------
128
129wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
130{
131 m_Word = word;
132
133 if (m_Word.Find(wxT('&')) != -1)
134 {
135#define ESCSEQ(escape, subst) \
136 { _T("&") _T(escape) _T(";"), _T("&") _T(escape) _T(" "), _T(subst) }
137 static wxChar* substitutions[][3] =
138 {
139 ESCSEQ("quot", "\""),
140 ESCSEQ("lt", "<"),
141 ESCSEQ("gt", ">"),
142
143 ESCSEQ("nbsp", " "),
144 ESCSEQ("iexcl", "!"),
145