Back to index

lightning-sunbird  0.9+nobinonly
qgeckoembed.h
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 #ifndef QECKOEMBED_H
00041 #define QECKOEMBED_H
00042 
00043 #include <qwidget.h>
00044 
00045 class nsIDOMKeyEvent;
00046 class nsIDOMMouseEvent;
00047 class nsIDOMUIEvent;
00048 class nsModuleComponentInfo;
00049 class nsIDirectoryServiceProvider;
00050 class nsIAppShell;
00051 class nsVoidArray;
00052 class nsProfileDirServiceProvider;
00053 class nsISupports;
00054 class EmbedWindow;
00055 class EmbedEventListener;
00056 class EmbedProgress;
00057 class nsIWebNavigation;
00058 class nsISHistory;
00059 class nsIDOMEventReceiver;
00060 class EmbedContentListener;
00061 class EmbedStream;
00062 class QHBox;
00063 class nsIDOMDocument;
00064 class nsPIDOMWindow;
00065 class QPaintEvent;
00066 
00067 class QGeckoEmbedPrivate;
00068 
00069 class QGeckoEmbed : public QWidget
00070 {
00071     Q_OBJECT
00072 public:
00073     static void initialize(const char *aDir, const char *aName);
00074 public:
00075     enum ReloadFlags
00076     {
00077         Normal,
00078         BypassCache,
00079         BypassProxy,
00080         BypassProxyAndCache,
00081         CharsetChange
00082     };
00083 public:
00084     QGeckoEmbed(QWidget *parent, const char *name);
00085     ~QGeckoEmbed();
00086 
00087     bool canGoBack() const;
00088     bool canGoForward() const;
00089 
00090     void setIsChrome(bool);
00091     int chromeMask() const;
00092 
00093     nsIDOMDocument *document() const;
00094     QString url() const;
00095     QString resolvedUrl(const QString &relativepath) const;
00096 
00097 public slots:
00098     void loadURL(const QString &url);
00099     void stopLoad();
00100     void goForward();
00101     void goBack();
00102 
00103     void renderData(const QCString &data, const QString &baseURI,
00104                     const QString &mimeType);
00105 
00106     int  openStream(const QString &baseURI, const QString &mimeType);
00107     int  appendData(const QCString &data);
00108     int  closeStream();
00109 
00110     void reload(ReloadFlags flags = Normal);
00111 
00112     void setChromeMask(int);
00113 
00114 signals:
00115     void linkMessage(const QString &message);
00116     void jsStatusMessage(const QString &message);
00117     void locationChanged(const QString &location);
00118     void windowTitleChanged(const QString &title);
00119 
00120     void progress(int current, int max);
00121     void progressAll(const QString &url, int current, int max);
00122 
00123     void netState(int state, int status);
00124     void netStateAll(const QString &url, int state, int status);
00125 
00126     void netStart();
00127     void netStop();
00128 
00129     void newWindow(QGeckoEmbed *newWindow, int chromeMask);
00130     void visibilityChanged(bool visible);
00131     void destroyBrowser();
00132     void openURI(const QString &url);
00133     void sizeTo(int width, int height);
00134 
00135     void securityChange(void *request, int status, void *message);
00136     void statusChange(void *request, int status, void *message);
00137 
00138     void showContextMenu(const QPoint &p, const QString &url);
00139 
00144     void domKeyDown(nsIDOMKeyEvent *keyEvent);
00145     void domKeyPress(nsIDOMKeyEvent *keyEvent);
00146     void domKeyUp(nsIDOMKeyEvent *keyEvent);
00147     void domMouseDown(nsIDOMMouseEvent *mouseEvent);
00148     void domMouseUp(nsIDOMMouseEvent *mouseEvent);
00149     void domMouseClick(nsIDOMMouseEvent *mouseEvent);
00150     void domMouseDblClick(nsIDOMMouseEvent *mouseEvent);
00151     void domMouseOver(nsIDOMMouseEvent *mouseEvent);
00152     void domMouseOut(nsIDOMMouseEvent *mouseEvent);
00153     void domActivate(nsIDOMUIEvent *event);
00154     void domFocusIn(nsIDOMUIEvent *event);
00155     void domFocusOut(nsIDOMUIEvent *event);
00156 
00157 
00158     void startURIOpen(const QString &url, bool &abort);
00159 
00160 protected:
00161     friend class EmbedEventListener;
00162     friend class EmbedContentListener;
00169     virtual bool domKeyDownEvent(nsIDOMKeyEvent *keyEvent);
00170     virtual bool domKeyPressEvent(nsIDOMKeyEvent *keyEvent);
00171     virtual bool domKeyUpEvent(nsIDOMKeyEvent *keyEvent);
00172 
00173     virtual bool domMouseDownEvent(nsIDOMMouseEvent *mouseEvent);
00174     virtual bool domMouseUpEvent(nsIDOMMouseEvent *mouseEvent);
00175     virtual bool domMouseClickEvent(nsIDOMMouseEvent *mouseEvent);
00176     virtual bool domMouseDblClickEvent(nsIDOMMouseEvent *mouseEvent);
00177     virtual bool domMouseOverEvent(nsIDOMMouseEvent *mouseEvent);
00178     virtual bool domMouseOutEvent(nsIDOMMouseEvent *mouseEvent);
00179 
00180     virtual bool domActivateEvent(nsIDOMUIEvent *event);
00181     virtual bool domFocusInEvent(nsIDOMUIEvent *event);
00182     virtual bool domFocusOutEvent(nsIDOMUIEvent *event);
00183 
00184 
00185 protected:
00186     friend class EmbedWindow;
00187     friend class EmbedWindowCreator;
00188     friend class EmbedProgress;
00189     friend class EmbedContextMenuListener;
00190     friend class EmbedStream;
00191     friend class QGeckoGlobals;
00192     void emitScriptStatus(const QString &str);
00193     void emitLinkStatus(const QString &str);
00194     void contentStateChanged();
00195     void contentFinishedLoading();
00196 
00197     bool isChrome() const;
00198     bool chromeLoaded() const;
00199 
00200 protected:
00201     void resizeEvent(QResizeEvent *e);
00202 
00203     void setupListener();
00204     void attachListeners();
00205 
00206     EmbedWindow *window() const;
00207     int GetPIDOMWindow(nsPIDOMWindow **aPIWin);
00208 
00209 protected:
00210     QGeckoEmbedPrivate *d;
00211 };
00212 
00213 #endif