Back to index

lightning-sunbird  0.9+nobinonly
nsAppShellWindowEnumerator.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.org 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) 2001
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 
00038 #include "nsCOMPtr.h"
00039 #include "nsString.h"
00040 
00041 #include "nsISimpleEnumerator.h"
00042 #include "nsIXULWindow.h"
00043 
00044 class nsWindowMediator;
00045 
00046 /********************************************************************/
00047 /**************************** nsWindowInfo **************************/
00048 /********************************************************************/
00049 
00050 struct nsWindowInfo
00051 {
00052   nsWindowInfo(nsIXULWindow* inWindow, PRInt32 inTimeStamp);
00053   ~nsWindowInfo();
00054 
00055   nsCOMPtr<nsIXULWindow>    mWindow;
00056   PRInt32                   mTimeStamp;
00057   PRUint32                  mZLevel;
00058 
00059   // each struct is in two, independent, circular, doubly-linked lists
00060   nsWindowInfo              *mYounger, // next younger in sequence
00061                             *mOlder;
00062   nsWindowInfo              *mLower,   // next lower in z-order
00063                             *mHigher;
00064   
00065   PRBool TypeEquals(const nsAString &aType);
00066   void   InsertAfter(nsWindowInfo *inOlder, nsWindowInfo *inHigher);
00067   void   Unlink(PRBool inAge, PRBool inZ);
00068   void   ReferenceSelf(PRBool inAge, PRBool inZ);
00069 };
00070 
00071 
00072 /********************************************************************/
00073 /************************ virtual enumerators ***********************/
00074 /********************************************************************/
00075 
00076 class nsAppShellWindowEnumerator : public nsISimpleEnumerator {
00077 
00078 friend class nsWindowMediator;
00079 
00080 public:
00081   nsAppShellWindowEnumerator (const PRUnichar* aTypeString,
00082                       nsWindowMediator& inMediator);
00083   virtual ~nsAppShellWindowEnumerator();
00084   NS_IMETHOD GetNext(nsISupports **retval) = 0;
00085   NS_IMETHOD HasMoreElements(PRBool *retval);
00086 
00087   NS_DECL_ISUPPORTS
00088 
00089 protected:
00090 
00091   void AdjustInitialPosition();
00092   virtual nsWindowInfo *FindNext() = 0;
00093 
00094   void WindowRemoved(nsWindowInfo *inInfo);
00095 
00096   nsWindowMediator *mWindowMediator;
00097   nsString          mType;
00098   nsWindowInfo     *mCurrentPosition;
00099 };
00100 
00101 class nsASDOMWindowEnumerator : public nsAppShellWindowEnumerator {
00102 
00103 public:
00104   nsASDOMWindowEnumerator (const PRUnichar* aTypeString,
00105                            nsWindowMediator& inMediator);
00106   virtual ~nsASDOMWindowEnumerator();
00107   NS_IMETHOD GetNext(nsISupports **retval);
00108 };
00109 
00110 class nsASXULWindowEnumerator : public nsAppShellWindowEnumerator {
00111 
00112 public:
00113   nsASXULWindowEnumerator (const PRUnichar* aTypeString,
00114                            nsWindowMediator& inMediator);
00115   virtual ~nsASXULWindowEnumerator();
00116   NS_IMETHOD GetNext(nsISupports **retval);
00117 };
00118 
00119 /********************************************************************/
00120 /*********************** concrete enumerators ***********************/
00121 /********************************************************************/
00122 
00123 class nsASDOMWindowEarlyToLateEnumerator : public nsASDOMWindowEnumerator {
00124 
00125 public:
00126   nsASDOMWindowEarlyToLateEnumerator(
00127              const PRUnichar* aTypeString,
00128              nsWindowMediator& inMediator);
00129 
00130   virtual ~nsASDOMWindowEarlyToLateEnumerator();
00131 
00132 protected:
00133   virtual nsWindowInfo *FindNext();
00134 };
00135 
00136 class nsASXULWindowEarlyToLateEnumerator : public nsASXULWindowEnumerator {
00137 
00138 public:
00139   nsASXULWindowEarlyToLateEnumerator(
00140              const PRUnichar* aTypeString,
00141              nsWindowMediator& inMediator);
00142 
00143   virtual ~nsASXULWindowEarlyToLateEnumerator();
00144 
00145 protected:
00146   virtual nsWindowInfo *FindNext();
00147 };
00148 
00149 class nsASDOMWindowFrontToBackEnumerator : public nsASDOMWindowEnumerator {
00150 
00151 public:
00152   nsASDOMWindowFrontToBackEnumerator(
00153              const PRUnichar* aTypeString,
00154              nsWindowMediator& inMediator);
00155 
00156   virtual ~nsASDOMWindowFrontToBackEnumerator();
00157 
00158 protected:
00159   virtual nsWindowInfo *FindNext();
00160 };
00161 
00162 class nsASXULWindowFrontToBackEnumerator : public nsASXULWindowEnumerator {
00163 
00164 public:
00165   nsASXULWindowFrontToBackEnumerator(
00166              const PRUnichar* aTypeString,
00167              nsWindowMediator& inMediator);
00168 
00169   virtual ~nsASXULWindowFrontToBackEnumerator();
00170 
00171 protected:
00172   virtual nsWindowInfo *FindNext();
00173 };
00174 
00175 class nsASDOMWindowBackToFrontEnumerator : public nsASDOMWindowEnumerator {
00176 
00177 public:
00178   nsASDOMWindowBackToFrontEnumerator (
00179              const PRUnichar* aTypeString,
00180              nsWindowMediator& inMediator);
00181 
00182   virtual ~nsASDOMWindowBackToFrontEnumerator();
00183 
00184 protected:
00185   virtual nsWindowInfo *FindNext();
00186 };
00187 
00188 class nsASXULWindowBackToFrontEnumerator : public nsASXULWindowEnumerator {
00189 
00190 public:
00191   nsASXULWindowBackToFrontEnumerator (
00192              const PRUnichar* aTypeString,
00193              nsWindowMediator& inMediator);
00194 
00195   virtual ~nsASXULWindowBackToFrontEnumerator();
00196 
00197 protected:
00198   virtual nsWindowInfo *FindNext();
00199 };
00200 
00201