summaryrefslogtreecommitdiffstats
path: root/khtml/khtml_events.h
blob: 446e5c6dded77e00d79a4cf36c571a15dcfbf789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* This file is part of the KDE project
   Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/
#ifndef __khtml_events_h__
#define __khtml_events_h__

#include <kparts/event.h>

#include "dom/dom_node.h"
#include "dom/dom_string.h"

namespace khtml
{

class MouseEvent : public KParts::Event
{
public:
  MouseEvent( const char *name, QMouseEvent *qmouseEvent, int x, int y,
              const DOM::DOMString &url, const DOM::DOMString& target,
              const DOM::Node &innerNode);
  virtual ~MouseEvent();

  QMouseEvent *qmouseEvent() const { return m_qmouseEvent; }
  int x() const { return m_x; }
  int y() const { return m_y; }
  int absX() const { return m_nodeAbsX; }
  int absY() const { return m_nodeAbsY; }

  DOM::DOMString url() const { return m_url; }
  DOM::DOMString target() const { return m_target; }
  DOM::Node innerNode() const { return m_innerNode; }

  // return the offset of innerNode
  long offset() const;

private:
  QMouseEvent *m_qmouseEvent;
  int m_x;
  int m_y;
  int m_nodeAbsX, m_nodeAbsY;
  DOM::DOMString m_url;
  DOM::DOMString m_target;
  DOM::Node m_innerNode;
  class MouseEventPrivate;
  MouseEventPrivate *d;
};

class MousePressEvent : public MouseEvent
{
public:
  MousePressEvent( QMouseEvent *mouseEvent, int x, int y,
                   const DOM::DOMString &url, const DOM::DOMString& target,
                   const DOM::Node &innerNode)
  : MouseEvent( s_strMousePressEvent, mouseEvent, x, y, url, target, innerNode )
  {}

  static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMousePressEvent ); }


private:
  static const char *s_strMousePressEvent;
};

class MouseDoubleClickEvent : public MouseEvent
{
public:
  // clickCount is 3 for a triple-click event
  MouseDoubleClickEvent( QMouseEvent *mouseEvent, int x, int y,
                         const DOM::DOMString &url, const DOM::DOMString& target,
		         const DOM::Node &innerNode, int clickCount = 2 )
  : MouseEvent( s_strMouseDoubleClickEvent, mouseEvent, x, y, url, target, innerNode ),
    m_clickCount( clickCount )
  {}

  static bool test( const QEvent *event )
  { return KParts::Event::test( event, s_strMouseDoubleClickEvent ); }

  int clickCount() const { return m_clickCount; }

private:
  int m_clickCount;
  static const char *s_strMouseDoubleClickEvent;
};

class MouseMoveEvent : public MouseEvent
{
public:
  MouseMoveEvent( QMouseEvent *mouseEvent, int x, int y,
                  const DOM::DOMString &url, const DOM::DOMString& target,
		   const DOM::Node &innerNode)
  : MouseEvent( s_strMouseMoveEvent, mouseEvent, x, y, url, target, innerNode )
  {}

  static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseMoveEvent ); }

private:
  static const char *s_strMouseMoveEvent;
};

class MouseReleaseEvent : public MouseEvent
{
public:
  MouseReleaseEvent( QMouseEvent *mouseEvent, int x, int y,
                     const DOM::DOMString &url, const DOM::DOMString& target,
		     const DOM::Node &innerNode, long = 0 )
  : MouseEvent( s_strMouseReleaseEvent, mouseEvent, x, y, url, target, innerNode )
  {}

  static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strMouseReleaseEvent ); }

private:
  static const char *s_strMouseReleaseEvent;
};

class DrawContentsEvent : public KParts::Event
{
public:
  DrawContentsEvent( QPainter *painter, int clipx, int clipy, int clipw, int cliph );
  virtual ~DrawContentsEvent();

  QPainter *painter() const { return m_painter; }
  int clipx() const { return m_clipx; }
  int clipy() const { return m_clipy; }
  int clipw() const { return m_clipw; }
  int cliph() const { return m_cliph; }

  static bool test( const QEvent *event ) { return KParts::Event::test( event, s_strDrawContentsEvent ); }

private:
  QPainter *m_painter;
  int m_clipx;
  int m_clipy;
  int m_clipw;
  int m_cliph;
  class DrawContentsEventPrivate;
  DrawContentsEventPrivate *d;
  static const char *s_strDrawContentsEvent;
};

}

#endif