Back to index

lightning-sunbird  0.9+nobinonly
nsEditorEventListeners.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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 editorInterfaces_h__
00039 #define editorInterfaces_h__
00040 
00041 #include "nsCOMPtr.h"
00042 
00043 
00044 #include "nsIDOMEvent.h"
00045 #include "nsIDOMKeyListener.h"
00046 #include "nsIDOMMouseListener.h"
00047 #include "nsIDOMTextListener.h"
00048 #include "nsIDOMDragListener.h"
00049 #include "nsIDOMCompositionListener.h"
00050 #include "nsIDOMFocusListener.h"
00051 
00052 #include "nsIEditor.h"
00053 #include "nsIPlaintextEditor.h"
00054 #include "nsICaret.h"
00055 #include "nsIPresShell.h"
00056 #include "nsWeakPtr.h"
00057 #include "nsIWeakReferenceUtils.h"
00058 
00063 class nsTextEditorKeyListener : public nsIDOMKeyListener {
00064 public:
00067   nsTextEditorKeyListener();
00070   virtual ~nsTextEditorKeyListener();
00071 
00075   void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
00076 
00077 /*interfaces for addref and release and queryinterface*/
00078   NS_DECL_ISUPPORTS
00079 
00080 /*BEGIN interfaces in to the keylistener base interface. must be supplied to handle pure virtual interfaces
00081   see the nsIDOMKeyListener interface implementation for details
00082   */
00083   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00084   NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
00085   NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
00086   NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
00087 /*END interfaces from nsIDOMKeyListener*/
00088 
00089 protected:
00090   nsIEditor*     mEditor;          // weak reference
00091 };
00092 
00093 
00096 class nsTextEditorTextListener : public nsIDOMTextListener
00097 {
00098 public:
00101   nsTextEditorTextListener();
00104   virtual ~nsTextEditorTextListener();
00105 
00109   void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
00110 
00111 /*interfaces for addref and release and queryinterface*/
00112   NS_DECL_ISUPPORTS
00113 
00114 /*BEGIN implementations of textevent handler interface*/
00115     NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00116     NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
00117 /*END implementations of textevent handler interface*/
00118 
00119 protected:
00120   nsIEditor*      mEditor;         // weak reference
00121        PRBool                             mCommitText;
00122        PRBool                             mInTransaction;
00123 };
00124 
00125 
00126 class nsIEditorIMESupport;
00127 
00128 class nsTextEditorCompositionListener : public nsIDOMCompositionListener
00129 {
00130 public:
00133   nsTextEditorCompositionListener();
00136   virtual ~nsTextEditorCompositionListener();
00137 
00141   void SetEditor(nsIEditor *aEditor);
00142 
00143 /*interfaces for addref and release and queryinterface*/
00144   NS_DECL_ISUPPORTS
00145 
00146 /*BEGIN implementations of textevent handler interface*/
00147   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00148   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
00149   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
00150   NS_IMETHOD HandleQueryComposition(nsIDOMEvent* aCompositionEvent);
00151   NS_IMETHOD HandleQueryReconversion(nsIDOMEvent* aReconvertionEvent);
00152   NS_IMETHOD HandleQueryCaretRect(nsIDOMEvent* aQueryCaretRectEvent);
00153 /*END implementations of textevent handler interface*/
00154 
00155 protected:
00156   nsIEditorIMESupport*     mEditor;              // weak reference
00157 };
00158 
00159 
00162 class nsTextEditorMouseListener : public nsIDOMMouseListener 
00163 {
00164 public:
00167   nsTextEditorMouseListener();
00170   virtual ~nsTextEditorMouseListener();
00171 
00175   void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
00176 
00177 /*interfaces for addref and release and queryinterface*/
00178   NS_DECL_ISUPPORTS
00179 
00180 /*BEGIN implementations of mouseevent handler interface*/
00181   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00182   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
00183   NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
00184   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
00185   NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
00186   NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
00187   NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
00188 /*END implementations of mouseevent handler interface*/
00189 
00190 protected:
00191   nsIEditor*     mEditor;          // weak reference
00192 
00193 };
00194 
00195 
00198 class nsTextEditorDragListener : public nsIDOMDragListener 
00199 {
00200 public:
00203   nsTextEditorDragListener();
00206   virtual ~nsTextEditorDragListener();
00207 
00211   void SetEditor(nsIEditor *aEditor)          { mEditor = aEditor; }
00212   void SetPresShell(nsIPresShell *aPresShell) {
00213     mPresShell = do_GetWeakReference(aPresShell);
00214   }
00215 
00216 /*interfaces for addref and release and queryinterface*/
00217   NS_DECL_ISUPPORTS
00218 
00219 /*BEGIN implementations of dragevent handler interface*/
00220   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00221   NS_IMETHOD DragEnter(nsIDOMEvent* aDragEvent);
00222   NS_IMETHOD DragOver(nsIDOMEvent* aDragEvent);
00223   NS_IMETHOD DragExit(nsIDOMEvent* aDragEvent);
00224   NS_IMETHOD DragDrop(nsIDOMEvent* aDragEvent);
00225   NS_IMETHOD DragGesture(nsIDOMEvent* aDragEvent);
00226 /*END implementations of dragevent handler interface*/
00227 
00228 protected:
00229 
00230   PRBool     CanDrop(nsIDOMEvent* aEvent);
00231   
00232 protected:
00233 
00234   nsIEditor* mEditor;
00235   nsWeakPtr  mPresShell;
00236   
00237   nsCOMPtr<nsICaret> mCaret;
00238   PRBool             mCaretDrawn;
00239 
00240 };
00241 
00244 class nsTextEditorFocusListener : public nsIDOMFocusListener 
00245 {
00246 public:
00249   nsTextEditorFocusListener();
00252   virtual ~nsTextEditorFocusListener();
00253 
00257   void SetEditor(nsIEditor *aEditor){mEditor = aEditor;}
00258 
00259 /*interfaces for addref and release and queryinterface*/
00260   NS_DECL_ISUPPORTS
00261 
00262 /*BEGIN implementations of focus event handler interface*/
00263   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
00264   NS_IMETHOD Focus(nsIDOMEvent* aEvent);
00265   NS_IMETHOD Blur(nsIDOMEvent* aEvent);
00266 /*END implementations of focus event handler interface*/
00267 
00268 protected:
00269   nsIEditor*     mEditor;          // weak reference
00270 };
00271 
00272 
00273 
00276 extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
00277 
00280 extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsIEditor *aEditor);
00281 
00284 extern nsresult NS_NewEditorTextListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
00285 
00288 extern nsresult NS_NewEditorDragListener(nsIDOMEventListener ** aInstancePtrResult, nsIPresShell* aPresShell,
00289                                             nsIEditor *aEditor);
00290 
00293 extern nsresult NS_NewEditorCompositionListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
00294 
00297 extern nsresult NS_NewEditorFocusListener(nsIDOMEventListener** aInstancePtrResult, nsIEditor *aEditor);
00298 
00299 #endif //editorInterfaces_h__
00300