kword

KWFrame.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999, 2000 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2000-2006 David Faure <faure@kde.org>
4 Copyright (C) 2005 Thomas Zander <zander@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef frame_h
23#define frame_h
24
25#include "defs.h"
26#include <KoRect.h>
27#include <tqbrush.h>
28#include "KoBorder.h"
29#include <tqptrlist.h>
30
31class KWCanvas;
32class KWDocument;
33class KWFrame;
34class KWFrameList;
35class KWFrameSet;
36class KWViewMode;
37
38class KoGenStyle;
39class KoGenStyles;
40class KoOasisContext;
41class KoStyleStack;
42class KoXmlWriter;
43
44class TQDomElement;
45
53class ZOrderedFrameList : public TQPtrList<KWFrame>
54{
55protected:
56 virtual int compareItems(TQPtrCollection::Item a, TQPtrCollection::Item b);
57};
58
59
67class KWFrame : public KoRect
68{
69public:
75 enum RunAround { RA_NO = 0, RA_BOUNDINGRECT = 1, RA_SKIP = 2 };
76
79 enum RunAroundSide { RA_BIGGEST = 0, RA_LEFT = 1, RA_RIGHT = 2 };
80
89 KWFrame(KWFrameSet *fs, double left, double top, double width, double height,
90 RunAround ra = RA_BOUNDINGRECT);
91 KWFrame(KWFrame * frame);
94 virtual ~KWFrame();
95
96 double runAroundLeft() const { return m_runAroundLeft; }
97 double runAroundRight() const { return m_runAroundRight; }
98 double runAroundTop() const { return m_runAroundTop; }
99 double runAroundBottom() const { return m_runAroundBottom; }
100
101 void setRunAroundGap( double left, double right, double top, double bottom ) {
102 m_runAroundLeft = left;
103 m_runAroundRight = right;
104 m_runAroundTop = top;
105 m_runAroundBottom = bottom;
106 }
107
108 RunAround runAround()const { return m_runAround; }
109 void setRunAround( RunAround _ra ) { m_runAround = _ra; }
110
111 RunAroundSide runAroundSide() const { return m_runAroundSide; }
112 void setRunAroundSide( RunAroundSide rs ) { m_runAroundSide = rs; }
113
116 enum FrameBehavior { AutoExtendFrame=0 , AutoCreateNewFrame=1, Ignore=2 };
117
118 FrameBehavior frameBehavior()const { return m_frameBehavior; }
119 void setFrameBehavior( FrameBehavior fb ) { m_frameBehavior = fb; }
120
121 /* Frame duplication properties */
122
126 enum SheetSide { AnySide=0, OddSide=1, EvenSide=2};
127 SheetSide sheetSide()const { return m_sheetSide; }
128 void setSheetSide( SheetSide ss ) { m_sheetSide = ss; }
129
132 enum NewFrameBehavior { Reconnect=0, NoFollowup=1, Copy=2 };
133 NewFrameBehavior newFrameBehavior()const { return m_newFrameBehavior; }
134 void setNewFrameBehavior( NewFrameBehavior nfb ) { m_newFrameBehavior = nfb; }
135
138 bool isCopy()const { return m_bCopy; }
139 void setCopy( bool copy ) { m_bCopy = copy; }
140
143 KWFrameSet *frameSet() const { return m_frameSet; }
144 void setFrameSet( KWFrameSet *fs ) { m_frameSet = fs; }
145
148 int pageNumber() const;
151 int pageNumber( KWDocument* doc ) const;
152
155 void setZOrder( int z ) { m_zOrder = z; }
156 int zOrder() const { return m_zOrder; }
157
163 static bool compareFrameZOrder(KWFrame *f1, KWFrame *f2);
164
165 KWFrameList* frameStack() { return m_frameStack; }
166 void setFrameStack(KWFrameList *fl) { m_frameStack = fl; }
167
170 const KoBorder &leftBorder() const { return m_borderLeft; }
171 const KoBorder &rightBorder() const { return m_borderRight; }
172 const KoBorder &topBorder() const { return m_borderTop; }
173 const KoBorder &bottomBorder() const { return m_borderBottom; }
174
175
176 void setLeftBorder( KoBorder _brd ) { m_borderLeft = _brd; }
177 void setRightBorder( KoBorder _brd ) { m_borderRight = _brd; }
178 void setTopBorder( KoBorder _brd ) { m_borderTop = _brd; }
179 void setBottomBorder( KoBorder _brd ) { m_borderBottom = _brd; }
180
184 TQRect outerRect( KWViewMode* viewMode ) const;
185
190 KoRect outerKoRect() const;
191
195 KoRect runAroundRect() const;
196
201 const KoRect& rect() const { return *this; }
202
206 void frameBordersChanged();
207 void updateRulerHandles();
208
209 TQBrush backgroundColor() const { return m_backgroundColor; }
210 void setBackgroundColor( const TQBrush &_color );
211 bool isTransparent() const { return m_backgroundColor.style() != TQt::SolidPattern; }
212
213 KoRect innerRect() const;
214
215 double innerWidth() const;
216 double innerHeight() const;
217
218
223 void setInternalY( double y ) { m_internalY = y; }
224 double internalY() const { return m_internalY; }
225
227 void setPaddingLeft( double b ) { m_paddingLeft = b; }
229 void setPaddingRight( double b ) { m_paddingRight = b; }
231 void setPaddingTop( double b ) { m_paddingTop = b; }
233 void setPaddingBottom( double b ) { m_paddingBottom = b; }
234
236 double paddingLeft() const { return m_paddingLeft; }
238 double paddingRight() const { return m_paddingRight; }
240 double paddingTop() const { return m_paddingTop; }
242 double paddingBottom() const { return m_paddingBottom; }
243
244 void setFramePadding( double _left, double _top, double right, double bottom);
247 KWFrame *getCopy();
248
249 void copySettings(KWFrame *frm);
250
253 void save( TQDomElement &frameElem );
256 void load( TQDomElement &frameElem, KWFrameSet* frameSet, int syntaxVersion );
257 void loadCommonOasisProperties( KoOasisContext& context, KWFrameSet* frameSet, const char* typeProperties );
258 void loadBorderProperties( KoStyleStack& styleStack );
259
260 TQString saveOasisFrameStyle( KoGenStyles& mainStyles ) const;
266 void startOasisFrame( KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, const TQString& name,
267 const TQString& lastFrameName = TQString() ) const;
268 void saveBorderProperties( KoGenStyle& frameStyle ) const;
269 void saveMarginProperties( KoGenStyle& frameStyle ) const;
270 void saveMarginAttributes( KoXmlWriter &writer ) const;
271
279 void setMinimumFrameHeight(double h) { m_minFrameHeight = h; }
284 double minimumFrameHeight(void)const {return m_minFrameHeight;}
285
290 bool frameAtPos( const TQPoint& nPoint, bool borderOfFrameOnly=false ) const;
291
297 void setDrawFootNoteLine( bool b ) { m_drawFootNoteLine = b; }
298 bool drawFootNoteLine()const { return m_drawFootNoteLine; }
299
300private:
301 SheetSide m_sheetSide : 2;
302 RunAround m_runAround : 2;
303 RunAroundSide m_runAroundSide : 2;
304 FrameBehavior m_frameBehavior : 2;
305 NewFrameBehavior m_newFrameBehavior : 2;
306 bool m_bCopy;
307 bool m_drawFootNoteLine;
308
309 double m_runAroundLeft, m_runAroundRight, m_runAroundTop, m_runAroundBottom;
310 double m_paddingLeft, m_paddingRight, m_paddingTop, m_paddingBottom;
311 double m_minFrameHeight;
312
313 double m_internalY;
314 int m_zOrder;
315
316 TQBrush m_backgroundColor;
317 KoBorder m_borderLeft, m_borderRight, m_borderTop, m_borderBottom;
318
322 KWFrameList *m_frameStack;
323 KWFrameSet *m_frameSet;
324
327 KWFrame &operator=( const KWFrame &_frame );
330 KWFrame ( const KWFrame &_frame );
331};
332
333#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 class calculates and caches a list of frames that are on top or below the KWFrame instance this ...
Definition KWFrameList.h:32
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
Definition KWFrameSet.h:62
This class represents a single frame.
Definition KWFrame.h:68
bool frameAtPos(const TQPoint &nPoint, bool borderOfFrameOnly=false) const
Return if the point is on the frame.
Definition KWFrame.cpp:718
NewFrameBehavior
What happens on new page (create a new frame and reconnect, no followup, make copy).
Definition KWFrame.h:132
TQRect outerRect(KWViewMode *viewMode) const
Return the zoomed rectangle for this frame, including the border - for drawing.
Definition KWFrame.cpp:185
double minimumFrameHeight(void) const
Definition KWFrame.h:284
KWFrameSet * frameSet() const
Data stucture methods.
Definition KWFrame.h:143
double paddingTop() const
get top padding
Definition KWFrame.h:240
double paddingBottom() const
get bottom padding
Definition KWFrame.h:242
void setPaddingLeft(double b)
set left padding (distance between frame contents and frame border)
Definition KWFrame.h:227
void setDrawFootNoteLine(bool b)
Only applicable to frames of the main text frameset.
Definition KWFrame.h:297
void setMinimumFrameHeight(double h)
The property minimum frame height is used to make the automatic frame shrinking code stop.
Definition KWFrame.h:279
static bool compareFrameZOrder(KWFrame *f1, KWFrame *f2)
This is a method used to sort a list using the STL sorting methods.
Definition KWFrame.cpp:750
virtual ~KWFrame()
Destructor.
Definition KWFrame.cpp:103
void setPaddingRight(double b)
set right padding
Definition KWFrame.h:229
FrameBehavior
what should happen when the frame is full
Definition KWFrame.h:116
void setZOrder(int z)
The z-order of the frame, relative to the other frames on the same page.
Definition KWFrame.h:155
void save(TQDomElement &frameElem)
create XML to describe yourself
Definition KWFrame.cpp:222
RunAround
Runaround types RA_NO = No run around, all text is just printed.
Definition KWFrame.h:75
void setPaddingBottom(double b)
set bottom padding
Definition KWFrame.h:233
void setInternalY(double y)
The "internal Y" is the offset (in pt) of the real frame showed in this one ("real" means "the last t...
Definition KWFrame.h:223
double paddingLeft() const
get left padding
Definition KWFrame.h:236
bool isCopy() const
Drawing property: if isCopy, this frame is a copy of the previous frame in the frameset.
Definition KWFrame.h:138
double paddingRight() const
get right padding
Definition KWFrame.h:238
void setPaddingTop(double b)
set top padding
Definition KWFrame.h:231
int pageNumber() const
The page on which this frame is.
Definition KWFrame.cpp:116
const KoBorder & leftBorder() const
All borders can be custom drawn with their own colors etc.
Definition KWFrame.h:170
KoRect outerKoRect() const
Return the unzoomed rectangle, including the border, for the frames-on-top list.
Definition KWFrame.cpp:200
void startOasisFrame(KoXmlWriter &xmlWriter, KoGenStyles &mainStyles, const TQString &name, const TQString &lastFrameName=TQString()) const
Write out a draw:frame element and its style.
Definition KWFrame.cpp:544
void load(TQDomElement &frameElem, KWFrameSet *frameSet, int syntaxVersion)
read attributes from XML.
Definition KWFrame.cpp:340
RunAroundSide
Runaround side - only meaningful when RA_BOUNDINGRECT is used.
Definition KWFrame.h:79
KoRect runAroundRect() const
Return the rectangle for this frame including the border and the runaround gap.
Definition KWFrame.cpp:212
KWFrame(KWFrameSet *fs, double left, double top, double width, double height, RunAround ra=RA_BOUNDINGRECT)
Constructor.
Definition KWFrame.cpp:70
const KoRect & rect() const
Return the rectangle for this frame.
Definition KWFrame.h:201
KWFrame * getCopy()
returns a copy of self
Definition KWFrame.cpp:135
SheetSide
This frame will only be copied to: AnySide, OddSide or EvenSide.
Definition KWFrame.h:126
void frameBordersChanged()
Marks a frame to have changed position/borders.
Definition KWFrame.cpp:167
Abstract base class for KWCanvas's view modes.
Definition KWViewMode.h:48
small utility class representing a sortable (by z-order) list of frames you can use sort() and inSort...
Definition KWFrame.h:54