X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fgui%2Fqxtnativeeventfilter.h;fp=src%2Fcontrib%2Flibqxt-2007-10-24%2Fsrc%2Fgui%2Fqxtnativeeventfilter.h;h=3fedf6a7cd11aeea7e14ee313a16cf4e24d84cf8;hb=a634acadbcf6017474f68a3eaf7cb632660e9e49;hp=0000000000000000000000000000000000000000;hpb=cd122ca8e0d2c0ffc5397e0a813c75d791a7e6e3;p=quassel.git diff --git a/src/contrib/libqxt-2007-10-24/src/gui/qxtnativeeventfilter.h b/src/contrib/libqxt-2007-10-24/src/gui/qxtnativeeventfilter.h new file mode 100644 index 00000000..3fedf6a7 --- /dev/null +++ b/src/contrib/libqxt-2007-10-24/src/gui/qxtnativeeventfilter.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) Qxt Foundation. Some rights reserved. +** +** This file is part of the QxtGui module of the Qt eXTension library +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of th Common Public License, version 1.0, as published by +** IBM. +** +** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY +** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR +** FITNESS FOR A PARTICULAR PURPOSE. +** +** You should have received a copy of the CPL along with this file. +** See the LICENSE file and the cpl1.0.txt file included with the source +** distribution for more information. If you did not receive a copy of the +** license, contact the Qxt Foundation. +** +** +** +****************************************************************************/ +#ifndef QXTNATIVEEVENTFILTER_H +#define QXTNATIVEEVENTFILTER_H + +#include "qxtapplication.h" + +typedef struct tagMSG MSG; +typedef union _XEvent XEvent; +typedef struct OpaqueEventRef *EventRef; +typedef struct OpaqueEventHandlerCallRef *EventHandlerCallRef; + +/*! + \class QxtNativeEventFilter QxtNativeEventFilter + \ingroup QxtGui + \brief A native event filter to access platform specific events. + + QxtNativeEventFilter provides access to platform specific native events + without the need of subclassing QApplication. + + \note QxtNativeEventFilter requires QxtApplication. + + Example usage: + \code + qxtApp->installNativeEventFilter(myWindow); + + class MyWindow : public QWidget, public QxtNativeEventFilter { + public: + ... + + bool x11EventFilter(XEvent* event) { + if (event->type == ...) { + ... + } + return false; + } + + bool winEventFilter(MSG* msg, long* result) { + if (msg->message == ...) { + ... + } + return false; + } + + bool macEventFilter(EventHandlerCallRef caller, EventRef event) { + if (GetEventClass(event) == ...) { + ... + } + return false; + } + }; + \endcode + + \sa QxtApplication::installNativeEventFilter() + */ + +/*! + \fn QxtNativeEventFilter::x11EventFilter(XEvent* event) + + Filters X11 events if this object has been installed as a native event filter. + In your reimplementation of this function, if you want to filter the event out, + i.e. stop it being handled further, return \b true; otherwise return \b false. + + \sa QxtApplication::installNativeEventFilter() + */ + +/*! + \fn QxtNativeEventFilter::winEventFilter(MSG* msg, long* result) + + Filters Windows events if this object has been installed as a native event filter. + In your reimplementation of this function, if you want to filter the event out, + i.e. stop it being handled further, return \b true; otherwise return \b false. + + \sa QxtApplication::installNativeEventFilter() + */ + +/*! + \fn QxtNativeEventFilter::macEventFilter(EventHandlerCallRef caller, EventRef event) + + Filters Mac events if this object has been installed as a native event filter. + In your reimplementation of this function, if you want to filter the event out, + i.e. stop it being handled further, return \b true; otherwise return \b false. + + \sa QxtApplication::installNativeEventFilter() + */ + +class QxtNativeEventFilter +{ +public: + virtual ~QxtNativeEventFilter() + { qxtApp->removeNativeEventFilter(this); } + + virtual bool x11EventFilter(XEvent* event) = 0; + virtual bool winEventFilter(MSG* msg, long* result) = 0; + virtual bool macEventFilter(EventHandlerCallRef caller, EventRef event) = 0; +}; + +#endif // QXTNATIVEEVENTFILTER_H