00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef KFORMULACONTAINER_H
00022
#define KFORMULACONTAINER_H
00023
00024
#include <qclipboard.h>
00025
#include <qdom.h>
00026
#include <qimage.h>
00027
#include <qptrlist.h>
00028
#include <qobject.h>
00029
#include <qptrstack.h>
00030
#include <qstring.h>
00031
00032
#include <kcommand.h>
00033
00034
#include "kocommandhistory.h"
00035
#include "kformuladefs.h"
00036
00037
class QColorGroup;
00038
class QKeyEvent;
00039
class QPainter;
00040
00041
class KCommand;
00042
class KPrinter;
00043
00044 KFORMULA_NAMESPACE_BEGIN
00045
00046
class BasicElement;
00047
class Document;
00048
class FormulaCursor;
00049
class FormulaElement;
00050
class IndexElement;
00051
class PlainCommand;
00052
class SymbolTable;
00053
00054
00062 class FormulaDocument {
00063
00064
FormulaDocument(
const FormulaDocument& ) {}
00065 FormulaDocument& operator=(
const FormulaDocument& ) {
return *
this; }
00066
public:
00067
00068 FormulaDocument() {}
00069
virtual ~FormulaDocument() {}
00070
00071
virtual void elementRemoval(
BasicElement* ) {}
00072
virtual void changed() {}
00073
virtual void cursorHasMoved(
FormulaCursor* ) {}
00074
virtual void moveOutLeft(
FormulaCursor* ) {}
00075
virtual void moveOutRight(
FormulaCursor* ) {}
00076
virtual void moveOutAbove(
FormulaCursor* ) {}
00077
virtual void moveOutBelow(
FormulaCursor* ) {}
00078
virtual void tell(
const QString& ) {}
00079
virtual void insertFormula(
FormulaCursor* ) {}
00080
virtual void removeFormula(
FormulaCursor* ) {}
00081
virtual void baseSizeChanged(
int,
bool ) {}
00082
virtual const SymbolTable& getSymbolTable()
const = 0;
00083 };
00084
00085
00090 class Container :
public QObject,
public FormulaDocument {
00091
friend class MimeSource;
00092 Q_OBJECT
00093
00094
00095
Container(
const Container& );
00096 Container& operator= (
const Container& );
00097
00098
public:
00099
00100
enum ViewActions { EXIT_LEFT, EXIT_RIGHT,
00101 EXIT_ABOVE, EXIT_BELOW,
00102 INSERT_FORMULA, REMOVE_FORMULA };
00103
00112 Container(
Document* doc,
int pos,
bool registerMe=
true );
00113 ~Container();
00114
00120
void initialize();
00121
00127
FormulaCursor*
createCursor();
00128
00133
void elementRemoval(
BasicElement* child);
00134
00139
void changed();
00140
00146
void cursorHasMoved(
FormulaCursor* );
00147
00152
void moveOutLeft(
FormulaCursor* );
00153
void moveOutRight(
FormulaCursor* );
00154
void moveOutAbove(
FormulaCursor* );
00155
void moveOutBelow(
FormulaCursor* );
00156
void tell(
const QString& msg );
00157
void removeFormula(
FormulaCursor* );
00158
00162
void registerFormula(
int pos=-1 );
00163
void unregisterFormula();
00164
00168
void baseSizeChanged(
int size,
bool owned );
00169
00173
void draw(
QPainter& painter,
const QRect& r,
00174
const QColorGroup& cg,
bool edit=
false );
00175
00179
void draw(
QPainter& painter,
const QRect& r,
bool edit=
false );
00180
00184
void save(
QDomElement root );
00185
00189
void saveMathML(
QTextStream& stream );
00190
00195
bool loadMathML(
QDomDocument doc );
00196
00200
bool load(
QDomElement fe );
00201
00205
QString texString();
00206
00207
QString formulaString();
00208
00212
void print(KPrinter& printer);
00213
00217
QImage drawImage(
int width,
int height );
00218
00222
FormulaCursor*
activeCursor();
00223
const FormulaCursor*
activeCursor()
const;
00224
00231
void setActiveCursor(
FormulaCursor* cursor);
00232
00236
QRect boundingRect()
const;
00237
00241
QRect coveredRect();
00242
00243
double width()
const;
00244
double height()
const;
00245
00250
double baseline()
const;
00251
00256
void moveTo(
int x,
int y );
00257
00264 virtual double getDocumentX()
const {
return -1; }
00265
virtual double getDocumentY()
const {
return -1; }
00266
virtual void setDocumentPosition(
double ,
double ) {}
00267
00275 virtual void startEvaluation() {}
00276
00280
void testDirty();
00281
00285
virtual void recalc();
00286
00290
bool isEmpty();
00291
00295
virtual Document*
document() const;
00296
00297 virtual const
SymbolTable& getSymbolTable() const;
00298
00299
int fontSize() const;
00300
00304
void setFontSize(
int pointSize,
bool forPrint = false );
00305
00306
void setFontSizeDirect(
int pointSize );
00307
00308 signals:
00309
00314
void cursorMoved(
FormulaCursor* cursor);
00315
00319
void leaveFormula( Container* formula,
FormulaCursor* cursor,
int cmd );
00320
00324
void formulaChanged(
int width,
int height );
00325
void formulaChanged(
double width,
double height );
00326
00330
void statusMsg( const
QString& msg );
00331
00335
void errorMsg( const
QString& );
00336
00340
void elementWillVanish(
BasicElement* element);
00341
00345
void formulaLoaded(
FormulaElement*);
00346
00350
void baseSizeChanged(
int );
00351
00352 public:
00353
00357
void input(
QKeyEvent* event );
00358
00359
void performRequest( Request* request );
00360
00361
00362
00366
void paste();
00367
00371
void paste(
QDomDocument document, QString desc );
00372
00376
void copy();
00377
00381
void cut();
00382
00383 protected:
00384
00385
KoCommandHistory* getHistory() const;
00386
00390 FormulaElement* rootElement() const;
00391
00395 virtual FormulaElement* createMainSequence();
00396
00397
void emitErrorMsg( const QString& );
00398
00399 private:
00400
00404
void execute(KCommand *command);
00405
00409
void checkCursor();
00410
00414
bool hasValidCursor() const;
00415
00416 struct Container_Impl;
00417 Container_Impl* impl;
00418
00419
00420 friend class TestFormulaCursor;
00421 friend class TestFormulaElement;
00422 friend class TestIndexElement;
00423 friend class TestCommands;
00424 };
00425
00426 KFORMULA_NAMESPACE_END
00427
00428 #endif