|
|
|
/*
|
|
|
|
* Copyright (C) 2001-2003, Richard J. Moore <rich@kde.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public License
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "jseventmapper.h"
|
|
|
|
#include <tqevent.h>
|
|
|
|
namespace KJSEmbed {
|
|
|
|
|
|
|
|
/** Used internally for the event handler table. */
|
|
|
|
struct EventType
|
|
|
|
{
|
|
|
|
EventType( KJS::Identifier _id, TTQEvent::Type _type ) :
|
|
|
|
id(_id), type(_type) {;}
|
|
|
|
|
|
|
|
const KJS::Identifier id;
|
|
|
|
const TTQEvent::Type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
static EventType events[] = {
|
|
|
|
EventType(KJS::Identifier("timerEvent"), TTQEvent::Timer),
|
|
|
|
|
|
|
|
#ifdef ENABLE_CHILDEVENTS
|
|
|
|
EventType( KJS::Identifier("childInsertEvent"), TTQEvent::ChildInserted ),
|
|
|
|
EventType( KJS::Identifier("childRemoveEvent"), TTQEvent::ChildRemoved ),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("mouseReleaseEvent"), TTQEvent::MouseButtonRelease ),
|
|
|
|
EventType( KJS::Identifier("mouseMoveEvent"), TTQEvent::MouseMove ),
|
|
|
|
EventType( KJS::Identifier("mouseDoubleClickEvent"), TTQEvent::MouseButtonDblClick ),
|
|
|
|
EventType( KJS::Identifier("mousePressEvent"), TTQEvent::MouseButtonPress ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("keyPressEvent"), TTQEvent::KeyPress ),
|
|
|
|
EventType( KJS::Identifier("keyReleaseEvent"), TTQEvent::KeyRelease ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("paintEvent"), TTQEvent::Paint ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("moveEvent"), TTQEvent::Move ),
|
|
|
|
EventType( KJS::Identifier("resizeEvent"), TTQEvent::Resize ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("closeEvent"), TTQEvent::Close ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("showEvent"), TTQEvent::Show ),
|
|
|
|
EventType( KJS::Identifier("hideEvent"), TTQEvent::Hide ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier("dragEnterEvent"), TTQEvent::DragEnter ),
|
|
|
|
EventType( KJS::Identifier("dragMoveEvent"), TTQEvent::DragMove ),
|
|
|
|
EventType( KJS::Identifier("dragLeaveEvent"), TTQEvent::DragLeave ),
|
|
|
|
EventType( KJS::Identifier("dragResponseEvent"), TTQEvent::DragResponse ),
|
|
|
|
EventType( KJS::Identifier("dropEvent"), TTQEvent::Drop ),
|
|
|
|
|
|
|
|
EventType( KJS::Identifier(), TTQEvent::None )
|
|
|
|
};
|
|
|
|
|
|
|
|
JSEventMapper::JSEventMapper()
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
do {
|
|
|
|
addEvent( events[i].id, events[i].type );
|
|
|
|
i++;
|
|
|
|
} while( events[i].type != TTQEvent::None );
|
|
|
|
}
|
|
|
|
|
|
|
|
JSEventMapper::~JSEventMapper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JSEventMapper::addEvent( const KJS::Identifier &name, TTQEvent::Type t )
|
|
|
|
{
|
|
|
|
handlerToEvent.insert( name.qstring(), (const uint *) t );
|
|
|
|
eventToHandler.insert( (long) t, &name );
|
|
|
|
}
|
|
|
|
|
|
|
|
TTQEvent::Type JSEventMapper::findEventType( const KJS::Identifier &name ) const
|
|
|
|
{
|
|
|
|
uint evt = (uint)(long)handlerToEvent[ name.qstring() ];
|
|
|
|
return static_cast<TTQEvent::Type>( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KJSEmbed
|
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// End:
|