00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00255 protected:
00256
Event(EventImpl *i);
00257 EventImpl *impl;
00258 };
00259
00260
00268 class
EventException
00269 {
00270
public:
00271 EventException(
unsigned short _code);
00272 EventException(
const EventException &other);
00273 EventException & operator = (
const EventException &other);
00274
virtual ~EventException() {}
00275
00285 enum EventExceptionCode {
00286 UNSPECIFIED_EVENT_TYPE_ERR = 0
00287 };
00288
00289
unsigned short code;
00290 };
00291
00292
00300 class UIEvent :
public Event {
00301
public:
00302
UIEvent();
00303
UIEvent(
const UIEvent &other);
00304
UIEvent(
const Event &other);
00305
UIEvent & operator = (
const UIEvent &other);
00306
UIEvent & operator = (
const Event &other);
00307
virtual ~
UIEvent();
00308
00314
AbstractView view()
const;
00315
00321
long detail()
const;
00322
00326
int keyCode()
const;
00327
00333
int pageX()
const;
00334
int pageY()
const;
00335
00340
int layerX()
const;
00341
int layerY()
const;
00342
00346
int which()
const;
00347
00368
void initUIEvent(
const DOMString &typeArg,
00369
bool canBubbleArg,
00370
bool cancelableArg,
00371
const AbstractView &viewArg,
00372
long detailArg);
00373
protected:
00374
UIEvent(UIEventImpl *impl);
00375 };
00376
00377
00378
00379
00398 class MouseEvent :
public UIEvent {
00399
public:
00400
MouseEvent();
00401
MouseEvent(
const MouseEvent &other);
00402
MouseEvent(
const Event &other);
00403
MouseEvent & operator = (
const MouseEvent &other);
00404
MouseEvent & operator = (
const Event &other);
00405
virtual ~
MouseEvent();
00406
00412
long screenX()
const;
00413
00419
long screenY()
const;
00420
00426
long clientX()
const;
00427
00433
long clientY()
const;
00434
00439
bool ctrlKey()
const;
00440
00446
bool shiftKey()
const;
00447
00454
bool altKey()
const;
00455
00462
bool metaKey()
const;
00463
00474
unsigned short button()
const;
00475
00483
Node relatedTarget()
const;
00484
00524
void initMouseEvent(
const DOMString &typeArg,
00525
bool canBubbleArg,
00526
bool cancelableArg,
00527
const AbstractView &viewArg,
00528
long detailArg,
00529
long screenXArg,
00530
long screenYArg,
00531
long clientXArg,
00532
long clientYArg,
00533
bool ctrlKeyArg,
00534
bool altKeyArg,
00535
bool shiftKeyArg,
00536
bool metaKeyArg,
00537
unsigned short buttonArg,
00538
const Node &relatedTargetArg);
00539
protected:
00540
MouseEvent(MouseEventImpl *impl);
00541 };
00542
00543
00550 class TextEvent :
public UIEvent {
00551
public:
00552
TextEvent();
00553
TextEvent(
const TextEvent &other);
00554
TextEvent(
const Event &other);
00555
TextEvent & operator = (
const TextEvent &other);
00556
TextEvent & operator = (
const Event &other);
00557
virtual ~
TextEvent();
00558
00596
void initTextEvent(
const DOMString &typeArg,
00597
bool canBubbleArg,
00598
bool cancelableArg,
00599
const AbstractView &viewArg,
00600
long detailArg,
00601
const DOMString &outputStringArg,
00602
unsigned long keyValArg,
00603
unsigned long virtKeyValArg,
00604
bool inputGeneratedArg,
00605
bool numPadArg);
00606
00639
void initModifier(
unsigned long modifierArg,
bool valueArg);
00640
00657
bool inputGenerated()
const;
00658
00666
unsigned long keyVal()
const;
00667
00675
bool numPad()
const;
00676
00686
DOMString outputString()
const;
00695
unsigned long virtKeyVal()
const;
00696
00729
bool checkModifier(
unsigned long modiferArg);
00730
00731
protected:
00732
TextEvent(TextEventImpl *impl);
00733 };
00734
00735
00743 class MutationEvent :
public Event {
00744
public:
00745
MutationEvent();
00746
MutationEvent(
const MutationEvent &other);
00747
MutationEvent(
const Event &other);
00748
MutationEvent & operator = (
const MutationEvent &other);
00749
MutationEvent & operator = (
const Event &other);
00750
virtual ~
MutationEvent();
00751
00762 enum attrChangeType {
00763 MODIFICATION = 1,
00764 ADDITION = 2,
00765 REMOVAL = 3
00766 };
00767
00768
00779
Node relatedNode() const;
00780
00787
DOMString prevValue() const;
00788
00794
DOMString newValue() const;
00795
00801
DOMString attrName() const;
00802
00809
unsigned short attrChange() const;
00810
00836
void initMutationEvent(const
DOMString &typeArg,
00837
bool canBubbleArg,
00838
bool cancelableArg,
00839 const
Node &relatedNodeArg,
00840 const
DOMString &prevValueArg,
00841 const
DOMString &newValueArg,
00842 const
DOMString &attrNameArg,
00843
unsigned short attrChangeArg);
00844 protected:
00845
MutationEvent(MutationEventImpl *impl);
00846 };
00847
00848
00849
00850 }
00851 #endif