File indexing completed on 2023-05-30 09:09:50
0001 /* This file is part of the KDE project 0002 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "khtml_events.h" 0021 #include "rendering/render_object.h" 0022 #include "xml/dom_nodeimpl.h" 0023 #include "xml/dom_position.h" 0024 0025 #include <QMouseEvent> 0026 0027 using namespace khtml; 0028 using namespace DOM; 0029 0030 class khtml::MouseEvent::MouseEventPrivate 0031 { 0032 }; 0033 0034 khtml::MouseEvent::MouseEvent(const char *name, QMouseEvent *qmouseEvent, int x, int y, 0035 const DOM::DOMString &url, const DOM::DOMString &target, 0036 const DOM::Node &innerNode) 0037 : KParts::Event(name), m_qmouseEvent(qmouseEvent), m_x(x), m_y(y), 0038 m_url(url), m_target(target), m_innerNode(innerNode) 0039 { 0040 d = nullptr; 0041 if (innerNode.handle() && innerNode.handle()->renderer()) { 0042 innerNode.handle()->renderer()->absolutePosition(m_nodeAbsX, m_nodeAbsY); 0043 } 0044 } 0045 0046 khtml::MouseEvent::~MouseEvent() 0047 { 0048 delete d; 0049 } 0050 0051 long khtml::MouseEvent::offset() const 0052 { 0053 Position pos; 0054 if (innerNode().handle()) { 0055 // FIXME: Shouldn't be necessary to skip text nodes. 0056 DOM::Node inner = innerNode(); 0057 if (inner.nodeType() == Node::TEXT_NODE) { 0058 inner = inner.parentNode(); 0059 } 0060 pos = inner.handle()->positionForCoordinates(m_x, m_y).position(); 0061 } 0062 return pos.offset(); 0063 } 0064 0065 const char *khtml::MousePressEvent::s_strMousePressEvent = "khtml/Events/MousePressEvent"; 0066 0067 const char *khtml::MouseDoubleClickEvent::s_strMouseDoubleClickEvent = "khtml/Events/MouseDoubleClickEvent"; 0068 0069 const char *khtml::MouseMoveEvent::s_strMouseMoveEvent = "khtml/Events/MouseMoveEvent"; 0070 0071 const char *khtml::MouseReleaseEvent::s_strMouseReleaseEvent = "khtml/Events/MouseReleaseEvent"; 0072 0073 const char *khtml::DrawContentsEvent::s_strDrawContentsEvent = "khtml/Events/DrawContentsEvent"; 0074 0075 class khtml::DrawContentsEvent::DrawContentsEventPrivate 0076 { 0077 public: 0078 DrawContentsEventPrivate() 0079 { 0080 } 0081 ~DrawContentsEventPrivate() 0082 { 0083 } 0084 }; 0085 0086 khtml::DrawContentsEvent::DrawContentsEvent(QPainter *painter, int clipx, int clipy, int clipw, int cliph) 0087 : KParts::Event(s_strDrawContentsEvent), m_painter(painter), m_clipx(clipx), m_clipy(clipy), 0088 m_clipw(clipw), m_cliph(cliph) 0089 { 0090 d = new DrawContentsEventPrivate; 0091 } 0092 0093 khtml::DrawContentsEvent::~DrawContentsEvent() 0094 { 0095 delete d; 0096 } 0097