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