khtml Library API Documentation

dom2_events.cpp

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