Back to index

lightning-sunbird  0.9+nobinonly
nsQtEventDispatcher.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  *  Zack Rusin <zack@kde.org>.
00020  * Portions created by the Initial Developer are Copyright (C) 2004
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Lars Knoll <knoll@kde.org>
00025  *   Zack Rusin <zack@kde.org>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 #include "nsQtEventDispatcher.h"
00041 
00042 #include "nsCommonWidget.h"
00043 
00044 #include <qwidget.h>
00045 #include <qevent.h>
00046 
00047 nsQtEventDispatcher::nsQtEventDispatcher(nsCommonWidget *receiver,
00048                                          QWidget *watchedWidget,
00049                                          const char *name, bool paint )
00050     : QObject(watchedWidget, name),
00051       mReceiver(receiver),
00052       m_paint(paint)
00053 
00054 {
00055     watchedWidget->installEventFilter(this);
00056 }
00057 
00058 bool
00059 nsQtEventDispatcher::eventFilter(QObject *o, QEvent *e)
00060 {
00061 #if 0
00062     if (m_paint && e->type() == QEvent::Paint) {
00063         qDebug("MMM PAINT FROM %d", o);
00064         QPaintEvent *ev = (QPaintEvent*)(e);
00065         return mReceiver->paintEvent(ev);
00066     }
00067 #endif
00068 
00069     switch(e->type()) {
00070     case QEvent::Accessibility:
00071     {
00072         qDebug("accessibility event received");
00073     }
00074     break;
00075     case QEvent::MouseButtonPress:
00076     {
00077         QMouseEvent *ms = (QMouseEvent*)(e);
00078         return mReceiver->mousePressEvent(ms);
00079     }
00080     break;
00081     case QEvent::MouseButtonRelease:
00082     {
00083         QMouseEvent *ms = (QMouseEvent*)(e);
00084         return mReceiver->mouseReleaseEvent(ms);
00085     }
00086     break;
00087     case QEvent::MouseButtonDblClick:
00088     {
00089         QMouseEvent *ms = (QMouseEvent*)(e);
00090         return mReceiver->mouseDoubleClickEvent(ms);
00091     }
00092     break;
00093     case QEvent::MouseMove:
00094     {
00095         QMouseEvent *ms = (QMouseEvent*)(e);
00096         return mReceiver->mouseMoveEvent(ms);
00097     }
00098     break;
00099     case QEvent::KeyPress:
00100     {
00101         QKeyEvent *kev = (QKeyEvent*)(e);
00102         return mReceiver->keyPressEvent(kev);
00103     }
00104     break;
00105     case QEvent::KeyRelease:
00106     {
00107         QKeyEvent *kev = (QKeyEvent*)(e);
00108         return mReceiver->keyReleaseEvent(kev);
00109     }
00110     break;
00111     case QEvent::IMStart:
00112     {
00113         QIMEvent *iev = (QIMEvent*)(e);
00114         return mReceiver->imStartEvent(iev);
00115     }
00116     break;
00117     case QEvent::IMCompose:
00118     {
00119         QIMEvent *iev = (QIMEvent*)(e);
00120         return mReceiver->imComposeEvent(iev);
00121     }
00122     break;
00123     case QEvent::IMEnd:
00124     {
00125         QIMEvent *iev = (QIMEvent*)(e);
00126         return mReceiver->imEndEvent(iev);
00127     }
00128     break;
00129     case QEvent::FocusIn:
00130     {
00131         QFocusEvent *fev = (QFocusEvent*)(e);
00132         return mReceiver->focusInEvent(fev);
00133     }
00134     break;
00135     case QEvent::FocusOut:
00136     {
00137         QFocusEvent *fev = (QFocusEvent*)(e);
00138         return mReceiver->focusOutEvent(fev);
00139     }
00140     break;
00141     case QEvent::Enter:
00142     {
00143         return mReceiver->enterEvent(e);
00144     }
00145     break;
00146     case QEvent::Leave:
00147     {
00148         return mReceiver->enterEvent(e);
00149     }
00150     break;
00151     case QEvent::Paint:
00152     {
00153         QPaintEvent *ev = (QPaintEvent*)(e);
00154         mReceiver->paintEvent(ev);
00155         return TRUE;
00156     }
00157     break;
00158     case QEvent::Move:
00159     {
00160         QMoveEvent *mev = (QMoveEvent*)(e);
00161         return mReceiver->moveEvent(mev);
00162     }
00163     break;
00164     case QEvent::Resize:
00165     {
00166         QResizeEvent *rev = (QResizeEvent*)(e);
00167         return mReceiver->resizeEvent(rev);
00168     }
00169         break;
00170     case QEvent::Show:
00171     {
00172         QShowEvent *sev = (QShowEvent*)(e);
00173         return mReceiver->showEvent(sev);
00174     }
00175     break;
00176     case QEvent::Hide:
00177     {
00178         QHideEvent *hev = (QHideEvent*)(e);
00179         return mReceiver->hideEvent(hev);
00180     }
00181         break;
00182     case QEvent::Close:
00183     {
00184         QCloseEvent *cev = (QCloseEvent*)(e);
00185         return mReceiver->closeEvent(cev);
00186     }
00187     break;
00188     case QEvent::Wheel:
00189     {
00190         QWheelEvent *wev = (QWheelEvent*)(e);
00191         return mReceiver->wheelEvent(wev);
00192     }
00193     break;
00194     case QEvent::ContextMenu:
00195     {
00196         QContextMenuEvent *cev = (QContextMenuEvent*)(e);
00197         return mReceiver->contextMenuEvent(cev);
00198     }
00199     break;
00200     case QEvent::DragEnter:
00201     {
00202         QDragEnterEvent *dev = (QDragEnterEvent*)(e);
00203         return mReceiver->dragEnterEvent(dev);
00204     }
00205         break;
00206     case QEvent::DragMove:
00207     {
00208         QDragMoveEvent *dev = (QDragMoveEvent*)(e);
00209         return mReceiver->dragMoveEvent(dev);
00210     }
00211     break;
00212     case QEvent::DragLeave:
00213     {
00214         QDragLeaveEvent *dev = (QDragLeaveEvent*)(e);
00215         return mReceiver->dragLeaveEvent(dev);
00216     }
00217     break;
00218     case QEvent::Drop:
00219     {
00220         QDropEvent *dev = (QDropEvent*)(e);
00221         return mReceiver->dropEvent(dev);
00222     }
00223     break;
00224     default:
00225         break;
00226     }
00227 
00228     return FALSE;
00229 }
00230