KHtml

editor.h
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2004 Leo Savernik <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef __EDITOR_H
22 #define __EDITOR_H
23 
24 #include "editor_command.h"
25 
26 #include <khtml_export.h>
27 
28 #include <QObject>
29 
30 #include "wtf/PassRefPtr.h"
31 
32 class QKeyEvent;
33 
34 class KHTMLPart;
35 class KHTMLView;
36 class KHTMLEditorPart;
37 
38 namespace khtml
39 {
40 class EditCommandImpl;
41 struct EditorContext;
42 }
43 
44 namespace DOM
45 {
46 
47 class Range;
48 class NodeImpl;
49 class ElementImpl;
50 class DOMString;
51 class CSSStyleDeclarationImpl;
52 class EditorPrivate;
53 
54 /**
55  * This class resembles the editing API when the associated khtml document
56  * is editable (in design mode), or contains editable elements.
57  *
58  * FIXME: document this thoroughly
59  *
60  * @short API to Wysiwyg Markup-Editor.
61  * @author Leo Savernik
62  */
63 class KHTML_EXPORT Editor : public QObject
64 {
65  Q_OBJECT
66 
67  Editor(KHTMLPart *);
68  virtual ~Editor();
69 public:
70 
71  /**
72  * Tri-state boolean.
73  */
74  enum TriState { FalseTriState, TrueTriState, MixedTriState };
75 
76  // == interface to editor commands
77 
78  /**
79  * Executes the given editor command.
80  * @param command name of command
81  * @param userInterface whether a user interface should be used to input data. This is command dependent.
82  * @param value value for command. Its semantic depends on the command.
83  */
84  bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
85  /** Checks whether the given command is enabled. */
86  bool queryCommandEnabled(const DOMString &command);
87  /** Checks whether the given command's style is indeterminate */
88  bool queryCommandIndeterm(const DOMString &command);
89  /** Checks whether the given command's style is state */
90  bool queryCommandState(const DOMString &command);
91  /** Checks whether the given command is supported in the current context */
92  bool queryCommandSupported(const DOMString &command);
93  /** Returns the given command's value */
94  DOMString queryCommandValue(const DOMString &command);
95 
96  /**
97  * Executes the given built-in editor command.
98  * @param EditorCommand index of command
99  * @param userInterface whether a user interface should be used to input data. This is command dependent.
100  * @param value value for command. Its semantic depends on the command.
101  */
102  bool execCommand(EditorCommand, bool userInterface, const DOMString &value);
103  /** Checks whether the given command is enabled. */
104  bool queryCommandEnabled(EditorCommand);
105  /** Checks whether the given command's style is indeterminate */
106  bool queryCommandIndeterm(EditorCommand);
107  /** Checks whether the given command's style is state */
108  bool queryCommandState(EditorCommand);
109  /** Checks whether the given command is supported in the current context */
110  bool queryCommandSupported(EditorCommand);
111  /** Returns the given command's value */
112  DOMString queryCommandValue(EditorCommand);
113 
114  // == direct interface to some built-in commands
115 
116  /** copy selection to clipboard */
117  void copy();
118  /** cut selection and insert into clipboard */
119  void cut();
120  /** paste into current selection from clipboard */
121  void paste();
122  /** returns whether clipboard contains data to be pasted */
123  bool canPaste() const;
124  /** redo last undone action */
125  void redo();
126  /** undo last action */
127  void undo();
128  /** returns whether any actions can be redone */
129  bool canRedo() const;
130  /** returns whether any actions can be undone */
131  bool canUndo() const;
132  /** applies the given style to the current selection */
133  void applyStyle(DOM::CSSStyleDeclarationImpl *);
134  /** returns whether the selection has got applied the given style */
135  TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const;
136  /** returns whether the selection has got applied the given style */
137  bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const;
138  /** ? */
139  DOM::DOMString selectionStartStylePropertyValue(int stylePropertyID) const;
140  /** prints the current document */
141  void print();
142  /** computed style of current selection */
143  DOM::CSSStyleDeclarationImpl *selectionComputedStyle(DOM::NodeImpl *&nodeToRemove) const;
144 
145  // == ### more stuff I'm not sure about whether it should be public
146 
147  /**
148  * Returns the most recent edit command applied.
149  */
150  WTF::PassRefPtr<khtml::EditCommandImpl> lastEditCommand() const;
151 
152  /**
153  * Called when editing has been applied.
154  */
155  void appliedEditing(khtml::EditCommandImpl *);
156 
157  /**
158  * Called when editing has been unapplied.
159  */
160  void unappliedEditing(khtml::EditCommandImpl *);
161 
162  /**
163  * Called when editing has been reapplied.
164  */
165  void reappliedEditing(khtml::EditCommandImpl *);
166 
167  /**
168  * Returns the typing style for the document.
169  */
170  DOM::CSSStyleDeclarationImpl *typingStyle() const;
171 
172  /**
173  * Sets the typing style for the document.
174  */
175  void setTypingStyle(DOM::CSSStyleDeclarationImpl *);
176 
177  /**
178  * Clears the typing style for the document.
179  */
180  void clearTypingStyle();
181 
182  void closeTyping();
183 
184  /**
185  * indent/outdent current selection
186  */
187  void indent();
188  void outdent();
189 
190 private:
191  /** Handles key events. Returns true if event has been handled. */
192  bool handleKeyEvent(QKeyEvent *);
193 
194 private:
195  EditorPrivate *const d;
196 
197  DOM::CSSStyleDeclarationImpl *m_typingStyle;
198 
199  KHTMLPart *m_part;
200 
201  friend class ::KHTMLPart;
202  friend class ::KHTMLView;
203  friend class ::KHTMLEditorPart;
204  friend struct khtml::EditorContext;
205  friend class DOM::ElementImpl;
206 };
207 
208 }/*namespace DOM*/
209 
210 #endif // __EDITOR_H
EditorCommand
This class resembles the editing API when the associated khtml document is editable (in design mode)...
Definition: editor.h:63
This file is part of the HTML rendering engine for KDE.
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
Renders and displays HTML in a QScrollArea.
Definition: khtmlview.h:97
TriState
Tri-state boolean.
Definition: editor.h:74
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.