File indexing completed on 2024-04-21 14:58:49

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 #ifndef __khtml_events_h__
0020 #define __khtml_events_h__
0021 
0022 #include <kparts/event.h>
0023 
0024 #include "dom/dom_node.h"
0025 #include "dom/dom_string.h"
0026 
0027 class QMouseEvent;
0028 class QPainter;
0029 
0030 namespace khtml
0031 {
0032 
0033 class KHTML_EXPORT MouseEvent : public KParts::Event
0034 {
0035 public:
0036     MouseEvent(const char *name, QMouseEvent *qmouseEvent, int x, int y,
0037                const DOM::DOMString &url, const DOM::DOMString &target,
0038                const DOM::Node &innerNode);
0039     virtual ~MouseEvent();
0040 
0041     QMouseEvent *qmouseEvent() const
0042     {
0043         return m_qmouseEvent;
0044     }
0045     int x() const
0046     {
0047         return m_x;
0048     }
0049     int y() const
0050     {
0051         return m_y;
0052     }
0053     int absX() const
0054     {
0055         return m_nodeAbsX;
0056     }
0057     int absY() const
0058     {
0059         return m_nodeAbsY;
0060     }
0061 
0062     DOM::DOMString url() const
0063     {
0064         return m_url;
0065     }
0066     DOM::DOMString target() const
0067     {
0068         return m_target;
0069     }
0070     DOM::Node innerNode() const
0071     {
0072         return m_innerNode;
0073     }
0074 
0075     // return the offset of innerNode
0076     long offset() const;
0077 
0078 private:
0079     QMouseEvent *m_qmouseEvent;
0080     int m_x;
0081     int m_y;
0082     int m_nodeAbsX, m_nodeAbsY;
0083     DOM::DOMString m_url;
0084     DOM::DOMString m_target;
0085     DOM::Node m_innerNode;
0086     class MouseEventPrivate;
0087     MouseEventPrivate *d;
0088 };
0089 
0090 class KHTML_EXPORT MousePressEvent : public MouseEvent
0091 {
0092 public:
0093     MousePressEvent(QMouseEvent *mouseEvent, int x, int y,
0094                     const DOM::DOMString &url, const DOM::DOMString &target,
0095                     const DOM::Node &innerNode)
0096         : MouseEvent(s_strMousePressEvent, mouseEvent, x, y, url, target, innerNode)
0097     {}
0098 
0099     static bool test(const QEvent *event)
0100     {
0101         return KParts::Event::test(event, s_strMousePressEvent);
0102     }
0103 
0104 private:
0105     static const char *s_strMousePressEvent;
0106 };
0107 
0108 class KHTML_EXPORT MouseDoubleClickEvent : public MouseEvent
0109 {
0110 public:
0111     // clickCount is 3 for a triple-click event
0112     MouseDoubleClickEvent(QMouseEvent *mouseEvent, int x, int y,
0113                           const DOM::DOMString &url, const DOM::DOMString &target,
0114                           const DOM::Node &innerNode, int clickCount = 2)
0115         : MouseEvent(s_strMouseDoubleClickEvent, mouseEvent, x, y, url, target, innerNode),
0116           m_clickCount(clickCount)
0117     {}
0118 
0119     static bool test(const QEvent *event)
0120     {
0121         return KParts::Event::test(event, s_strMouseDoubleClickEvent);
0122     }
0123 
0124     int clickCount() const
0125     {
0126         return m_clickCount;
0127     }
0128 
0129 private:
0130     int m_clickCount;
0131     static const char *s_strMouseDoubleClickEvent;
0132 };
0133 
0134 class KHTML_EXPORT MouseMoveEvent : public MouseEvent
0135 {
0136 public:
0137     MouseMoveEvent(QMouseEvent *mouseEvent, int x, int y,
0138                    const DOM::DOMString &url, const DOM::DOMString &target,
0139                    const DOM::Node &innerNode)
0140         : MouseEvent(s_strMouseMoveEvent, mouseEvent, x, y, url, target, innerNode)
0141     {}
0142 
0143     static bool test(const QEvent *event)
0144     {
0145         return KParts::Event::test(event, s_strMouseMoveEvent);
0146     }
0147 
0148 private:
0149     static const char *s_strMouseMoveEvent;
0150 };
0151 
0152 class KHTML_EXPORT MouseReleaseEvent : public MouseEvent
0153 {
0154 public:
0155     MouseReleaseEvent(QMouseEvent *mouseEvent, int x, int y,
0156                       const DOM::DOMString &url, const DOM::DOMString &target,
0157                       const DOM::Node &innerNode, long = 0)
0158         : MouseEvent(s_strMouseReleaseEvent, mouseEvent, x, y, url, target, innerNode)
0159     {}
0160 
0161     static bool test(const QEvent *event)
0162     {
0163         return KParts::Event::test(event, s_strMouseReleaseEvent);
0164     }
0165 
0166 private:
0167     static const char *s_strMouseReleaseEvent;
0168 };
0169 
0170 class KHTML_EXPORT DrawContentsEvent : public KParts::Event
0171 {
0172 public:
0173     DrawContentsEvent(QPainter *painter, int clipx, int clipy, int clipw, int cliph);
0174     virtual ~DrawContentsEvent();
0175 
0176     QPainter *painter() const
0177     {
0178         return m_painter;
0179     }
0180     int clipx() const
0181     {
0182         return m_clipx;
0183     }
0184     int clipy() const
0185     {
0186         return m_clipy;
0187     }
0188     int clipw() const
0189     {
0190         return m_clipw;
0191     }
0192     int cliph() const
0193     {
0194         return m_cliph;
0195     }
0196 
0197     static bool test(const QEvent *event)
0198     {
0199         return KParts::Event::test(event, s_strDrawContentsEvent);
0200     }
0201 
0202 private:
0203     QPainter *m_painter;
0204     int m_clipx;
0205     int m_clipy;
0206     int m_clipw;
0207     int m_cliph;
0208     class DrawContentsEventPrivate;
0209     DrawContentsEventPrivate *d;
0210     static const char *s_strDrawContentsEvent;
0211 };
0212 
0213 }
0214 
0215 #endif