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

KTextEditor

  • 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
32class QMenu;
33
34namespace KTextEditor
35{
36
37class 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.
145class 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
633class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface
634{
635 public:
637 virtual ~CoordinatesToCursorInterface();
638
650 virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0;
651};
652
653}
654
655Q_DECLARE_INTERFACE(KTextEditor::CoordinatesToCursorInterface, "org.kde.KTextEditor.CoordinatesToCursorInterface")
656
657#endif
658
659// kate: space-indent on; indent-width 2; replace-tabs on;
KTextEditor::CoordinatesToCursorInterface
Pixel coordinate to Cursor extension interface for the View.
Definition: view.h:634
KTextEditor::CoordinatesToCursorInterface::coordinatesToCursor
virtual KTextEditor::Cursor coordinatesToCursor(const QPoint &coord) const =0
Get the text-cursor in the document from the screen coordinates, relative to the view widget.
KTextEditor::Cursor
An object which represents a position in a Document.
Definition: cursor.h:62
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:112
KTextEditor::Range
An object representing a section of text, from one Cursor to another.
Definition: range.h:55
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
KTextEditor::View::horizontalScrollPositionChanged
void horizontalScrollPositionChanged(KTextEditor::View *view)
This signal should be emitted whenever the view is scrolled horizontally.
KTextEditor::View::setCursorPosition
virtual bool setCursorPosition(Cursor position)=0
Set the view's new cursor to position.
KTextEditor::View::viewEditMode
virtual enum EditMode viewEditMode() const =0
Get the view's current edit mode.
KTextEditor::View::EditMode
EditMode
Possible edit modes.
Definition: view.h:205
KTextEditor::View::setMouseTrackingEnabled
virtual bool setMouseTrackingEnabled(bool enable)=0
Try to enable or disable mouse tracking according to enable.
KTextEditor::View::document
virtual Document * document() const =0
Get the view's document, that means the view is a view of the returned document.
KTextEditor::View::removeSelectionText
virtual bool removeSelectionText()=0
Remove the view's current selection including the selected text.
KTextEditor::View::blockSelection
virtual bool blockSelection() const =0
Get the status of the selection mode.
KTextEditor::View::textInserted
void textInserted(KTextEditor::View *view, const KTextEditor::Cursor &position, const QString &text)
This signal is emitted from view whenever the users inserts text at position, that means the user typ...
KTextEditor::View::cursorPositionCoordinates
virtual QPoint cursorPositionCoordinates() const =0
Get the screen coordinates (x/y) of the cursor position in pixels.
KTextEditor::View::cursorToCoordinate
virtual QPoint cursorToCoordinate(const KTextEditor::Cursor &cursor) const =0
Get the screen coordinates (x, y) of the supplied cursor relative to the view widget in pixels.
KTextEditor::View::focusOut
void focusOut(KTextEditor::View *view)
This signal is emitted whenever the view loses the focus.
KTextEditor::View::cursorPosition
virtual Cursor cursorPosition() const =0
Get the view's current cursor position.
KTextEditor::View::informationMessage
void informationMessage(KTextEditor::View *view, const QString &message)
This signal is emitted whenever the view wants to display a information message.
KTextEditor::View::focusIn
void focusIn(KTextEditor::View *view)
This signal is emitted whenever the view gets the focus.
KTextEditor::View::verticalScrollPositionChanged
void verticalScrollPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &newPos)
This signal should be emitted whenever the view is scrolled vertically.
KTextEditor::View::contextMenu
virtual QMenu * contextMenu() const =0
Get the context menu for this view.
KTextEditor::View::selectionRange
virtual const Range & selectionRange() const =0
Get the range occupied by the current selection.
KTextEditor::View::mouseTrackingEnabled
virtual bool mouseTrackingEnabled() const =0
Check, whether mouse tracking is enabled.
KTextEditor::View::setContextMenu
virtual void setContextMenu(QMenu *menu)=0
Set a context menu for this view to menu.
KTextEditor::View::selection
virtual bool selection() const =0
Query the view whether it has selected text, i.e.
KTextEditor::View::cursorPositionVirtual
virtual Cursor cursorPositionVirtual() const =0
Get the current virtual cursor position, virtual means the tabulator character (TAB) counts multiple ...
KTextEditor::View::viewModeChanged
void viewModeChanged(KTextEditor::View *view)
This signal is emitted whenever the view mode of view changes.
KTextEditor::View::setSelection
virtual bool setSelection(const Range &range)=0
Set the view's selection to the range selection.
KTextEditor::View::selectionChanged
void selectionChanged(KTextEditor::View *view)
This signal is emitted whenever the view's selection changes.
KTextEditor::View::mousePositionChanged
void mousePositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &newPosition)
This signal is emitted whenever the position of the mouse changes over this view.
KTextEditor::View::setBlockSelection
virtual bool setBlockSelection(bool on)=0
Set block selection mode to state on.
KTextEditor::View::viewEditModeChanged
void viewEditModeChanged(KTextEditor::View *view, enum KTextEditor::View::EditMode mode)
This signal is emitted whenever the view's edit mode changed from either EditInsert to EditOverwrite ...
KTextEditor::View::viewMode
virtual QString viewMode() const =0
Get the current view mode/state.
KTextEditor::View::contextMenuAboutToShow
void contextMenuAboutToShow(KTextEditor::View *view, QMenu *menu)
Signal which is emitted immediately prior to showing the current context menu.
KTextEditor::View::removeSelection
virtual bool removeSelection()=0
Remove the view's current selection, without deleting the selected text.
KTextEditor::View::selectionText
virtual QString selectionText() const =0
Get the view's selected text.
KTextEditor::View::defaultContextMenu
virtual QMenu * defaultContextMenu(QMenu *menu=0L) const =0
Populate menu with default text editor actions.
KTextEditor::View::cursorPositionChanged
void cursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &newPosition)
This signal is emitted whenever the view's cursor position changed.
KXMLGUIClient
QMenu
QWidget
ktexteditor_export.h
kxmlguiclient.h
KTextEditor
Namespace for the KDE Text Editor Interfaces.
Definition: annotationinterface.h:31
range.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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