kformulaview.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
3 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
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 as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KFORMULAVIEW_H
22#define KFORMULAVIEW_H
23
24#include <tqevent.h>
25#include <tqobject.h>
26#include <tqrect.h>
27
28#include "kformuladefs.h"
29#include "contextstyle.h"
30
31class TQColorGroup;
32
33KFORMULA_NAMESPACE_BEGIN
34
35class BasicElement;
36class FormulaCursor;
37class FormulaElement;
38class Container;
39
40
50class KOFORMULA_EXPORT View : public TQObject {
51 TQ_OBJECT
52
53
54public:
55
57 virtual ~View();
58
62 TQPoint getCursorPoint() const;
63
67 void setReadOnly(bool ro);
68
69 void mousePressEvent(TQMouseEvent* event);
70 void mouseReleaseEvent(TQMouseEvent* event);
71 void mouseDoubleClickEvent(TQMouseEvent* event);
72 void mouseMoveEvent(TQMouseEvent* event);
73 void wheelEvent(TQWheelEvent* event);
74
75 // the mouse event happened at a certain point
76 void mousePressEvent( TQMouseEvent* event, const PtPoint& pos );
77 void mouseReleaseEvent( TQMouseEvent* event, const PtPoint& pos );
78 void mouseDoubleClickEvent( TQMouseEvent* event, const PtPoint& pos );
79 void mouseMoveEvent( TQMouseEvent* event, const PtPoint& pos );
80 void wheelEvent( TQWheelEvent* event, const PtPoint& pos );
81
82 // the mouse event happened at a certain point
83 void mousePressEvent( TQMouseEvent* event, const LuPixelPoint& pos );
84 void mouseReleaseEvent( TQMouseEvent* event, const LuPixelPoint& pos );
85 void mouseDoubleClickEvent( TQMouseEvent* event, const LuPixelPoint& pos );
86 void mouseMoveEvent( TQMouseEvent* event, const LuPixelPoint& pos );
87 void wheelEvent( TQWheelEvent* event, const LuPixelPoint& pos );
88
89 void keyPressEvent(TQKeyEvent* event);
90 virtual void focusInEvent(TQFocusEvent* event);
91 virtual void focusOutEvent(TQFocusEvent* event);
92
93 void calcCursor();
94
95 void draw(TQPainter& painter, const TQRect& rect, const TQColorGroup& cg);
96 void draw(TQPainter& painter, const TQRect& rect);
97
101 virtual Container* getDocument() const { return container(); }
102
106 FormulaCursor* getCursor() const { return cursor(); }
107
108 void setSmallCursor(bool small);
109
110 // simple cursor movement.
111
112 void moveLeft( int flag = NormalMovement );
113 void moveRight( int flag = NormalMovement );
114 void moveUp( int flag = NormalMovement );
115 void moveDown( int flag = NormalMovement );
116
117 void moveHome( int flag = NormalMovement );
118 void moveEnd( int flag = NormalMovement );
119
121 bool isHome() const;
122
124 bool isEnd() const;
125
126 void eraseSelection( Direction direction = beforeCursor );
127 void addText( TQString str );
128
129signals:
130
134 void cursorChanged(bool visible, bool selecting);
135
136public slots:
137
138 void slotSelectAll();
139
140protected slots:
141
146 void slotCursorMoved(FormulaCursor* cursor);
147
151 void slotFormulaLoaded(FormulaElement*);
152
157 void slotElementWillVanish(BasicElement*);
158
162 void slotBlinkCursor();
163
164protected:
165
166 virtual bool cursorVisible();
167
168private:
169
173 void emitCursorChanged();
174
175 bool& cursorHasChanged();
176 bool& smallCursor();
177 bool& activeCursor();
178 Container* container() const;
179 void startCursorTimer();
180 void stopCursorTimer();
181 const ContextStyle& contextStyle() const;
182 FormulaCursor* cursor() const;
183
184 struct View_Impl;
185 View_Impl* impl;
186};
187
188KFORMULA_NAMESPACE_END
189
190#endif // KFORMULAVIEW_H
Basis of every formula element.
The document.
Contains all the style information for the formela.
The selection.
The main element.
A point whose coordinates are floating-point values ( "double"s ).
Definition KoPoint.h:30
The view that shows the formula.
void cursorChanged(bool visible, bool selecting)
Is emitted every time the cursor might have changed.
FormulaCursor * getCursor() const
Our cursor.
virtual Container * getDocument() const
The document we show.