khtml Library API Documentation

dom2_events.cpp

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 &/*evt*/) 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 if( impl->isTextEvent() ) 00255 return static_cast<TextEventImpl*>( impl )->keyCode(); 00256 00257 return 0; 00258 } 00259 00260 int UIEvent::charCode() const 00261 { 00262 if (!impl) 00263 throw DOMException(DOMException::INVALID_STATE_ERR); 00264 00265 if( impl->isTextEvent() ) 00266 return static_cast<TextEventImpl*>( impl )->charCode(); 00267 00268 return 0; 00269 } 00270 00271 int UIEvent::pageX() const 00272 { 00273 if (!impl) 00274 throw DOMException(DOMException::INVALID_STATE_ERR); 00275 00276 if (impl->isMouseEvent() ) 00277 return static_cast<MouseEventImpl*>( impl )->pageX(); 00278 else 00279 return 0; 00280 } 00281 00282 int UIEvent::pageY() const 00283 { 00284 if (!impl) 00285 throw DOMException(DOMException::INVALID_STATE_ERR); 00286 00287 if ( impl->isMouseEvent() ) 00288 return static_cast<MouseEventImpl*>( impl )->pageY(); 00289 else 00290 return 0; 00291 } 00292 00293 int UIEvent::layerX() const 00294 { 00295 if( !impl ) 00296 throw DOMException( DOMException::INVALID_STATE_ERR ); 00297 00298 if( impl->isMouseEvent() ) 00299 return static_cast<MouseEventImpl*>( impl )->layerX(); 00300 return 0; 00301 } 00302 00303 int UIEvent::layerY() const 00304 { 00305 if( !impl ) 00306 throw DOMException( DOMException::INVALID_STATE_ERR ); 00307 00308 if( impl->isMouseEvent() ) 00309 return static_cast<MouseEventImpl*>( impl )->layerY(); 00310 return 0; 00311 } 00312 00313 int UIEvent::which() const 00314 { 00315 if( !impl ) throw DOMException( DOMException::INVALID_STATE_ERR ); 00316 00317 if( impl->isMouseEvent() ) 00318 return static_cast<MouseEventImpl*>( impl )->button() + 1; 00319 else if( impl->isTextEvent() ) 00320 return static_cast<TextEventImpl*>( impl )->keyCode(); 00321 00322 return 0; 00323 } 00324 00325 void UIEvent::initUIEvent(const DOMString &typeArg, 00326 bool canBubbleArg, 00327 bool cancelableArg, 00328 const AbstractView &viewArg, 00329 long detailArg) 00330 { 00331 if (!impl) 00332 throw DOMException(DOMException::INVALID_STATE_ERR); 00333 00334 static_cast<UIEventImpl*>(impl)->initUIEvent(typeArg,canBubbleArg,cancelableArg, 00335 viewArg,detailArg); 00336 } 00337 00338 // ----------------------------------------------------------------------------- 00339 00340 MouseEvent::MouseEvent() : UIEvent() 00341 { 00342 } 00343 00344 MouseEvent::MouseEvent(const MouseEvent &other) : UIEvent(other) 00345 { 00346 } 00347 00348 MouseEvent::MouseEvent(const Event &other) : UIEvent() 00349 { 00350 (*this)=other; 00351 } 00352 00353 MouseEvent::MouseEvent(MouseEventImpl *impl) : UIEvent(impl) 00354 { 00355 } 00356 00357 MouseEvent &MouseEvent::operator = (const MouseEvent &other) 00358 { 00359 UIEvent::operator = (other); 00360 return *this; 00361 } 00362 00363 MouseEvent &MouseEvent::operator = (const Event &other) 00364 { 00365 Event e; 00366 e = other; 00367 if (!e.isNull() && !e.handle()->isMouseEvent()) { 00368 if ( impl ) impl->deref(); 00369 impl = 0; 00370 } else 00371 UIEvent::operator = (other); 00372 return *this; 00373 } 00374 00375 MouseEvent::~MouseEvent() 00376 { 00377 } 00378 00379 long MouseEvent::screenX() const 00380 { 00381 if (!impl) 00382 throw DOMException(DOMException::INVALID_STATE_ERR); 00383 00384 return static_cast<MouseEventImpl*>(impl)->screenX(); 00385 } 00386 00387 long MouseEvent::screenY() const 00388 { 00389 if (!impl) 00390 throw DOMException(DOMException::INVALID_STATE_ERR); 00391 00392 return static_cast<MouseEventImpl*>(impl)->screenY(); 00393 } 00394 00395 long MouseEvent::clientX() const 00396 { 00397 if (!impl) 00398 throw DOMException(DOMException::INVALID_STATE_ERR); 00399 00400 return static_cast<MouseEventImpl*>(impl)->clientX(); 00401 } 00402 00403 long MouseEvent::clientY() const 00404 { 00405 if (!impl) 00406 throw DOMException(DOMException::INVALID_STATE_ERR); 00407 00408 return static_cast<MouseEventImpl*>(impl)->clientY(); 00409 } 00410 00411 bool MouseEvent::ctrlKey() const 00412 { 00413 if (!impl) 00414 throw DOMException(DOMException::INVALID_STATE_ERR); 00415 00416 return static_cast<MouseEventImpl*>(impl)->ctrlKey(); 00417 } 00418 00419 bool MouseEvent::shiftKey() const 00420 { 00421 if (!impl) 00422 throw DOMException(DOMException::INVALID_STATE_ERR); 00423 00424 return static_cast<MouseEventImpl*>(impl)->shiftKey(); 00425 } 00426 00427 bool MouseEvent::altKey() const 00428 { 00429 if (!impl) 00430 throw DOMException(DOMException::INVALID_STATE_ERR); 00431 00432 return static_cast<MouseEventImpl*>(impl)->altKey(); 00433 } 00434 00435 bool MouseEvent::metaKey() const 00436 { 00437 if (!impl) 00438 throw DOMException(DOMException::INVALID_STATE_ERR); 00439 00440 return static_cast<MouseEventImpl*>(impl)->metaKey(); 00441 } 00442 00443 unsigned short MouseEvent::button() const 00444 { 00445 if (!impl) 00446 throw DOMException(DOMException::INVALID_STATE_ERR); 00447 00448 return static_cast<MouseEventImpl*>(impl)->button(); 00449 } 00450 00451 Node MouseEvent::relatedTarget() const 00452 { 00453 if (!impl) 00454 throw DOMException(DOMException::INVALID_STATE_ERR); 00455 00456 return static_cast<MouseEventImpl*>(impl)->relatedTarget(); 00457 } 00458 00459 void MouseEvent::initMouseEvent(const DOMString &typeArg, 00460 bool canBubbleArg, 00461 bool cancelableArg, 00462 const AbstractView &viewArg, 00463 long detailArg, 00464 long screenXArg, 00465 long screenYArg, 00466 long clientXArg, 00467 long clientYArg, 00468 bool ctrlKeyArg, 00469 bool altKeyArg, 00470 bool shiftKeyArg, 00471 bool metaKeyArg, 00472 unsigned short buttonArg, 00473 const Node &relatedTargetArg) 00474 { 00475 if (!impl) 00476 throw DOMException(DOMException::INVALID_STATE_ERR); 00477 00478 static_cast<MouseEventImpl*>(impl)->initMouseEvent(typeArg,canBubbleArg, 00479 cancelableArg,viewArg,detailArg,screenXArg,screenYArg,clientXArg, 00480 clientYArg,ctrlKeyArg,altKeyArg,shiftKeyArg,metaKeyArg,buttonArg, 00481 relatedTargetArg); 00482 } 00483 00484 // ----------------------------------------------------------------------------- 00485 00486 TextEvent::TextEvent() : UIEvent() 00487 { 00488 } 00489 00490 TextEvent::TextEvent(const TextEvent &other) : UIEvent(other) 00491 { 00492 } 00493 00494 TextEvent::TextEvent(const Event &other) : UIEvent() 00495 { 00496 (*this)=other; 00497 } 00498 00499 TextEvent::TextEvent(TextEventImpl *impl) : UIEvent(impl) 00500 { 00501 } 00502 00503 TextEvent &TextEvent::operator = (const TextEvent &other) 00504 { 00505 UIEvent::operator = (other); 00506 return *this; 00507 } 00508 00509 TextEvent &TextEvent::operator = (const Event &other) 00510 { 00511 Event e; 00512 e = other; 00513 if (!e.isNull() && !e.handle()->isTextEvent()) { 00514 if ( impl ) impl->deref(); 00515 impl = 0; 00516 } else 00517 UIEvent::operator = (other); 00518 return *this; 00519 } 00520 00521 TextEvent::~TextEvent() 00522 { 00523 } 00524 00525 void TextEvent::initTextEvent(const DOMString &typeArg, 00526 bool canBubbleArg, 00527 bool cancelableArg, 00528 const AbstractView &viewArg, 00529 long detailArg, 00530 const DOMString &outputStringArg, 00531 unsigned long keyValArg, 00532 unsigned long virtKeyValArg, 00533 bool inputGeneratedArg, 00534 bool numPadArg) 00535 { 00536 if (!impl) 00537 throw DOMException(DOMException::INVALID_STATE_ERR); 00538 00539 return static_cast<TextEventImpl*>(impl)->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, outputStringArg, keyValArg, virtKeyValArg, inputGeneratedArg, numPadArg); 00540 } 00541 00542 unsigned long TextEvent::keyVal() const 00543 { 00544 if (!impl) 00545 throw DOMException(DOMException::INVALID_STATE_ERR); 00546 00547 return static_cast<TextEventImpl*>(impl)->keyVal(); 00548 } 00549 00550 DOMString TextEvent::outputString() const 00551 { 00552 if (!impl) 00553 throw DOMException(DOMException::INVALID_STATE_ERR); 00554 00555 return static_cast<TextEventImpl*>(impl)->outputString(); 00556 } 00557 00558 unsigned long TextEvent::virtKeyVal() const 00559 { 00560 if (!impl) 00561 throw DOMException(DOMException::INVALID_STATE_ERR); 00562 00563 return static_cast<TextEventImpl*>(impl)->virtKeyVal(); 00564 } 00565 00566 void TextEvent::initModifier(unsigned long modifierArg, bool valueArg) 00567 { 00568 if (!impl) 00569 throw DOMException(DOMException::INVALID_STATE_ERR); 00570 00571 return static_cast<TextEventImpl*>(impl)->initModifier(modifierArg,valueArg); 00572 } 00573 00574 bool TextEvent::checkModifier(unsigned long modiferArg) 00575 { 00576 if (!impl) 00577 throw DOMException(DOMException::INVALID_STATE_ERR); 00578 00579 return static_cast<TextEventImpl*>(impl)->checkModifier(modiferArg); 00580 } 00581 00582 bool TextEvent::inputGenerated() const 00583 { 00584 if (!impl) 00585 throw DOMException(DOMException::INVALID_STATE_ERR); 00586 00587 return static_cast<TextEventImpl*>(impl)->inputGenerated(); 00588 } 00589 00590 bool TextEvent::numPad() const 00591 { 00592 if (!impl) 00593 throw DOMException(DOMException::INVALID_STATE_ERR); 00594 00595 return static_cast<TextEventImpl*>(impl)->numPad(); 00596 } 00597 // ----------------------------------------------------------------------------- 00598 00599 MutationEvent::MutationEvent() : Event() 00600 { 00601 } 00602 00603 MutationEvent::MutationEvent(const MutationEvent &other) : Event(other) 00604 { 00605 } 00606 00607 MutationEvent::MutationEvent(const Event &other) : Event() 00608 { 00609 (*this)=other; 00610 } 00611 00612 MutationEvent::MutationEvent(MutationEventImpl *impl) : Event(impl) 00613 { 00614 } 00615 00616 MutationEvent &MutationEvent::operator = (const MutationEvent &other) 00617 { 00618 Event::operator = (other); 00619 return *this; 00620 } 00621 00622 MutationEvent &MutationEvent::operator = (const Event &other) 00623 { 00624 Event e; 00625 e = other; 00626 if (!e.isNull() && !e.handle()->isMutationEvent()) { 00627 if ( impl ) impl->deref(); 00628 impl = 0; 00629 } else 00630 Event::operator = (other); 00631 return *this; 00632 } 00633 00634 MutationEvent::~MutationEvent() 00635 { 00636 } 00637 00638 Node MutationEvent::relatedNode() const 00639 { 00640 if (!impl) 00641 throw DOMException(DOMException::INVALID_STATE_ERR); 00642 00643 return static_cast<MutationEventImpl*>(impl)->relatedNode(); 00644 } 00645 00646 DOMString MutationEvent::prevValue() const 00647 { 00648 if (!impl) 00649 throw DOMException(DOMException::INVALID_STATE_ERR); 00650 00651 return static_cast<MutationEventImpl*>(impl)->prevValue(); 00652 } 00653 00654 DOMString MutationEvent::newValue() const 00655 { 00656 if (!impl) 00657 throw DOMException(DOMException::INVALID_STATE_ERR); 00658 00659 return static_cast<MutationEventImpl*>(impl)->newValue(); 00660 } 00661 00662 DOMString MutationEvent::attrName() const 00663 { 00664 if (!impl) 00665 throw DOMException(DOMException::INVALID_STATE_ERR); 00666 00667 return static_cast<MutationEventImpl*>(impl)->attrName(); 00668 } 00669 00670 unsigned short MutationEvent::attrChange() const 00671 { 00672 if (!impl) 00673 throw DOMException(DOMException::INVALID_STATE_ERR); 00674 00675 return static_cast<MutationEventImpl*>(impl)->attrChange(); 00676 } 00677 00678 void MutationEvent::initMutationEvent(const DOMString &typeArg, 00679 bool canBubbleArg, 00680 bool cancelableArg, 00681 const Node &relatedNodeArg, 00682 const DOMString &prevValueArg, 00683 const DOMString &newValueArg, 00684 const DOMString &attrNameArg, 00685 unsigned short attrChangeArg) 00686 { 00687 if (!impl) 00688 throw DOMException(DOMException::INVALID_STATE_ERR); 00689 00690 static_cast<MutationEventImpl*>(impl)->initMutationEvent(typeArg, 00691 canBubbleArg,cancelableArg,relatedNodeArg,prevValueArg, 00692 newValueArg,attrNameArg,attrChangeArg); 00693 } 00694 00695
KDE Logo
This file is part of the documentation for khtml Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:38:26 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003