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 namespace KFormula {
00027     class FormulaCursor;
00028     class Container;
00029     class View;
00030 }
00031 
00032 /******************************************************************/
00033 /* Class: KWFormulaFrameSet                                       */
00034 /******************************************************************/
00035 
00036 // needed for signals & slots ;(
00037 using KFormula::Container;
00038 using KFormula::FormulaCursor;
00039 using KFormula::View;
00040 
00041 class KWFormulaFrameSetEdit;
00042 
00043 class KWFormulaFrameSet : public KWFrameSet
00044 {
00045     Q_OBJECT
00046 public:
00047     KWFormulaFrameSet( KWDocument *doc, const QString & name );
00048     virtual ~KWFormulaFrameSet();
00049 
00050     virtual KWordFrameSetIface* dcopObject();
00051 
00055     virtual FrameSetType type() const { return FT_FORMULA; }
00056 
00057     virtual void addFrame( KWFrame *frame, bool recalc = true );
00058 
00065     virtual void deleteFrame( unsigned int num, bool remove = true, bool recalc = true );
00066 
00067     virtual KWFrameSetEdit* createFrameSetEdit(KWCanvas*);
00068 
00069     virtual MouseMeaning getMouseMeaningInsideFrame( const KoPoint& );
00070 
00074     virtual void drawFrameContents(KWFrame *, QPainter*, const QRect&,
00075                                    const QColorGroup&, bool onlyChanged, bool resetChanged,
00076                                    KWFrameSetEdit *edit, KWViewMode *viewMode);
00077 
00078     virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
00079     virtual void load( QDomElement &attributes, bool loadFrames = true );
00080     virtual void saveOasis(KoXmlWriter&, KoSavingContext&, bool saveFrames ) const;
00081     void paste( QDomNode& formulaElem );
00082 
00083     KFormula::Container* getFormula() const { return formula; }
00084 
00085     void setChanged() { m_changed = true; }
00086 
00087     virtual void moveFloatingFrame( int frameNum, const KoPoint &position );
00088     virtual int floatingFrameBaseline( int /*frameNum*/ );
00089 
00090     virtual void setAnchorFormat( KoTextFormat* format, int /*frameNum*/ );
00091 
00092 
00093     // TODO support for protecting the formula's contents
00094     virtual void setProtectContent ( bool ) {}
00095     virtual bool protectContent() const { return false; }
00096 
00097 protected slots:
00098 
00099     void slotFormulaChanged( double width, double height );
00100     void slotErrorMessage( const QString& msg );
00101 
00102 private:
00103 
00104     static QPixmap* doubleBufferPixmap( const QSize& s );
00105     static QPixmap* m_bufPixmap;
00106 
00107     friend class KWFormulaFrameSetEdit;
00108 
00109     KFormula::Container* formula;
00110     bool m_changed;
00111 
00112     KWFormulaFrameSetEdit* m_edit;
00113 };
00114 
00115 
00116 class KWFormulaFrameSetEdit : public QObject, public KWFrameSetEdit
00117 {
00118     Q_OBJECT
00119 public:
00120     KWFormulaFrameSetEdit(KWFormulaFrameSet* fs, KWCanvas* canvas);
00121     virtual ~KWFormulaFrameSetEdit();
00122 
00123     KWFormulaFrameSet* formulaFrameSet() const
00124     {
00125         return static_cast<KWFormulaFrameSet*>(frameSet());
00126     }
00127 
00128     const KFormula::View* getFormulaView() const;
00129     KFormula::View* getFormulaView();
00130 
00131     virtual DCOPObject* dcopObject();
00132 
00133     // Events forwarded by the canvas (when being in "edit" mode)
00134     virtual void keyPressEvent(QKeyEvent*);
00135     virtual void mousePressEvent(QMouseEvent*, const QPoint & n, const KoPoint & d );
00136     virtual void mouseMoveEvent(QMouseEvent*, const QPoint & n, const KoPoint & d); // only called if button is pressed
00137     virtual void mouseReleaseEvent(QMouseEvent*, const QPoint & n, const KoPoint & d);
00138     //virtual void mouseDoubleClickEvent( QMouseEvent *, const QPoint & n, const KoPoint & d ) {}
00139     //virtual void dragEnterEvent( QDragEnterEvent * ) {}
00140     //virtual void dragMoveEvent( QDragMoveEvent *, const QPoint &, const KoPoint & ) {}
00141     //virtual void dragLeaveEvent( QDragLeaveEvent * ) {}
00142     //virtual void dropEvent( QDropEvent *, const QPoint &, const KoPoint &, KWView* ) {}
00143     virtual void focusInEvent();
00144     virtual void focusOutEvent();
00145     virtual void copy();
00146     virtual void cut();
00147     virtual void paste();
00148     virtual void pasteData( QMimeSource* data, int provides, bool drop );
00149     virtual void selectAll();
00150 
00152     void moveHome();
00154     void moveEnd();
00155 
00156     void removeFormula();
00157 
00158 protected slots:
00159 
00163     void cursorChanged( bool visible, bool selecting );
00164 
00165     void slotLeaveFormula( Container*, FormulaCursor*, int );
00166 
00167 private:
00168     KFormula::View* formulaView;
00169     DCOPObject *dcop;
00170 };
00171 
00172 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys