khtml Library API Documentation

dom2_events.h

00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
00005  *           (C) 2003 Apple Computer, Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  *
00022  */
00023 
00024 #ifndef _DOM_Events_h_
00025 #define _DOM_Events_h_
00026 
00027 #include <dom/dom_node.h>
00028 #include <dom/dom_misc.h>
00029 
00030 namespace KJS {
00031     class Image;
00032 }
00033 
00034 namespace DOM {
00035 
00036 class Event;
00037 class EventException;
00038 class UIEvent;
00039 class MouseEvent;
00040 class TextEvent;
00041 class MutationEvent;
00042 class AbstractView;
00043 
00044 class EventListenerImpl;
00045 class EventImpl;
00046 class UIEventImpl;
00047 class MouseEventImpl;
00048 class TextEventImpl;
00049 class MutationEventImpl;
00050 
00051 
00052 
00068 class EventListener : public DomShared {
00069 public:
00070     EventListener();
00071     virtual ~EventListener();
00072 
00082     virtual void handleEvent(Event &evt);
00083 
00092     virtual DOMString eventListenerType();
00093 
00094 protected:
00099     EventListenerImpl *impl;
00100 };
00101 
00102 
00115 class Event {
00116     friend class Document;
00117     friend class NodeImpl;
00118     friend class DocumentImpl;
00119     friend class KJS::Image;
00120 public:
00121     Event();
00122     Event(const Event &other);
00123     virtual ~Event();
00124 
00125     Event & operator = (const Event &other);
00126 
00138     enum PhaseType {
00139     CAPTURING_PHASE = 1,
00140     AT_TARGET = 2,
00141     BUBBLING_PHASE = 3
00142     };
00143 
00148     DOMString type() const;
00149 
00155     Node target() const;
00156 
00163     Node currentTarget() const;
00164 
00169     unsigned short eventPhase() const;
00170 
00176     bool bubbles() const;
00177 
00184     bool cancelable() const;
00185 
00194     DOMTimeStamp timeStamp() const;
00195 
00204     void stopPropagation();
00205 
00218     void preventDefault();
00219 
00220 
00246     void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg);
00247 
00252     EventImpl *handle() const;
00253     bool isNull() const;
00254 
00262     DOMString eventModuleName();
00263 
00264 protected:
00265     Event(EventImpl *i);
00266     EventImpl *impl;
00267 };
00268 
00269 
00277 class EventException
00278 {
00279 public:
00280     EventException(unsigned short _code);
00281     EventException(const EventException &other);
00282     EventException & operator = (const EventException &other);
00283     virtual ~EventException() {}
00284 
00294     enum EventExceptionCode {
00295         UNSPECIFIED_EVENT_TYPE_ERR     = 0
00296     };
00297 
00298     unsigned short code;
00299 };
00300 
00301 
00309 class UIEvent : public Event {
00310 public:
00311     UIEvent();
00312     UIEvent(const UIEvent &other);
00313     UIEvent(const Event &other);
00314     UIEvent & operator = (const UIEvent &other);
00315     UIEvent & operator = (const Event &other);
00316     virtual ~UIEvent();
00317 
00323     AbstractView view() const;
00324 
00330     long detail() const;
00331 
00335     int keyCode() const;
00336 
00341     int layerX() const;
00342     int layerY() const;
00343 
00347     int which() const;
00348 
00369     void initUIEvent(const DOMString &typeArg,
00370                                  bool canBubbleArg,
00371                                  bool cancelableArg,
00372                                  const AbstractView &viewArg,
00373                                  long detailArg);
00374 protected:
00375     UIEvent(UIEventImpl *impl);
00376 };
00377 
00378 
00379 
00380 
00399 class MouseEvent : public UIEvent {
00400 public:
00401     MouseEvent();
00402     MouseEvent(const MouseEvent &other);
00403     MouseEvent(const Event &other);
00404     MouseEvent & operator = (const MouseEvent &other);
00405     MouseEvent & operator = (const Event &other);
00406     virtual ~MouseEvent();
00407 
00413     long screenX() const;
00414 
00420     long screenY() const;
00421 
00427     long clientX() const;
00428 
00434     long clientY() const;
00435 
00440     bool ctrlKey() const;
00441 
00447     bool shiftKey() const;
00448 
00455     bool altKey() const;
00456 
00463     bool metaKey() const;
00464 
00475     unsigned short button() const;
00476 
00484     Node relatedTarget() const;
00485 
00525     void initMouseEvent(const DOMString &typeArg,
00526                                     bool canBubbleArg,
00527                                     bool cancelableArg,
00528                                     const AbstractView &viewArg,
00529                                     long detailArg,
00530                                     long screenXArg,
00531                                     long screenYArg,
00532                                     long clientXArg,
00533                                     long clientYArg,
00534                                     bool ctrlKeyArg,
00535                                     bool altKeyArg,
00536                                     bool shiftKeyArg,
00537                                     bool metaKeyArg,
00538                                     unsigned short buttonArg,
00539                                     const Node &relatedTargetArg);
00540 protected:
00541     MouseEvent(MouseEventImpl *impl);
00542 };
00543 
00544 // Introduced in DOM Level 3:
00551 class TextEvent : public UIEvent {
00552 public:
00553     TextEvent();
00554     TextEvent(const TextEvent &other);
00555     TextEvent(const Event &other);
00556     TextEvent & operator = (const TextEvent &other);
00557     TextEvent & operator = (const Event &other);
00558     virtual ~TextEvent();
00559 
00597     void initTextEvent(const DOMString &typeArg,
00598                       bool canBubbleArg,
00599                       bool cancelableArg,
00600                       const AbstractView &viewArg,
00601                       long detailArg,
00602                       const DOMString &outputStringArg,
00603                       unsigned long keyValArg,
00604                       unsigned long virtKeyValArg,
00605                       bool inputGeneratedArg,
00606                       bool numPadArg);
00607 
00640     void initModifier(unsigned long modifierArg, bool valueArg);
00641 
00658     bool inputGenerated() const;
00659 
00667     unsigned long keyVal() const;
00668 
00676     bool numPad() const;
00677 
00687     DOMString     outputString() const;
00696     unsigned long virtKeyVal() const;
00697 
00730     bool checkModifier(unsigned long modiferArg);
00731 
00732 protected:
00733     TextEvent(TextEventImpl *impl);
00734 };
00735 
00736 
00744 class MutationEvent : public Event {
00745 public:
00746     MutationEvent();
00747     MutationEvent(const MutationEvent &other);
00748     MutationEvent(const Event &other);
00749     MutationEvent & operator = (const MutationEvent &other);
00750     MutationEvent & operator = (const Event &other);
00751     virtual ~MutationEvent();
00752 
00763     enum attrChangeType {
00764     MODIFICATION = 1,
00765     ADDITION = 2,
00766     REMOVAL = 3
00767     };
00768 
00769 
00780     Node relatedNode() const;
00781 
00788     DOMString prevValue() const;
00789 
00795     DOMString newValue() const;
00796 
00802     DOMString attrName() const;
00803 
00810     unsigned short attrChange() const;
00811 
00837     void initMutationEvent(const DOMString &typeArg,
00838                                        bool canBubbleArg,
00839                                        bool cancelableArg,
00840                                        const Node &relatedNodeArg,
00841                                        const DOMString &prevValueArg,
00842                                        const DOMString &newValueArg,
00843                                        const DOMString &attrNameArg,
00844                                        unsigned short attrChangeArg);
00845 protected:
00846     MutationEvent(MutationEventImpl *impl);
00847 };
00848 
00849 
00850 
00851 } //namespace
00852 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:37:16 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003