KHtml

dom2_events.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 2001 Peter Kelly ([email protected])
5  * Copyright 2003 Apple Computer, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  * This file includes excerpts from the Document Object Model (DOM)
23  * Level 3 Events Specification (Working Group Note 07 November 2003)
24  * https://www.w3.org/TR/DOM-Level-3-Events/
25  * Copyright © 2003 World Wide Web Consortium , (Massachusetts Institute of
26  * Technology, European Research Consortium for Informatics and Mathematics,
27  * Keio University ). All Rights Reserved.
28  *
29  */
30 
31 #ifndef _DOM_Events_h_
32 #define _DOM_Events_h_
33 
34 #include <dom/dom_node.h>
35 #include <dom/dom_misc.h>
36 
37 namespace DOM
38 {
39 
40 class Event;
41 class EventException;
42 class UIEvent;
43 class MouseEvent;
44 class TextEvent;
45 class MutationEvent;
46 class AbstractView;
47 
48 class EventListenerImpl;
49 class EventImpl;
50 class UIEventImpl;
51 class MouseEventImpl;
52 class MutationEventImpl;
53 
69 class KHTML_EXPORT EventListener : public DomShared
70 {
71 public:
72  EventListener();
73  virtual ~EventListener();
74 
84  virtual void handleEvent(Event &evt);
85 
94  virtual DOMString eventListenerType();
95 
96 protected:
101  EventListenerImpl *impl;
102 };
103 
116 class KHTML_EXPORT Event
117 {
118  friend class Document;
119  friend class NodeImpl;
120  friend class DocumentImpl;
121 public:
122  Event();
123  Event(const Event &other);
124  virtual ~Event();
125 
126  Event &operator = (const Event &other);
127 
139  enum PhaseType {
140  CAPTURING_PHASE = 1,
141  AT_TARGET = 2,
142  BUBBLING_PHASE = 3
143  };
144 
149  DOMString type() const;
150 
156  Node target() const;
157 
164  Node currentTarget() const;
165 
170  unsigned short eventPhase() const;
171 
177  bool bubbles() const;
178 
185  bool cancelable() const;
186 
195  DOMTimeStamp timeStamp() const;
196 
205  void stopPropagation();
206 
219  void preventDefault();
220 
246  void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg);
247 
252  EventImpl *handle() const;
253  bool isNull() const;
254 
255  Event(EventImpl *i);
256 protected:
257  EventImpl *impl;
258 };
259 
267 class KHTML_EXPORT EventException
268 {
269 public:
270  EventException(unsigned short _code);
271  EventException(const EventException &other);
272  EventException &operator = (const EventException &other);
273  virtual ~EventException() {}
274 
285  UNSPECIFIED_EVENT_TYPE_ERR = 0,
286  _EXCEPTION_OFFSET = 3000,
287  _EXCEPTION_MAX = 3999
288  };
289 
290  unsigned short code;
291 
293  DOMString codeAsString() const;
294 
296  static DOMString codeAsString(int cssCode);
297 
299  static bool isEventExceptionCode(int exceptioncode);
300 
301 };
302 
310 class KHTML_EXPORT UIEvent : public Event
311 {
312 public:
313  UIEvent();
314  UIEvent(const UIEvent &other);
315  UIEvent(const Event &other);
316  UIEvent &operator = (const UIEvent &other);
317  UIEvent &operator = (const Event &other);
318  virtual ~UIEvent();
319 
325  AbstractView view() const;
326 
332  long detail() const;
333 
338  int keyCode() const;
339 
344  int charCode() const;
345 
350  int pageX() const;
351  int pageY() const;
352 
357  int layerX() const;
358  int layerY() const;
359 
364  int which() const;
365 
386  void initUIEvent(const DOMString &typeArg,
387  bool canBubbleArg,
388  bool cancelableArg,
389  const AbstractView &viewArg,
390  long detailArg);
391 protected:
392  UIEvent(UIEventImpl *impl);
393 };
394 
413 class KHTML_EXPORT MouseEvent : public UIEvent
414 {
415 public:
416  MouseEvent();
417  MouseEvent(const MouseEvent &other);
418  MouseEvent(const Event &other);
419  MouseEvent &operator = (const MouseEvent &other);
420  MouseEvent &operator = (const Event &other);
421  virtual ~MouseEvent();
422 
428  long screenX() const;
429 
435  long screenY() const;
436 
442  long clientX() const;
443 
449  long clientY() const;
450 
455  bool ctrlKey() const;
456 
462  bool shiftKey() const;
463 
470  bool altKey() const;
471 
478  bool metaKey() const;
479 
490  unsigned short button() const;
491 
499  Node relatedTarget() const;
500 
540  void initMouseEvent(const DOMString &typeArg,
541  bool canBubbleArg,
542  bool cancelableArg,
543  const AbstractView &viewArg,
544  long detailArg,
545  long screenXArg,
546  long screenYArg,
547  long clientXArg,
548  long clientYArg,
549  bool ctrlKeyArg,
550  bool altKeyArg,
551  bool shiftKeyArg,
552  bool metaKeyArg,
553  unsigned short buttonArg,
554  const Node &relatedTargetArg);
555 protected:
556  MouseEvent(MouseEventImpl *impl);
557 };
558 
565 class KHTML_EXPORT TextEvent : public UIEvent
566 {
567 public:
568  TextEvent();
569  TextEvent(const TextEvent &other);
570  TextEvent(const Event &other);
571  TextEvent &operator = (const TextEvent &other);
572  TextEvent &operator = (const Event &other);
573  virtual ~TextEvent();
574 
593  void initTextEvent(const DOMString &typeArg,
594  bool canBubbleArg,
595  bool cancelableArg,
596  const AbstractView &viewArg,
597  const DOMString &dataArg);
598 
606  DOMString data() const;
607 };
608 
627 class KHTML_EXPORT KeyboardEvent : public UIEvent
628 {
629 public:
630  KeyboardEvent();
631  KeyboardEvent(const KeyboardEvent &other);
632  KeyboardEvent(const Event &other);
633  KeyboardEvent &operator = (const KeyboardEvent &other);
634  KeyboardEvent &operator = (const Event &other);
635  virtual ~KeyboardEvent();
636 
637  enum KeyLocation {
645  DOM_KEY_LOCATION_STANDARD = 0x00,
646 
654  DOM_KEY_LOCATION_LEFT = 0x01,
655 
663  DOM_KEY_LOCATION_RIGHT = 0x02,
664 
670  DOM_KEY_LOCATION_NUMPAD = 0x03
671  };
672 
680  DOMString keyIdentifier() const;
681 
689  unsigned long keyLocation() const;
690 
696  bool ctrlKey() const;
697 
703  bool shiftKey() const;
704 
710  bool altKey() const;
711 
717  bool metaKey() const;
718 
733  bool getModifierState(DOMString keyIdentifierArg) const;
734 
758  void initKeyboardEvent(DOMString typeArg,
759  bool canBubbleArg,
760  bool cancelableArg,
761  AbstractView viewArg,
762  DOMString keyIdentifierArg,
763  unsigned long keyLocationArg,
764  DOMString modifiersList);
765 };
766 
774 class KHTML_EXPORT MutationEvent : public Event
775 {
776 public:
777  MutationEvent();
778  MutationEvent(const MutationEvent &other);
779  MutationEvent(const Event &other);
780  MutationEvent &operator = (const MutationEvent &other);
781  MutationEvent &operator = (const Event &other);
782  virtual ~MutationEvent();
783 
795  MODIFICATION = 1,
796  ADDITION = 2,
797  REMOVAL = 3
798  };
799 
810  Node relatedNode() const;
811 
818  DOMString prevValue() const;
819 
825  DOMString newValue() const;
826 
832  DOMString attrName() const;
833 
840  unsigned short attrChange() const;
841 
867  void initMutationEvent(const DOMString &typeArg,
868  bool canBubbleArg,
869  bool cancelableArg,
870  const Node &relatedNodeArg,
871  const DOMString &prevValueArg,
872  const DOMString &newValueArg,
873  const DOMString &attrNameArg,
874  unsigned short attrChangeArg);
875 protected:
876  MutationEvent(MutationEventImpl *impl);
877 };
878 
879 } //namespace
880 #endif
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
Introduced in DOM Level 2.
Definition: dom2_views.h:42
Introduced in DOM Level 2.
Definition: dom2_events.h:310
Introduced in DOM Level 2.
Definition: dom2_events.h:413
attrChangeType
An integer indicating in which way the Attr was changed.
Definition: dom2_events.h:794
Introduced in DOM Level 2:
Definition: dom2_events.h:267
Introduced in DOM Level 3.
Definition: dom2_events.h:627
Introduced in DOM Level 3.
Definition: dom2_events.h:565
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
Introduced in DOM Level 2.
Definition: dom2_events.h:774
Introduced in DOM Level 2.
Definition: dom2_events.h:69
This library provides a full-featured HTML parser and widget.
EventExceptionCode
An integer indicating the type of error generated.
Definition: dom2_events.h:284
Introduced in DOM Level 2.
Definition: dom2_events.h:116
PhaseType
An integer indicating which phase of event flow is being processed.
Definition: dom2_events.h:139
unsigned long long DOMTimeStamp
EventListenerImpl * impl
Definition: dom2_events.h:101
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 22:49:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.