00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _KJS_EVENTS_H_
00022 #define _KJS_EVENTS_H_
00023
00024 #include "ecma/kjs_dom.h"
00025 #include "dom/dom2_events.h"
00026 #include "dom/dom_misc.h"
00027
00028 namespace KJS {
00029
00030 class Window;
00031
00032 class JSEventListener : public DOM::EventListener {
00033 public:
00039 JSEventListener(Object _listener, const Object &_win, bool _html = false);
00040 virtual ~JSEventListener();
00041 void hackSetThisObj( Object& thisObj ) { m_hackThisObj = thisObj; }
00042 void hackUnsetThisObj() { m_hackThisObj = Object(0L); }
00043 virtual void handleEvent(DOM::Event &evt);
00044 virtual DOM::DOMString eventListenerType();
00045
00046 Object listenerObj() const { return listener; }
00047
00048 ObjectImp *listenerObjImp() const { return static_cast<ObjectImp *>(listener.imp()); }
00049
00050 void clear() { listener = Object(); }
00051
00052 protected:
00053 Object listener;
00054 bool html;
00055 Object win, m_hackThisObj;
00056 };
00057
00058 Value getNodeEventListener(DOM::Node n, int eventId);
00059
00060
00061 class EventConstructor : public DOMObject {
00062 public:
00063 EventConstructor(ExecState *);
00064 virtual Value tryGet(ExecState *exec,const UString &p) const;
00065 Value getValueProperty(ExecState *, int token) const;
00066
00067 virtual const ClassInfo* classInfo() const { return &info; }
00068 static const ClassInfo info;
00069 };
00070
00071 Value getEventConstructor(ExecState *exec);
00072
00073 class DOMEvent : public DOMObject {
00074 public:
00075 DOMEvent(ExecState *exec, DOM::Event e);
00076 ~DOMEvent();
00077 virtual Value tryGet(ExecState *exec,const UString &p) const;
00078 Value getValueProperty(ExecState *, int token) const;
00079 virtual void tryPut(ExecState *exec, const UString &propertyName,
00080 const Value& value, int attr = None);
00081 void putValueProperty(ExecState *exec, int token, const Value& value, int);
00082 virtual const ClassInfo* classInfo() const { return &info; }
00083 static const ClassInfo info;
00084 enum { Type, Target, CurrentTarget, EventPhase, Bubbles,
00085 Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
00086
00087 SrcElement, ReturnValue, CancelBubble };
00088 DOM::Event toEvent() const { return event; }
00089 protected:
00090 DOM::Event event;
00091 };
00092
00093 Value getDOMEvent(ExecState *exec, DOM::Event e);
00094
00098 DOM::Event toEvent(const Value&);
00099
00100
00101 class EventExceptionConstructor : public DOMObject {
00102 public:
00103 EventExceptionConstructor(ExecState *);
00104 virtual Value tryGet(ExecState *exec,const UString &p) const;
00105 Value getValueProperty(ExecState *, int token) const;
00106
00107 virtual const ClassInfo* classInfo() const { return &info; }
00108 static const ClassInfo info;
00109 };
00110
00111 Value getEventExceptionConstructor(ExecState *exec);
00112
00113 class DOMUIEvent : public DOMEvent {
00114 public:
00115 DOMUIEvent(ExecState *exec, DOM::UIEvent ue) : DOMEvent(exec, ue) {}
00116 ~DOMUIEvent();
00117 virtual Value tryGet(ExecState *exec,const UString &p) const;
00118 Value getValueProperty(ExecState *, int token) const;
00119
00120 virtual const ClassInfo* classInfo() const { return &info; }
00121 static const ClassInfo info;
00122 enum { View, Detail, InitUIEvent };
00123 DOM::UIEvent toUIEvent() const { return static_cast<DOM::UIEvent>(event); }
00124 };
00125
00126 class DOMMouseEvent : public DOMUIEvent {
00127 public:
00128 DOMMouseEvent(ExecState *exec, DOM::MouseEvent me) : DOMUIEvent(exec, me) {}
00129 ~DOMMouseEvent();
00130 virtual Value tryGet(ExecState *exec,const UString &p) const;
00131 Value getValueProperty(ExecState *, int token) const;
00132
00133 virtual const ClassInfo* classInfo() const { return &info; }
00134 static const ClassInfo info;
00135 enum { ScreenX, ScreenY, ClientX, X, ClientY, Y, OffsetX, OffsetY,
00136 CtrlKey, ShiftKey, AltKey,
00137 MetaKey, Button, RelatedTarget, FromElement, ToElement,
00138 InitMouseEvent };
00139 DOM::MouseEvent toMouseEvent() const { return static_cast<DOM::MouseEvent>(event); }
00140 };
00141
00142 class DOMTextEvent : public DOMUIEvent {
00143 public:
00144 DOMTextEvent(ExecState *exec, DOM::TextEvent ke) : DOMUIEvent(exec, ke) {}
00145 ~DOMTextEvent();
00146 virtual Value tryGet(ExecState *exec,const UString &p) const;
00147 Value getValueProperty(ExecState *, int token) const;
00148
00149 virtual const ClassInfo* classInfo() const { return &info; }
00150 static const ClassInfo info;
00151 enum { Key, VirtKey, OutputString, InitTextEvent, InputGenerated, NumPad };
00152 DOM::TextEvent toTextEvent() const { return static_cast<DOM::TextEvent>(event); }
00153 };
00154
00155
00156 class MutationEventConstructor : public DOMObject {
00157 public:
00158 MutationEventConstructor(ExecState *);
00159 virtual Value tryGet(ExecState *exec,const UString &p) const;
00160 Value getValueProperty(ExecState *, int token) const;
00161
00162 virtual const ClassInfo* classInfo() const { return &info; }
00163 static const ClassInfo info;
00164 };
00165
00166 Value getMutationEventConstructor(ExecState *exec);
00167
00168 class DOMMutationEvent : public DOMEvent {
00169 public:
00170 DOMMutationEvent(ExecState *exec, DOM::MutationEvent me) : DOMEvent(exec, me) {}
00171 ~DOMMutationEvent();
00172 virtual Value tryGet(ExecState *exec,const UString &p) const;
00173 Value getValueProperty(ExecState *, int token) const;
00174
00175 virtual const ClassInfo* classInfo() const { return &info; }
00176 static const ClassInfo info;
00177 enum { AttrChange, RelatedNode, AttrName, PrevValue, NewValue,
00178 InitMutationEvent };
00179 DOM::MutationEvent toMutationEvent() const { return static_cast<DOM::MutationEvent>(event); }
00180 };
00181
00182 };
00183
00184 #endif