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

KTextEditor

  • sources
  • kde-4.12
  • kdelibs
  • interfaces
  • 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 
504  virtual bool setSelection ( const Cursor &position,
505  int length,
506  bool wrap = true );
507 
514  virtual bool selection() const = 0;
515 
521  virtual const Range &selectionRange() const = 0;
522 
528  virtual QString selectionText () const = 0;
529 
536  virtual bool removeSelection () = 0;
537 
543  virtual bool removeSelectionText () = 0;
544 
545  /*
546  * Blockselection stuff
547  */
548  public:
555  virtual bool setBlockSelection (bool on) = 0;
556 
565  virtual bool blockSelection () const = 0;
566 
567  /*
568  * SIGNALS
569  * following signals should be emitted by the editor view for selection
570  * handling.
571  */
572  Q_SIGNALS:
580  void selectionChanged (KTextEditor::View *view);
581 
582  public:
591  virtual bool insertText (const QString &text);
592 
593  private:
594  class ViewPrivate* const d;
595 };
596 
633 class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface
634 {
635  public:
637  virtual ~CoordinatesToCursorInterface();
638 
650  virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0;
651 };
652 
653 }
654 
655 Q_DECLARE_INTERFACE(KTextEditor::CoordinatesToCursorInterface, "org.kde.KTextEditor.CoordinatesToCursorInterface")
656 
657 #endif
658 
659 // 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:633
QString
KTextEditor::Cursor
An object which represents a position in a Document.
Definition: cursor.h:61
range.h
ktexteditor_export.h
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:111
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:52:20 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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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