kword

KWFormulaFrameSet.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KWFORMULAFRAME_H
21#define KWFORMULAFRAME_H
22
23#include "KWFrameSet.h"
24#include "KWFrameSetEdit.h"
25
26class DCOPObject;
27namespace KFormula {
28 class FormulaCursor;
29 class Container;
30 class View;
31}
32
33/******************************************************************/
34/* Class: KWFormulaFrameSet */
35/******************************************************************/
36
37// needed for signals & slots ;(
38using KFormula::Container;
39using KFormula::FormulaCursor;
40using KFormula::View;
41
42class KWFormulaFrameSetEdit;
43
44class KWFormulaFrameSet : public KWFrameSet
45{
46 TQ_OBJECT
47
48public:
49 KWFormulaFrameSet( KWDocument *doc, const TQString & name );
51 KWFormulaFrameSet( KWDocument* doc, const TQDomElement& frame,
52 const TQDomElement& objectTag, KoOasisContext& context );
53 virtual ~KWFormulaFrameSet();
54
55 virtual KWordFrameSetIface* dcopObject();
56
60 virtual FrameSetType type() const { return FT_FORMULA; }
61
62 virtual void addFrame( KWFrame *frame, bool recalc = true );
63
70 virtual void deleteFrame( unsigned int num, bool remove = true, bool recalc = true );
71
73
74 virtual MouseMeaning getMouseMeaningInsideFrame( const KoPoint& );
75
79 virtual void drawFrameContents(KWFrame *, TQPainter*, const TQRect&,
80 const TQColorGroup&, bool onlyChanged, bool resetChanged,
81 KWFrameSetEdit *edit, KWViewMode *viewMode);
82
83 virtual TQDomElement save( TQDomElement &parentElem, bool saveFrames = true );
84 virtual void load( TQDomElement &attributes, bool loadFrames = true );
85 virtual void saveOasis(KoXmlWriter&, KoSavingContext&, bool saveFrames ) const;
86 void paste( TQDomNode& formulaElem );
87
88 KFormula::Container* getFormula() const { return formula; }
89
90 void setChanged() { m_changed = true; }
91
92 virtual void moveFloatingFrame( int frameNum, const KoPoint &position );
93 virtual int floatingFrameBaseline( int /*frameNum*/ );
94
95 virtual void setAnchorFormat( KoTextFormat* format, int /*frameNum*/ );
96
97
98 // TODO support for protecting the formula's contents
99 virtual void setProtectContent ( bool ) {}
100 virtual bool protectContent() const { return false; }
101
102protected slots:
103
104 void slotFormulaChanged( double width, double height );
105 void slotErrorMessage( const TQString& msg );
106
107private:
108 void init();
109
110 static TQPixmap* doubleBufferPixmap( const TQSize& s );
111 static TQPixmap* m_bufPixmap;
112
113 friend class KWFormulaFrameSetEdit;
114
115 KFormula::Container* formula;
116 bool m_changed;
117
118 KWFormulaFrameSetEdit* m_edit;
119};
120
121
122class KWFormulaFrameSetEdit : public TQObject, public KWFrameSetEdit
123{
124 TQ_OBJECT
125
126public:
127 KWFormulaFrameSetEdit(KWFormulaFrameSet* fs, KWCanvas* canvas);
128 virtual ~KWFormulaFrameSetEdit();
129
130 KWFormulaFrameSet* formulaFrameSet() const
131 {
132 return static_cast<KWFormulaFrameSet*>(frameSet());
133 }
134
135 const KFormula::View* getFormulaView() const;
136 KFormula::View* getFormulaView();
137
138 virtual DCOPObject* dcopObject();
139
140 // Events forwarded by the canvas (when being in "edit" mode)
141 virtual void keyPressEvent(TQKeyEvent*);
142 virtual void mousePressEvent(TQMouseEvent*, const TQPoint & n, const KoPoint & d );
143 virtual void mouseMoveEvent(TQMouseEvent*, const TQPoint & n, const KoPoint & d); // only called if button is pressed
144 virtual void mouseReleaseEvent(TQMouseEvent*, const TQPoint & n, const KoPoint & d);
145 //virtual void mouseDoubleClickEvent( TQMouseEvent *, const TQPoint & n, const KoPoint & d ) {}
146 //virtual void dragEnterEvent( TQDragEnterEvent * ) {}
147 //virtual void dragMoveEvent( TQDragMoveEvent *, const TQPoint &, const KoPoint & ) {}
148 //virtual void dragLeaveEvent( TQDragLeaveEvent * ) {}
149 //virtual void dropEvent( TQDropEvent *, const TQPoint &, const KoPoint &, KWView* ) {}
150 virtual void focusInEvent();
151 virtual void focusOutEvent();
152 virtual void copy();
153 virtual void cut();
154 virtual void paste();
155 virtual void pasteData( TQMimeSource* data, int provides, bool drop );
156 virtual void selectAll();
157
159 void moveHome();
161 void moveEnd();
162
163 void removeFormula();
164
165protected slots:
166
170 void cursorChanged( bool visible, bool selecting );
171
172 void slotLeaveFormula( Container*, FormulaCursor*, int );
173
174private:
175 KFormula::View* formulaView;
176 DCOPObject *dcop;
177};
178
179#endif
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
Definition KWCanvas.h:61
This object is created to edit a particular frameset in a particular view The view's canvas creates i...
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
Definition KWFrameSet.h:62
virtual void moveFloatingFrame(int frameNum, const KoPoint &position)
Move the frame frameNum to the given position - this is called when the frame is anchored and the anc...
virtual void setAnchorFormat(KoTextFormat *, int)
Tell this frame the format of it's anchor.
Definition KWFrameSet.h:380
virtual void deleteFrame(unsigned int num, bool remove=true, bool recalc=true)
Delete a frame from the set of frames this frameSet has.
virtual FrameSetType type() const
The type of frameset.
Definition KWFrameSet.h:76
virtual KWFrameSetEdit * createFrameSetEdit(KWCanvas *)
Create a framesetedit object to edit this frameset in canvas.
Definition KWFrameSet.h:169
virtual int floatingFrameBaseline(int)
Get the 'baseline' to use for the "floating frame" identified by frameNum.
Definition KWFrameSet.h:397
virtual void load(TQDomElement &framesetElem, bool loadFrames=true)
load from XML - when loading
KWFrame * frame(unsigned int _num) const
get a frame by number
TQString name() const
get/set frameset name. For tables in particular, this must be unique
Definition KWFrameSet.h:428
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context, bool saveFrames) const =0
Save to OASIS format.
virtual void drawFrameContents(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode)
Implement this one instead of drawFrame to benefit from double-buffering AND transparency handling (p...
virtual TQDomElement save(TQDomElement &parentElem, bool saveFrames=true)=0
save to XML - when saving
This class represents a single frame.
Definition KWFrame.h:68
Abstract base class for KWCanvas's view modes.
Definition KWViewMode.h:48