BrowserWindow.h

Go to the documentation of this file.
00001 #ifndef __BROWSERWINDOW_H__
00002 #define __BROWSERWINDOW_H__
00003 
00004 /*
00005 
00006 $Header$
00007 
00008 */
00009 
00010 #include <nsIDOMWindow.h>
00011 #include <nsIDOMKeyEvent.h>
00012 #include <nsIDOMMouseEvent.h>
00013 #include <nsIDOMUIEvent.h>
00014 
00015 #include <gtkmozembed.h>
00016 #include <gtkmozembed_internal.h>
00017 
00018 #include "Object.h"
00019 
00020 // Messages.
00021 static const char *const MSG_BROWSER_WINDOW_CANNOT_GET_SINGLETON_EMBED_OBJECT = "Cannot get embedded object singleton.";
00022 static const char *const MSG_BROWSER_WINDOW_LOCATION_CANNOT_GET               = "Failed to get location.";
00023 
00024 static const double EPSILON = 0.000001;
00025 
00026 class BrowserWindow : public Object
00027 {
00028 
00029   PYLON_OBJECT
00030 
00031 public:
00032 
00033   BrowserWindow(const String &profilePath = "", const unsigned int chromeMask = GTK_MOZ_EMBED_FLAG_ALLCHROME);
00034   virtual ~BrowserWindow();
00035 
00036   int mozillaWidget(GtkWidget **mozilla);
00037 
00038   int setVisibility(const bool visible = true);
00039   int show();
00040   int hide();
00041 
00042   int setScrollBarsVisibility(const bool visible = true);
00043 
00044   int setStatusBarVisibility(const bool visible = true);
00045   int showStatusBar();
00046   int hideStatusBar();
00047 
00048   int setProgressBarVisibility(const bool visible = true);
00049   int showProgressBar();
00050   int hideProgressBar();
00051   int setProgressBarAutoMode(const bool enabled = true);
00052 
00053   int size(int &width, int &height);
00054   int setSize(const int width, const int height);
00055 
00056   int position(int &x, int &y);
00057   int setPos(const int x, const int y);
00058   int setXPos(const int x);
00059   int setYPos(const int y);
00060 
00061   int textScale(unsigned int &scale);
00062   int setTextScale(const unsigned int scale);
00063 
00064   int load(const String& url);
00065 
00066   int close();
00067   int focus();
00068   int stop();
00069 
00070   int canGoBack(bool &yes);
00071   int back();
00072 
00073   int canGoForward(bool &yes);
00074   int forward();
00075 
00076   int reload(const bool useCache = true);
00077 
00078   String status() const;
00079   int loadPercent() const;
00080   int bytesLoaded() const;
00081   int maxBytesLoaded() const;
00082   bool loadFinished() const;
00083 
00084   int renderData(const String &data);
00085 
00086   SIGNAL(closed);
00087   SIGNAL(shown);
00088   SIGNAL(hidden);
00089   SIGNAL(started);
00090   SIGNAL(finished);
00091 
00092 protected:
00093 
00094   virtual int onDelete();
00095   virtual int onDestroy();
00096 
00097   // Callbacks from the widget.
00098   virtual int onLocationChanged(const String &newLocation);
00099   virtual int onTitleChanged(const String &newTitle);
00100   virtual int onLoadStarted();
00101   virtual int onLoadFinished();
00102   virtual int onNetStateChange(const int flags, const unsigned int status);
00103   virtual int onNetStateChangeAll(const char *uri, const int flags, unsigned int status);
00104   virtual int onProgressChange(const int cur, const int max);
00105   virtual int onProgressChangeAll(const char *uri, const int cur, const int max);
00106   virtual int onLinkMessage(const String &message);
00107   virtual int onJSStatus(const String &message);
00108   virtual int onNewWindow(const unsigned int chromeMask, BrowserWindow **newBrowser);
00109   virtual int onVisibility(const bool visibility);
00110   virtual int onDestroyBrowser();
00111   virtual int onOpenUri(const char *uri, bool &interrupt);
00112   virtual int onSizeTo(const int width, const int height);
00113 
00114   virtual int onKeyDown(nsIDOMKeyEvent *event);
00115   virtual int onKeyPress(nsIDOMKeyEvent *event);
00116   virtual int onKeyUp(nsIDOMKeyEvent *event);
00117   virtual int onMouseDown(nsIDOMMouseEvent *event);
00118   virtual int onMouseUp(nsIDOMMouseEvent *event);
00119   virtual int onMouseClick(nsIDOMMouseEvent *event);
00120   virtual int onMouseDoubleClick(nsIDOMMouseEvent *event);
00121   virtual int onMouseOver(nsIDOMMouseEvent *event);
00122   virtual int onMouseOut(nsIDOMMouseEvent *event);
00123   virtual int onActivate(nsIDOMUIEvent *event);
00124   virtual int onFocusIn(nsIDOMUIEvent *event);
00125   virtual int onFocusOut(nsIDOMUIEvent *event);
00126 
00127   virtual BrowserWindow *newWindow(const unsigned int chromeMask);
00128 
00129 private:
00130 
00131   struct Status
00132   {
00133     int loadPercent;
00134     int bytesLoaded;
00135     int maxBytesLoaded;
00136     bool loadFinished;
00137     String message;
00138     String tempMessage;
00139 
00140     inline Status() :
00141       loadPercent(0),
00142       bytesLoaded(0),
00143       maxBytesLoaded(0),
00144       loadFinished(true),
00145       message(),
00146       tempMessage()
00147     {
00148     }
00149   };
00150 
00151   int browser(nsIWebBrowser **webBrowser);
00152   int topDomWindow(nsIDOMWindow **window);
00153 
00154   // Callbacks from the UI.
00155   static gboolean _onDelete(GtkWidget *widget, GdkEventAny *event, BrowserWindow *browser);
00156   static void _onDestroy(GtkWidget *widget, BrowserWindow *browser);
00157 
00158   // Callbacks from the widget.
00159   static void _onLocationChanged(GtkMozEmbed *embed, BrowserWindow *browser);
00160   static void _onTitleChanged(GtkMozEmbed *embed, BrowserWindow *browser);
00161   static void _onLoadStarted(GtkMozEmbed *embed, BrowserWindow *browser);
00162   static void _onLoadFinished(GtkMozEmbed *embed, BrowserWindow *browser);
00163   static void _onNetStateChange(GtkMozEmbed *embed, gint flags, guint status, BrowserWindow *browser);
00164   static void _onNetStateChangeAll(GtkMozEmbed *embed, const char *uri, gint flags, guint status, BrowserWindow *browser);
00165   static void _onProgressChange(GtkMozEmbed *embed, gint cur, gint max, BrowserWindow *browser);
00166   static void _onProgressChangeAll(GtkMozEmbed *embed, const char *uri, gint cur, gint max, BrowserWindow *browser);
00167   static void _onLinkMessage(GtkMozEmbed *embed, BrowserWindow *browser);
00168   static void _onJSStatus(GtkMozEmbed *embed, BrowserWindow *browser);
00169   static void _onNewWindow(GtkMozEmbed *embed, GtkMozEmbed **newEmbed, guint chromeMask, BrowserWindow *browser);
00170   static void _onVisibility(GtkMozEmbed *embed, gboolean visibility, BrowserWindow *browser);
00171   static void _onDestroyBrowser(GtkMozEmbed *embed, BrowserWindow *browser);
00172   static gint _onOpenUri(GtkMozEmbed *embed, const char *uri, BrowserWindow *browser);
00173   static void _onSizeTo(GtkMozEmbed *embed, gint width, gint height, BrowserWindow *browser);
00174 
00175   static gint _onKeyDown(GtkMozEmbed *embed, nsIDOMKeyEvent *event, BrowserWindow *browser);
00176   static gint _onKeyPress(GtkMozEmbed *embed, nsIDOMKeyEvent *event, BrowserWindow *browser);
00177   static gint _onKeyUp(GtkMozEmbed *embed, nsIDOMKeyEvent *event, BrowserWindow *browser);
00178   static gint _onMouseDown(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00179   static gint _onMouseUp(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00180   static gint _onMouseClick(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00181   static gint _onMouseDoubleClick(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00182   static gint _onMouseOver(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00183   static gint _onMouseOut(GtkMozEmbed *embed, nsIDOMMouseEvent *event, BrowserWindow *browser);
00184 
00185   static void _onSecurityChange(GtkMozEmbed *embed, gpointer request, guint state, BrowserWindow *browser);
00186 
00187   static gint _onActivate(GtkMozEmbed *embed, nsIDOMUIEvent *event, BrowserWindow *browser);
00188   static gint _onFocusIn(GtkMozEmbed *embed, nsIDOMUIEvent *event, BrowserWindow *browser);
00189   static gint _onFocusOut(GtkMozEmbed *embed, nsIDOMUIEvent *event, BrowserWindow *browser);
00190 
00191   // Callbacks from the singleton object.
00192   static void _onNewWindowOrphan(GtkMozEmbedSingle *embed,  GtkMozEmbed **newEmbed, guint chromeMask, BrowserWindow *browser);
00193 
00194   int updateStatusBar();
00195 
00196   GtkWidget *_topLevelWindow;
00197   GtkWidget *_topLevelVBox;
00198   GtkWidget *_mozEmbed;
00199   GtkWidget *_progressAreaHBox;
00200   GtkWidget *_statusAlign;
00201   GtkWidget *_statusBar;
00202   GtkWidget *_progressAlign;
00203   GtkWidget *_progressBar;
00204 
00205   bool _statusBarVisible;
00206   bool _progressBarVisible;
00207   bool _progressBarAutoMode;
00208   Status _status;
00209 };
00210 
00211 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1