lib Library API Documentation

matrixelement.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 MATRIXELEMENT_H
00022 #define MATRIXELEMENT_H
00023 
00024 #include <qptrlist.h>
00025 
00026 #include "basicelement.h"
00027 
00028 KFORMULA_NAMESPACE_BEGIN
00029 
00030 
00031 class MatrixSequenceElement;
00032 
00033 
00037 class MatrixElement : public BasicElement {
00038     friend class KFCRemoveColumn;
00039     friend class KFCRemoveRow;
00040     friend class MatrixSequenceElement;
00041 
00042     MatrixElement& operator=( const MatrixElement& ) { return *this; }
00043 public:
00044     MatrixElement(uint rows = 1, uint columns = 1, BasicElement* parent = 0);
00045     ~MatrixElement();
00046 
00047     MatrixElement( const MatrixElement& );
00048 
00049     virtual MatrixElement* clone() {
00050         return new MatrixElement( *this );
00051     }
00052 
00053     virtual bool accept( ElementVisitor* visitor );
00054 
00059     virtual void entered( SequenceElement* child );
00060 
00067     virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
00068                                    const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00069 
00070     // drawing
00071     //
00072     // Drawing depends on a context which knows the required properties like
00073     // fonts, spaces and such.
00074     // It is essential to calculate elements size with the same context
00075     // before you draw.
00076 
00081     virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00082 
00088     virtual void draw( QPainter& painter, const LuPixelRect& r,
00089                        const ContextStyle& context,
00090                        ContextStyle::TextStyle tstyle,
00091                        ContextStyle::IndexStyle istyle,
00092                        const LuPixelPoint& parentOrigin );
00093 
00097     virtual void dispatchFontCommand( FontCommand* cmd );
00098 
00099     // navigation
00100     //
00101     // The elements are responsible to handle cursor movement themselves.
00102     // To do this they need to know the direction the cursor moves and
00103     // the element it comes from.
00104     //
00105     // The cursor might be in normal or in selection mode.
00106 
00112     virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00113 
00119     virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00120 
00126     virtual void moveUp(FormulaCursor*, BasicElement*);
00127 
00133     virtual void moveDown(FormulaCursor*, BasicElement*);
00134 
00139     virtual void goInside(FormulaCursor* cursor);
00140 
00144     // If there is a main child we must provide the insert/remove semantics.
00145     virtual SequenceElement* getMainChild();
00146 
00151     //virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00152 
00157     //virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00158 
00163     //virtual void normalize(FormulaCursor*, Direction);
00164 
00169     virtual void selectChild(FormulaCursor*, BasicElement*);
00170 
00175     //virtual void childWillVanish(FormulaCursor* cursor, BasicElement* child) = 0;
00176 
00182     //virtual bool isSenseless();
00183 
00188     virtual QString toLatex();
00189 
00190     virtual QString formulaString();
00191 
00192     uint getRows() const { return content.count(); }
00193     uint getColumns() const { return content.getFirst()->count(); }
00194 
00195     SequenceElement* elementAt(uint row, uint column);
00196 
00197     virtual void writeMathML( QDomDocument doc, QDomNode parent );
00198 
00199 protected:
00200 
00201     //Save/load support
00202 
00206     virtual QString getTagName() const { return "MATRIX"; }
00207 
00211     virtual void writeDom(QDomElement element);
00212 
00217     virtual bool readAttributesFromDom(QDomElement element);
00218 
00224     virtual bool readContentFromDom(QDomNode& node);
00225 
00226 private:
00227 
00228     MatrixSequenceElement* getElement(uint row, uint column)
00229         { return content.at(row)->at(column); }
00230 
00236     bool searchElement(BasicElement* element, uint& row, uint& column);
00237 
00241     QPtrList< QPtrList< MatrixSequenceElement > > content;
00242 };
00243 
00244 
00245 
00246 class MultilineSequenceElement;
00247 
00248 
00252 class MultilineElement : public BasicElement {
00253     friend class KFCNewLine;
00254 
00255     typedef BasicElement inherited;
00256 public:
00257 
00262     MultilineElement( BasicElement* parent = 0 );
00263     ~MultilineElement();
00264 
00265     MultilineElement( const MultilineElement& );
00266 
00267     virtual MultilineElement* clone() {
00268         return new MultilineElement( *this );
00269     }
00270 
00271     virtual bool accept( ElementVisitor* visitor );
00272 
00277     virtual void entered( SequenceElement* child );
00278 
00282     BasicElement* goToPos( FormulaCursor* cursor, bool& handled,
00283                            const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00284 
00289     virtual void goInside(FormulaCursor* cursor);
00290 
00296     virtual void moveLeft( FormulaCursor* cursor, BasicElement* from );
00297 
00303     virtual void moveRight( FormulaCursor* cursor, BasicElement* from );
00304 
00310     virtual void moveUp( FormulaCursor* cursor, BasicElement* from );
00311 
00317     virtual void moveDown( FormulaCursor* cursor, BasicElement* from );
00318 
00323     virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00324 
00330     virtual void draw( QPainter& painter, const LuPixelRect& r,
00331                        const ContextStyle& context,
00332                        ContextStyle::TextStyle tstyle,
00333                        ContextStyle::IndexStyle istyle,
00334                        const LuPixelPoint& parentOrigin );
00335 
00339     virtual void dispatchFontCommand( FontCommand* cmd );
00340 
00341     virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00342     virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00343 
00344     virtual void normalize(FormulaCursor*, Direction);
00345 
00346     virtual SequenceElement* getMainChild();
00347 
00352     virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00353 
00358     virtual QString toLatex();
00359 
00360     virtual QString formulaString();
00361 
00362     virtual void writeMathML( QDomDocument doc, QDomNode parent );
00363 
00364 protected:
00365 
00366     //Save/load support
00367 
00371     virtual QString getTagName() const { return "MULTILINE"; }
00372 
00376     virtual void writeDom(QDomElement element);
00377 
00382     virtual bool readAttributesFromDom(QDomElement element);
00383 
00389     virtual bool readContentFromDom(QDomNode& node);
00390 
00391 
00392 private:
00393 
00397     QPtrList< MultilineSequenceElement > content;
00398 };
00399 
00400 
00401 KFORMULA_NAMESPACE_END
00402 
00403 #endif // MATRIXELEMENT_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 Sun Mar 20 14:25:28 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003