23 #include "dom/dom2_views.h"
24 #include "dom/dom_exception.h"
25 #include "xml/dom2_eventsimpl.h"
29 EventListener::EventListener()
33 EventListener::~EventListener()
41 DOMString EventListener::eventListenerType()
54 Event::Event(
const Event &other)
57 if (impl) impl->ref();
60 Event::Event(EventImpl *i)
63 if (impl) impl->ref();
68 if (impl) impl->deref();
73 if ( impl != other.impl ) {
74 if(impl) impl->deref();
94 return impl->target();
102 return impl->currentTarget();
110 return impl->eventPhase();
118 return impl->bubbles();
126 return impl->cancelable();
134 return impl->timeStamp();
142 impl->stopPropagation(
true);
150 impl->preventDefault(
true);
158 impl->initEvent(eventTypeArg,canBubbleArg,cancelableArg);
161 EventImpl *Event::handle()
const
166 bool Event::isNull()
const
175 EventException::EventException(
unsigned short _code)
195 UIEvent::UIEvent() :
Event()
203 UIEvent::UIEvent(
const Event &other) :
Event()
208 UIEvent::UIEvent(UIEventImpl *impl) :
Event(impl)
214 Event::operator = (other);
222 if (!e.isNull() && !e.handle()->isUIEvent()) {
223 if ( impl ) impl->deref();
226 Event::operator = (other);
239 return static_cast<UIEventImpl*
>(impl)->
view();
247 return static_cast<UIEventImpl*
>(impl)->
detail();
252 if ( !impl )
throw DOMException( DOMException::INVALID_STATE_ERR );
254 if( impl->isTextInputEvent() || impl->isKeyboardEvent() )
255 return static_cast<KeyEventBaseImpl*>( impl )->keyCode();
265 if( impl->isTextInputEvent() || impl->isKeyboardEvent() )
266 return static_cast<KeyEventBaseImpl*>( impl )->charCode();
276 if (impl->isMouseEvent() )
277 return static_cast<MouseEventImpl*>( impl )->pageX();
282 int UIEvent::pageY()
const
287 if ( impl->isMouseEvent() )
288 return static_cast<MouseEventImpl*>( impl )->pageY();
298 if( impl->isMouseEvent() )
299 return static_cast<MouseEventImpl*>( impl )->layerX();
303 int UIEvent::layerY()
const
308 if( impl->isMouseEvent() )
309 return static_cast<MouseEventImpl*>( impl )->layerY();
315 if( !impl )
throw DOMException( DOMException::INVALID_STATE_ERR );
317 if( impl->isMouseEvent() )
318 return static_cast<MouseEventImpl*>( impl )->button() + 1;
319 else if( impl->isTextInputEvent() || impl->isKeyboardEvent() )
322 if ( static_cast<KeyEventBaseImpl*>( impl )->keyVal() )
323 return static_cast<KeyEventBaseImpl*>( impl )->keyCode();
338 static_cast<UIEventImpl*
>(impl)->
initUIEvent(typeArg,canBubbleArg,cancelableArg,
344 MouseEvent::MouseEvent() :
UIEvent()
357 MouseEvent::MouseEvent(MouseEventImpl *impl) :
UIEvent(impl)
363 UIEvent::operator = (other);
371 if (!e.isNull() && !e.handle()->isMouseEvent()) {
372 if ( impl ) impl->deref();
375 UIEvent::operator = (other);
379 MouseEvent::~MouseEvent()
388 return static_cast<MouseEventImpl*
>(impl)->
screenX();
396 return static_cast<MouseEventImpl*
>(impl)->
screenY();
404 return static_cast<MouseEventImpl*
>(impl)->
clientX();
412 return static_cast<MouseEventImpl*
>(impl)->
clientY();
420 return static_cast<MouseEventImpl*
>(impl)->
ctrlKey();
428 return static_cast<MouseEventImpl*
>(impl)->
shiftKey();
436 return static_cast<MouseEventImpl*
>(impl)->
altKey();
444 return static_cast<MouseEventImpl*
>(impl)->
metaKey();
452 return static_cast<MouseEventImpl*
>(impl)->
button();
476 unsigned short buttonArg,
477 const Node &relatedTargetArg)
482 static_cast<MouseEventImpl*
>(impl)->
initMouseEvent(typeArg,canBubbleArg,
483 cancelableArg,viewArg,detailArg,screenXArg,screenYArg,clientXArg,
484 clientYArg,ctrlKeyArg,altKeyArg,shiftKeyArg,metaKeyArg,buttonArg,
490 TextEvent::TextEvent() :
UIEvent()
503 TextEvent::TextEvent(KeyEventBaseImpl *impl) :
UIEvent(impl)
509 UIEvent::operator = (other);
517 if (!e.isNull() && !(e.handle()->isTextInputEvent() || e.handle()->isKeyboardEvent())) {
518 if ( impl ) impl->deref();
521 UIEvent::operator = (other);
525 TextEvent::~TextEvent()
535 unsigned long keyValArg,
536 unsigned long virtKeyValArg,
543 if (impl->isTextInputEvent()) {
545 TQString text = outputStringArg.string();
546 if (outputStringArg.length() == 0 && virtKeyValArg) {
547 text += TQChar((
unsigned short)virtKeyValArg);
550 TextEventImpl* tImpl =
static_cast<TextEventImpl*
>(impl);
551 tImpl->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, text);
553 KeyboardEventImpl* kbImpl =
static_cast<KeyboardEventImpl*
>(impl);
554 kbImpl->initKeyboardEvent(typeArg, canBubbleArg, cancelableArg, viewArg,
555 keyValArg, virtKeyValArg, 0, numPadArg ?
556 KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD : KeyboardEventImpl::DOM_KEY_LOCATION_STANDARD);
565 return static_cast<KeyEventBaseImpl*
>(impl)->
keyVal();
573 KeyEventBaseImpl* ke =
static_cast<KeyEventBaseImpl*
>(impl);
574 if (ke->isTextInputEvent())
575 return static_cast<TextEventImpl*>(ke)->data();
578 return TQString(TQChar((ushort)ke->keyVal()));
589 return static_cast<KeyEventBaseImpl*
>(impl)->
virtKeyVal();
597 return static_cast<KeyEventBaseImpl*
>(impl)->
initModifier(modifierArg,valueArg);
605 return static_cast<KeyEventBaseImpl*
>(impl)->
checkModifier(modifierArg);
621 KeyEventBaseImpl* ke =
static_cast<KeyEventBaseImpl*
>(impl);
622 if (ke->isKeyboardEvent())
623 return static_cast<KeyboardEventImpl*>(ke)->keyLocation() ==
624 KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD;
629 MutationEvent::MutationEvent() :
Event()
637 MutationEvent::MutationEvent(
const Event &other) :
Event()
642 MutationEvent::MutationEvent(MutationEventImpl *impl) :
Event(impl)
648 Event::operator = (other);
656 if (!e.isNull() && !e.handle()->isMutationEvent()) {
657 if ( impl ) impl->deref();
660 Event::operator = (other);
664 MutationEvent::~MutationEvent()
673 return static_cast<MutationEventImpl*
>(impl)->
relatedNode();
681 return static_cast<MutationEventImpl*
>(impl)->
prevValue();
689 return static_cast<MutationEventImpl*
>(impl)->
newValue();
697 return static_cast<MutationEventImpl*
>(impl)->
attrName();
705 return static_cast<MutationEventImpl*
>(impl)->
attrChange();
711 const Node &relatedNodeArg,
715 unsigned short attrChangeArg)
721 canBubbleArg,cancelableArg,relatedNodeArg,prevValueArg,
722 newValueArg,attrNameArg,attrChangeArg);