Back to index

lightning-sunbird  0.9+nobinonly
nsIEventStateManager.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) 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 
00038 #ifndef nsIEventStateManager_h__
00039 #define nsIEventStateManager_h__
00040 
00041 #include "nsEvent.h"
00042 #include "nsISupports.h"
00043 #include "nsVoidArray.h"
00044 
00045 class nsIContent;
00046 class nsPresContext;
00047 class nsIDOMEvent;
00048 class nsIFrame;
00049 class nsIView;
00050 class nsIWidget;
00051 class imgIContainer;
00052 
00053 /*
00054  * Event state manager interface.
00055  */
00056 // 2270e188-6743-441e-b6e1-af83f1047a53
00057 #define NS_IEVENTSTATEMANAGER_IID \
00058 { 0x2270e188, 0x6743, 0x441e, \
00059   { 0xb6, 0xe1, 0xaf, 0x83, 0xf1, 0x04, 0x7a, 0x53 } }
00060 
00061 
00062 #define NS_EVENT_NEEDS_FRAME(event) (!NS_IS_FOCUS_EVENT(event))
00063 
00064 class nsIEventStateManager : public nsISupports {
00065 
00066 public:
00067   enum EFocusedWithType {
00068     eEventFocusedByUnknown,     // focus gained via unknown method
00069     eEventFocusedByMouse,       // focus gained via mouse
00070     eEventFocusedByKey,         // focus gained via key press (like tab)
00071     eEventFocusedByContextMenu, // focus gained via context menu
00072     eEventFocusedByApplication  // focus gained via Application (like script)
00073   };
00074 
00075   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IEVENTSTATEMANAGER_IID)
00076 
00077   NS_IMETHOD Init() = 0;
00078 
00079   NS_IMETHOD PreHandleEvent(nsPresContext* aPresContext, 
00080                             nsEvent *aEvent, 
00081                             nsIFrame* aTargetFrame,
00082                             nsEventStatus* aStatus,
00083                             nsIView* aView) = 0;
00084 
00085   NS_IMETHOD PostHandleEvent(nsPresContext* aPresContext, 
00086                              nsEvent *aEvent, 
00087                              nsIFrame* aTargetFrame,
00088                              nsEventStatus* aStatus,
00089                              nsIView* aView) = 0;
00090 
00091   NS_IMETHOD SetPresContext(nsPresContext* aPresContext) = 0;
00092   NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
00093 
00094   NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
00095   NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
00096   NS_IMETHOD GetEventRelatedContent(nsIContent** aContent) = 0;
00097 
00098   NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0;
00099   NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0;
00100 
00101   NS_IMETHOD GetFocusedContent(nsIContent **aContent) = 0;
00102   NS_IMETHOD SetFocusedContent(nsIContent* aContent) = 0;
00103 
00104   // Get the previously-focused content node for this document
00105   NS_IMETHOD GetLastFocusedContent(nsIContent **aContent) = 0;
00106 
00107   NS_IMETHOD GetFocusedFrame(nsIFrame **aFrame) = 0;
00108 
00109   NS_IMETHOD ContentRemoved(nsIContent* aContent) = 0;
00110   NS_IMETHOD EventStatusOK(nsGUIEvent* aEvent, PRBool *aOK) = 0;
00111 
00112   // Return whether browse with caret is enabled or not
00113   virtual PRBool GetBrowseWithCaret() = 0;
00114 
00115   // This is called after find text or when a cursor movement key is pressed
00116   // If aCanFocusDoc == PR_TRUE, the current document will be focused if caret is not on a focusable element
00117   NS_IMETHOD MoveFocusToCaret(PRBool aCanFocusDoc, PRBool *aIsSelectionWithFocus) = 0;
00118   NS_IMETHOD MoveCaretToFocus() = 0;
00119 
00120   // Set focus on any element that can receive focus, or on document via aFocusContent == nsnull
00121   // Must supply method that focus is being set with
00122   NS_IMETHOD ChangeFocusWith(nsIContent *aFocusContent, EFocusedWithType aFocusedWith) = 0;
00123 
00124   // This is an experiment and may be temporary
00125   NS_IMETHOD ConsumeFocusEvents(PRBool aDoConsume) = 0;
00126 
00127   // Access Key Registration
00128   NS_IMETHOD RegisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
00129   NS_IMETHOD UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
00130 
00131   NS_IMETHOD SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
00132                        PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
00133                        nsIWidget* aWidget, PRBool aLockCursor) = 0;
00134 
00135   //Method for centralized distribution of new DOM events
00136   NS_IMETHOD DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent, PRBool* aDefaultActionEnabled) = 0;
00137 
00138   // Method for moving the focus forward/back.
00139   NS_IMETHOD ShiftFocus(PRBool aDirection, nsIContent* aStart)=0;
00140 };
00141 
00142 #define NS_EVENT_STATE_ACTIVE        0x00000001 // mouse is down on content
00143 #define NS_EVENT_STATE_FOCUS         0x00000002 // content has focus
00144 #define NS_EVENT_STATE_HOVER         0x00000004 // mouse is hovering over content
00145 #define NS_EVENT_STATE_DRAGOVER      0x00000008 // drag  is hovering over content
00146 #define NS_EVENT_STATE_URLTARGET     0x00000010 // content is URL's target (ref)
00147 
00148 // The following states are used only for ContentStatesChanged
00149 // CSS 3 Selectors
00150 #define NS_EVENT_STATE_CHECKED       0x00000020
00151 #define NS_EVENT_STATE_ENABLED       0x00000040
00152 #define NS_EVENT_STATE_DISABLED      0x00000080
00153 // CSS 3 UI
00154 #define NS_EVENT_STATE_REQUIRED      0x00000100
00155 #define NS_EVENT_STATE_OPTIONAL      0x00000200
00156 #define NS_EVENT_STATE_VISITED       0x00000400
00157 #define NS_EVENT_STATE_VALID         0x00000800
00158 #define NS_EVENT_STATE_INVALID       0x00001000
00159 #define NS_EVENT_STATE_INRANGE       0x00002000
00160 #define NS_EVENT_STATE_OUTOFRANGE    0x00004000
00161 #define NS_EVENT_STATE_MOZ_READONLY  0x00008000
00162 #define NS_EVENT_STATE_MOZ_READWRITE 0x00010000
00163 
00164 #endif // nsIEventStateManager_h__