~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kword/kwframe.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef frame_h
21
21
#define frame_h
22
22
 
 
23
#include <qdom.h>
 
24
 
23
25
#include "defs.h"
24
 
#include "kwimage.h"
25
 
#include <koClipart.h>
 
26
#include <koPicture.h>
26
27
#include <koRect.h>
27
28
#include <qbrush.h>
28
 
#include <qlist.h>
 
29
#include <qptrlist.h>
 
30
#include <qptrvector.h>
29
31
#include "kwstyle.h"
30
 
#include "border.h"
 
32
#include "koborder.h"
31
33
 
32
 
namespace KFormula {
33
 
    class KFormulaContainer;
34
 
    class KFormulaView;
35
 
}
36
34
 
37
35
class KCommand;
38
36
class KWAnchor;
41
39
class KWDocument;
42
40
class KWFrame;
43
41
class KWFrameSet;
 
42
class KWTextFrameSet;
44
43
class KWResizeHandle;
45
44
class KWTableFrameSet;
46
45
class KWTextDocument;
55
54
class QProgressDialog;
56
55
class KWTextFrameSet;
57
56
class KWFramePartMoveCommand;
 
57
class KWordFrameSetIface;
 
58
class DCOPObject;
 
59
 
 
60
 
 
61
/**
 
62
 * small utility class representing a sortable (by z-order) list of frames
 
63
 * you can use sort() and inSort(item)
 
64
 **/
 
65
class KWFrameList: public QPtrList<KWFrame>
 
66
{
 
67
protected:
 
68
        virtual int compareItems(QPtrCollection::Item a, QPtrCollection::Item b);
 
69
};
58
70
 
59
71
/**
60
72
 * This class represents a single frame.
73
85
     */
74
86
    enum RunAround { RA_NO = 0, RA_BOUNDINGRECT = 1, RA_SKIP = 2 };
75
87
 
 
88
    /** Runaround side - only meaningful when RA_BOUNDINGRECT is used
 
89
     */
 
90
    enum RunAroundSide { RA_BIGGEST = 0, RA_LEFT = 1, RA_RIGHT = 2 };
 
91
 
76
92
    /**
77
93
     * Constructor
78
94
     * @param fs parent frameset
85
101
    KWFrame(KWFrameSet *fs, double left, double top, double width, double height,
86
102
            RunAround ra = RA_BOUNDINGRECT, double gap = MM_TO_POINT( 1.0 ));
87
103
    KWFrame(KWFrame * frame);
88
 
    /* Destructor */
 
104
    /** Destructor
 
105
     */
89
106
    virtual ~KWFrame();
90
107
 
91
108
    /** a frame can be selected by the user clicking on it. The frame
93
110
     * - which is actually pretty bad in terms of doc/view design (DF)
94
111
     */
95
112
    void setSelected( bool _selected );
96
 
    bool isSelected() { return selected; }
97
 
 
98
 
    QCursor getMouseCursor( const KoPoint& docPoint, bool table, QCursor defaultCursor );
99
 
 
100
 
    double runAroundGap() { return m_runAroundGap; }
 
113
    bool isSelected()const { return m_selected; }
 
114
 
 
115
    MouseMeaning getMouseMeaning( const KoPoint& docPoint, MouseMeaning defaultMeaning );
 
116
 
 
117
    double runAroundGap()const { return m_runAroundGap; }
101
118
    void setRunAroundGap( double gap ) { m_runAroundGap = gap; }
102
119
 
103
 
    RunAround runAround() { return m_runAround; }
104
 
    void setRunAround( RunAround _ra ) { m_runAround = _ra; }
105
 
 
106
 
 
107
 
    /** what should happen when the frame is full */
108
 
    enum FrameBehaviour { AutoExtendFrame=0 , AutoCreateNewFrame=1, Ignore=2 };
109
 
 
110
 
    FrameBehaviour getFrameBehaviour() { return frameBehaviour; }
111
 
    void setFrameBehaviour( FrameBehaviour fb ) { frameBehaviour = fb; }
 
120
    // Don't look at the implementation, it's about saving one byte ;)
 
121
    RunAround runAround()const { return (RunAround)(m_runAround & 0x0f); }
 
122
    void setRunAround( RunAround _ra ) { m_runAround = 16 * runAroundSide() + _ra; }
 
123
 
 
124
    RunAroundSide runAroundSide() const { return (RunAroundSide)(m_runAround / 16); }
 
125
    void setRunAroundSide( RunAroundSide rs ) { m_runAround = 16 * rs + runAround(); }
 
126
 
 
127
    /** what should happen when the frame is full
 
128
     */
 
129
    enum FrameBehavior { AutoExtendFrame=0 , AutoCreateNewFrame=1, Ignore=2 };
 
130
 
 
131
    FrameBehavior frameBehavior()const { return (FrameBehavior)m_frameBehavior; }
 
132
    void setFrameBehavior( FrameBehavior fb ) { m_frameBehavior = fb; }
112
133
 
113
134
    /* Frame duplication properties */
114
135
 
116
137
     *   AnySide, OddSide or EvenSide
117
138
     */
118
139
    enum SheetSide { AnySide=0, OddSide=1, EvenSide=2};
119
 
    SheetSide getSheetSide() { return sheetSide; }
120
 
    void setSheetSide( SheetSide ss ) { sheetSide = ss; }
121
 
 
122
 
    /** What happens on new page (create a new frame and reconnect, no followup, make copy) */
123
 
    enum NewFrameBehaviour { Reconnect=0, NoFollowup=1, Copy=2 };
124
 
    NewFrameBehaviour getNewFrameBehaviour() { return newFrameBehaviour; }
125
 
    void setNewFrameBehaviour( NewFrameBehaviour nfb ) { newFrameBehaviour = nfb; }
126
 
 
127
 
    /** Drawing property: if isCopy, this frame is a copy of the previous frame in the frameset */
128
 
    bool isCopy() { return m_bCopy; }
 
140
    SheetSide sheetSide()const { return (SheetSide)m_sheetSide; }
 
141
    void setSheetSide( SheetSide ss ) { m_sheetSide = ss; }
 
142
 
 
143
    /** What happens on new page
 
144
     * (create a new frame and reconnect, no followup, make copy) */
 
145
    enum NewFrameBehavior { Reconnect=0, NoFollowup=1, Copy=2 };
 
146
    NewFrameBehavior newFrameBehavior()const { return (NewFrameBehavior)m_newFrameBehavior; }
 
147
    void setNewFrameBehavior( NewFrameBehavior nfb ) { m_newFrameBehavior = nfb; }
 
148
 
 
149
    /** Drawing property: if isCopy, this frame is a copy of the previous frame in the frameset
 
150
     */
 
151
    bool isCopy()const { return m_bCopy; }
129
152
    void setCopy( bool copy ) { m_bCopy = copy; }
130
153
 
131
 
    /* Data stucture methods */
132
 
    KWFrameSet *getFrameSet() const { return frameSet; }
133
 
    void setFrameSet( KWFrameSet *fs ) { frameSet = fs; }
 
154
    /** Data stucture methods
 
155
     */
 
156
    KWFrameSet *frameSet() const { return m_frameSet; }
 
157
    void setFrameSet( KWFrameSet *fs ) { m_frameSet = fs; }
134
158
 
135
 
    /* The page on which this frame is (0 based)*/
 
159
    /** The page on which this frame is (0 based)
 
160
     */
136
161
    int pageNum() const;
137
 
 
138
 
    /* All borders can be custom drawn with their own colors etc. */
139
 
    const Border &leftBorder() const { return brd_left; }
140
 
    const Border &rightBorder() const { return brd_right; }
141
 
    const Border &topBorder() const { return brd_top; }
142
 
    const Border &bottomBorder() const { return brd_bottom; }
143
 
 
144
 
    void setLeftBorder( Border _brd ) { brd_left = _brd; }
145
 
    void setRightBorder( Border _brd ) { brd_right = _brd; }
146
 
    void setTopBorder( Border _brd ) { brd_top = _brd; }
147
 
    void setBottomBorder( Border _brd ) { brd_bottom = _brd; }
148
 
 
149
 
    /** Return the _zoomed_ rectangle for this frame, including the border - for drawing */
150
 
    QRect outerRect() const;
 
162
    /** Same as pageNum(), but works if the frame hasn't been added to a frameset yet
 
163
     */
 
164
    int pageNum( KWDocument* doc ) const;
 
165
 
 
166
    /** The z-order of the frame, relative to the other frames on the same page
 
167
     */
 
168
    void setZOrder( int z ) { m_zOrder = z; }
 
169
    int zOrder() const { return m_zOrder; }
 
170
 
 
171
    /** For KWFrameSet::updateFrames only. Clear list of frames on top of this one.
 
172
     */
 
173
    void clearFramesOnTop() { m_framesOnTop.clear(); }
 
174
    void clearFramesBelow() { m_framesBelow.clear(); }
 
175
 
 
176
    /** For KWFrameSet::updateFrames only. Add a frame on top of this one.
 
177
     * Note that order doesn't matter in that list, it's for clipping only. */
 
178
    void addFrameOnTop( KWFrame* fot ) { m_framesOnTop.append( fot ); }
 
179
 
 
180
    /**
 
181
     * order DOES matter for this one tho. this one is for transparency & selection.
 
182
     **/
 
183
    void addFrameBelow( KWFrame* fbl ) { m_framesBelow.append( fbl ); }
 
184
    void sortFramesBelow() { m_framesBelow.sort(); }
 
185
 
 
186
    const QPtrList<KWFrame>& framesOnTop() const { return m_framesOnTop; }
 
187
    const QPtrList<KWFrame>& framesBelow() const { return m_framesBelow; }
 
188
 
 
189
    /** All borders can be custom drawn with their own colors etc.
 
190
     */
 
191
    const KoBorder &leftBorder() const { return brd_left; }
 
192
    const KoBorder &rightBorder() const { return brd_right; }
 
193
    const KoBorder &topBorder() const { return brd_top; }
 
194
    const KoBorder &bottomBorder() const { return brd_bottom; }
 
195
 
 
196
 
 
197
    void setLeftBorder( KoBorder _brd ) { brd_left = _brd; }
 
198
    void setRightBorder( KoBorder _brd ) { brd_right = _brd; }
 
199
    void setTopBorder( KoBorder _brd ) { brd_top = _brd; }
 
200
    void setBottomBorder( KoBorder _brd ) { brd_bottom = _brd; }
 
201
 
 
202
    void invalidateParentFrameset();
 
203
 
 
204
    /** Return the _zoomed_ rectangle for this frame, including the border - for drawing
 
205
     * @param viewMode needed to know if borders are visible or not
 
206
     */
 
207
    QRect outerRect( KWViewMode* viewMode ) const;
 
208
 
151
209
    /** Return the unzoomed rectangle, including the border, for the frames-on-top list.
152
 
        The default border of size 1-pixel that is drawn on screen is _not_ included here
153
 
        [since it depends on the zoom] */
 
210
     * The default border of size 1-pixel that is drawn on screen is _not_ included here
 
211
     * [since it depends on the zoom]
 
212
     */
154
213
    KoRect outerKoRect() const;
155
214
 
156
 
    /* Resize handles (in kwcanvas.h) are the dots that are drawn on selected
 
215
    /** Return the rectangle for this frame including the border and the runaround gap.
 
216
     * This is the rectangle that the surrounding text must run around.
 
217
     */
 
218
    KoRect runAroundRect() const;
 
219
 
 
220
    /** Resize handles (in kwcanvas.h) are the dots that are drawn on selected
157
221
       frames, this creates and deletes them */
158
222
    void createResizeHandles();
159
223
    void createResizeHandlesForPage(KWCanvas *canvas);
160
224
    void removeResizeHandlesForPage(KWCanvas *canvas);
161
225
    void removeResizeHandles();
 
226
    void frameBordersChanged();
162
227
    void updateResizeHandles();
 
228
    void repaintResizeHandles();
163
229
    void updateRulerHandles();
164
 
 
165
 
    QBrush getBackgroundColor() const { return backgroundColor; }
166
 
    void setBackgroundColor( QBrush _color ) { backgroundColor = _color; }
167
 
 
168
 
    // For text frames only
169
 
    void setInternalY( int y ) { m_internalY = y; }
170
 
    int internalY() const { return m_internalY; }
171
 
 
172
 
    /** set left margin size */
 
230
    void updateCursorType();
 
231
 
 
232
    QBrush backgroundColor() const { return m_backgroundColor; }
 
233
    void setBackgroundColor( const QBrush &_color );
 
234
 
 
235
    KoRect innerRect() const;
 
236
 
 
237
    double innerWidth() const;
 
238
    double innerHeight() const;
 
239
 
 
240
 
 
241
    /** The "internal Y" is the offset (in pt) of the real frame showed in this one
 
242
     * ("real" means "the last that isn't a copy")
 
243
     * This offset in pt is the sum of the height of the frames before that one.
 
244
     * For text frames, this is equivalent to the layout units (after multiplication). */
 
245
    void setInternalY( double y ) { m_internalY = y; }
 
246
    double internalY() const { return m_internalY; }
 
247
 
 
248
    /** set left margin size
 
249
     */
173
250
    void setBLeft( double b ) { bleft = b; }
174
 
    /** set right margin size */
 
251
    /** set right margin size
 
252
     */
175
253
    void setBRight( double b ) { bright = b; }
176
 
    /** set top margin size */
 
254
    /** set top margin size
 
255
     */
177
256
    void setBTop( double b ) { btop = b; }
178
 
    /** set bottom margin size */
 
257
    /** set bottom margin size
 
258
     */
179
259
    void setBBottom( double b ) { bbottom = b; }
180
260
 
181
 
    /** get left margin size */
182
 
    double getBLeft() { return bleft; }
183
 
    /** get right margin size */
184
 
    double getBRight() { return bright; }
185
 
    /** get top margin size */
186
 
    double getBTop() { return btop; }
187
 
    /** get bottom margin size */
188
 
    double getBBottom() { return bbottom; }
 
261
    /** get left margin size
 
262
     */
 
263
    double bLeft()const { return bleft; }
 
264
    /** get right margin size
 
265
     */
 
266
    double bRight()const { return bright; }
 
267
    /** get top margin size
 
268
     */
 
269
    double bTop()const { return btop; }
 
270
    /** get bottom margin size
 
271
     */
 
272
    double bBottom()const { return bbottom; }
189
273
 
190
 
    /** returns a copy of self */
 
274
    void setFrameMargins( double _left, double _top, double right, double bottom);
 
275
    /** returns a copy of self
 
276
     */
191
277
    KWFrame *getCopy();
192
278
 
193
279
    void copySettings(KWFrame *frm);
194
280
 
195
 
    /** create XML to describe yourself */
 
281
    /** create XML to describe yourself
 
282
     */
196
283
    void save( QDomElement &frameElem );
197
 
    /** read attributes from XML. @p headerOrFooter if true some defaults are different */
198
 
    void load( QDomElement &frameElem, bool headerOrFooter, int syntaxVersion );
 
284
    /** read attributes from XML. @p headerOrFooter if true some defaults are different
 
285
     */
 
286
    void load( QDomElement &frameElem, KWFrameSet* frameSet, int syntaxVersion );
199
287
 
200
288
    void setMinFrameHeight(double h) {m_minFrameHeight=h;}
201
 
    double minFrameHeight(void) {return m_minFrameHeight;}
 
289
    double minFrameHeight(void)const {return m_minFrameHeight;}
 
290
 
 
291
    /** Return if the point is on the frame.
 
292
        @param point the point in normal coordinates.
 
293
        @param borderOfFrameOnly when true an additional check is done if the point
 
294
          is on the border.  */
 
295
    bool frameAtPos( const QPoint& nPoint, bool borderOfFrameOnly=false );
 
296
 
 
297
    /**
 
298
     * Only applicable to frames of the main text frameset.
 
299
     * Set to true by KWFrameLayout if the "footnote line" should be
 
300
     * drawn under this frame.
 
301
     */
 
302
    void setDrawFootNoteLine( bool b ) { m_drawFootNoteLine = b; }
 
303
    bool drawFootNoteLine()const { return m_drawFootNoteLine; }
202
304
 
203
305
private:
204
 
    SheetSide sheetSide;
205
 
    RunAround m_runAround;
206
 
    FrameBehaviour frameBehaviour;
207
 
    NewFrameBehaviour newFrameBehaviour;
 
306
    char /*SheetSide*/ m_sheetSide;
 
307
    char /*RunAroundSide*/ m_runAround; // includes runaround side
 
308
    char /*FrameBehavior*/ m_frameBehavior;
 
309
    char /*NewFrameBehavior*/ m_newFrameBehavior;
208
310
    double m_runAroundGap;
209
311
    double bleft, bright, btop, bbottom; // margins
 
312
    double m_minFrameHeight;
210
313
 
 
314
    double m_internalY;
 
315
    int m_zOrder;
211
316
    bool m_bCopy;
212
 
    bool selected;
213
 
    int m_internalY; // for text frames only
214
 
    double m_minFrameHeight;
215
 
 
216
 
    QBrush backgroundColor;
217
 
    Border brd_left, brd_right, brd_top, brd_bottom;
218
 
 
219
 
    QList<KWResizeHandle> handles;
220
 
    KWFrameSet *frameSet;
221
 
 
222
 
    // Prevent operator= and copy constructor
 
317
    bool m_selected;
 
318
    bool m_drawFootNoteLine;
 
319
 
 
320
    QBrush m_backgroundColor;
 
321
    KoBorder brd_left, brd_right, brd_top, brd_bottom;
 
322
 
 
323
    QPtrList<KWResizeHandle> handles;
 
324
    KWFrameList m_framesOnTop; // List of frames on top of us, those we shouldn't overwrite
 
325
    KWFrameList m_framesBelow; // List of frames below us. needed for selection code & transparency
 
326
    KWFrameSet *m_frameSet;
 
327
 
 
328
    /** Prevent operator=
 
329
     */
223
330
    KWFrame &operator=( const KWFrame &_frame );
 
331
    /** Prevent copy constructor
 
332
     */
224
333
    KWFrame ( const KWFrame &_frame );
225
334
};
226
335
 
246
355
    /**
247
356
     * Called before destruction, when terminating edition - use to e.g. hide cursor
248
357
     */
249
 
    virtual void terminate() {}
 
358
    virtual void terminate(bool /*removeselection*/ = true) {}
250
359
 
251
360
    /**
252
361
     * Paint this frameset in "has focus" mode (e.g. with a cursor)
254
363
     * Most framesets don't need to reimplement that (the KWFrameSetEdit gets passed to drawFrame)
255
364
     */
256
365
    virtual void drawContents( QPainter *, const QRect &,
257
 
                               QColorGroup &, bool onlyChanged, bool resetChanged,
258
 
                               KWViewMode *viewMode, KWCanvas *canvas );
 
366
                               const QColorGroup &, bool onlyChanged, bool resetChanged,
 
367
                               KWViewMode *viewMode );
259
368
 
260
369
    // Events forwarded by the canvas (when being in "edit" mode)
261
370
    virtual void keyPressEvent( QKeyEvent * ) {}
 
371
    virtual void keyReleaseEvent( QKeyEvent * ) {}
262
372
    virtual void mousePressEvent( QMouseEvent *, const QPoint &, const KoPoint & ) {}
263
373
    virtual void mouseMoveEvent( QMouseEvent *, const QPoint &, const KoPoint & ) {} // only called if button is pressed
264
374
    virtual void mouseReleaseEvent( QMouseEvent *, const QPoint &, const KoPoint & ) {}
274
384
    virtual void paste() {}
275
385
    virtual void selectAll() {}
276
386
 
 
387
    /** Show a popup menu - called when right-clicking inside a frame of this frameset.
 
388
     * The default implementation calls the frameset's showPopup.
 
389
     * @param frame the frame which was clicked.
 
390
     * @param view the view - we use it to get the popupmenu by name
 
391
     * @param point the mouse position (at which to show the menu)
 
392
     */
 
393
    virtual void showPopup( KWFrame* frame, KWView* view, const QPoint & _point );
 
394
 
277
395
protected:
278
396
    KWFrameSet * m_fs;
279
397
    KWCanvas * m_canvas;
290
408
 * content.
291
409
 * The different types of content are implemented in the different
292
410
 * types of frameSet implementations (see below)
293
 
 * @see KWTextFrameSet, KWPartFramSet, KWPictureFrameSet,
294
 
 *      KWPartFrameSet, KWFormulaFrameSet
 
411
 * @see KWTextFrameSet, KWPartFrameSet, KWPictureFrameSet,
 
412
 *      KWFormulaFrameSet, KWTableFrameSet
295
413
 */
296
414
class KWFrameSet : public QObject
297
415
{
302
420
    // destructor
303
421
    virtual ~KWFrameSet();
304
422
 
 
423
    virtual KWordFrameSetIface* dcopObject();
 
424
 
 
425
    /** The type of frameset. Use this to differentiate between different instantiations of
 
426
     *  the framesets. Each implementation will return a different frameType.
 
427
     */
305
428
    virtual FrameSetType type() { return FT_BASE; }
306
429
 
307
 
    virtual void addTextFramesets( QList<KWTextFrameSet> & /*lst*/ ) {};
 
430
    /**
 
431
     *  Return the type of FrameSet that would have been used in KWord 1.1
 
432
     */
 
433
    virtual FrameSetType typeAsKOffice1Dot1(void) { return type(); }
 
434
 
 
435
    virtual void addTextFrameSets( QPtrList<KWTextFrameSet> & /*lst*/, bool /*onlyReadWrite*/ = false ) {};
 
436
    virtual bool ownLine() const { return FALSE;}
308
437
 
309
438
    /** The different types of textFramesets (that TEXT is important here!)
310
439
     * FI_BODY = normal text frames.<br>
311
440
     * FI_FIRST_HEADER = Header on page 1<br>
 
441
     * FI_EVEN_HEADER = header on any even page<br>
312
442
     * FI_ODD_HEADER = header on any odd page (can be including page 1)<br>
313
 
     * FI_EVEN_HEADER = header on any even page<br>
314
443
     * FI_FIRST_FOOTER = footer on page 1<br>
 
444
     * FI_EVEN_FOOTER = footer on any even page<br>
315
445
     * FI_ODD_FOOTER = footer on any odd page (can be including page 1)<br>
316
 
     * FI_EVEN_FOOTER = footer on any even page<br>
317
446
     * FI_FOOTNOTE = a footnote frame.
318
447
     */
319
 
    enum Info { FI_BODY = 0, FI_FIRST_HEADER = 1, FI_ODD_HEADER = 2, FI_EVEN_HEADER = 3,
320
 
                FI_FIRST_FOOTER = 4, FI_ODD_FOOTER = 5, FI_EVEN_FOOTER = 6,
 
448
    enum Info { FI_BODY = 0, FI_FIRST_HEADER = 1, FI_EVEN_HEADER = 2, FI_ODD_HEADER = 3,
 
449
                FI_FIRST_FOOTER = 4, FI_EVEN_FOOTER = 5, FI_ODD_FOOTER = 6,
321
450
                FI_FOOTNOTE = 7 };
322
 
    Info frameSetInfo() { return m_info; }
 
451
    /** Returns the type of TextFrameSet this is */
 
452
    Info frameSetInfo()const { return m_info; }
 
453
    /** Set the type of TextFrameSet this is */
323
454
    void setFrameSetInfo( Info fi ) { m_info = fi; }
324
455
 
325
456
    bool isAHeader() const;
326
457
    bool isAFooter() const;
327
458
    bool isHeaderOrFooter() const { return isAHeader() || isAFooter(); }
 
459
    bool isFootEndNote() const;
328
460
 
329
 
    bool isAWrongHeader( KoHFType t ) const;
330
 
    bool isAWrongFooter( KoHFType t ) const;
 
461
    virtual bool isFootNote() const { return false; }
 
462
    virtual bool isEndNote() const { return false; }
331
463
 
332
464
    bool isMainFrameset() const;
333
465
    bool isMoveable() const;
334
466
 
335
467
    // frame management
336
468
    virtual void addFrame( KWFrame *_frame, bool recalc = true );
337
 
    virtual void delFrame( unsigned int _num );
338
 
    virtual void delFrame( KWFrame *frm, bool remove = true );
 
469
 
 
470
    /** Delete a frame from the set of frames this frameSet has.
 
471
    *   @param num The frameNumber to be removed.
 
472
    *   @param remove passing true means that there can not be an undo of the action.
 
473
    *   @param recalc do an updateFrames()
 
474
    */
 
475
    virtual void delFrame( unsigned int _num, bool remove = true, bool recalc = true );
 
476
 
 
477
    /** Delete a frame from the set of frames this frameSet has.
 
478
    *   @param frm. The frame that should be deleted
 
479
    *   @param remove passing true means that there can not be an undo of the action.
 
480
    *   @param recalc do an updateFrames()
 
481
    */
 
482
    void delFrame( KWFrame *frm, bool remove = true, bool recalc = true ); // calls the virtual one
 
483
 
 
484
    /// Called by delFrame when it really deletes a frame (remove=true), to remove it from the table too
 
485
    virtual void frameDeleted( KWFrame* /*frm*/, bool /*recalc*/ ) {}
 
486
 
339
487
    void deleteAllFrames();
340
488
    void deleteAllCopies(); // for headers/footers only
341
489
 
342
490
    /** retrieve frame from x and y coords (unzoomed coords) */
343
491
    KWFrame *frameAtPos( double _x, double _y );
 
492
 
 
493
    /** Return if the point is on the frame.
 
494
        @param point the point in normal coordinates.
 
495
        @param borderOfFrameOnly when true an additional check is done if the point
 
496
          is on the border.  */
 
497
    bool isFrameAtPos( KWFrame* frame, const QPoint& nPoint, bool borderOfFrameOnly=false );
 
498
 
344
499
    /** return a frame if nPoint in on one of its borders */
345
 
    virtual KWFrame *frameByBorder( const QPoint & nPoint );
 
500
    KWFrame *frameByBorder( const QPoint & nPoint );
346
501
 
347
502
    /** get a frame by number */
348
 
    KWFrame *getFrame( unsigned int _num );
 
503
    KWFrame *frame( unsigned int _num );
349
504
 
350
505
    /** get the frame whose settings apply for @p frame
351
506
        (usually @p frame, but can also be the real frame if frame is a copy) */
352
 
    static KWFrame * settingsFrame(KWFrame* frame);
 
507
    static KWFrame * settingsFrame( const KWFrame* frame );
353
508
 
354
 
    /* Iterator over the child frames */
355
 
    const QList<KWFrame> &frameIterator() const { return frames; }
356
 
    /* Get frame number */
357
 
    int getFrameFromPtr( KWFrame *frame );
358
 
    /* Get number of child frames */
 
509
    /** Iterator over the child frames */
 
510
    const QPtrList<KWFrame> &frameIterator() const { return frames; }
 
511
    /** Get frame number */
 
512
    int frameFromPtr( KWFrame *frame );
 
513
    /** Get number of child frames */
359
514
    unsigned int getNumFrames() const { return frames.count(); }
360
515
 
 
516
    /** Called when the user resizes a frame. Calls resizeFrame. */
 
517
    void resizeFrameSetCoords( KWFrame* frame, double newLeft, double newTop, double newRight, double newBottom, bool finalSize );
 
518
    /** Called when the user resizes a frame. Reimplemented by KWPictureFrameSet. */
 
519
    virtual void resizeFrame( KWFrame* frame, double newWidth, double newHeight, bool finalSize );
 
520
    /** Called when the user moves a frame. */
 
521
    virtual void moveFrame( KWFrame* ) {}
 
522
 
361
523
    /** True if the frameset was deleted (but not destroyed, since it's in the undo/redo) */
362
524
    bool isDeleted() const { return frames.isEmpty(); }
363
525
 
373
535
    virtual void createEmptyRegion( const QRect & crect, QRegion & emptyRegion, KWViewMode *viewMode );
374
536
 
375
537
    /**
376
 
     * Paint the borders for one frame of this frameset.
377
 
     * @param painter The painter in which to draw the contents of the frameset
378
 
     * @param frame The frame to be drawn
379
 
     * @param settingsFrame The frame from which we take the settings (usually @p frame, but not with Copy behaviour)
380
 
     * @param crect The rectangle (in "contents coordinates") to be painted
381
 
     * @param canvas The canvas in which we are drawing (for settings)
382
 
     */
383
 
    void drawFrameBorder( QPainter *painter, KWFrame *frame, KWFrame *settingsFrame,
384
 
                          const QRect &crect, KWViewMode *viewMode, KWCanvas *canvas );
385
 
 
386
 
    /**
387
538
     * Paint this frameset
388
539
     * @param painter The painter in which to draw the contents of the frameset
389
 
     * @param crect The rectangle (in "contents coordinates") to be painted
 
540
     * @param crect The rectangle (in scrollview "contents coordinates", i.e. "view coords")
 
541
     * to be painted
390
542
     * @param cg The colorgroup from which to get the colors
391
543
     * @param onlyChanged If true, only redraw what has changed (see KWCanvas::repaintChanged)
392
544
     * @param resetChanged If true, set the changed flag to false after drawing.
404
556
     * Framesets shouldn't reimplement this one in theory [but KWTableFrameSet has to].
405
557
     */
406
558
    virtual void drawContents( QPainter *painter, const QRect &crect,
407
 
                               QColorGroup &cg, bool onlyChanged, bool resetChanged,
408
 
                               KWFrameSetEdit *edit, KWViewMode *viewMode, KWCanvas *canvas );
409
 
 
410
 
    // This is used (e.g. by KWTextParag) to get the view settings
411
 
    KWCanvas * currentDrawnCanvas() const { return m_currentDrawnCanvas; }
 
559
                               const QColorGroup &cg, bool onlyChanged, bool resetChanged,
 
560
                               KWFrameSetEdit *edit, KWViewMode *viewMode );
 
561
 
 
562
    /**
 
563
     * This one is called by drawContents for each frame.
 
564
     * It sets up clip rect and painter translation, and calls drawFrame, drawFrameBorder and drawMargins
 
565
     *
 
566
     * @param drawUnderlyingFrames if the frame implements it, then it should draw underlying frames.
 
567
     * This is set to false by the default drawFrame implementation, so that the frames under a
 
568
     * transparent frame are simply drawn, without transparency handling (nor their own
 
569
     * double-buffering).
 
570
     */
 
571
    void drawFrameAndBorders( KWFrame *frame,
 
572
                              QPainter *painter, const QRect &crect,
 
573
                              const QColorGroup &cg, bool, bool,
 
574
                              KWFrameSetEdit *edit, KWViewMode *viewMode,
 
575
                              KWFrame *settingsFrame, bool drawUnderlyingFrames );
 
576
 
 
577
    /**
 
578
     * Paint the borders for one frame of this frameset.
 
579
     * @param painter The painter in which to draw the contents of the frameset
 
580
     * @param frame The frame to be drawn
 
581
     * @param settingsFrame The frame from which we take the settings (usually @p frame, but not with Copy behaviour)
 
582
     * @param crect The rectangle (in "contents coordinates") to be painted
 
583
     */
 
584
    void drawFrameBorder( QPainter *painter, KWFrame *frame, KWFrame *settingsFrame,
 
585
                          const QRect &crect, KWViewMode *viewMode );
412
586
 
413
587
    /**
414
588
     * Draw a particular frame of this frameset.
415
589
     * This is called by drawContents and is what framesets must reimplement.
416
 
     */
417
 
    virtual void drawFrame( KWFrame *frame, QPainter *painter, const QRect &crect,
418
 
                            QColorGroup &cg, bool onlyChanged, bool resetChanged,
419
 
                            KWFrameSetEdit *edit ) = 0;
420
 
 
 
590
     * @param fcrect rectangle to be repainted, in the _frame_'s coordinate system (in pixels). Doesn't include margins.
 
591
     @
 
592
     * @param crect rectangle to be repainted, in view coordinates. Includes margins.
 
593
     * Default implementation does double-buffering and calls drawFrameContents.
 
594
     */
 
595
    virtual void drawFrame( KWFrame *frame, QPainter *painter, const QRect &fcrect, const QRect &crect,
 
596
                            const QPoint& translationOffset,
 
597
                            KWFrame *settingsFrame, const QColorGroup &cg, bool onlyChanged, bool resetChanged,
 
598
                            KWFrameSetEdit *edit, KWViewMode *viewMode, bool drawUnderlyingFrames );
 
599
 
 
600
    /**
 
601
     * Implement this one instead of drawFrame to benefit from double-buffering
 
602
     * AND transparency handling (painting frames below this one) automatically.
 
603
     * You MUST reimplement one or the other, or you'll get infinite recursion ;)
 
604
     *
 
605
     * In this method, the painter has been translated to the frame's coordinate system
 
606
     * @param fcrect rectangle to be repainted, in the _frame_'s coordinate system (in pixels). Doesn't include margins.
 
607
     */
 
608
    virtual void drawFrameContents( KWFrame * frame, QPainter *painter, const QRect& fcrect,
 
609
                                    const QColorGroup &cg, bool onlyChanged, bool resetChanged,
 
610
                                    KWFrameSetEdit * edit, KWViewMode *viewMode );
 
611
 
 
612
    /**
 
613
     * Draw a margin of a specific frame of this frameSet
 
614
     */
 
615
    virtual void drawMargins( KWFrame *frame, QPainter *p, const QRect &fcrect, const QColorGroup &cg, KWViewMode *viewMode);
 
616
 
 
617
    enum UpdateFramesFlags {
 
618
        UpdateFramesInPage = 1,
 
619
        SortFrames = 2 // kwtextframeset only
 
620
        // next one is 4, not 3 ;)
 
621
    };
421
622
    /**
422
623
     * Called when our frames change, or when another frameset's frames change.
423
624
     * Framesets can reimplement it, but should always call the parent method.
424
625
     */
425
 
    virtual void updateFrames();
 
626
    virtual void updateFrames( int flags = 0xff );
 
627
 
 
628
    /** Return list of frames in page @p pageNum.
 
629
     * This is fast since it uses the m_framesInPage array.*/
 
630
    const QPtrList<KWFrame> & framesInPage( int pageNum ) const;
 
631
 
 
632
    /** Allows to detect that updateFrames() hasn't been called yet (e.g. on loading) */
 
633
    bool hasFramesInPageArray() const { return !m_framesInPage.isEmpty(); }
426
634
 
427
635
    /** relayout text in frames, so that it flows correctly around other frames */
428
636
    virtual void layout() {}
431
639
    /** returns true if we have a frame occupying that position */
432
640
    virtual bool contains( double mx, double my );
433
641
 
434
 
    virtual bool getMouseCursor( const QPoint &nPoint, bool controlPressed, QCursor & cursor );
 
642
    /**
 
643
     * Return "what it means" to have the mouse at position nPoint,
 
644
     * (which kwdoc tests to be over one of our frames).
 
645
     * The meaning is "what will happen when clicking".
 
646
     */
 
647
    virtual MouseMeaning getMouseMeaning( const QPoint &nPoint, int keyState );
 
648
    /**
 
649
     * Return the meaning of clicking inside the frame (when neither Ctrl nor Shift is pressed)
 
650
     */
 
651
    virtual MouseMeaning getMouseMeaningInsideFrame( const KoPoint& );
435
652
 
436
 
    /** which popup (from the XML file) should be shown when right-clicking inside this frame */
437
 
    virtual QString getPopupName() = 0;
 
653
    /** Show a popup menu - called when right-clicking inside a frame of this frameset.
 
654
     * The default implementation shows "frame_popup".
 
655
     * @param frame the frame which was clicked. Always one of ours.
 
656
     * @param view the view - we use it to get the popupmenu by name
 
657
     * @param point the mouse position (at which to show the menu)
 
658
     */
 
659
    virtual void showPopup( KWFrame *frame, KWView *view, const QPoint &point );
438
660
 
439
661
    /** save to XML - when saving */
440
662
    virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true ) = 0;
451
673
    /** Apply the new zoom/resolution - values are to be taken from kWordDocument() */
452
674
    virtual void zoom( bool forPrint );
453
675
 
454
 
    virtual void preparePrinting( QPainter *, QProgressDialog *, int & ) { }
 
676
    //virtual void preparePrinting( QPainter *, QProgressDialog *, int & ) { }
455
677
 
456
678
    /** Called once the frameset has been completely loaded or constructed.
457
679
     * The default implementation calls updateFrames() and zoom(). Call the parent :) */
458
680
    virtual void finalize();
459
681
 
460
682
    virtual int paragraphs() { return 0; }
 
683
    virtual int paragraphsSelected() { return 0; }
461
684
    virtual bool statistics( QProgressDialog */*progress*/,  ulong & /*charsWithSpace*/, ulong & /*charsWithoutSpace*/, ulong & /*words*/,
462
 
        ulong & /*sentences*/, ulong & /*syllables*/ ) { return true; }
 
685
                             ulong & /*sentences*/, ulong & /*syllables*/, ulong & /*lines*/,  bool /*process only selected */ ) { return true; }
463
686
 
464
687
    KWDocument* kWordDocument() const { return m_doc; }
465
688
 
466
689
    // Return true if page @p num can be removed, as far as this frameset is concerned
467
690
    virtual bool canRemovePage( int num );
468
691
 
469
 
    // only used for headers and footers...
470
 
    void setCurrent( int i ) { m_current = i; }
471
 
    int getCurrent() { return m_current; }
472
 
 
473
692
    //Note: none of those floating-frameset methods creates undo/redo
474
693
    //They are _called_ by the undo/redo commands.
475
694
 
476
695
    /** Make this frameset floating, as close to its current position as possible. */
477
696
    void setFloating();
478
697
    /** Make this frameset floating, with the anchor at @p paragId,@p index in the text frameset @p textfs */
479
 
    void setAnchored( KWTextFrameSet* textfs, int paragId, int index, bool placeHolderExists = false );
 
698
    void setAnchored( KWTextFrameSet* textfs, int paragId, int index, bool placeHolderExists = false, bool repaint = true );
480
699
    /** Note that this frameset has been made floating already, and store anchor position */
481
700
    void setAnchored( KWTextFrameSet* textfs );
482
701
    /** Make this frameset fixed, i.e. not anchored */
483
702
    void setFixed();
484
 
    /** Return true if this frameset is floating, false if it's fixed */
 
703
    /** Return true if this frameset is floating (inline), false if it's fixed */
485
704
    bool isFloating() const { return m_anchorTextFs; }
486
705
    /** Return the frameset in which our anchor is - assuming isFloating() */
487
706
    KWTextFrameSet * anchorFrameset() const { return m_anchorTextFs; }
488
707
    /** Return the anchor object for this frame number */
489
708
    KWAnchor * findAnchor( int frameNum );
 
709
    /** Tell this frame the format of it's anchor */
 
710
    virtual void setAnchorFormat( KoTextFormat* /*format*/, int /*frameNum*/ ) {}
490
711
 
491
712
    /** Create an anchor for the floating frame identified by frameNum */
492
 
    virtual KWAnchor * createAnchor( KWTextDocument * textdoc, int frameNum );
 
713
    virtual KWAnchor * createAnchor( KoTextDocument *txt, int frameNum );
493
714
 
494
715
    /** Move the frame frameNum to the given position - this is called when
495
716
        the frame is anchored and the anchor moves (see KWAnchor). */
496
 
    virtual void moveFloatingFrame( int frameNum, const QPoint &position );
497
 
    /** Get the [zoomed] size of the "floating frame" identified by frameNum.
 
717
    virtual void moveFloatingFrame( int frameNum, const KoPoint &position );
 
718
    /** Get the size of the "floating frame" identified by frameNum.
498
719
        By default a real frame but not for tables. */
499
 
    virtual QSize floatingFrameSize( int frameNum );
 
720
    virtual KoSize floatingFrameSize( int frameNum = 0 );
 
721
    /** Get the rect of the "floating frame" identified by frameNum,
 
722
        in coordinates RELATIVE TO THE PARENT FRAMESET.
 
723
        This is especially important for multi-parent inline frames. */
 
724
    KoRect floatingFrameRect( int frameNum = 0 );
500
725
    /** Get the 'baseline' to use for the "floating frame" identified by frameNum.
501
726
        -1 means same as the height (usual case) */
502
727
    virtual int floatingFrameBaseline( int /*frameNum*/ ) { return -1; }
509
734
     * @see KWTableFrameSet
510
735
     */
511
736
    void setGroupManager( KWTableFrameSet *gm ) { grpMgr = gm; }
512
 
    KWTableFrameSet *getGroupManager() { return grpMgr; }
 
737
    /** returns the groupManager this frameset belongs to. A Groupmanager is better known as a table */
 
738
    KWTableFrameSet *getGroupManager()const { return grpMgr; }
513
739
 
514
740
    /** table headers can created by the groupmanager, we store the fact that
515
741
     this is one in here. */
516
742
    void setIsRemoveableHeader( bool h ) { m_removeableHeader = h; }
517
 
    bool isRemoveableHeader() { return m_removeableHeader; }
 
743
    bool isRemoveableHeader()const { return m_removeableHeader; }
518
744
 
519
745
    /** returns if one of our frames has been selected. */
520
746
    bool hasSelectedFrame();
521
747
 
 
748
    bool isProtectSize()const { return m_protectSize; }
 
749
    void setProtectSize( bool _b) { m_protectSize = _b;}
 
750
 
522
751
    /**
523
752
     * Returns true if the frameset is visible.
524
753
     * A frameset is visible if setVisible(false) wasn't called,
525
754
     * but also, for a header frameset, if m_doc->isHeaderVisible is true, etc.
526
755
     * For an "even pages header" frameset, the corresponding headerType setting
527
756
     * must be selected (i.e. different headers for even and odd pages).
 
757
     * @param viewMode pass the current viewmode when using this method for any visual
 
758
     * stuff (drawing, handling input etc.). Frameset visibility depends on the viewmode.
528
759
     */
529
 
    bool isVisible() const;
 
760
    bool isVisible( KWViewMode* viewMode = 0L ) const;
530
761
 
531
762
    /** set the visibility of the frameset. */
532
763
    virtual void setVisible( bool v );
535
766
    QString getName() const { return m_name; }
536
767
    void setName( const QString &_name ) { m_name = _name; }
537
768
 
 
769
    /** set frameBehavior on all frames, see KWFrame for specifics */
 
770
    void setFrameBehavior( KWFrame::FrameBehavior fb );
 
771
 
 
772
    /** set newFrameBehavior on all frames, see KWFrame for specifics */
 
773
    void setNewFrameBehavior( KWFrame::NewFrameBehavior nfb );
 
774
 
538
775
#ifndef NDEBUG
539
776
    virtual void printDebug();
540
777
    virtual void printDebug( KWFrame * );
541
778
#endif
542
779
 
 
780
    virtual KWTextFrameSet* nextTextObject( KWFrameSet * ) { return 0L;}
 
781
 
 
782
    bool isPaintedBy( KWFrameSet* fs ) const;
 
783
 
 
784
    /** set z-order for all frames */
 
785
    virtual void setZOrder();
 
786
 
543
787
signals:
544
788
 
545
789
    // Emitted when something has changed in this frameset,
552
796
    /** save the common attributes for the frameset */
553
797
    void saveCommon( QDomElement &parentElem, bool saveFrames );
554
798
 
555
 
    // Determine the clipping rectangle for drawing the contents of @p frame with @p painter
556
 
    // in the rectangle delimited by @p crect.
 
799
    /**Determine the clipping rectangle for drawing the contents of @p frame with @p painter
 
800
     * in the rectangle delimited by @p crect.
 
801
     * This determines where to clip the painter to draw the contents of a given frame
 
802
     */
557
803
    QRegion frameClipRegion( QPainter * painter, KWFrame *frame, const QRect & crect,
558
 
                             KWViewMode * viewMode, bool onlyChanged );
 
804
                             KWViewMode * viewMode );
559
805
 
560
806
    void deleteAnchor( KWAnchor * anchor );
561
807
    virtual void deleteAnchors();
562
 
    virtual void createAnchors( KWTextParag * parag, int index, bool placeHolderExists = false );
 
808
    virtual void createAnchors( KWTextParag * parag, int index, bool placeHolderExists = false, bool repaint = true );
 
809
 
563
810
 
564
811
    KWDocument *m_doc;            // Document
565
 
    QList<KWFrame> frames;        // Our frames
566
 
    struct FrameOnTop {
567
 
        FrameOnTop() {} // for QValueList
568
 
        FrameOnTop( const KoRect & r, KWFrame * f )
569
 
            : intersection( r ), frame( f ) {}
570
 
        KoRect intersection;
571
 
        KWFrame * frame;
572
 
    };
573
 
    QValueList<FrameOnTop> m_framesOnTop; // List of frames on top of us, those we shouldn't overwrite
 
812
    QPtrList<KWFrame> frames;        // Our frames
 
813
 
 
814
    // Cached info for optimization
 
815
    /** This array provides a direct access to the frames on page N */
 
816
    QPtrVector< QPtrList<KWFrame> > m_framesInPage;
 
817
    /** always equal to m_framesInPage[0].first()->pageNum() :) */
 
818
    int m_firstPage;
 
819
    /** always empty, for convenience in @ref framesInPage */
 
820
    QPtrList<KWFrame> m_emptyList; // ## make static pointer to save memory ?
574
821
 
575
822
    Info m_info;
576
 
    int m_current; // used for headers and footers, not too sure what it means
577
823
    KWTableFrameSet *grpMgr;
578
824
    bool m_removeableHeader, m_visible;
 
825
    bool m_protectSize;
579
826
    QString m_name;
580
827
    KWTextFrameSet * m_anchorTextFs;
581
 
    KWCanvas * m_currentDrawnCanvas;           // The canvas currently being drawn.
 
828
    KWordFrameSetIface *m_dcop;
582
829
};
583
830
 
584
831
/******************************************************************/
590
837
    KWPictureFrameSet( KWDocument *_doc, const QString & name );
591
838
    virtual ~KWPictureFrameSet();
592
839
 
593
 
    virtual FrameSetType type() { return FT_PICTURE; }
594
 
 
595
 
    void setImage( const KWImage &image ) { m_image = image; }
596
 
    KWImage image() const { return m_image; }
597
 
 
598
 
    KoImageKey key() const { return m_image.key(); }
599
 
 
600
 
    void loadImage( const QString &fileName, const QSize &_imgSize );
 
840
    virtual KWordFrameSetIface* dcopObject();
 
841
 
 
842
    /**
 
843
     * The type of frameset. Use this to differentiate between different instantiations of
 
844
     *  the framesets. Each implementation will return a different frameType.
 
845
     */
 
846
    virtual FrameSetType type( void );
 
847
 
 
848
    virtual FrameSetType typeAsKOffice1Dot1( void );
 
849
 
 
850
    void setPicture( const KoPicture &picture ) { m_picture = picture; }
 
851
    KoPicture picture() const { return m_picture; }
 
852
 
 
853
    KoPictureKey key() const { return m_picture.getKey(); }
 
854
 
 
855
    void loadPicture( const QString &fileName );
 
856
    void insertPicture( const KoPicture& picture );
 
857
 
 
858
    /**
 
859
     * Reload a picture, which already exists in the picture collection
 
860
     * (if not, it gives a defaulft KoPicture() )
 
861
     */
 
862
    void reloadPicture( const KoPictureKey& key );
 
863
 
 
864
    /**
 
865
     * @deprecated
 
866
     * The size of the image is now only needed at drawing time, not before anymore.
 
867
     * However at drawing time, it is the frame's size that matters.
 
868
     */
601
869
    void setSize( const QSize & _imgSize );
602
870
 
 
871
    /**
 
872
     * Called when the user resizes a frame.
 
873
     */
 
874
    virtual void resizeFrame( KWFrame* frame, double newWidth, double newHeight, bool finalSize );
 
875
 
603
876
    virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
604
877
    virtual void load( QDomElement &attributes, bool loadFrames = true );
605
878
 
606
 
    virtual void drawFrame( KWFrame *frame, QPainter *painter, const QRect & crect,
607
 
                            QColorGroup &, bool onlyChanged, bool resetChanged,
608
 
                            KWFrameSetEdit *edit = 0L );
 
879
    virtual void drawFrameContents( KWFrame * frame, QPainter *painter, const QRect & crect,
 
880
                                    const QColorGroup &cg, bool onlyChanged, bool resetChanged,
 
881
                                    KWFrameSetEdit * edit, KWViewMode *viewMode );
609
882
 
610
883
    // Pixmaps can be transparent
611
884
    virtual void createEmptyRegion( const QRect &, QRegion &, KWViewMode * ) { }
612
885
 
613
 
    virtual KWFrame *frameByBorder( const QPoint & nPoint );
614
 
 
615
 
    // RMB -> normal frame popup
616
 
    virtual QString getPopupName() { return "frame_popup"; }
617
 
 
618
 
    bool keepAspectRatio() const { return m_keepAspectRatio; }
619
 
    void setKeepAspectRatio( bool b ) { m_keepAspectRatio = b; }
 
886
#ifndef NDEBUG
 
887
    virtual void printDebug( KWFrame* frame );
 
888
#endif
 
889
 
 
890
    bool keepAspectRatio() const;
 
891
    void setKeepAspectRatio( bool b );
620
892
protected:
621
 
    KWImage m_image;
 
893
    /// The picture
 
894
    KoPicture m_picture;
622
895
    bool m_keepAspectRatio;
623
 
};
624
 
 
625
 
/******************************************************************/
626
 
/* Class: KWClipartFrameSet                                       */
627
 
/******************************************************************/
628
 
class KWClipartFrameSet : public KWFrameSet
629
 
{
630
 
public:
631
 
    KWClipartFrameSet( KWDocument *_doc, const QString & name );
632
 
    virtual ~KWClipartFrameSet() {}
633
 
 
634
 
    virtual FrameSetType type() { return FT_CLIPART; }
635
 
 
636
 
    void setClipart( const KoClipart &clipart ) { m_clipart = clipart; }
637
 
    KoClipart clipart() const { return m_clipart; }
638
 
 
639
 
    KoClipartKey key() const { return m_clipart.key(); }
640
 
 
641
 
    void loadClipart( const QString &fileName );
642
 
    //void setSize( const QSize & _imgSize );
643
 
 
644
 
    virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
645
 
    virtual void load( QDomElement &attributes, bool loadFrames = true );
646
 
 
647
 
    virtual void drawFrame( KWFrame *frame, QPainter *painter, const QRect & crect,
648
 
                            QColorGroup &, bool onlyChanged, bool resetChanged,
649
 
                            KWFrameSetEdit *edit = 0L );
650
 
 
651
 
    // Cliparts can be transparent
652
 
    virtual void createEmptyRegion( const QRect &, QRegion &, KWViewMode * ) { }
653
 
 
654
 
    virtual KWFrame *frameByBorder( const QPoint & nPoint );
655
 
 
656
 
    // RMB -> normal frame popup
657
 
    virtual QString getPopupName() { return "frame_popup"; }
658
 
protected:
659
 
    KoClipart m_clipart;
660
 
};
661
 
 
662
 
/******************************************************************/
663
 
/* Class: KWPartFrameSet                                          */
664
 
/******************************************************************/
665
 
 
666
 
class KWPartFrameSet : public KWFrameSet
667
 
{
668
 
    Q_OBJECT
669
 
public:
670
 
    KWPartFrameSet( KWDocument *_doc, KWChild *_child, const QString & name );
671
 
    virtual ~KWPartFrameSet();
672
 
 
673
 
    virtual FrameSetType type() { return FT_PART; }
674
 
 
675
 
    virtual KWFrameSetEdit * createFrameSetEdit( KWCanvas * );
676
 
 
677
 
    KWChild *getChild() { return m_child; }
678
 
 
679
 
    void updateChildGeometry();
680
 
    virtual void updateFrames();
681
 
 
682
 
    virtual void drawFrame( KWFrame * frame, QPainter * p, const QRect & crect,
683
 
                            QColorGroup &, bool onlyChanged, bool resetChanged,
684
 
                            KWFrameSetEdit *edit = 0L );
685
 
 
686
 
    // Embedded parts can be transparent
687
 
    virtual void createEmptyRegion( const QRect &, QRegion &, KWViewMode * ) { }
688
 
 
689
 
    virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
690
 
    virtual void load( QDomElement &attributes, bool loadFrames = true );
691
 
 
692
 
    // RMB -> normal frame popup
693
 
    virtual QString getPopupName() { return "frame_popup"; }
694
 
 
695
 
 
696
 
protected:
697
 
    KWChild *m_child;
698
 
};
699
 
 
700
 
class KWPartFrameSetEdit :  public QObject, public KWFrameSetEdit
701
 
{
702
 
    Q_OBJECT
703
 
public:
704
 
    KWPartFrameSetEdit( KWPartFrameSet * fs, KWCanvas * canvas );
705
 
    virtual ~KWPartFrameSetEdit();
706
 
 
707
 
    KWPartFrameSet * partFrameSet() const
708
 
    {
709
 
        return static_cast<KWPartFrameSet*>(frameSet());
710
 
    }
711
 
 
712
 
    // Events forwarded by the canvas (when being in "edit" mode)
713
 
    virtual void mousePressEvent( QMouseEvent *, const QPoint &, const KoPoint & );
714
 
    virtual void mouseDoubleClickEvent( QMouseEvent *, const QPoint &, const KoPoint & );
715
 
 
716
 
private:
717
 
    KWFramePartMoveCommand *m_cmdMoveChild;
718
 
protected slots:
719
 
    void slotChildChanged();
720
 
    void slotChildActivated(bool);
721
 
};
722
 
 
723
 
/******************************************************************/
724
 
/* Class: KWFormulaFrameSet                                       */
725
 
/******************************************************************/
726
 
 
727
 
class KWFormulaFrameSet : public KWFrameSet
728
 
{
729
 
    Q_OBJECT
730
 
public:
731
 
    KWFormulaFrameSet( KWDocument *_doc, const QString & name );
732
 
    virtual ~KWFormulaFrameSet();
733
 
 
734
 
    virtual FrameSetType type() { return FT_FORMULA; }
735
 
 
736
 
    virtual KWFrameSetEdit* createFrameSetEdit(KWCanvas*);
737
 
 
738
 
    /**
739
 
     * Paint this frameset
740
 
     */
741
 
    virtual void drawFrame(KWFrame *, QPainter*, const QRect&,
742
 
                           QColorGroup&, bool onlyChanged, bool resetChanged,
743
 
                           KWFrameSetEdit *edit = 0L);
744
 
 
745
 
    virtual void updateFrames();
746
 
 
747
 
    virtual QDomElement save( QDomElement &parentElem, bool saveFrames = true );
748
 
    virtual void load( QDomElement &attributes, bool loadFrames = true );
749
 
 
750
 
    /** Apply the new zoom/resolution - values are to be taken from kWordDocument() */
751
 
    virtual void zoom( bool forPrint );
752
 
 
753
 
    KFormula::KFormulaContainer* getFormula() const { return formula; }
754
 
 
755
 
    void setChanged() { m_changed = true; }
756
 
 
757
 
    virtual int floatingFrameBaseline( int /*frameNum*/ );
758
 
 
759
 
    virtual QString getPopupName() { return "Formula";}
760
 
 
761
 
protected slots:
762
 
 
763
 
    void slotFormulaChanged(int width, int height);
764
 
 
765
 
private:
766
 
    KFormula::KFormulaContainer* formula;
767
 
    bool m_changed;
768
 
};
769
 
 
770
 
 
771
 
class KWFormulaFrameSetEdit : public QObject, public KWFrameSetEdit
772
 
{
773
 
    Q_OBJECT
774
 
public:
775
 
    KWFormulaFrameSetEdit(KWFormulaFrameSet* fs, KWCanvas* canvas);
776
 
    virtual ~KWFormulaFrameSetEdit();
777
 
 
778
 
    KWFormulaFrameSet* formulaFrameSet() const
779
 
    {
780
 
        return static_cast<KWFormulaFrameSet*>(frameSet());
781
 
    }
782
 
 
783
 
    KFormula::KFormulaView* getFormulaView() const
784
 
    {
785
 
        return formulaView;
786
 
    }
787
 
 
788
 
    // Events forwarded by the canvas (when being in "edit" mode)
789
 
    virtual void keyPressEvent(QKeyEvent*);
790
 
    virtual void mousePressEvent(QMouseEvent*, const QPoint & n, const KoPoint & d );
791
 
    virtual void mouseMoveEvent(QMouseEvent*, const QPoint & n, const KoPoint & d); // only called if button is pressed
792
 
    virtual void mouseReleaseEvent(QMouseEvent*, const QPoint & n, const KoPoint & d);
793
 
    //virtual void mouseDoubleClickEvent( QMouseEvent *, const QPoint & n, const KoPoint & d ) {}
794
 
    //virtual void dragEnterEvent( QDragEnterEvent * ) {}
795
 
    //virtual void dragMoveEvent( QDragMoveEvent *, const QPoint &, const KoPoint & ) {}
796
 
    //virtual void dragLeaveEvent( QDragLeaveEvent * ) {}
797
 
    //virtual void dropEvent( QDropEvent *, const QPoint &, const KoPoint & ) {}
798
 
    virtual void focusInEvent();
799
 
    virtual void focusOutEvent();
800
 
    virtual void copy();
801
 
    virtual void cut();
802
 
    virtual void paste();
803
 
    virtual void selectAll();
804
 
 
805
 
    /** Moves the cursor to the first position */
806
 
    void moveHome();
807
 
    /** Moves the cursor to the last position */
808
 
    void moveEnd();
809
 
 
810
 
protected slots:
811
 
 
812
 
    /**
813
 
     * Make sure the cursor can be seen at its new position.
814
 
     */
815
 
    void cursorChanged( bool visible, bool selecting );
816
 
 
817
 
private:
818
 
    KFormula::KFormulaView* formulaView;
819
 
};
 
896
    /// Cache the finalSize parameter of the method resizeFrame for drawFrame
 
897
    bool m_finalSize;
 
898
};
 
899
 
 
900
#if 0 // KWORD_HORIZONTAL_LINE
 
901
// MOC_SKIP_BEGIN
 
902
/******************************************************************/
 
903
/* Class: KWHorzLineFrameSet                                      */
 
904
/******************************************************************/
 
905
class KWHorzLineFrameSet : public KWPictureFrameSet
 
906
{
 
907
public:
 
908
    KWHorzLineFrameSet( KWDocument *_doc, const QString & name );
 
909
    virtual ~KWHorzLineFrameSet();
 
910
 
 
911
    virtual KWordFrameSetIface* dcopObject();
 
912
 
 
913
    /**
 
914
     * The type of frameset. Use this to differentiate between different instantiations of
 
915
     *  the framesets. Each implementation will return a different frameType.
 
916
     */
 
917
    virtual FrameSetType type( void );
 
918
    virtual bool ownLine() const;
 
919
    void drawFrameContents( KWFrame *frame, QPainter *painter, const QRect &crect,
 
920
                            const QColorGroup &, bool, bool, KWFrameSetEdit *, KWViewMode * );
 
921
 
 
922
};
 
923
// MOC_SKIP_END
 
924
#endif
820
925
 
821
926
#endif