1/*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2006 Zack Rusin <zack@kde.org>
4 * Copyright (C) 2006 Apple Computer, Inc.
5 * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef EditorClientHaiku_H
32#define EditorClientHaiku_H
33
34#include "EditorClient.h"
35#include "TextCheckerClient.h"
36#include "RefCounted.h"
37#include "Page.h"
38
39#include <wtf/Forward.h>
40
41
42namespace WebCore {
43
44class EditorClientHaiku : public EditorClient, public TextCheckerClient {
45    public:
46        EditorClientHaiku();
47        void setPage( Page* page );
48
49        virtual void pageDestroyed();
50
51        virtual bool shouldDeleteRange(Range*);
52        virtual bool shouldShowDeleteInterface(HTMLElement*);
53        virtual bool smartInsertDeleteEnabled();
54        virtual bool isSelectTrailingWhitespaceEnabled();
55        virtual bool isContinuousSpellCheckingEnabled();
56        virtual void toggleContinuousSpellChecking();
57        virtual bool isGrammarCheckingEnabled();
58        virtual void toggleGrammarChecking();
59        virtual int spellCheckerDocumentTag();
60
61        virtual bool shouldBeginEditing(Range*);
62        virtual bool shouldEndEditing(Range*);
63        virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction);
64        virtual bool shouldInsertText(const String&, Range*, EditorInsertAction);
65        virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange,
66                                               EAffinity, bool stillSelecting);
67
68        virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*);
69        virtual bool shouldMoveRangeAfterDelete(Range*, Range*);
70
71        virtual void didBeginEditing();
72        virtual void respondToChangedContents();
73        virtual void respondToChangedSelection();
74        virtual void didEndEditing();
75        virtual void didWriteSelectionToPasteboard();
76        virtual void didSetSelectionTypesForPasteboard();
77
78        virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
79        virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
80        virtual void clearUndoRedoOperations();
81
82        virtual bool canCopyCut(bool defaultValue) const;
83        virtual bool canPaste(bool defaultValue) const;
84        virtual bool canUndo() const;
85        virtual bool canRedo() const;
86
87        virtual void undo();
88        virtual void redo();
89
90        virtual void handleKeyboardEvent(KeyboardEvent*);
91        virtual void handleInputMethodKeydown(KeyboardEvent*);
92
93        virtual void textFieldDidBeginEditing(Element*);
94        virtual void textFieldDidEndEditing(Element*);
95        virtual void textDidChangeInTextField(Element*);
96        virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*);
97        virtual void textWillBeDeletedInTextField(Element*);
98        virtual void textDidChangeInTextArea(Element*);
99
100        virtual void ignoreWordInSpellDocument(const String&);
101        virtual void learnWord(const String&);
102        virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation,
103                                           int* misspellingLength);
104        virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
105        virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&,
106                                          int* badGrammarLocation, int* badGrammarLength);
107        virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
108        virtual void updateSpellingUIWithMisspelledWord(const String&);
109        virtual void showSpellingUI(bool show);
110        virtual bool spellingUIIsShowing();
111        virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
112        virtual void willSetInputMethodState();
113        virtual void setInputMethodState(bool enabled);
114        virtual void requestCheckingOfString(SpellChecker*, int, WebCore::TextCheckingTypeMask, const String&) {}
115        virtual TextCheckerClient* textChecker() { return this; }
116
117        bool isEditing() const;
118
119    private:
120        Page* m_page;
121        bool m_editing;
122        bool m_inUndoRedo; // our undo stack works differently - don't re-enter!
123    };
124
125} // namespace WebCore
126
127#endif // EditorClientHaiku_h
128