00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org> 00003 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de> 00004 2006 Martin Pfeiffer <hubipete@gmx.net> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef FORMULACURSOR_H 00023 #define FORMULACURSOR_H 00024 00025 #include <QString> 00026 #include <QStack> 00027 00028 class QPainter; 00029 00030 namespace KFormula { 00031 00032 class BasicElement; 00033 00046 class FormulaCursor { 00047 public: 00052 explicit FormulaCursor( BasicElement* element ); 00053 00055 BasicElement* currentElement() const; 00056 00058 int position() const; 00059 00064 void paint( QPainter &painter ) const; 00065 00071 void setCursorTo( BasicElement* current, int position ); 00072 00074 void moveLeft(); 00075 00077 void moveRight(); 00078 00080 void moveUp(); 00081 00083 void moveDown(); 00084 00086 void moveHome(); 00087 00089 void moveEnd(); 00090 00092 bool isHome() const; 00093 00095 bool isEnd() const; 00096 00101 void setSelecting( bool selecting ); 00102 00104 bool hasSelection() const; 00105 00110 void setWordMovement( bool wordMovement ); 00111 00112 private: 00114 BasicElement* m_currentElement; 00115 00117 int m_positionInElement; 00118 00120 bool m_wordMovement; 00121 00123 bool m_selecting; 00124 00125 QStack<BasicElement*> m_selectedElements; 00126 }; 00127 00128 } // namespace KFormula 00129 00130 #endif // FORMULACURSOR_H