21#ifndef KFORMULACONTAINER_H
22#define KFORMULACONTAINER_H
24#include <tqclipboard.h>
29#include <tqptrstack.h>
34#include "KoCommandHistory.h"
35#include "kformuladefs.h"
44KFORMULA_NAMESPACE_BEGIN
62class FormulaDocument {
64 FormulaDocument(
const FormulaDocument& ) {}
65 FormulaDocument& operator=(
const FormulaDocument& ) {
return *
this; }
69 virtual ~FormulaDocument() {}
72 virtual void changed() {}
78 virtual void tell(
const TQString& ) {}
81 virtual void baseSizeChanged(
int,
bool ) {}
82 virtual const SymbolTable& getSymbolTable()
const = 0;
90class KOFORMULA_EXPORT Container :
public TQObject,
public FormulaDocument {
91 friend class MimeSource;
96 Container(
const Container& );
97 Container& operator= (
const Container& );
101 enum ViewActions { EXIT_LEFT, EXIT_RIGHT,
102 EXIT_ABOVE, EXIT_BELOW,
103 INSERT_FORMULA, REMOVE_FORMULA };
113 Container(
Document* doc,
int pos,
bool registerMe=
true );
157 void tell(
const TQString& msg );
164 void unregisterFormula();
174 void draw( TQPainter& painter,
const TQRect& r,
175 const TQColorGroup& cg,
bool edit=
false );
180 void draw( TQPainter& painter,
const TQRect& r,
bool edit=
false );
185 void save( TQDomElement &root );
190 void saveMathML( TQTextStream& stream,
bool oasisFormat =
false );
196 bool loadMathML(
const TQDomDocument &doc,
bool oasisFormat =
false );
202 bool loadMathML(
const TQDomElement &doc,
bool oasisFormat =
false );
207 bool load(
const TQDomElement &fe );
214 TQString formulaString();
219 void print(KPrinter& printer);
224 TQImage
drawImage(
int width,
int height );
250 double width()
const;
251 double height()
const;
263 void moveTo(
int x,
int y );
272 virtual double getDocumentY()
const {
return -1; }
273 virtual void setDocumentPosition(
double ,
double ) {}
292 virtual void recalc();
306 int fontSize()
const;
311 void setFontSize(
int pointSize,
bool forPrint =
false );
313 void setFontSizeDirect(
int pointSize );
318 void updateMatrixActions();
369 void input( TQKeyEvent* event );
371 void performRequest( Request* request );
409 void emitErrorMsg(
const TQString& );
426 bool hasValidCursor()
const;
428 struct Container_Impl;
429 Container_Impl* impl;
432 friend class TestFormulaCursor;
433 friend class TestFormulaElement;
434 friend class TestIndexElement;
435 friend class TestCommands;
438KFORMULA_NAMESPACE_END
Basis of every formula element.
bool loadMathML(const TQDomDocument &doc, bool oasisFormat=false)
Load function.
FormulaElement * rootElement() const
void registerFormula(int pos=-1)
Register and unregister this formula with its document.
void leaveFormula(Container *formula, FormulaCursor *cursor, int cmd)
The cursor wants to leave this formula.
void copy()
Copy the current selection to the clipboard.
FormulaCursor * createCursor()
Returns a new cursor.
void paste()
Insert data from the clipboard.
void initialize()
Needs to be called before anything else can be done with a newly created formula!
void cursorMoved(FormulaCursor *cursor)
The cursor has been moved but the formula hasn't been changed.
void errorMsg(const TQString &)
A message that describes an error.
void baseSizeChanged(int size, bool owned)
The base size changed.
void cursorHasMoved(FormulaCursor *)
Gets called when a request has the side effect of moving the cursor.
virtual double getDocumentX() const
KWord uses a transformed painter to draw formulas, so every formula has the internal position (0,...
void formulaChanged(int width, int height)
The formula has changed and needs to be redrawn.
void baseSizeChanged(int)
We've got a new base size.
virtual Document * document() const
TQImage drawImage(int width, int height)
virtual void startEvaluation()
Start the documents evaluation at this formula.
bool load(const TQDomElement &fe)
Loads a formula from the document.
virtual FormulaElement * createMainSequence()
Factory method.
void setActiveCursor(FormulaCursor *cursor)
Sets the cursor that is to be used for any editing.
void save(TQDomElement &root)
Saves the data into the document.
void moveOutLeft(FormulaCursor *)
Inside the formula occurred an event that must be handled outside.
void cut()
Copy and remove.
void print(KPrinter &printer)
Prints the formula.
void statusMsg(const TQString &msg)
A message that might be a useful hint.
void changed()
Gets called when ever something changes and we need to recalc.
void input(TQKeyEvent *event)
General input.
void formulaLoaded(FormulaElement *)
Tells the cursors that we have just loaded a new formula.
void elementWillVanish(BasicElement *element)
The element is going to leave the formula with and all its children.
FormulaCursor * activeCursor()
void draw(TQPainter &painter, const TQRect &r, const TQColorGroup &cg, bool edit=false)
Draws the whole thing.
void moveTo(int x, int y)
Moves the formula to a new location.
void elementRemoval(BasicElement *child)
Gets called just before the child is removed from the element tree.
TQRect boundingRect() const
void saveMathML(TQTextStream &stream, bool oasisFormat=false)
Save formula as MathML.
A document that can contain a lot of formulas (container).
The element with up to four indexes in the four corners.
The command history stores a (user) configurable amount of Commands.
Base for all kformula commands.