dom2_events.cpp Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

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

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:36 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001