1 /****************************************************************************
\r
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
\r
5 ** This file is part of the QxtGui module of the Qt eXTension library
\r
7 ** This library is free software; you can redistribute it and/or modify it
\r
8 ** under the terms of th Common Public License, version 1.0, as published by
\r
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
\r
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
\r
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
\r
14 ** FITNESS FOR A PARTICULAR PURPOSE.
\r
16 ** You should have received a copy of the CPL along with this file.
\r
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
\r
18 ** distribution for more information. If you did not receive a copy of the
\r
19 ** license, contact the Qxt Foundation.
\r
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
\r
23 ****************************************************************************/
\r
24 #ifndef QXTNATIVEEVENTFILTER_H
\r
25 #define QXTNATIVEEVENTFILTER_H
\r
27 #include "qxtapplication.h"
\r
29 typedef struct tagMSG MSG;
\r
30 typedef union _XEvent XEvent;
\r
31 typedef struct OpaqueEventRef *EventRef;
\r
32 typedef struct OpaqueEventHandlerCallRef *EventHandlerCallRef;
\r
35 \class QxtNativeEventFilter QxtNativeEventFilter
\r
37 \brief A native event filter to access platform specific events.
\r
39 QxtNativeEventFilter provides access to platform specific native events
\r
40 without the need of subclassing QApplication.
\r
42 \note QxtNativeEventFilter requires QxtApplication.
\r
46 qxtApp->installNativeEventFilter(myWindow);
\r
48 class MyWindow : public QWidget, public QxtNativeEventFilter {
\r
52 bool x11EventFilter(XEvent* event) {
\r
53 if (event->type == ...) {
\r
59 bool winEventFilter(MSG* msg, long* result) {
\r
60 if (msg->message == ...) {
\r
66 bool macEventFilter(EventHandlerCallRef caller, EventRef event) {
\r
67 if (GetEventClass(event) == ...) {
\r
75 \sa QxtApplication::installNativeEventFilter()
\r
79 \fn QxtNativeEventFilter::x11EventFilter(XEvent* event)
\r
81 Filters X11 events if this object has been installed as a native event filter.
\r
82 In your reimplementation of this function, if you want to filter the event out,
\r
83 i.e. stop it being handled further, return \b true; otherwise return \b false.
\r
85 \sa QxtApplication::installNativeEventFilter()
\r
89 \fn QxtNativeEventFilter::winEventFilter(MSG* msg, long* result)
\r
91 Filters Windows events if this object has been installed as a native event filter.
\r
92 In your reimplementation of this function, if you want to filter the event out,
\r
93 i.e. stop it being handled further, return \b true; otherwise return \b false.
\r
95 \sa QxtApplication::installNativeEventFilter()
\r
99 \fn QxtNativeEventFilter::macEventFilter(EventHandlerCallRef caller, EventRef event)
\r
101 Filters Mac events if this object has been installed as a native event filter.
\r
102 In your reimplementation of this function, if you want to filter the event out,
\r
103 i.e. stop it being handled further, return \b true; otherwise return \b false.
\r
105 \sa QxtApplication::installNativeEventFilter()
\r
108 class QxtNativeEventFilter
\r
111 virtual ~QxtNativeEventFilter()
\r
112 { qxtApp->removeNativeEventFilter(this); }
\r
114 virtual bool x11EventFilter(XEvent* event) = 0;
\r
115 virtual bool winEventFilter(MSG* msg, long* result) = 0;
\r
116 virtual bool macEventFilter(EventHandlerCallRef caller, EventRef event) = 0;
\r
119 #endif // QXTNATIVEEVENTFILTER_H
\r