kword

KWFormulaFrameSet.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KWFORMULAFRAME_H
00021 #define KWFORMULAFRAME_H
00022 
00023 #include "KWFrameSet.h"
00024 #include "KWFrameSetEdit.h"
00025 
00026 class DCOPObject;
00027 namespace KFormula {
00028     class FormulaCursor;
00029     class Container;
00030     class View;
00031 }
00032 
00033 /******************************************************************/
00034 /* Class: KWFormulaFrameSet                                       */
00035 /******************************************************************/
00036 
00037 // needed for signals & slots ;(
00038 using KFormula::Container;
00039 using KFormula::FormulaCursor;
00040 using KFormula::View;
00041 
00042 class KWFormulaFrameSetEdit;
00043 
00044 class KWFormulaFrameSet : public KWFrameSet
00045 {
00046     Q_OBJECT
00047 public:
00048     KWFormulaFrameSet( KWDocument *doc, const QString & name );
00050     KWFormulaFrameSet( KWDocument* doc, const QDomElement& frame,
00051                        const QDomElement& objectTag, KoOasisContext& context );
00052     virtual ~KWFormulaFrameSet();
00053 
00054     virtual KWordFrameSetIface* dcopObject();
00055 
00059     virtual FrameSetType type() const { return FT_FORMULA; }
00060 
00061     virtual void addFrame( KWFrame *frame, bool recalc = true );
00062 
00069     virtual void deleteFrame( unsigned int num, bool remove = true, bool recalc = true );
00070 
00071     virtual KWFrameSetEdit* createFrameSetEdit(KWCanvas*);
00072 
00073     virtual MouseMeaning getMouseMeaningInsideFrame( const KoPoint& );
00074 
00078     virtual void drawFrameContents(KWFrame *, QPainter*, const QRect&,
00079                                    const QColorGroup&, bool onlyChanged, bool resetChanged,
00080                                    KWFrameSetEdit *edit, KWViewMode *viewMode);
00081 
00082     virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
00083     virtual void load( QDomElement &attributes, bool loadFrames = true );
00084     virtual void saveOasis(KoXmlWriter&, KoSavingContext&, bool saveFrames ) const;
00085     void paste( QDomNode& formulaElem );
00086 
00087     KFormula::Container* getFormula() const { return formula; }
00088 
00089     void setChanged() { m_changed = true; }
00090 
00091     virtual void moveFloatingFrame( int frameNum, const KoPoint &position );
00092     virtual int floatingFrameBaseline( int /*frameNum*/ );
00093 
00094     virtual void setAnchorFormat( KoTextFormat* format, int /*frameNum*/ );
00095 
00096 
00097     // TODO support for protecting the formula's contents
00098     virtual void setProtectContent ( bool ) {}
00099     virtual bool protectContent() const { return false; }
00100 
00101 protected slots:
00102 
00103     void slotFormulaChanged( double width, double height );
00104     void slotErrorMessage( const QString& msg );
00105 
00106 private:
00107     void init();
00108 
00109     static QPixmap* doubleBufferPixmap( const QSize& s );
00110     static QPixmap* m_bufPixmap;
00111 
00112     friend class KWFormulaFrameSetEdit;
00113 
00114     KFormula::Container* formula;
00115     bool m_changed;
00116 
00117     KWFormulaFrameSetEdit* m_edit;
00118 };
00119 
00120 
00121 class KWFormulaFrameSetEdit : public QObject, public KWFrameSetEdit
00122 {
00123     Q_OBJECT
00124 public:
00125     KWFormulaFrameSetEdit(KWFormulaFrameSet* fs, KWCanvas* canvas);
00126     virtual ~KWFormulaFrameSetEdit();
00127 
00128     KWFormulaFrameSet* formulaFrameSet() const
00129     {
00130         return static_cast<KWFormulaFrameSet*>(frameSet());
00131     }
00132 
00133     const KFormula::View* getFormulaView() const;
00134     KFormula::View* getFormulaView();
00135 
00136     virtual DCOPObject* dcopObject();
00137 
00138     // Events forwarded by the canvas (when being in "edit" mode)
00139     virtual void keyPressEvent(QKeyEvent*);
00140     virtual void mousePressEvent(QMouseEvent*, const QPoint & n, const KoPoint & d );
00141     virtual void mouseMoveEvent(QMouseEvent*, const QPoint & n, const KoPoint & d); // only called if button is pressed
00142     virtual void mouseReleaseEvent(QMouseEvent*, const QPoint & n, const KoPoint & d);
00143     //virtual void mouseDoubleClickEvent( QMouseEvent *, const QPoint & n, const KoPoint & d ) {}
00144     //virtual void dragEnterEvent( QDragEnterEvent * ) {}
00145     //virtual void dragMoveEvent( QDragMoveEvent *, const QPoint &, const KoPoint & ) {}
00146     //virtual void dragLeaveEvent( QDragLeaveEvent * ) {}
00147     //virtual void dropEvent( QDropEvent *, const QPoint &, const KoPoint &, KWView* ) {}
00148     virtual void focusInEvent();
00149     virtual void focusOutEvent();
00150     virtual void copy();
00151     virtual void cut();
00152     virtual void paste();
00153     virtual void pasteData( QMimeSource* data, int provides, bool drop );
00154     virtual void selectAll();
00155 
00157     void moveHome();
00159     void moveEnd();
00160 
00161     void removeFormula();
00162 
00163 protected slots:
00164 
00168     void cursorChanged( bool visible, bool selecting );
00169 
00170     void slotLeaveFormula( Container*, FormulaCursor*, int );
00171 
00172 private:
00173     KFormula::View* formulaView;
00174     DCOPObject *dcop;
00175 };
00176 
00177 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys