00001
00023 #include "dom/dom2_views.h"
00024 #include "dom/dom_exception.h"
00025 #include "xml/dom2_eventsimpl.h"
00026
00027 using namespace DOM;
00028
00029 EventListener::EventListener()
00030 {
00031 }
00032
00033 EventListener::~EventListener()
00034 {
00035 }
00036
00037 void EventListener::handleEvent(Event &)
00038 {
00039 }
00040
00041 DOMString EventListener::eventListenerType()
00042 {
00043 return "";
00044 }
00045
00046
00047
00048 Event::Event()
00049 {
00050 impl = 0;
00051 }
00052
00053
00054 Event::Event(const Event &other)
00055 {
00056 impl = other.impl;
00057 if (impl) impl->ref();
00058 }
00059
00060 Event::Event(EventImpl *i)
00061 {
00062 impl = i;
00063 if (impl) impl->ref();
00064 }
00065
00066 Event::~Event()
00067 {
00068 if (impl) impl->deref();
00069 }
00070
00071 Event &Event::operator = (const Event &other)
00072 {
00073 if ( impl != other.impl ) {
00074 if(impl) impl->deref();
00075 impl = other.impl;
00076 if(impl) impl->ref();
00077 }
00078 return *this;
00079 }
00080
00081 DOMString Event::type() const
00082 {
00083 if (!impl)
00084 throw DOMException(DOMException::INVALID_STATE_ERR);
00085
00086 return impl->type();
00087 }
00088
00089 Node Event::target() const
00090 {
00091 if (!impl)
00092 throw DOMException(DOMException::INVALID_STATE_ERR);
00093
00094 return impl->target();
00095 }
00096
00097 Node Event::currentTarget() const
00098 {
00099 if (!impl)
00100 throw DOMException(DOMException::INVALID_STATE_ERR);
00101
00102 return impl->currentTarget();
00103 }
00104
00105 unsigned short Event::eventPhase() const
00106 {
00107 if (!impl)
00108 throw DOMException(DOMException::INVALID_STATE_ERR);
00109
00110 return impl->eventPhase();
00111 }
00112
00113 bool Event::bubbles() const
00114 {
00115 if (!impl)
00116 throw DOMException(DOMException::INVALID_STATE_ERR);
00117
00118 return impl->bubbles();
00119 }
00120
00121 bool Event::cancelable() const
00122 {
00123 if (!impl)
00124 throw DOMException(DOMException::INVALID_STATE_ERR);
00125
00126 return impl->cancelable();
00127 }
00128
00129 DOMTimeStamp Event::timeStamp() const
00130 {
00131 if (!impl)
00132 throw DOMException(DOMException::INVALID_STATE_ERR);
00133
00134 return impl->timeStamp();
00135 }
00136
00137 void Event::stopPropagation()
00138 {
00139 if (!impl)
00140 throw DOMException(DOMException::INVALID_STATE_ERR);
00141
00142 impl->stopPropagation(true);
00143 }
00144
00145 void Event::preventDefault()
00146 {
00147 if (!impl)
00148 throw DOMException(DOMException::INVALID_STATE_ERR);
00149
00150 impl->preventDefault(true);
00151 }
00152
00153 void Event::initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg)
00154 {
00155 if (!impl)
00156 throw DOMException(DOMException::INVALID_STATE_ERR);
00157
00158 impl->initEvent(eventTypeArg,canBubbleArg,cancelableArg);
00159 }
00160
00161 EventImpl *Event::handle() const
00162 {
00163 return impl;
00164 }
00165
00166 bool Event::isNull() const
00167 {
00168 return (impl == 0);
00169 }
00170
00171
00172
00173 #ifndef SAVE_SPACE
00174
00175 EventException::EventException(unsigned short _code)
00176 {
00177 code = _code;
00178 }
00179
00180 EventException::EventException(const EventException &other)
00181 {
00182 code = other.code;
00183 }
00184
00185 EventException & EventException::operator = (const EventException &other)
00186 {
00187 code = other.code;
00188 return *this;
00189 }
00190
00191 #endif
00192
00193
00194
00195 UIEvent::UIEvent() : Event()
00196 {
00197 }
00198
00199 UIEvent::UIEvent(const UIEvent &other) : Event(other)
00200 {
00201 }
00202
00203 UIEvent::UIEvent(const Event &other) : Event()
00204 {
00205 (*this)=other;
00206 }
00207
00208 UIEvent::UIEvent(UIEventImpl *impl) : Event(impl)
00209 {
00210 }
00211
00212 UIEvent &UIEvent::operator = (const UIEvent &other)
00213 {
00214 Event::operator = (other);
00215 return *this;
00216 }
00217
00218 UIEvent &UIEvent::operator = (const Event &other)
00219 {
00220 Event e;
00221 e = other;
00222 if (!e.isNull() && !e.handle()->isUIEvent()) {
00223 if ( impl ) impl->deref();
00224 impl = 0;
00225 } else
00226 Event::operator = (other);
00227 return *this;
00228 }
00229
00230 UIEvent::~UIEvent()
00231 {
00232 }
00233
00234 AbstractView UIEvent::view() const
00235 {
00236 if (!impl)
00237 throw DOMException(DOMException::INVALID_STATE_ERR);
00238
00239 return static_cast<UIEventImpl*>(impl)->view();
00240 }
00241
00242 long UIEvent::detail() const
00243 {
00244 if (!impl)
00245 throw DOMException(DOMException::INVALID_STATE_ERR);
00246
00247 return static_cast<UIEventImpl*>(impl)->detail();
00248 }
00249
00250 int UIEvent::keyCode() const
00251 {
00252 if ( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR );
00253
00254 return static_cast<UIEventImpl*>(impl)->keyCode();
00255 }
00256
00257 int UIEvent::charCode() const
00258 {
00259 if (!impl)
00260 throw DOMException(DOMException::INVALID_STATE_ERR);
00261
00262 return static_cast<UIEventImpl*>(impl)->charCode();
00263 }
00264
00265 int UIEvent::pageX() const
00266 {
00267 if (!impl)
00268 throw DOMException(DOMException::INVALID_STATE_ERR);
00269
00270 return static_cast<UIEventImpl*>(impl)->pageX();
00271 }
00272
00273 int UIEvent::pageY() const
00274 {
00275 if (!impl)
00276 throw DOMException(DOMException::INVALID_STATE_ERR);
00277
00278 return static_cast<UIEventImpl*>(impl)->pageY();
00279 }
00280
00281 int UIEvent::layerX() const
00282 {
00283 if( !impl )
00284 throw DOMException( DOMException::INVALID_STATE_ERR );
00285
00286 return static_cast<UIEventImpl*>(impl)->layerX();
00287 }
00288
00289 int UIEvent::layerY() const
00290 {
00291 if( !impl )
00292 throw DOMException( DOMException::INVALID_STATE_ERR );
00293
00294 return static_cast<UIEventImpl*>(impl)->layerY();
00295 }
00296
00297 int UIEvent::which() const
00298 {
00299 if( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR );
00300 return static_cast<UIEventImpl*>(impl)->which();
00301 }
00302
00303 void UIEvent::initUIEvent(const DOMString &typeArg,
00304 bool canBubbleArg,
00305 bool cancelableArg,
00306 const AbstractView &viewArg,
00307 long detailArg)
00308 {
00309 if (!impl)
00310 throw DOMException(DOMException::INVALID_STATE_ERR);
00311
00312 static_cast<UIEventImpl*>(impl)->initUIEvent(typeArg,canBubbleArg,cancelableArg,
00313 viewArg.handle(),detailArg);
00314 }
00315
00316
00317
00318 MouseEvent::MouseEvent() : UIEvent()
00319 {
00320 }
00321
00322 MouseEvent::MouseEvent(const MouseEvent &other) : UIEvent(other)
00323 {
00324 }
00325
00326 MouseEvent::MouseEvent(const Event &other) : UIEvent()
00327 {
00328 (*this)=other;
00329 }
00330
00331 MouseEvent::MouseEvent(MouseEventImpl *impl) : UIEvent(impl)
00332 {
00333 }
00334
00335 MouseEvent &MouseEvent::operator = (const MouseEvent &other)
00336 {
00337 UIEvent::operator = (other);
00338 return *this;
00339 }
00340
00341 MouseEvent &MouseEvent::operator = (const Event &other)
00342 {
00343 Event e;
00344 e = other;
00345 if (!e.isNull() && !e.handle()->isMouseEvent()) {
00346 if ( impl ) impl->deref();
00347 impl = 0;
00348 } else
00349 UIEvent::operator = (other);
00350 return *this;
00351 }
00352
00353 MouseEvent::~MouseEvent()
00354 {
00355 }
00356
00357 long MouseEvent::screenX() const
00358 {
00359 if (!impl)
00360 throw DOMException(DOMException::INVALID_STATE_ERR);
00361
00362 return static_cast<MouseEventImpl*>(impl)->screenX();
00363 }
00364
00365 long MouseEvent::screenY() const
00366 {
00367 if (!impl)
00368 throw DOMException(DOMException::INVALID_STATE_ERR);
00369
00370 return static_cast<MouseEventImpl*>(impl)->screenY();
00371 }
00372
00373 long MouseEvent::clientX() const
00374 {
00375 if (!impl)
00376 throw DOMException(DOMException::INVALID_STATE_ERR);
00377
00378 return static_cast<MouseEventImpl*>(impl)->clientX();
00379 }
00380
00381 long MouseEvent::clientY() const
00382 {
00383 if (!impl)
00384 throw DOMException(DOMException::INVALID_STATE_ERR);
00385
00386 return static_cast<MouseEventImpl*>(impl)->clientY();
00387 }
00388
00389 bool MouseEvent::ctrlKey() const
00390 {
00391 if (!impl)
00392 throw DOMException(DOMException::INVALID_STATE_ERR);
00393
00394 return static_cast<MouseEventImpl*>(impl)->ctrlKey();
00395 }
00396
00397 bool MouseEvent::shiftKey() const
00398 {
00399 if (!impl)
00400 throw DOMException(DOMException::INVALID_STATE_ERR);
00401
00402 return static_cast<MouseEventImpl*>(impl)->shiftKey();
00403 }
00404
00405 bool MouseEvent::altKey() const
00406 {
00407 if (!impl)
00408 throw DOMException(DOMException::INVALID_STATE_ERR);
00409
00410 return static_cast<MouseEventImpl*>(impl)->altKey();
00411 }
00412
00413 bool MouseEvent::metaKey() const
00414 {
00415 if (!impl)
00416 throw DOMException(DOMException::INVALID_STATE_ERR);
00417
00418 return static_cast<MouseEventImpl*>(impl)->metaKey();
00419 }
00420
00421 unsigned short MouseEvent::button() const
00422 {
00423 if (!impl)
00424 throw DOMException(DOMException::INVALID_STATE_ERR);
00425
00426 return static_cast<MouseEventImpl*>(impl)->button();
00427 }
00428
00429 Node MouseEvent::relatedTarget() const
00430 {
00431 if (!impl)
00432 throw DOMException(DOMException::INVALID_STATE_ERR);
00433
00434 return static_cast<MouseEventImpl*>(impl)->relatedTarget();
00435 }
00436
00437 void MouseEvent::initMouseEvent(const DOMString &typeArg,
00438 bool canBubbleArg,
00439 bool cancelableArg,
00440 const AbstractView &viewArg,
00441 long detailArg,
00442 long screenXArg,
00443 long screenYArg,
00444 long clientXArg,
00445 long clientYArg,
00446 bool ctrlKeyArg,
00447 bool altKeyArg,
00448 bool shiftKeyArg,
00449 bool metaKeyArg,
00450 unsigned short buttonArg,
00451 const Node &relatedTargetArg)
00452 {
00453 if (!impl)
00454 throw DOMException(DOMException::INVALID_STATE_ERR);
00455
00456 static_cast<MouseEventImpl*>(impl)->initMouseEvent(typeArg,canBubbleArg,
00457 cancelableArg,viewArg.handle(),detailArg,screenXArg,screenYArg,clientXArg,
00458 clientYArg,ctrlKeyArg,altKeyArg,shiftKeyArg,metaKeyArg,buttonArg,
00459 relatedTargetArg);
00460 }
00461
00462
00463
00464 TextEvent::TextEvent() : UIEvent()
00465 {
00466 }
00467
00468 TextEvent::TextEvent(const TextEvent &other) : UIEvent(other)
00469 {
00470 }
00471
00472 TextEvent::TextEvent(const Event &other) : UIEvent()
00473 {
00474 (*this)=other;
00475 }
00476
00477 TextEvent &TextEvent::operator = (const TextEvent &other)
00478 {
00479 UIEvent::operator = (other);
00480 return *this;
00481 }
00482
00483 TextEvent &TextEvent::operator = (const Event &other)
00484 {
00485 Event e;
00486 e = other;
00487 if (!e.isNull() && !e.handle()->isTextInputEvent()) {
00488 if ( impl ) impl->deref();
00489 impl = 0;
00490 } else
00491 UIEvent::operator = (other);
00492 return *this;
00493 }
00494
00495 TextEvent::~TextEvent()
00496 {
00497 }
00498
00499 void TextEvent::initTextEvent(const DOMString &typeArg,
00500 bool canBubbleArg,
00501 bool cancelableArg,
00502 const AbstractView &viewArg,
00503 const DOMString &dataArg)
00504 {
00505 static_cast<TextEventImpl*>(impl)->initTextEvent(
00506 typeArg, canBubbleArg, cancelableArg, viewArg.handle(), dataArg);
00507 }
00508
00509
00510 KeyboardEvent::KeyboardEvent() : UIEvent()
00511 {
00512 }
00513
00514 KeyboardEvent::KeyboardEvent(const KeyboardEvent &other) : UIEvent(other)
00515 {
00516 }
00517
00518 KeyboardEvent::KeyboardEvent(const Event &other) : UIEvent()
00519 {
00520 (*this)=other;
00521 }
00522
00523 KeyboardEvent &KeyboardEvent::operator = (const KeyboardEvent &other)
00524 {
00525 UIEvent::operator = (other);
00526 return *this;
00527 }
00528
00529 KeyboardEvent &KeyboardEvent::operator = (const Event &other)
00530 {
00531 Event e;
00532 e = other;
00533 if (!e.isNull() && !e.handle()->isKeyboardEvent()) {
00534 if ( impl ) impl->deref();
00535 impl = 0;
00536 } else
00537 UIEvent::operator = (other);
00538 return *this;
00539 }
00540
00541 KeyboardEvent::~KeyboardEvent()
00542 {
00543 }
00544
00545 DOMString KeyboardEvent::keyIdentifier() const
00546 {
00547 return static_cast<const KeyboardEventImpl*>(impl)->keyIdentifier();
00548 }
00549
00550 unsigned long KeyboardEvent::keyLocation() const
00551 {
00552 return static_cast<const KeyboardEventImpl*>(impl)->keyLocation();
00553 }
00554
00555 bool KeyboardEvent::ctrlKey() const
00556 {
00557 return static_cast<const KeyboardEventImpl*>(impl)->ctrlKey();
00558 }
00559
00560 bool KeyboardEvent::shiftKey() const
00561 {
00562 return static_cast<const KeyboardEventImpl*>(impl)->shiftKey();
00563 }
00564
00565 bool KeyboardEvent::altKey() const
00566 {
00567 return static_cast<const KeyboardEventImpl*>(impl)->altKey();
00568 }
00569
00570 bool KeyboardEvent::metaKey() const
00571 {
00572 return static_cast<const KeyboardEventImpl*>(impl)->metaKey();
00573 }
00574
00575 bool KeyboardEvent::getModifierState(DOMString keyIdentifierArg) const
00576 {
00577 return static_cast<const KeyboardEventImpl*>(impl)->getModifierState(keyIdentifierArg);
00578 }
00579
00580 void KeyboardEvent::initKeyboardEvent(DOMString typeArg,
00581 bool canBubbleArg,
00582 bool cancelableArg,
00583 AbstractView viewArg,
00584 DOMString keyIdentifierArg,
00585 unsigned long keyLocationArg,
00586 DOMString modifiersList)
00587 {
00588 static_cast<KeyboardEventImpl*>(impl)->initKeyboardEvent(typeArg,
00589 canBubbleArg, cancelableArg, viewArg.handle(), keyIdentifierArg, keyLocationArg, modifiersList);
00590 }
00591
00592
00593
00594
00595 MutationEvent::MutationEvent() : Event()
00596 {
00597 }
00598
00599 MutationEvent::MutationEvent(const MutationEvent &other) : Event(other)
00600 {
00601 }
00602
00603 MutationEvent::MutationEvent(const Event &other) : Event()
00604 {
00605 (*this)=other;
00606 }
00607
00608 MutationEvent::MutationEvent(MutationEventImpl *impl) : Event(impl)
00609 {
00610 }
00611
00612 MutationEvent &MutationEvent::operator = (const MutationEvent &other)
00613 {
00614 Event::operator = (other);
00615 return *this;
00616 }
00617
00618 MutationEvent &MutationEvent::operator = (const Event &other)
00619 {
00620 Event e;
00621 e = other;
00622 if (!e.isNull() && !e.handle()->isMutationEvent()) {
00623 if ( impl ) impl->deref();
00624 impl = 0;
00625 } else
00626 Event::operator = (other);
00627 return *this;
00628 }
00629
00630 MutationEvent::~MutationEvent()
00631 {
00632 }
00633
00634 Node MutationEvent::relatedNode() const
00635 {
00636 if (!impl)
00637 throw DOMException(DOMException::INVALID_STATE_ERR);
00638
00639 return static_cast<MutationEventImpl*>(impl)->relatedNode();
00640 }
00641
00642 DOMString MutationEvent::prevValue() const
00643 {
00644 if (!impl)
00645 throw DOMException(DOMException::INVALID_STATE_ERR);
00646
00647 return static_cast<MutationEventImpl*>(impl)->prevValue();
00648 }
00649
00650 DOMString MutationEvent::newValue() const
00651 {
00652 if (!impl)
00653 throw DOMException(DOMException::INVALID_STATE_ERR);
00654
00655 return static_cast<MutationEventImpl*>(impl)->newValue();
00656 }
00657
00658 DOMString MutationEvent::attrName() const
00659 {
00660 if (!impl)
00661 throw DOMException(DOMException::INVALID_STATE_ERR);
00662
00663 return static_cast<MutationEventImpl*>(impl)->attrName();
00664 }
00665
00666 unsigned short MutationEvent::attrChange() const
00667 {
00668 if (!impl)
00669 throw DOMException(DOMException::INVALID_STATE_ERR);
00670
00671 return static_cast<MutationEventImpl*>(impl)->attrChange();
00672 }
00673
00674 void MutationEvent::initMutationEvent(const DOMString &typeArg,
00675 bool canBubbleArg,
00676 bool cancelableArg,
00677 const Node &relatedNodeArg,
00678 const DOMString &prevValueArg,
00679 const DOMString &newValueArg,
00680 const DOMString &attrNameArg,
00681 unsigned short attrChangeArg)
00682 {
00683 if (!impl)
00684 throw DOMException(DOMException::INVALID_STATE_ERR);
00685
00686 static_cast<MutationEventImpl*>(impl)->initMutationEvent(typeArg,
00687 canBubbleArg,cancelableArg,relatedNodeArg,prevValueArg,
00688 newValueArg,attrNameArg,attrChangeArg);
00689 }
00690
00691