KHTML
editor.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2004 Leo Savernik <l.savernik@aon.at> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 * Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef __EDITOR_H 00022 #define __EDITOR_H 00023 00024 #include "editor_command.h" 00025 00026 #include <khtml_export.h> 00027 00028 #include <QObject> 00029 00030 #include "wtf/PassRefPtr.h" 00031 00032 class QKeyEvent; 00033 00034 class KHTMLPart; 00035 class KHTMLView; 00036 class KHTMLEditorPart; 00037 00038 namespace khtml { 00039 class EditCommandImpl; 00040 struct EditorContext; 00041 } 00042 00043 namespace DOM { 00044 00045 class Range; 00046 class NodeImpl; 00047 class ElementImpl; 00048 class DOMString; 00049 class CSSStyleDeclarationImpl; 00050 class EditorPrivate; 00051 00061 class KHTML_EXPORT Editor : public QObject { 00062 Q_OBJECT 00063 00064 Editor(KHTMLPart *); 00065 virtual ~Editor(); 00066 public: 00067 00071 enum TriState { FalseTriState, TrueTriState, MixedTriState }; 00072 00073 // == interface to editor commands 00074 00081 bool execCommand(const DOMString &command, bool userInterface, const DOMString &value); 00083 bool queryCommandEnabled(const DOMString &command); 00085 bool queryCommandIndeterm(const DOMString &command); 00087 bool queryCommandState(const DOMString &command); 00089 bool queryCommandSupported(const DOMString &command); 00091 DOMString queryCommandValue(const DOMString &command); 00092 00099 bool execCommand(EditorCommand, bool userInterface, const DOMString &value); 00101 bool queryCommandEnabled(EditorCommand); 00103 bool queryCommandIndeterm(EditorCommand); 00105 bool queryCommandState(EditorCommand); 00107 bool queryCommandSupported(EditorCommand); 00109 DOMString queryCommandValue(EditorCommand); 00110 00111 // == direct interface to some built-in commands 00112 00114 void copy(); 00116 void cut(); 00118 void paste(); 00120 bool canPaste() const; 00122 void redo(); 00124 void undo(); 00126 bool canRedo() const; 00128 bool canUndo() const; 00130 void applyStyle(DOM::CSSStyleDeclarationImpl *); 00132 TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const; 00134 bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const; 00136 DOM::DOMString selectionStartStylePropertyValue(int stylePropertyID) const; 00138 void print(); 00140 DOM::CSSStyleDeclarationImpl *selectionComputedStyle(DOM::NodeImpl *&nodeToRemove) const; 00141 00142 00143 // == ### more stuff I'm not sure about whether it should be public 00144 00148 WTF::PassRefPtr<khtml::EditCommandImpl> lastEditCommand() const; 00149 00153 void appliedEditing(khtml::EditCommandImpl *); 00154 00158 void unappliedEditing(khtml::EditCommandImpl *); 00159 00163 void reappliedEditing(khtml::EditCommandImpl *); 00164 00168 DOM::CSSStyleDeclarationImpl *typingStyle() const; 00169 00173 void setTypingStyle(DOM::CSSStyleDeclarationImpl *); 00174 00178 void clearTypingStyle(); 00179 00180 void closeTyping(); 00181 00185 void indent(); 00186 void outdent(); 00187 00188 private: 00190 bool handleKeyEvent(QKeyEvent *); 00191 00192 private: 00193 EditorPrivate *const d; 00194 00195 DOM::CSSStyleDeclarationImpl *m_typingStyle; 00196 00197 KHTMLPart *m_part; 00198 00199 friend class ::KHTMLPart; 00200 friend class ::KHTMLView; 00201 friend class ::KHTMLEditorPart; 00202 friend struct khtml::EditorContext; 00203 friend class DOM::ElementImpl; 00204 }; 00205 00206 }/*namespace DOM*/ 00207 00208 #endif // __EDITOR_H
KDE 4.6 API Reference