kword

KWFrameStyle.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>
00003                  2005 David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; using
00008    version 2 of the License.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef kwframestyle_h
00022 #define kwframestyle_h
00023 
00024 #include <KoUserStyle.h>
00025 #include <KoUserStyleCollection.h>
00026 
00027 #include "KoBorder.h"
00028 #include <qbrush.h>
00029 
00030 class QDomElement;
00031 class KoOasisContext;
00032 class KoSavingContext;
00033 class KoGenStyles;
00034 class KWFrameStyle;
00035 class KWFrame;
00036 
00041 class KWFrameStyle : public KoUserStyle
00042 {
00043 public:
00045     KWFrameStyle( const QString & name );
00046 
00047     KWFrameStyle( const QString & name, KWFrame * frame );
00048     KWFrameStyle( QDomElement & parentElem, int docVersion=2 );
00049 
00051     KWFrameStyle( const KWFrameStyle & rhs );
00052     void operator=( const KWFrameStyle& rhs );
00053 
00054     ~KWFrameStyle() {}
00055 
00056     enum { Borders = 1,
00057            Background = 2
00058     } Flags;
00059 
00060     int compare( const KWFrameStyle & frameStyle ) const;
00061 
00062     // ATTRIBUTES
00063     QBrush backgroundColor() const { return m_backgroundColor; }
00064     void setBackgroundColor( const QBrush &_color ) { m_backgroundColor = _color; }
00065 
00066     const KoBorder & leftBorder() const { return m_borderLeft; }
00067     void setLeftBorder( KoBorder _left )  { m_borderLeft = _left; }
00068 
00069     const KoBorder & rightBorder() const { return m_borderRight; }
00070     void setRightBorder( KoBorder _right )  { m_borderRight = _right; }
00071 
00072     const KoBorder & topBorder() const { return m_borderTop; }
00073     void setTopBorder( KoBorder _top )  { m_borderTop = _top; }
00074 
00075     const KoBorder & bottomBorder() const { return m_borderBottom; }
00076     void setBottomBorder( KoBorder _bottom )  { m_borderBottom = _bottom; }
00077 
00079     void saveFrameStyle( QDomElement & parentElem );
00081     void saveOasis( KoGenStyles& mainStyles, KoSavingContext& savingContext ) const;
00082 
00084     static KWFrameStyle *loadStyle( QDomElement & parentElem, int docVersion=2 );
00086     void loadOasis( QDomElement & styleElem, KoOasisContext& context );
00087 
00088 private:
00089     QBrush m_backgroundColor;
00090     KoBorder m_borderLeft, m_borderRight, m_borderTop, m_borderBottom;
00091 };
00092 
00096 class KWFrameStyleCollection : public KoUserStyleCollection
00097 {
00098 public:
00099     KWFrameStyleCollection();
00100 
00101     static QString defaultStyleName() { return QString::fromLatin1( "Plain" ); }
00102 
00107     KWFrameStyle* findStyle( const QString & name ) const {
00108         return static_cast<KWFrameStyle*>( KoUserStyleCollection::findStyle( name, defaultStyleName() ) );
00109     }
00110 
00116     KWFrameStyle* findStyleByDisplayName( const QString & name ) const {
00117         return static_cast<KWFrameStyle*>( KoUserStyleCollection::findStyleByDisplayName( name ) );
00118     }
00119 
00124     KWFrameStyle* addStyle( KWFrameStyle* sty ) {
00125         return static_cast<KWFrameStyle*>( KoUserStyleCollection::addStyle( sty ) );
00126     }
00127 
00131     KWFrameStyle* frameStyleAt( int i ) const {
00132         return static_cast<KWFrameStyle*>( m_styleList[i] );
00133     }
00134 
00135     void saveOasis( KoGenStyles& mainStyles, KoSavingContext& savingContext ) const;
00136     int loadOasisStyles( KoOasisContext& context );
00137 };
00138 
00139 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys