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