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

KTextEditor

  • sources
  • kde-4.12
  • 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 
397  virtual QPoint cursorPositionCoordinates () const = 0;
398 
399  /*
400  * SIGNALS
401  * following signals should be emitted by the editor view
402  * if the cursor position changes
403  */
404  Q_SIGNALS:
412  void cursorPositionChanged (KTextEditor::View *view,
413  const KTextEditor::Cursor& newPosition);
414 
420  void verticalScrollPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor& newPos);
421 
426  void horizontalScrollPositionChanged (KTextEditor::View *view);
427  /*
428  * Mouse position
429  */
430  public:
439  virtual bool mouseTrackingEnabled() const = 0;
440 
456  virtual bool setMouseTrackingEnabled(bool enable) = 0;
457 
458  Q_SIGNALS:
470  void mousePositionChanged (KTextEditor::View *view,
471  const KTextEditor::Cursor& newPosition);
472 
473  /*
474  * Selection methodes.
475  * This deals with text selection and copy&paste
476  */
477  public:
486  virtual bool setSelection ( const Range &range ) = 0;
487 
503  virtual bool setSelection ( const Cursor &position,
504  int length,
505  bool wrap = true );
506 
513  virtual bool selection() const = 0;
514 
520  virtual const Range &selectionRange() const = 0;
521 
527  virtual QString selectionText () const = 0;
528 
535  virtual bool removeSelection () = 0;
536 
542  virtual bool removeSelectionText () = 0;
543 
544  /*
545  * Blockselection stuff
546  */
547  public:
554  virtual bool setBlockSelection (bool on) = 0;
555 
564  virtual bool blockSelection () const = 0;
565 
566  /*
567  * SIGNALS
568  * following signals should be emitted by the editor view for selection
569  * handling.
570  */
571  Q_SIGNALS:
579  void selectionChanged (KTextEditor::View *view);
580 
581  public:
590  virtual bool insertText (const QString &text);
591 
592  private:
593  class ViewPrivate* const d;
594 };
595 
632 class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface
633 {
634  public:
636  virtual ~CoordinatesToCursorInterface();
637 
649  virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0;
650 };
651 
652 }
653 
654 Q_DECLARE_INTERFACE(KTextEditor::CoordinatesToCursorInterface, "org.kde.KTextEditor.CoordinatesToCursorInterface")
655 
656 #endif
657 
658 // kate: space-indent on; indent-width 2; replace-tabs on;
KXMLGUIClient
QWidget
KTextEditor::CoordinatesToCursorInterface
Pixel coordinate to Cursor extension interface for the View.
Definition: view.h:632
QString
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
KTextEditor::Range
An object representing a section of text, from one Cursor to another.
Definition: range.h:54
QMenu
kxmlguiclient.h
QPoint
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:41 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
  • Applications
  •   Libraries
  •     libkonq
  • 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