Back to index

lightning-sunbird  0.9+nobinonly
nsXPBaseWindow.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsXPBaseWindow_h___
00038 #define nsXPBaseWindow_h___
00039 
00040 #include "nsIXPBaseWindow.h"
00041 #include "nsIStreamListener.h"
00042 #include "nsString.h"
00043 #include "nsVoidArray.h"
00044 #include "nsCRT.h"
00045 
00046 #include "nsIContent.h"
00047 #include "nsIDOMNode.h"
00048 #include "nsIDOMElement.h"
00049 #include "nsIDOMMouseListener.h"
00050 #include "nsIWidget.h"
00051 
00052 class nsViewerApp;
00053 class nsIPresShell;
00054 
00058 class nsXPBaseWindow : public nsIXPBaseWindow,
00059                        public nsIDOMMouseListener
00060 {
00061 public:
00062   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
00063 
00064   nsXPBaseWindow();
00065   virtual ~nsXPBaseWindow();
00066 
00067   // nsISupports
00068   NS_DECL_ISUPPORTS
00069 
00070   // nsIBrowserWindow
00071   NS_IMETHOD Init(nsXPBaseWindowType aType,
00072                   nsIAppShell*       aAppShell,
00073                   const nsString&    aDialogURL,
00074                   const nsString&    aTitle,
00075                   const nsRect&      aBounds,
00076                   PRUint32           aChromeMask,
00077                   PRBool             aAllowPlugins = PR_TRUE);
00078 
00079 
00080   NS_IMETHOD SetLocation(PRInt32 aX, PRInt32 aY);
00081   NS_IMETHOD SetDimensions(PRInt32 aWidth, PRInt32 aHeight);
00082 
00083   NS_IMETHOD GetWindowBounds(nsRect& aBounds);
00084   NS_IMETHOD GetBounds(nsRect& aBounds);
00085   NS_IMETHOD SetVisible(PRBool aIsVisible);
00086   NS_IMETHOD Close();
00087   NS_IMETHOD SetTitle(const PRUnichar* aTitle);
00088   NS_IMETHOD GetTitle(const PRUnichar** aResult);
00089   NS_IMETHOD GetDocShell(nsIDocShell*& aResult);
00090   NS_IMETHOD GetPresShell(nsIPresShell*& aPresShell);
00091 
00092   //NS_IMETHOD HandleEvent(nsGUIEvent * anEvent);
00093 
00094   NS_IMETHOD LoadURL(const nsString &aURL);
00095 
00096   void Layout(PRInt32 aWidth, PRInt32 aHeight);
00097 
00098   void ForceRefresh();
00099 
00100   //nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent);
00101 
00102 
00103   void SetApp(nsViewerApp* aApp) {
00104     mApp = aApp;
00105   }
00106 
00107   // DOM Element & Node Interfaces
00108   NS_IMETHOD GetDocument(nsIDOMHTMLDocument *& aDocument);
00109   NS_IMETHOD AddEventListener(nsIDOMNode * aNode);
00110   NS_IMETHOD RemoveEventListener(nsIDOMNode * aNode);
00111   NS_IMETHOD AddWindowListener(nsIWindowListener * aWindowListener);
00112 
00113   // nsIDOMEventListener
00114   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00115 
00116   // nsIDOMMouseListener (is derived from nsIDOMEventListener)
00117   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
00118   NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
00119   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
00120   NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
00121   NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
00122   NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
00123 
00124 protected:
00125   void         GetContentRoot(); //Gets the Root Content node after Doc is loaded
00126   nsIContent * mContentRoot; // Points at the Root Content Node
00127 
00128 
00129 protected:
00130   nsViewerApp* mApp;
00131 
00132   nsString     mTitle;
00133   nsString     mDialogURL;
00134 
00135   nsIWidget*   mWindow;
00136   nsIDocShell* mDocShell;
00137 
00138   nsIWindowListener * mWindowListener; // XXX Someday this will be a list
00139   PRBool       mDocIsLoaded;
00140 
00141   //for creating more instances
00142   nsIAppShell* mAppShell;       //not addref'ed!
00143   PRBool       mAllowPlugins;
00144 
00145   nsXPBaseWindowType mWindowType;
00146 
00147 };
00148 
00149 // XXX This is bad; because we can't hang a closure off of the event
00150 // callback we have no way to store our This pointer; therefore we
00151 // have to hunt to find the browswer that events belong too!!!
00152 
00153 // aWhich for FindBrowserFor
00154 #define FIND_WINDOW   0
00155 #define FIND_BACK     1
00156 #define FIND_FORWARD  2
00157 #define FIND_LOCATION 3
00158 
00159 
00160 
00161 #endif /* nsXPBaseWindow_h___ */