kpresenter
KPrBackground.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef kpbackground_h
00023 #define kpbackground_h
00024
00025 #include <qsize.h>
00026 #include <qdatetime.h>
00027 #include <KoBrush.h>
00028 #include <KoStyleStack.h>
00029 #include <KoOasisStyles.h>
00030 #include <KoOasisContext.h>
00031
00032 #include <KoPictureCollection.h>
00033
00034 #include "global.h"
00035
00036 class KPrDocument;
00037 class QPainter;
00038 class QPixmap;
00039 class KPrGradientCollection;
00040 class QDomDocument;
00041 class QDomElement;
00042 class KoTextZoomHandler;
00043 class KPrPage;
00044 class KoXmlWriter;
00045 class KoGenStyles;
00046 class KoGenStyle;
00047
00048
00049 class KPrBackGround
00050 {
00051 public:
00052 struct Settings
00053 {
00054 Settings( const BackType backType, const QColor backColor1, const QColor backColor2,
00055 const BCType bcType, const bool unbalanced, const int xfactor, const int yfactor,
00056 const KoPictureKey &key, const BackView backView )
00057 : m_backType( backType )
00058 , m_backColor1( backColor1 )
00059 , m_backColor2( backColor2 )
00060 , m_bcType( bcType )
00061 , m_unbalanced( unbalanced )
00062 , m_xfactor( xfactor )
00063 , m_yfactor( yfactor )
00064 , m_backPictureKey( key )
00065 , m_backView( backView )
00066 {}
00067
00068 BackType m_backType;
00069 QColor m_backColor1;
00070 QColor m_backColor2;
00071
00072 BCType m_bcType;
00073 bool m_unbalanced;
00074
00075 int m_xfactor, m_yfactor;
00076
00077 KoPictureKey m_backPictureKey;
00078 BackView m_backView;
00079 };
00080
00081 KPrBackGround( KPrPage *_page );
00082 ~KPrBackGround() {}
00083
00084 void setBackType( BackType _backType )
00085 {
00086 backType = _backType;
00087 if (backType==BT_PICTURE || backType==BT_CLIPART)
00088 removeGradient();
00089 }
00090 void setBackView( BackView _backView )
00091 { backView = _backView; }
00092 void setBackColor1( const QColor &_color )
00093 { removeGradient(); backColor1 = _color; }
00094 void setBackColor2( const QColor &_color )
00095 { removeGradient(); backColor2 = _color; }
00096 void setBackColorType( BCType _bcType )
00097 { removeGradient(); bcType = _bcType; }
00098 void setBackUnbalanced( bool _unbalanced )
00099 { removeGradient(); unbalanced = _unbalanced; }
00100 void setBackXFactor( int _xfactor )
00101 { removeGradient(); xfactor = _xfactor; }
00102 void setBackYFactor( int _yfactor )
00103 { removeGradient(); yfactor = _yfactor; }
00105 void setBackPicture( const KoPicture& picture );
00106 void setBackPicture ( const KoPictureKey& key );
00107 void setBackGround( const struct Settings &settings );
00108 struct Settings getBackGround() const;
00109
00110 KoPicture picture() const { return backPicture;}
00111
00112 BackType getBackType() const
00113 { return backType; }
00114 BackView getBackView() const
00115 { return backView; }
00116 QColor getBackColor1() const
00117 { return backColor1; }
00118 QColor getBackColor2() const
00119 { return backColor2; }
00120 BCType getBackColorType() const
00121 { return bcType; }
00122 KoPictureKey getBackPictureKey() const
00123 { return backPicture.getKey(); }
00124 KoPicture getBackPicture() const
00125 { return backPicture;}
00126
00127 bool getBackUnbalanced() const
00128 { return unbalanced; }
00129 int getBackXFactor() const
00130 { return xfactor; }
00131 int getBackYFactor() const
00132 { return yfactor; }
00133
00134
00135
00136 void drawBackground( QPainter *_painter, const KoTextZoomHandler* zoomHandler,
00137 const QRect& crect, bool _drawBorders );
00138
00139 void drawBackground( QPainter *_painter, const QSize& ext,
00140 const QRect& crect, bool _drawBorders );
00141
00142 void reload();
00143
00144 QDomElement save( QDomDocument &doc );
00145 void load( const QDomElement &element );
00146 void loadOasis( KoOasisContext & context );
00147 void saveOasisBackgroundPageStyle( KoGenStyle &stylepageauto, KoGenStyles &mainStyles );
00148
00149 protected:
00150 void drawBackColor( QPainter *_painter, const QSize& ext, const QRect& crect );
00151 void drawBackPix( QPainter *_painter, const QSize& ext, const QRect& crect );
00152 void drawBorders( QPainter *_painter, const QSize& ext, const QRect& crect );
00153
00154 void removeGradient();
00155
00156 void generateGradient( const QSize& size );
00157
00158 KoPictureCollection *pictureCollection() const;
00159 KPrGradientCollection *gradientCollection() const;
00160
00161 QString saveOasisPictureStyle( KoGenStyles& mainStyles );
00162
00163 private:
00164 BackType backType;
00165 BackView backView;
00166 QColor backColor1;
00167 QColor backColor2;
00168 BCType bcType;
00169
00170
00171 KoPicture backPicture;
00172
00173
00174 const QPixmap *gradientPixmap;
00175
00176
00177 KPrPage *m_page;
00178
00179
00180
00181
00182 int xfactor, yfactor;
00183
00184
00185 bool unbalanced;
00186 };
00187
00188 #endif
|