KHtml

khtml_events.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2000 Simon Hausmann <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "khtml_events.h"
21 #include "rendering/render_object.h"
22 #include "xml/dom_nodeimpl.h"
23 #include "xml/dom_position.h"
24 
25 #include <QMouseEvent>
26 
27 using namespace khtml;
28 using namespace DOM;
29 
30 class khtml::MouseEvent::MouseEventPrivate
31 {
32 };
33 
34 khtml::MouseEvent::MouseEvent(const char *name, QMouseEvent *qmouseEvent, int x, int y,
35  const DOM::DOMString &url, const DOM::DOMString &target,
36  const DOM::Node &innerNode)
37  : KParts::Event(name), m_qmouseEvent(qmouseEvent), m_x(x), m_y(y),
38  m_url(url), m_target(target), m_innerNode(innerNode)
39 {
40  d = nullptr;
41  if (innerNode.handle() && innerNode.handle()->renderer()) {
42  innerNode.handle()->renderer()->absolutePosition(m_nodeAbsX, m_nodeAbsY);
43  }
44 }
45 
46 khtml::MouseEvent::~MouseEvent()
47 {
48  delete d;
49 }
50 
51 long khtml::MouseEvent::offset() const
52 {
53  Position pos;
54  if (innerNode().handle()) {
55  // FIXME: Shouldn't be necessary to skip text nodes.
56  DOM::Node inner = innerNode();
57  if (inner.nodeType() == Node::TEXT_NODE) {
58  inner = inner.parentNode();
59  }
60  pos = inner.handle()->positionForCoordinates(m_x, m_y).position();
61  }
62  return pos.offset();
63 }
64 
65 const char *khtml::MousePressEvent::s_strMousePressEvent = "khtml/Events/MousePressEvent";
66 
67 const char *khtml::MouseDoubleClickEvent::s_strMouseDoubleClickEvent = "khtml/Events/MouseDoubleClickEvent";
68 
69 const char *khtml::MouseMoveEvent::s_strMouseMoveEvent = "khtml/Events/MouseMoveEvent";
70 
71 const char *khtml::MouseReleaseEvent::s_strMouseReleaseEvent = "khtml/Events/MouseReleaseEvent";
72 
73 const char *khtml::DrawContentsEvent::s_strDrawContentsEvent = "khtml/Events/DrawContentsEvent";
74 
75 class khtml::DrawContentsEvent::DrawContentsEventPrivate
76 {
77 public:
78  DrawContentsEventPrivate()
79  {
80  }
81  ~DrawContentsEventPrivate()
82  {
83  }
84 };
85 
86 khtml::DrawContentsEvent::DrawContentsEvent(QPainter *painter, int clipx, int clipy, int clipw, int cliph)
87  : KParts::Event(s_strDrawContentsEvent), m_painter(painter), m_clipx(clipx), m_clipy(clipy),
88  m_clipw(clipw), m_cliph(cliph)
89 {
90  d = new DrawContentsEventPrivate;
91 }
92 
93 khtml::DrawContentsEvent::~DrawContentsEvent()
94 {
95  delete d;
96 }
97 
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
This file is part of the HTML rendering engine for KDE.
EventImpl * handle() const
Node parentNode() const
The parent of this node.
Definition: dom_node.cpp:250
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
Introduced in DOM Level 2.
Definition: dom2_events.h:116
NodeImpl * handle() const
Definition: dom_node.h:936
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.
Definition: dom_node.cpp:242
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.