kword

KWFrame.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999, 2000 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C) 2000-2006 David Faure <faure@kde.org>
00004    Copyright (C) 2005 Thomas Zander <zander@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef frame_h
00023 #define frame_h
00024 
00025 #include "defs.h"
00026 #include <KoRect.h>
00027 #include <qbrush.h>
00028 #include "KoBorder.h"
00029 #include <qptrlist.h>
00030 
00031 class KWCanvas;
00032 class KWDocument;
00033 class KWFrame;
00034 class KWFrameList;
00035 class KWFrameSet;
00036 class KWViewMode;
00037 
00038 class KoGenStyle;
00039 class KoGenStyles;
00040 class KoOasisContext;
00041 class KoStyleStack;
00042 class KoXmlWriter;
00043 
00044 class QDomElement;
00045 
00055 class ZOrderedFrameList : public QPtrList<KWFrame>
00056 {
00057 protected:
00058     virtual int compareItems(QPtrCollection::Item a, QPtrCollection::Item b);
00059 };
00060 
00061 
00069 class KWFrame : public KoRect
00070 {
00071 public:
00077     enum RunAround { RA_NO = 0, RA_BOUNDINGRECT = 1, RA_SKIP = 2 };
00078 
00081     enum RunAroundSide { RA_BIGGEST = 0, RA_LEFT = 1, RA_RIGHT = 2 };
00082 
00091     KWFrame(KWFrameSet *fs, double left, double top, double width, double height,
00092             RunAround ra = RA_BOUNDINGRECT);
00093     KWFrame(KWFrame * frame);
00096     virtual ~KWFrame();
00097 
00098     double runAroundLeft() const { return m_runAroundLeft; }
00099     double runAroundRight() const { return m_runAroundRight; }
00100     double runAroundTop() const { return m_runAroundTop; }
00101     double runAroundBottom() const { return m_runAroundBottom; }
00102 
00103     void setRunAroundGap( double left, double right, double top, double bottom ) {
00104         m_runAroundLeft = left;
00105         m_runAroundRight = right;
00106         m_runAroundTop = top;
00107         m_runAroundBottom = bottom;
00108     }
00109 
00110     RunAround runAround()const { return m_runAround; }
00111     void setRunAround( RunAround _ra ) { m_runAround = _ra; }
00112 
00113     RunAroundSide runAroundSide() const { return m_runAroundSide; }
00114     void setRunAroundSide( RunAroundSide rs ) { m_runAroundSide = rs; }
00115 
00118     enum FrameBehavior { AutoExtendFrame=0 , AutoCreateNewFrame=1, Ignore=2 };
00119 
00120     FrameBehavior frameBehavior()const { return m_frameBehavior; }
00121     void setFrameBehavior( FrameBehavior fb ) { m_frameBehavior = fb; }
00122 
00123     /* Frame duplication properties */
00124 
00128     enum SheetSide { AnySide=0, OddSide=1, EvenSide=2};
00129     SheetSide sheetSide()const { return m_sheetSide; }
00130     void setSheetSide( SheetSide ss ) { m_sheetSide = ss; }
00131 
00134     enum NewFrameBehavior { Reconnect=0, NoFollowup=1, Copy=2 };
00135     NewFrameBehavior newFrameBehavior()const { return m_newFrameBehavior; }
00136     void setNewFrameBehavior( NewFrameBehavior nfb ) { m_newFrameBehavior = nfb; }
00137 
00140     bool isCopy()const { return m_bCopy; }
00141     void setCopy( bool copy ) { m_bCopy = copy; }
00142 
00145     KWFrameSet *frameSet() const { return m_frameSet; }
00146     void setFrameSet( KWFrameSet *fs ) { m_frameSet = fs; }
00147 
00150     int pageNumber() const;
00153     int pageNumber( KWDocument* doc ) const;
00154 
00157     void setZOrder( int z ) { m_zOrder = z; }
00158     int zOrder() const { return m_zOrder; }
00159 
00165     static bool compareFrameZOrder(KWFrame *f1, KWFrame *f2);
00166 
00167     KWFrameList* frameStack() { return m_frameStack; }
00168     void setFrameStack(KWFrameList *fl) { m_frameStack = fl; }
00169 
00172     const KoBorder &leftBorder() const { return m_borderLeft; }
00173     const KoBorder &rightBorder() const { return m_borderRight; }
00174     const KoBorder &topBorder() const { return m_borderTop; }
00175     const KoBorder &bottomBorder() const { return m_borderBottom; }
00176 
00177 
00178     void setLeftBorder( KoBorder _brd ) { m_borderLeft = _brd; }
00179     void setRightBorder( KoBorder _brd ) { m_borderRight = _brd; }
00180     void setTopBorder( KoBorder _brd ) { m_borderTop = _brd; }
00181     void setBottomBorder( KoBorder _brd ) { m_borderBottom = _brd; }
00182 
00186     QRect outerRect( KWViewMode* viewMode ) const;
00187 
00192     KoRect outerKoRect() const;
00193 
00197     KoRect runAroundRect() const;
00198 
00203     const KoRect& rect() const { return *this; }
00204 
00208     void frameBordersChanged();
00209     void updateRulerHandles();
00210 
00211     QBrush backgroundColor() const { return m_backgroundColor; }
00212     void setBackgroundColor( const QBrush &_color );
00213     bool isTransparent() const { return m_backgroundColor.style() != Qt::SolidPattern; }
00214 
00215     KoRect innerRect() const;
00216 
00217     double innerWidth() const;
00218     double innerHeight() const;
00219 
00220 
00225     void setInternalY( double y ) { m_internalY = y; }
00226     double internalY() const { return m_internalY; }
00227 
00229     void setPaddingLeft( double b ) { m_paddingLeft = b; }
00231     void setPaddingRight( double b ) { m_paddingRight = b; }
00233     void setPaddingTop( double b ) { m_paddingTop = b; }
00235     void setPaddingBottom( double b ) { m_paddingBottom = b; }
00236 
00238     double paddingLeft() const { return m_paddingLeft; }
00240     double paddingRight() const { return m_paddingRight; }
00242     double paddingTop() const { return m_paddingTop; }
00244     double paddingBottom() const { return m_paddingBottom; }
00245 
00246     void setFramePadding( double _left, double _top, double right, double bottom);
00249     KWFrame *getCopy();
00250 
00251     void copySettings(KWFrame *frm);
00252 
00255     void save( QDomElement &frameElem );
00258     void load( QDomElement &frameElem, KWFrameSet* frameSet, int syntaxVersion );
00259     void loadCommonOasisProperties( KoOasisContext& context, KWFrameSet* frameSet, const char* typeProperties );
00260     void loadBorderProperties( KoStyleStack& styleStack );
00261 
00262     QString saveOasisFrameStyle( KoGenStyles& mainStyles ) const;
00268     void startOasisFrame( KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, const QString& name,
00269                           const QString& lastFrameName = QString::null ) const;
00270     void saveBorderProperties( KoGenStyle& frameStyle ) const;
00271     void saveMarginProperties( KoGenStyle& frameStyle ) const;
00272     void saveMarginAttributes( KoXmlWriter &writer ) const;
00273 
00281     void setMinimumFrameHeight(double h) { m_minFrameHeight = h; }
00286     double minimumFrameHeight(void)const {return m_minFrameHeight;}
00287 
00292     bool frameAtPos( const QPoint& nPoint, bool borderOfFrameOnly=false ) const;
00293 
00299     void setDrawFootNoteLine( bool b ) { m_drawFootNoteLine = b; }
00300     bool drawFootNoteLine()const { return m_drawFootNoteLine; }
00301 
00302 private:
00303     SheetSide m_sheetSide : 2;
00304     RunAround m_runAround : 2;
00305     RunAroundSide m_runAroundSide : 2;
00306     FrameBehavior m_frameBehavior : 2;
00307     NewFrameBehavior m_newFrameBehavior : 2;
00308     bool m_bCopy;
00309     bool m_drawFootNoteLine;
00310 
00311     double m_runAroundLeft, m_runAroundRight, m_runAroundTop, m_runAroundBottom;
00312     double m_paddingLeft, m_paddingRight, m_paddingTop, m_paddingBottom;
00313     double m_minFrameHeight;
00314 
00315     double m_internalY;
00316     int m_zOrder;
00317 
00318     QBrush m_backgroundColor;
00319     KoBorder m_borderLeft, m_borderRight, m_borderTop, m_borderBottom;
00320 
00324     KWFrameList *m_frameStack;
00325     KWFrameSet *m_frameSet;
00326 
00329     KWFrame &operator=( const KWFrame &_frame );
00332     KWFrame ( const KWFrame &_frame );
00333 };
00334 
00335 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys