1 | /* This file is part of the KDE project |
2 | Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> |
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 | using namespace khtml; |
26 | using namespace DOM; |
27 | |
28 | class khtml::MouseEvent::MouseEventPrivate |
29 | { |
30 | }; |
31 | |
32 | khtml::MouseEvent::MouseEvent( const char *name, QMouseEvent *qmouseEvent, int x, int y, |
33 | const DOM::DOMString &url, const DOM::DOMString& target, |
34 | const DOM::Node &innerNode ) |
35 | : KParts::Event( name ), m_qmouseEvent( qmouseEvent ), m_x( x ), m_y( y ), |
36 | m_url( url ), m_target(target), m_innerNode( innerNode ) |
37 | { |
38 | d = 0; |
39 | if (innerNode.handle() && innerNode.handle()->renderer()) |
40 | innerNode.handle()->renderer()->absolutePosition(m_nodeAbsX, m_nodeAbsY); |
41 | } |
42 | |
43 | khtml::MouseEvent::~MouseEvent() |
44 | { |
45 | delete d; |
46 | } |
47 | |
48 | long khtml::MouseEvent::offset() const |
49 | { |
50 | Position pos; |
51 | if (innerNode().handle()) { |
52 | // FIXME: Shouldn't be necessary to skip text nodes. |
53 | DOM::Node inner = innerNode(); |
54 | if (inner.nodeType() == Node::TEXT_NODE) |
55 | inner = inner.parentNode(); |
56 | pos = inner.handle()->positionForCoordinates(m_x, m_y).position(); |
57 | } |
58 | return pos.offset(); |
59 | } |
60 | |
61 | const char *khtml::MousePressEvent::s_strMousePressEvent = "khtml/Events/MousePressEvent" ; |
62 | |
63 | const char *khtml::MouseDoubleClickEvent::s_strMouseDoubleClickEvent = "khtml/Events/MouseDoubleClickEvent" ; |
64 | |
65 | const char *khtml::MouseMoveEvent::s_strMouseMoveEvent = "khtml/Events/MouseMoveEvent" ; |
66 | |
67 | const char *khtml::MouseReleaseEvent::s_strMouseReleaseEvent = "khtml/Events/MouseReleaseEvent" ; |
68 | |
69 | const char *khtml::DrawContentsEvent::s_strDrawContentsEvent = "khtml/Events/DrawContentsEvent" ; |
70 | |
71 | class khtml::DrawContentsEvent::DrawContentsEventPrivate |
72 | { |
73 | public: |
74 | DrawContentsEventPrivate() |
75 | { |
76 | } |
77 | ~DrawContentsEventPrivate() |
78 | { |
79 | } |
80 | }; |
81 | |
82 | khtml::DrawContentsEvent::DrawContentsEvent( QPainter *painter, int clipx, int clipy, int clipw, int cliph ) |
83 | : KParts::Event( s_strDrawContentsEvent ), m_painter( painter ), m_clipx( clipx ), m_clipy( clipy ), |
84 | m_clipw( clipw ), m_cliph( cliph ) |
85 | { |
86 | d = new DrawContentsEventPrivate; |
87 | } |
88 | |
89 | khtml::DrawContentsEvent::~DrawContentsEvent() |
90 | { |
91 | delete d; |
92 | } |
93 | |
94 | |