• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

kjsembed

jseventmapper.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2001,2002,2003,2004,2005,2006 Ian Reinhart Geiser <geiseri@kde.org>
00003     Copyright (C) 2001,2002,2003,2004,2005,2006 Matt Broadstone <mbroadst@gmail.com>
00004     Copyright (C) 2001,2002,2003,2004,2005,2006 Richard J. Moore <rich@kde.org>
00005     Copyright (C) 2001,2002,2003,2004,2005,2006 Erik L. Bunce <kde@bunce.us>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #include "jseventmapper.h"
00023 
00024 #include "kjseglobal.h"
00025 
00026 namespace KJSEmbed {
00027 
00028 JSEventMapper *JSEventMapper::m_inst = 0;
00029 
00031 struct EventType
00032 {
00033     EventType( KJS::Identifier _id, QEvent::Type _type ) :
00034             id(_id), type(_type) {;}
00035 
00036     const KJS::Identifier id;
00037     const QEvent::Type type;
00038 };
00039 /*
00040 Qt4 events as of Qt 4.0
00041         None = 0,                               // invalid event
00042         Timer = 1,                              // timer event
00043         MouseButtonPress = 2,                   // mouse button pressed
00044         MouseButtonRelease = 3,                 // mouse button released
00045         MouseButtonDblClick = 4,                // mouse button double click
00046         MouseMove = 5,                          // mouse move
00047         KeyPress = 6,                           // key pressed
00048         KeyRelease = 7,                         // key released
00049         FocusIn = 8,                            // keyboard focus received
00050         FocusOut = 9,                           // keyboard focus lost
00051         Enter = 10,                             // mouse enters widget
00052         Leave = 11,                             // mouse leaves widget
00053         Paint = 12,                             // paint widget
00054         Move = 13,                              // move widget
00055         Resize = 14,                            // resize widget
00056         Create = 15,                            // after widget creation
00057         Destroy = 16,                           // during widget destruction
00058         Show = 17,                              // widget is shown
00059         Hide = 18,                              // widget is hidden
00060         Close = 19,                             // request to close widget
00061         Quit = 20,                              // request to quit application
00062         ParentChange = 21,                      // widget has been reparented
00063         ParentAboutToChange = 131,              // sent just before the parent change is done
00064         ThreadChange = 22,                      // object has changed threads
00065         WindowActivate = 24,                    // window was activated
00066         WindowDeactivate = 25,                  // window was deactivated
00067         ShowToParent = 26,                      // widget is shown to parent
00068         HideToParent = 27,                      // widget is hidden to parent
00069         Wheel = 31,                             // wheel event
00070         WindowTitleChange = 33,                 // window title changed
00071         WindowIconChange = 34,                  // icon changed
00072         ApplicationWindowIconChange = 35,       // application icon changed
00073         ApplicationFontChange = 36,             // application font changed
00074         ApplicationLayoutDirectionChange = 37,  // application layout direction changed
00075         ApplicationPaletteChange = 38,          // application palette changed
00076         PaletteChange = 39,                     // widget palette changed
00077         Clipboard = 40,                         // internal clipboard event
00078         Speech = 42,                            // reserved for speech input
00079         MetaCall =  43,                         // meta call event
00080         SockAct = 50,                           // socket activation
00081         WinEventAct = 123,                      // win event activation
00082         DeferredDelete = 52,                    // deferred delete event
00083         DragEnter = 60,                         // drag moves into widget
00084         DragMove = 61,                          // drag moves in widget
00085         DragLeave = 62,                         // drag leaves or is canceled
00086         Drop = 63,                              // actual drop
00087         DragResponse = 64,                      // drag accepted/rejected
00088         ChildAdded = 68,                        // new child widget
00089         ChildPolished = 69,                     // polished child widget
00090         ChildRemoved = 71,                      // deleted child widget
00091         ShowWindowRequest = 73,                 // widget's window should be mapped
00092         PolishRequest = 74,                     // widget should be polished
00093         Polish = 75,                            // widget is polished
00094         LayoutRequest = 76,                     // widget should be relayouted
00095         UpdateRequest = 77,                     // widget should be repainted
00096         EmbeddingControl = 79,                  // ActiveX embedding
00097         ActivateControl = 80,                   // ActiveX activation
00098         DeactivateControl = 81,                 // ActiveX deactivation
00099         ContextMenu = 82,                       // context popup menu
00100         InputMethod = 83,                       // input method
00101         AccessibilityPrepare = 86,              // accessibility information is requested
00102         TabletMove = 87,                        // Wacom tablet event
00103         LocaleChange = 88,                      // the system locale changed
00104         LanguageChange = 89,                    // the application language changed
00105         LayoutDirectionChange = 90,             // the layout direction changed
00106         Style = 91,                             // internal style event
00107         TabletPress = 92,                       // tablet press
00108         TabletRelease = 93,                     // tablet release
00109         OkRequest = 94,                         // CE (Ok) button pressed
00110         HelpRequest = 95,                       // CE (?)  button pressed
00111         IconDrag = 96,                          // proxy icon dragged
00112         FontChange = 97,                        // font has changed
00113         EnabledChange = 98,                     // enabled state has changed
00114         ActivationChange = 99,                  // window activation has changed
00115         StyleChange = 100,                      // style has changed
00116         IconTextChange = 101,                   // icon text has changed
00117         ModifiedChange = 102,                   // modified state has changed
00118         MouseTrackingChange = 109,              // mouse tracking state has changed
00119         WindowBlocked = 103,                    // window is about to be blocked modally
00120         WindowUnblocked = 104,                  // windows modal blocking has ended
00121         WindowStateChange = 105,
00122         ToolTip = 110,
00123         WhatsThis = 111,
00124         StatusTip = 112,
00125         ActionChanged = 113,
00126         ActionAdded = 114,
00127         ActionRemoved = 115,
00128         FileOpen = 116,                         // file open request
00129         Shortcut = 117,                         // shortcut triggered
00130         ShortcutOverride = 51,                  // shortcut override request
00131         WhatsThisClicked = 118,
00132         ToolBarChange = 120,                    // toolbar visibility toggled
00133         ApplicationActivated = 121,             // application has been changed to active
00134         ApplicationDeactivated = 122,           // application has been changed to inactive
00135         QueryWhatsThis = 123,                   // query what's this widget help
00136         EnterWhatsThisMode = 124,
00137         LeaveWhatsThisMode = 125,
00138         ZOrderChange = 126,                     // child widget has had its z-order changed
00139         HoverEnter = 127,                       // mouse cursor enters a hover widget
00140         HoverLeave = 128,                       // mouse cursor leaves a hover widget
00141         HoverMove = 129,                        // mouse cursor move inside a hover widget
00142         AccessibilityHelp = 119,                // accessibility help text request
00143         AccessibilityDescription = 130
00144 */
00145 static EventType events[] = {
00146     EventType( KJS::Identifier("onTimerEvent"), QEvent::Timer ),
00147     EventType( KJS::Identifier("onMouseButtonPressEvent"), QEvent::MouseButtonPress ),
00148     EventType( KJS::Identifier("onMouseButtonReleaseEvent"), QEvent::MouseButtonRelease ),
00149     EventType( KJS::Identifier("onMouseButtonDblClickEvent"), QEvent::MouseButtonDblClick ),
00150     EventType( KJS::Identifier("onMouseMoveEvent"), QEvent::MouseMove ),
00151     EventType( KJS::Identifier("onKeyPressEvent"), QEvent::KeyPress ),
00152     EventType( KJS::Identifier("onKeyReleaseEvent"), QEvent::KeyRelease ),
00153     EventType( KJS::Identifier("onFocusInEvent"), QEvent::FocusIn ),
00154     EventType( KJS::Identifier("onFocusOutEvent"), QEvent::FocusOut ),
00155     EventType( KJS::Identifier("onEnterEvent"), QEvent::Enter ),
00156     EventType( KJS::Identifier("onLeaveEvent"), QEvent::Leave ),
00157     EventType( KJS::Identifier("onPaintEvent"), QEvent::Paint ),
00158     EventType( KJS::Identifier("onMoveEvent"), QEvent::Move ),
00159     EventType( KJS::Identifier("onResizeEvent"), QEvent::Resize ),
00160     EventType( KJS::Identifier("onCreateEvent"), QEvent::Create ),
00161     EventType( KJS::Identifier("onDestroyEvent"), QEvent::Destroy ),
00162     EventType( KJS::Identifier("onShowEvent"), QEvent::Show ),
00163     EventType( KJS::Identifier("onHideEvent"), QEvent::Hide ),
00164     EventType( KJS::Identifier("onCloseEvent"), QEvent::Close ),
00165     EventType( KJS::Identifier("onQuitEvent"), QEvent::Quit ),
00166     EventType( KJS::Identifier("onParentChangeEvent"), QEvent::ParentChange ),
00167     EventType( KJS::Identifier("onParentAboutToChangeEvent"), QEvent::ParentAboutToChange ),
00168     EventType( KJS::Identifier("onThreadChangeEvent"), QEvent::ThreadChange ),
00169     EventType( KJS::Identifier("onWindowActivateEvent"), QEvent::WindowActivate ),
00170     EventType( KJS::Identifier("onWindowDeactivateEvent"), QEvent::WindowDeactivate ),
00171     EventType( KJS::Identifier("onShowToParentEvent"), QEvent::ShowToParent ),
00172     EventType( KJS::Identifier("onHideToParentEvent"), QEvent::HideToParent ),
00173     EventType( KJS::Identifier("onWheelEvent"), QEvent::Wheel ),
00174     EventType( KJS::Identifier("onWindowTitleChangeEvent"), QEvent::WindowTitleChange ),
00175     EventType( KJS::Identifier("onWindowIconChangeEvent"), QEvent::WindowIconChange ),
00176     EventType( KJS::Identifier("onApplicationWindowIconChangeEvent"), QEvent::ApplicationWindowIconChange ),
00177     EventType( KJS::Identifier("onApplicationFontChangeEvent"), QEvent::ApplicationFontChange ),
00178     EventType( KJS::Identifier("onApplicationLayoutDirectionChangeEvent"), QEvent::ApplicationLayoutDirectionChange ),
00179     EventType( KJS::Identifier("onApplicationPaletteChangeEvent"), QEvent::ApplicationPaletteChange ),
00180     EventType( KJS::Identifier("onPaletteChangeEvent"), QEvent::PaletteChange ),
00181     EventType( KJS::Identifier("onClipboardEvent"), QEvent::Clipboard ),
00182     EventType( KJS::Identifier("onSpeechEvent"), QEvent::Speech ),
00183     EventType( KJS::Identifier("onMetaCallEvent"), QEvent::MetaCall ),
00184     EventType( KJS::Identifier("onSockActEvent"), QEvent::SockAct ),
00185     EventType( KJS::Identifier("onWinEventActEvent"), QEvent::WinEventAct ),
00186     EventType( KJS::Identifier("onDeferredDeleteEvent"), QEvent::DeferredDelete ),
00187     EventType( KJS::Identifier("onDragEnterEvent"), QEvent::DragEnter ),
00188     EventType( KJS::Identifier("onDragMoveEvent"), QEvent::DragMove ),
00189     EventType( KJS::Identifier("onDragLeaveEvent"), QEvent::DragLeave ),
00190     EventType( KJS::Identifier("onDropEvent"), QEvent::Drop ),
00191     EventType( KJS::Identifier("onDragResponseEvent"), QEvent::DragResponse ),
00192     EventType( KJS::Identifier("onChildAddedEvent"), QEvent::ChildAdded ),
00193     EventType( KJS::Identifier("onChildPolishedEvent"), QEvent::ChildRemoved ),
00194     EventType( KJS::Identifier("onShowWindowRequestEvent"), QEvent::ShowWindowRequest ),
00195     EventType( KJS::Identifier("onPolishRequestEvent"), QEvent::PolishRequest ),
00196     EventType( KJS::Identifier("onPolishEvent"), QEvent::Polish ),
00197     EventType( KJS::Identifier("onLayoutRequestEvent"), QEvent::LayoutRequest ),
00198     EventType( KJS::Identifier("onUpdateRequestEvent"), QEvent::UpdateRequest ),
00199     EventType( KJS::Identifier("onEmbeddingControlEvent"), QEvent::EmbeddingControl ),
00200     EventType( KJS::Identifier("onActivateControlEvent"), QEvent::ActivateControl ),
00201     EventType( KJS::Identifier("onDeactivateControlEvent"), QEvent::DeactivateControl ),
00202     EventType( KJS::Identifier("onContextMenuEvent"), QEvent::ContextMenu ),
00203     EventType( KJS::Identifier("onInputMethodEvent"), QEvent::InputMethod ),
00204     EventType( KJS::Identifier("onAccessibilityPrepareEvent"), QEvent::AccessibilityPrepare ),
00205     EventType( KJS::Identifier("onTabletMoveEvent"), QEvent::TabletMove ),
00206     EventType( KJS::Identifier("onLocaleChangeEvent"), QEvent::LocaleChange ),
00207     EventType( KJS::Identifier("onLanguageChangeEvent"), QEvent::LanguageChange ),
00208     EventType( KJS::Identifier("onLayoutDirectionChangeEvent"), QEvent::LayoutDirectionChange ),
00209     EventType( KJS::Identifier("onStyleEvent"), QEvent::Style ),
00210     EventType( KJS::Identifier("onTabletPressEvent"), QEvent::TabletPress ),
00211     EventType( KJS::Identifier("onTabletReleaseEvent"), QEvent::TabletRelease ),
00212     EventType( KJS::Identifier("onOkRequestEvent"), QEvent::OkRequest ),
00213     EventType( KJS::Identifier("onHelpRequestEvent"), QEvent::HelpRequest ),
00214     EventType( KJS::Identifier("onIconDragEvent"), QEvent::IconDrag ),
00215     EventType( KJS::Identifier("onFontChangeEvent"), QEvent::FontChange ),
00216     EventType( KJS::Identifier("onEnabledChangeEvent"), QEvent::EnabledChange ),
00217     EventType( KJS::Identifier("onActivationChangeEvent"), QEvent::ActivationChange ),
00218     EventType( KJS::Identifier("onStyleChangeEvent"), QEvent::StyleChange ),
00219     EventType( KJS::Identifier("onIconTextChangeEvent"), QEvent::IconTextChange ),
00220     EventType( KJS::Identifier("onModifiedChangeEvent"), QEvent::ModifiedChange ),
00221     EventType( KJS::Identifier("onMouseTrackingChangeEvent"), QEvent::MouseTrackingChange ),
00222     EventType( KJS::Identifier("onWindowBlockedEvent"), QEvent::WindowBlocked ),
00223     EventType( KJS::Identifier("onWindowUnblockedEvent"), QEvent::WindowUnblocked ),
00224     EventType( KJS::Identifier("onWindowStateChangeEvent"), QEvent::WindowStateChange ),
00225     EventType( KJS::Identifier("onToolTipEvent"), QEvent::ToolTip ),
00226     EventType( KJS::Identifier("onWhatsThisEvent"), QEvent::WhatsThis ),
00227     EventType( KJS::Identifier("onStatusTipEvent"), QEvent::StatusTip ),
00228     EventType( KJS::Identifier("onActionChangedEvent"), QEvent::ActionChanged ),
00229     EventType( KJS::Identifier("onActionAddedEvent"), QEvent::ActionAdded ),
00230     EventType( KJS::Identifier("onActionRemovedEvent"), QEvent::ActionRemoved ),
00231     EventType( KJS::Identifier("onFileOpenEvent"), QEvent::FileOpen ),
00232     EventType( KJS::Identifier("onShortcutEvent"), QEvent::Shortcut ),
00233     EventType( KJS::Identifier("onShortcutOverrideEvent"), QEvent::ShortcutOverride ),
00234     EventType( KJS::Identifier("onWhatsThisClickedEvent"), QEvent::WhatsThisClicked ),
00235     EventType( KJS::Identifier("onToolBarChangeEvent"), QEvent::ToolBarChange ),
00236     EventType( KJS::Identifier("onApplicationActivatedEvent"), QEvent::ApplicationActivated ),
00237     EventType( KJS::Identifier("onApplicationDeactivatedEvent"), QEvent::ApplicationDeactivated ),
00238     EventType( KJS::Identifier("onQueryWhatsThisEvent"), QEvent::QueryWhatsThis ),
00239     EventType( KJS::Identifier("onEnterWhatsThisModeEvent"), QEvent::EnterWhatsThisMode ),
00240     EventType( KJS::Identifier("onLeaveWhatsThisModeEvent"), QEvent::LeaveWhatsThisMode ),
00241     EventType( KJS::Identifier("onZOrderChangeEvent"), QEvent::ZOrderChange ),
00242     EventType( KJS::Identifier("onHoverEnterEvent"), QEvent::HoverEnter ),
00243     EventType( KJS::Identifier("onHoverLeaveEvent"), QEvent::HoverLeave ),
00244     EventType( KJS::Identifier("onHoverMoveEvent"), QEvent::HoverMove ),
00245     EventType( KJS::Identifier("onAccessibilityHelpEvent"), QEvent::AccessibilityHelp ),
00246     EventType( KJS::Identifier("onAccessibilityDescriptionEvent"), QEvent::AccessibilityDescription ),
00247     EventType(KJS::Identifier(), QEvent::None )
00248 };
00249 
00250 JSEventMapper::JSEventMapper()
00251 {
00252     int i = 0;
00253     do {
00254         addEvent( events[i].id, events[i].type );
00255         i++;
00256     } while( events[i].type != QEvent::None );
00257 }
00258 
00259 JSEventMapper::~JSEventMapper()
00260 {
00261 }
00262 
00263 void JSEventMapper::addEvent( const KJS::Identifier &name, QEvent::Type t )
00264 {
00265     m_handlerToEvent[ toQString(name) ] = t;
00266     m_eventToHandler[ t ] = name;
00267 }
00268 
00269 QEvent::Type JSEventMapper::findEventType( const KJS::Identifier &name ) const
00270 {
00271     return  m_handlerToEvent[ toQString(name) ];
00272 }
00273 
00274 bool JSEventMapper::isEventHandler( const KJS::Identifier &name ) const
00275 {
00276     return m_handlerToEvent.contains( toQString(name) );
00277 }
00278 
00279 KJS::Identifier JSEventMapper::findEventHandler( QEvent::Type t ) const
00280 {
00281     return m_eventToHandler[t];
00282 }
00283 
00284 JSEventMapper *JSEventMapper::mapper()
00285 {
00286     if ( m_inst )
00287         return m_inst;
00288     m_inst = new JSEventMapper();
00289     return m_inst;
00290 }
00291 
00292 
00293 } // namespace KJSEmbed
00294 
00295 // Local Variables:
00296 // c-basic-offset: 4
00297 // End:
00298 
00299 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal