lib

formulaelement.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 FORMULAELEMENT_H
22#define FORMULAELEMENT_H
23
24// Formula include
25#include "sequenceelement.h"
26
27KFORMULA_NAMESPACE_BEGIN
28
29class BasicElement;
30class ContextStyle;
31class FormulaDocument;
32class SymbolTable;
33
34
40class FormulaElement : public SequenceElement {
41 typedef SequenceElement inherited;
42public:
43
49
50 virtual FormulaElement* clone() { return 0; }
51
55 BasicElement* goToPos( FormulaCursor*, const LuPixelPoint& point );
56
60 virtual bool readOnly( const BasicElement* /*child*/ ) const { return false; }
61
65 virtual bool readOnly( const FormulaCursor* ) const { return false; }
66
70 virtual FormulaElement* formula() { return this; }
71
75 virtual const FormulaElement* formula() const { return this; }
76
81 void elementRemoval(BasicElement* child);
82
87 virtual void changed();
88
95
96 void moveOutLeft( FormulaCursor* );
97 void moveOutRight( FormulaCursor* );
98 void moveOutBelow( FormulaCursor* );
99 void moveOutAbove( FormulaCursor* );
100
104 void tell( const TQString& msg );
105
111
112 void insertFormula( FormulaCursor* );
113
118 virtual void calcSizes( const ContextStyle& context,
120 ContextStyle::IndexStyle istyle,
121 StyleAttributes& style );
122
128 virtual void draw( TQPainter& painter, const LuPixelRect& r,
129 const ContextStyle& context,
131 ContextStyle::IndexStyle istyle,
132 StyleAttributes& style,
133 const LuPixelPoint& parentOrigin );
134
138 void calcSizes( ContextStyle& context );
139
143 void draw( TQPainter& painter, const LuPixelRect& r, ContextStyle& context );
144
153 virtual KCommand* buildCommand( Container*, Request* );
154
158 const SymbolTable& getSymbolTable() const;
159
164 virtual TQString toLatex();
165
166 int getBaseSize() const { return baseSize; }
167 void setBaseSize( int size );
168
169 bool hasOwnBaseSize() const { return ownBaseSize; }
170
171 virtual KCommand* input( Container* container, TQKeyEvent* event );
172
173 virtual void writeMathML( TQDomDocument& doc, TQDomNode& parent, bool oasisFormat = false ) const ;
174
178 virtual void writeDom(TQDomElement element);
179
183 TQDomElement emptyFormulaElement( TQDomDocument& doc );
184
185protected:
186
187 //Save/load support
188
192 virtual TQString getTagName() const { return "FORMULA"; }
193
198 virtual bool readAttributesFromDom(TQDomElement element);
199
205 virtual bool readContentFromDom(TQDomNode& node);
206
207
208private:
209
214 void convertNames( TQDomNode node );
215
219 FormulaDocument* document;
220
224 int baseSize;
225
229 bool ownBaseSize;
230};
231
232KFORMULA_NAMESPACE_END
233
234#endif // FORMULAELEMENT_H
Basis of every formula element.
The document.
Contains all the style information for the formela.
TextStyle
Textstyles like in TeX.
The selection.
The interface the elements expect from its document.
virtual void calcSizes(const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)
Calculates our width and height and our children's parentPosition.
BasicElement * goToPos(FormulaCursor *, const LuPixelPoint &point)
Returns the element the point is in.
virtual bool readOnly(const FormulaCursor *) const
void elementRemoval(BasicElement *child)
Gets called just before the child is removed from the element tree.
virtual KCommand * buildCommand(Container *, Request *)
This is called by the container to get a command depending on the current cursor position (this is ho...
void tell(const TQString &msg)
Tell the user something has happened.
void cursorHasMoved(FormulaCursor *)
Gets called when a request has the side effect of moving the cursor.
FormulaElement(FormulaDocument *container)
The container this FormulaElement belongs to must not be 0, except you really know what you are doing...
virtual TQString toLatex()
virtual void changed()
Gets called whenever something changes and we need to recalc.
virtual bool readContentFromDom(TQDomNode &node)
Reads our content from the node.
virtual const FormulaElement * formula() const
Provide fast access to the rootElement for each child.
void draw(TQPainter &painter, const LuPixelRect &r, ContextStyle &context)
Draws the whole thing.
const SymbolTable & getSymbolTable() const
virtual bool readAttributesFromDom(TQDomElement element)
Reads our attributes from the element.
virtual void writeDom(TQDomElement element)
Appends our attributes to the dom element.
virtual void writeMathML(TQDomDocument &doc, TQDomNode &parent, bool oasisFormat=false) const
Same as above, just MathML.
virtual KCommand * input(Container *container, TQKeyEvent *event)
Parses the input.
TQDomElement emptyFormulaElement(TQDomDocument &doc)
For copy&paste we need to create an empty XML element.
virtual bool readOnly(const BasicElement *) const
Ordinary formulas are not write protected.
void removeFormula(FormulaCursor *)
Gets called when the formula wants to vanish.
virtual TQString getTagName() const
Returns the tag name of this element type.
virtual FormulaElement * formula()
Provide fast access to the rootElement for each child.
The symbol table.
Definition symboltable.h:77