• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • kde-4.14
  • applications
  • kate
  • ktexteditor
view.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3  Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation)
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 version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KDELIBS_KTEXTEDITOR_VIEW_H
21 #define KDELIBS_KTEXTEDITOR_VIEW_H
22 
23 #include <ktexteditor/ktexteditor_export.h>
24 #include <ktexteditor/range.h>
25 
26 // gui merging
27 #include <kxmlguiclient.h>
28 
29 // widget
30 #include <QtGui/QWidget>
31 
32 class QMenu;
33 
34 namespace KTextEditor
35 {
36 
37 class Document;
38 
141 // KDE5: consider deriving from QFrame instead of QWidget, since e.g. the Oxygen style
142 // http://lxr.kde.org/source/kde/kde-workspace/kstyles/oxygen/oxygenstyle.cpp#614
143 // checks for a QFrame and then KStyle::pixelMetric returns a better margin (Frame_FrameWidth)
144 // This is needed because the Oxygen "focus border" paints over the line numbers otherwise.
145 class KTEXTEDITOR_EXPORT View : public QWidget, public KXMLGUIClient
146 {
147  Q_OBJECT
148 
149  public:
157  View ( QWidget *parent );
158 
162  virtual ~View ();
163 
164  /*
165  * Accessor for the document
166  */
167  public:
173  virtual Document *document () const = 0;
174 
182  bool isActiveView() const;
183 
184  /*
185  * General information about this view
186  */
187  public:
199  virtual QString viewMode () const = 0;
200 
205  enum EditMode {
206  EditInsert = 0,
207  EditOverwrite = 1,
208  EditViMode = 2
209  };
210 
220  virtual enum EditMode viewEditMode() const = 0;
221 
222  /*
223  * SIGNALS
224  * following signals should be emitted by the editor view
225  */
226  Q_SIGNALS:
232  void focusIn ( KTextEditor::View *view );
233 
239  void focusOut ( KTextEditor::View *view );
240 
246  void viewModeChanged ( KTextEditor::View *view );
247 
255  void viewEditModeChanged ( KTextEditor::View *view,
256  enum KTextEditor::View::EditMode mode );
257 
265  void informationMessage ( KTextEditor::View *view, const QString &message );
266 
275  void textInserted ( KTextEditor::View *view,
276  const KTextEditor::Cursor &position,
277  const QString &text );
278 
279  /*
280  * Context menu handling
281  */
282  public:
296  virtual void setContextMenu ( QMenu *menu ) = 0;
297 
306  virtual QMenu *contextMenu () const = 0;
307 
341  virtual QMenu* defaultContextMenu(QMenu* menu = 0L) const = 0;
342 
343  Q_SIGNALS:
348  void contextMenuAboutToShow(KTextEditor::View* view, QMenu* menu);
349 
350  /*
351  * Cursor handling
352  */
353  public:
361  virtual bool setCursorPosition (Cursor position) = 0;
362 
369  virtual Cursor cursorPosition () const = 0;
370 
381  virtual Cursor cursorPositionVirtual () const = 0;
382 
391  virtual QPoint cursorToCoordinate(const KTextEditor::Cursor& cursor) const = 0;
392 
404  virtual QPoint cursorPositionCoordinates () const = 0;
405 
406  /*
407  * SIGNALS
408  * following signals should be emitted by the editor view
409  * if the cursor position changes
410  */
411  Q_SIGNALS:
419  void cursorPositionChanged (KTextEditor::View *view,
420  const KTextEditor::Cursor& newPosition);
421 
427  void verticalScrollPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor& newPos);
428 
433  void horizontalScrollPositionChanged (KTextEditor::View *view);
434  /*
435  * Mouse position
436  */
437  public:
446  virtual bool mouseTrackingEnabled() const = 0;
447 
463  virtual bool setMouseTrackingEnabled(bool enable) = 0;
464 
465  Q_SIGNALS:
477  void mousePositionChanged (KTextEditor::View *view,
478  const KTextEditor::Cursor& newPosition);
479 
480  /*
481  * Selection methodes.
482  * This deals with text selection and copy&paste
483  */
484  public:
493  virtual bool setSelection ( const Range &range ) = 0;
494 
510  virtual bool setSelection ( const Cursor &position,
511  int length,
512  bool wrap = true );
513 
520  virtual bool selection() const = 0;
521 
527  virtual const Range &selectionRange() const = 0;
528 
534  virtual QString selectionText () const = 0;
535 
542  virtual bool removeSelection () = 0;
543 
549  virtual bool removeSelectionText () = 0;
550 
551  /*
552  * Blockselection stuff
553  */
554  public:
561  virtual bool setBlockSelection (bool on) = 0;
562 
571  virtual bool blockSelection () const = 0;
572 
573  /*
574  * SIGNALS
575  * following signals should be emitted by the editor view for selection
576  * handling.
577  */
578  Q_SIGNALS:
586  void selectionChanged (KTextEditor::View *view);
587 
588  public:
597  virtual bool insertText (const QString &text);
598 
599  private:
600  class ViewPrivate* const d;
601 };
602 
639 class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface
640 {
641  public:
643  virtual ~CoordinatesToCursorInterface();
644 
656  virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0;
657 };
658 
659 }
660 
661 Q_DECLARE_INTERFACE(KTextEditor::CoordinatesToCursorInterface, "org.kde.KTextEditor.CoordinatesToCursorInterface")
662 
663 #endif
664 
665 // kate: space-indent on; indent-width 2; replace-tabs on;
QWidget
KXMLGUIClient
KTextEditor::CoordinatesToCursorInterface
Pixel coordinate to Cursor extension interface for the View.
Definition: view.h:639
QPoint
KTextEditor::Cursor
An object which represents a position in a Document.
Definition: cursor.h:55
range.h
ktexteditor_export.h
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:111
KTEXTEDITOR_EXPORT
#define KTEXTEDITOR_EXPORT
Definition: ktexteditor_export.h:35
QString
KTextEditor::Range
An object representing a section of text, from one Cursor to another.
Definition: range.h:54
QMenu
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:145
KTextEditor::View::EditMode
EditMode
Possible edit modes.
Definition: view.h:205
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal