1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Masayuki Nakano <masayuki@d-toybox.com>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef nsEditorEventListener_h__
40 : #define nsEditorEventListener_h__
41 :
42 : #include "nsCOMPtr.h"
43 :
44 : #include "nsIDOMEvent.h"
45 : #include "nsIDOMEventListener.h"
46 :
47 : #include "nsCaret.h"
48 :
49 : // X.h defines KeyPress
50 : #ifdef KeyPress
51 : #undef KeyPress
52 : #endif
53 :
54 : #ifdef XP_WIN
55 : // On Windows, we support switching the text direction by pressing Ctrl+Shift
56 : #define HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
57 : #endif
58 :
59 : class nsEditor;
60 : class nsIDOMDragEvent;
61 :
62 : class nsEditorEventListener : public nsIDOMEventListener
63 : {
64 : public:
65 : nsEditorEventListener();
66 : virtual ~nsEditorEventListener();
67 :
68 : virtual nsresult Connect(nsEditor* aEditor);
69 :
70 : void Disconnect();
71 :
72 : NS_DECL_ISUPPORTS
73 : NS_DECL_NSIDOMEVENTLISTENER
74 :
75 : #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
76 : NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
77 : NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
78 : #endif
79 : NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
80 : NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
81 : NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
82 : NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
83 : NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
84 0 : NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
85 : NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
86 : NS_IMETHOD Focus(nsIDOMEvent* aEvent);
87 : NS_IMETHOD Blur(nsIDOMEvent* aEvent);
88 :
89 : void SpellCheckIfNeeded();
90 :
91 : protected:
92 : nsresult InstallToEditor();
93 : void UninstallFromEditor();
94 :
95 : bool CanDrop(nsIDOMDragEvent* aEvent);
96 : nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
97 : nsresult DragOver(nsIDOMDragEvent* aDragEvent);
98 : nsresult DragExit(nsIDOMDragEvent* aDragEvent);
99 : nsresult Drop(nsIDOMDragEvent* aDragEvent);
100 : nsresult DragGesture(nsIDOMDragEvent* aDragEvent);
101 : void CleanupDragDropCaret();
102 : already_AddRefed<nsIPresShell> GetPresShell();
103 :
104 : protected:
105 : nsEditor* mEditor; // weak
106 : nsRefPtr<nsCaret> mCaret;
107 : bool mCommitText;
108 : bool mInTransaction;
109 : #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
110 : bool mHaveBidiKeyboards;
111 : bool mShouldSwitchTextDirection;
112 : bool mSwitchToRTL;
113 : #endif
114 : };
115 :
116 : #endif // nsEditorEventListener_h__
|