Back to index

lightning-sunbird  0.9+nobinonly
nsFocusController.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   David W. Hyatt <hyatt@netscape.com> (Original Author)
00025  *   Dan Rosen <dr@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or 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 
00041 #ifndef nsFocusController_h__
00042 #define nsFocusController_h__
00043 
00044 #include "nsCOMPtr.h"
00045 #include "nsIFocusController.h"
00046 #include "nsIDOMFocusListener.h"
00047 #include "nsIDOMElement.h"
00048 #include "nsIDOMWindow.h"
00049 #include "nsWeakReference.h"
00050 
00051 class nsIDOMElement;
00052 class nsIDOMWindow;
00053 class nsPIDOMWindow;
00054 class nsIController;
00055 class nsIControllers;
00056 
00057 class nsFocusController : public nsIFocusController_MOZILLA_1_8_BRANCH,
00058                           public nsIDOMFocusListener,
00059                           public nsSupportsWeakReference
00060 {
00061 public:
00062   static NS_IMETHODIMP Create(nsIFocusController** aResult);
00063 
00064 protected:
00065   nsFocusController(void);
00066   virtual ~nsFocusController(void);
00067 
00068 public:
00069   NS_DECL_ISUPPORTS
00070 
00071   NS_IMETHOD GetFocusedElement(nsIDOMElement** aResult);
00072   NS_IMETHOD SetFocusedElement(nsIDOMElement* aElement);
00073 
00074   NS_IMETHOD GetFocusedWindow(nsIDOMWindowInternal** aResult);
00075   NS_IMETHOD SetFocusedWindow(nsIDOMWindowInternal* aResult);
00076 
00077   NS_IMETHOD GetSuppressFocus(PRBool* aSuppressFlag);
00078   NS_IMETHOD SetSuppressFocus(PRBool aSuppressFlag, const char* aReason);
00079 
00080   NS_IMETHOD GetSuppressFocusScroll(PRBool* aSuppressFlag);
00081   NS_IMETHOD SetSuppressFocusScroll(PRBool aSuppressFlag);
00082   
00083   NS_IMETHOD GetActive(PRBool* aActive);
00084   NS_IMETHOD SetActive(PRBool aActive);
00085 
00086   NS_IMETHOD GetPopupNode(nsIDOMNode** aNode);
00087   NS_IMETHOD SetPopupNode(nsIDOMNode* aNode);
00088 
00089   NS_IMETHOD GetPopupEvent(nsIDOMEvent** aEvent);
00090   NS_IMETHOD SetPopupEvent(nsIDOMEvent* aEvent);
00091 
00092   NS_IMETHOD GetControllerForCommand(const char *aCommand, nsIController** aResult);
00093   NS_IMETHOD GetControllers(nsIControllers** aResult);
00094 
00095   NS_IMETHOD MoveFocus(PRBool aForward, nsIDOMElement* aElt);
00096   NS_IMETHOD RewindFocusState();
00097 
00098   NS_IMETHOD ResetElementFocus();
00099 
00100   // nsIDOMFocusListener
00101   NS_IMETHOD Focus(nsIDOMEvent* aEvent);
00102   NS_IMETHOD Blur(nsIDOMEvent* aEvent);
00103 
00104   // nsIDOMEventListener
00105   NS_IMETHOD HandleEvent(nsIDOMEvent* anEvent) { return NS_OK; };
00106 
00107 protected:
00108   void UpdateCommands();
00109   void UpdateWWActiveWindow();
00110 
00111 public:
00112   static nsPIDOMWindow *GetWindowFromDocument(nsIDOMDocument* aElement);
00113 
00114 // Members
00115 protected:
00116   nsCOMPtr<nsIDOMElement> mCurrentElement; // [OWNER]
00117   nsCOMPtr<nsIDOMElement> mPreviousElement; // [OWNER]
00118   nsCOMPtr<nsIDOMWindowInternal> mCurrentWindow; // [OWNER]
00119   nsCOMPtr<nsIDOMWindowInternal> mPreviousWindow; // [OWNER]
00120   nsCOMPtr<nsIDOMNode> mPopupNode; // [OWNER]
00121   nsCOMPtr<nsIDOMEvent> mPopupEvent;
00122 
00123   PRUint32 mSuppressFocus;
00124   PRPackedBool mSuppressFocusScroll;
00125   PRPackedBool mActive;
00126   PRPackedBool mUpdateWindowWatcher;
00127   PRPackedBool mNeedUpdateCommands;
00128 };
00129 
00130 #endif // nsFocusController_h__