KTextEditor
view.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KDELIBS_KTEXTEDITOR_VIEW_H 00021 #define KDELIBS_KTEXTEDITOR_VIEW_H 00022 00023 #include <ktexteditor/ktexteditor_export.h> 00024 #include <ktexteditor/range.h> 00025 00026 // gui merging 00027 #include <kxmlguiclient.h> 00028 00029 // widget 00030 #include <QtGui/QWidget> 00031 00032 class QMenu; 00033 00034 namespace KTextEditor 00035 { 00036 00037 class Document; 00038 00141 class KTEXTEDITOR_EXPORT View : public QWidget, public KXMLGUIClient 00142 { 00143 Q_OBJECT 00144 00145 public: 00153 View ( QWidget *parent ); 00154 00158 virtual ~View (); 00159 00160 /* 00161 * Accessor for the document 00162 */ 00163 public: 00169 virtual Document *document () const = 0; 00170 00178 bool isActiveView() const; 00179 00180 /* 00181 * General information about this view 00182 */ 00183 public: 00194 virtual QString viewMode () const = 0; 00195 00200 enum EditMode { 00201 EditInsert = 0, 00202 EditOverwrite = 1 00203 }; 00204 00214 virtual enum EditMode viewEditMode() const = 0; 00215 00216 /* 00217 * SIGNALS 00218 * following signals should be emitted by the editor view 00219 */ 00220 Q_SIGNALS: 00226 void focusIn ( KTextEditor::View *view ); 00227 00233 void focusOut ( KTextEditor::View *view ); 00234 00240 void viewModeChanged ( KTextEditor::View *view ); 00241 00249 void viewEditModeChanged ( KTextEditor::View *view, 00250 enum KTextEditor::View::EditMode mode ); 00251 00259 void informationMessage ( KTextEditor::View *view, const QString &message ); 00260 00269 void textInserted ( KTextEditor::View *view, 00270 const KTextEditor::Cursor &position, 00271 const QString &text ); 00272 00273 /* 00274 * Context menu handling 00275 */ 00276 public: 00290 virtual void setContextMenu ( QMenu *menu ) = 0; 00291 00300 virtual QMenu *contextMenu () const = 0; 00301 00335 virtual QMenu* defaultContextMenu(QMenu* menu = 0L) const = 0; 00336 00337 Q_SIGNALS: 00342 void contextMenuAboutToShow(KTextEditor::View* view, QMenu* menu); 00343 00344 /* 00345 * Cursor handling 00346 */ 00347 public: 00355 virtual bool setCursorPosition (Cursor position) = 0; 00356 00363 virtual Cursor cursorPosition () const = 0; 00364 00375 virtual Cursor cursorPositionVirtual () const = 0; 00376 00385 virtual QPoint cursorToCoordinate(const KTextEditor::Cursor& cursor) const = 0; 00386 00391 virtual QPoint cursorPositionCoordinates () const = 0; 00392 00393 /* 00394 * SIGNALS 00395 * following signals should be emitted by the editor view 00396 * if the cursor position changes 00397 */ 00398 Q_SIGNALS: 00406 void cursorPositionChanged (KTextEditor::View *view, 00407 const KTextEditor::Cursor& newPosition); 00408 00414 void verticalScrollPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor& newPos); 00415 00420 void horizontalScrollPositionChanged (KTextEditor::View *view); 00421 /* 00422 * Mouse position 00423 */ 00424 public: 00433 virtual bool mouseTrackingEnabled() const = 0; 00434 00450 virtual bool setMouseTrackingEnabled(bool enable) = 0; 00451 00452 Q_SIGNALS: 00464 void mousePositionChanged (KTextEditor::View *view, 00465 const KTextEditor::Cursor& newPosition); 00466 00467 /* 00468 * Selection methodes. 00469 * This deals with text selection and copy&paste 00470 */ 00471 public: 00480 virtual bool setSelection ( const Range &range ) = 0; 00481 00498 virtual bool setSelection ( const Cursor &position, 00499 int length, 00500 bool wrap = true ); 00501 00508 virtual bool selection() const = 0; 00509 00515 virtual const Range &selectionRange() const = 0; 00516 00522 virtual QString selectionText () const = 0; 00523 00530 virtual bool removeSelection () = 0; 00531 00537 virtual bool removeSelectionText () = 0; 00538 00539 /* 00540 * Blockselection stuff 00541 */ 00542 public: 00549 virtual bool setBlockSelection (bool on) = 0; 00550 00559 virtual bool blockSelection () const = 0; 00560 00561 /* 00562 * SIGNALS 00563 * following signals should be emitted by the editor view for selection 00564 * handling. 00565 */ 00566 Q_SIGNALS: 00574 void selectionChanged (KTextEditor::View *view); 00575 00576 public: 00585 virtual bool insertText (const QString &text); 00586 00587 private: 00588 class ViewPrivate* const d; 00589 }; 00590 00625 class KTEXTEDITOR_EXPORT CoordinatesToCursorInterface 00626 { 00627 public: 00629 virtual ~CoordinatesToCursorInterface(); 00630 00642 virtual KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const = 0; 00643 }; 00644 00645 } 00646 00647 Q_DECLARE_INTERFACE(KTextEditor::CoordinatesToCursorInterface, "org.kde.KTextEditor.CoordinatesToCursorInterface") 00648 00649 #endif 00650 00651 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference