fix logic
[personal-kdelibs.git] / khtml / khtml_events.h
blob96970fa08e0f199621e7ae7f996da3ebc425fbd1
1 /* This file is part of the KDE project
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
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.
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.
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.
19 #ifndef __khtml_events_h__
20 #define __khtml_events_h__
22 #include <kparts/event.h>
24 #include "dom/dom_node.h"
25 #include "dom/dom_string.h"
27 namespace khtml
30 class KHTML_EXPORT MouseEvent : public KParts::Event
32 public:
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();
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; }
44 DOM::DOMString url() const { return m_url; }
45 DOM::DOMString target() const { return m_target; }
46 DOM::Node innerNode() const { return m_innerNode; }
48 // return the offset of innerNode
49 long offset() const;
51 private:
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;
63 class KHTML_EXPORT MousePressEvent : public MouseEvent
65 public:
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 )
72 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMousePressEvent ); }
75 private:
76 static const char *s_strMousePressEvent;
79 class KHTML_EXPORT MouseDoubleClickEvent : public MouseEvent
81 public:
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 )
90 static bool test( const QEvent *event )
91 { return KParts::Event::test( event, s_strMouseDoubleClickEvent ); }
93 int clickCount() const { return m_clickCount; }
95 private:
96 int m_clickCount;
97 static const char *s_strMouseDoubleClickEvent;
100 class KHTML_EXPORT MouseMoveEvent : public MouseEvent
102 public:
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 )
109 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseMoveEvent ); }
111 private:
112 static const char *s_strMouseMoveEvent;
115 class KHTML_EXPORT MouseReleaseEvent : public MouseEvent
117 public:
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 )
124 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseReleaseEvent ); }
126 private:
127 static const char *s_strMouseReleaseEvent;
130 class KHTML_EXPORT DrawContentsEvent : public KParts::Event
132 public:
133 DrawContentsEvent( QPainter *painter, int clipx, int clipy, int clipw, int cliph );
134 virtual ~DrawContentsEvent();
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; }
142 static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strDrawContentsEvent ); }
144 private:
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;
157 #endif