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