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#ifndef __khtml_events_h__
20#define __khtml_events_h__
21
22#include <kparts/event.h>
23
24#include "dom/dom_node.h"
25#include "dom/dom_string.h"
26
27namespace khtml
28{
29
30class KHTML_EXPORT MouseEvent : public KParts::Event
31{
32public:
33 MouseEvent( const char *name, QMouseEvent *qmouseEvent, int x, int y,
34 const DOM::DOMString &url, const DOM::DOMString& target,
35 const DOM::Node &innerNode);
36 virtual ~MouseEvent();
37
38 QMouseEvent *qmouseEvent() const { return m_qmouseEvent; }
39 int x() const { return m_x; }
40 int y() const { return m_y; }
41 int absX() const { return m_nodeAbsX; }
42 int absY() const { return m_nodeAbsY; }
43
44 DOM::DOMString url() const { return m_url; }
45 DOM::DOMString target() const { return m_target; }
46 DOM::Node innerNode() const { return m_innerNode; }
47
48 // return the offset of innerNode
49 long offset() const;
50
51private:
52 QMouseEvent *m_qmouseEvent;
53 int m_x;
54 int m_y;
55 int m_nodeAbsX, m_nodeAbsY;
56 DOM::DOMString m_url;
57 DOM::DOMString m_target;
58 DOM::Node m_innerNode;
59 class MouseEventPrivate;
60 MouseEventPrivate *d;
61};
62
63class KHTML_EXPORT MousePressEvent : public MouseEvent
64{
65public:
66 MousePressEvent( QMouseEvent *mouseEvent, int x, int y,
67 const DOM::DOMString &url, const DOM::DOMString& target,
68 const DOM::Node &innerNode)
69 : MouseEvent( s_strMousePressEvent, mouseEvent, x, y, url, target, innerNode )
70 {}
71
72 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMousePressEvent ); }
73
74
75private:
76 static const char *s_strMousePressEvent;
77};
78
79class KHTML_EXPORT MouseDoubleClickEvent : public MouseEvent
80{
81public:
82 // clickCount is 3 for a triple-click event
83 MouseDoubleClickEvent( QMouseEvent *mouseEvent, int x, int y,
84 const DOM::DOMString &url, const DOM::DOMString& target,
85 const DOM::Node &innerNode, int clickCount = 2 )
86 : MouseEvent( s_strMouseDoubleClickEvent, mouseEvent, x, y, url, target, innerNode ),
87 m_clickCount( clickCount )
88 {}
89
90 static bool test( const QEvent *event )
91 { return KParts::Event::test( event, s_strMouseDoubleClickEvent ); }
92
93 int clickCount() const { return m_clickCount; }
94
95private:
96 int m_clickCount;
97 static const char *s_strMouseDoubleClickEvent;
98};
99
100class KHTML_EXPORT MouseMoveEvent : public MouseEvent
101{
102public:
103 MouseMoveEvent( QMouseEvent *mouseEvent, int x, int y,
104 const DOM::DOMString &url, const DOM::DOMString& target,
105 const DOM::Node &innerNode)
106 : MouseEvent( s_strMouseMoveEvent, mouseEvent, x, y, url, target, innerNode )
107 {}
108
109 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseMoveEvent ); }
110
111private:
112 static const char *s_strMouseMoveEvent;
113};
114
115class KHTML_EXPORT MouseReleaseEvent : public MouseEvent
116{
117public:
118 MouseReleaseEvent( QMouseEvent *mouseEvent, int x, int y,
119 const DOM::DOMString &url, const DOM::DOMString& target,
120 const DOM::Node &innerNode, long = 0 )
121 : MouseEvent( s_strMouseReleaseEvent, mouseEvent, x, y, url, target, innerNode )
122 {}
123
124 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseReleaseEvent ); }
125
126private:
127 static const char *s_strMouseReleaseEvent;
128};
129
130class KHTML_EXPORT DrawContentsEvent : public KParts::Event
131{
132public:
133 DrawContentsEvent( QPainter *painter, int clipx, int clipy, int clipw, int cliph );
134 virtual ~DrawContentsEvent();
135
136 QPainter *painter() const { return m_painter; }
137 int clipx() const { return m_clipx; }
138 int clipy() const { return m_clipy; }
139 int clipw() const { return m_clipw; }
140 int cliph() const { return m_cliph; }
141
142 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strDrawContentsEvent ); }
143
144private:
145 QPainter *m_painter;
146 int m_clipx;
147 int m_clipy;
148 int m_clipw;
149 int m_cliph;
150 class DrawContentsEventPrivate;
151 DrawContentsEventPrivate *d;
152 static const char *s_strDrawContentsEvent;
153};
154
155}
156
157#endif
158