kword

KWFrameStyle.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>
3 2005 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; using
8 version 2 of the License.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef kwframestyle_h
22#define kwframestyle_h
23
24#include <KoUserStyle.h>
25#include <KoUserStyleCollection.h>
26
27#include "KoBorder.h"
28#include <tqbrush.h>
29
30class TQDomElement;
31class KoOasisContext;
32class KoSavingContext;
33class KoGenStyles;
34class KWFrameStyle;
35class KWFrame;
36
41class KWFrameStyle : public KoUserStyle
42{
43public:
45 KWFrameStyle( const TQString & name );
46
47 KWFrameStyle( const TQString & name, KWFrame * frame );
48 KWFrameStyle( TQDomElement & parentElem, int docVersion=2 );
49
51 KWFrameStyle( const KWFrameStyle & rhs );
52 void operator=( const KWFrameStyle& rhs );
53
54 ~KWFrameStyle() {}
55
56 enum { Borders = 1,
57 Background = 2
58 } Flags;
59
60 int compare( const KWFrameStyle & frameStyle ) const;
61
62 // ATTRIBUTES
63 TQBrush backgroundColor() const { return m_backgroundColor; }
64 void setBackgroundColor( const TQBrush &_color ) { m_backgroundColor = _color; }
65
66 const KoBorder & leftBorder() const { return m_borderLeft; }
67 void setLeftBorder( KoBorder _left ) { m_borderLeft = _left; }
68
69 const KoBorder & rightBorder() const { return m_borderRight; }
70 void setRightBorder( KoBorder _right ) { m_borderRight = _right; }
71
72 const KoBorder & topBorder() const { return m_borderTop; }
73 void setTopBorder( KoBorder _top ) { m_borderTop = _top; }
74
75 const KoBorder & bottomBorder() const { return m_borderBottom; }
76 void setBottomBorder( KoBorder _bottom ) { m_borderBottom = _bottom; }
77
79 void saveFrameStyle( TQDomElement & parentElem );
81 void saveOasis( KoGenStyles& mainStyles, KoSavingContext& savingContext ) const;
82
84 static KWFrameStyle *loadStyle( TQDomElement & parentElem, int docVersion=2 );
86 void loadOasis( TQDomElement & styleElem, KoOasisContext& context );
87
88private:
89 TQBrush m_backgroundColor;
90 KoBorder m_borderLeft, m_borderRight, m_borderTop, m_borderBottom;
91};
92
96class KWFrameStyleCollection : public KoUserStyleCollection
97{
98public:
100
101 static TQString defaultStyleName() { return TQString::fromLatin1( "Plain" ); }
102
107 KWFrameStyle* findStyle( const TQString & name ) const {
108 return static_cast<KWFrameStyle*>( KoUserStyleCollection::findStyle( name, defaultStyleName() ) );
109 }
110
116 KWFrameStyle* findStyleByDisplayName( const TQString & name ) const {
117 return static_cast<KWFrameStyle*>( KoUserStyleCollection::findStyleByDisplayName( name ) );
118 }
119
125 return static_cast<KWFrameStyle*>( KoUserStyleCollection::addStyle( sty ) );
126 }
127
131 KWFrameStyle* frameStyleAt( int i ) const {
132 return static_cast<KWFrameStyle*>( m_styleList[i] );
133 }
134
135 void saveOasis( KoGenStyles& mainStyles, KoSavingContext& savingContext ) const;
136 int loadOasisStyles( KoOasisContext& context );
137};
138
139#endif
Collection of frame styles.
KWFrameStyle * findStyle(const TQString &name) const
Find style based on the untranslated name name.
KWFrameStyle * addStyle(KWFrameStyle *sty)
See KoUserStyleCollection::addStyle.
KWFrameStyle * frameStyleAt(int i) const
Return style number i.
KWFrameStyle * findStyleByDisplayName(const TQString &name) const
Find style based on the display name name.
The user-visible style for frames (borders and background)
static KWFrameStyle * loadStyle(TQDomElement &parentElem, int docVersion=2)
load (old xml format)
void saveOasis(KoGenStyles &mainStyles, KoSavingContext &savingContext) const
save (new oasis xml format)
void loadOasis(TQDomElement &styleElem, KoOasisContext &context)
load (new oasis xml format)
void saveFrameStyle(TQDomElement &parentElem)
save (old xml format)
This class represents a single frame.
Definition KWFrame.h:68