kformulacontainer.h
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 KOFORMULA_EXPORT 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, bool oasisFormat = false );
00190
00195 bool loadMathML( const QDomDocument &doc, bool oasisFormat = false );
00196
00200 bool load( const 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
00311 void updateMatrixActions();
00312
00313 signals:
00314
00319 void cursorMoved(FormulaCursor* cursor);
00320
00324 void leaveFormula( Container* formula, FormulaCursor* cursor, int cmd );
00325
00329 void formulaChanged( int width, int height );
00330 void formulaChanged( double width, double height );
00331
00335 void statusMsg( const QString& msg );
00336
00340 void errorMsg( const QString& );
00341
00345 void elementWillVanish(BasicElement* element);
00346
00350 void formulaLoaded(FormulaElement*);
00351
00355 void baseSizeChanged( int );
00356
00357 public:
00358
00362 void input( QKeyEvent* event );
00363
00364 void performRequest( Request* request );
00365
00366
00367
00371 void paste();
00372
00376 void paste( const QDomDocument& document, QString desc );
00377
00381 void copy();
00382
00386 void cut();
00387
00388 protected:
00389
00390 KoCommandHistory* getHistory() const;
00391
00395 FormulaElement* rootElement() const;
00396
00400 virtual FormulaElement* createMainSequence();
00401
00402 void emitErrorMsg( const QString& );
00403
00404 private:
00405
00409 void execute(KCommand *command);
00410
00414 void checkCursor();
00415
00419 bool hasValidCursor() const;
00420
00421 struct Container_Impl;
00422 Container_Impl* impl;
00423
00424
00425 friend class TestFormulaCursor;
00426 friend class TestFormulaElement;
00427 friend class TestIndexElement;
00428 friend class TestCommands;
00429 };
00430
00431 KFORMULA_NAMESPACE_END
00432
00433 #endif // KFORMULACONTAINER_H
This file is part of the documentation for lib Library Version 1.4.2.