lib Library API Documentation

kformulacontainer.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                   Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
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 //#include <kocommandhistory.h>
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     // not allowed
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* /*child*/) {}
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& /*msg*/ ) {}
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     // no copying
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 /*x*/, double /*y*/ ) {}
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     // There are a lot of thing we can do with the formula.
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     // debug
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 // KFORMULACONTAINER_H
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 13:19:21 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003