libs/flake

KoPatternBackground.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KOPATTERNBACKGROUND_H
00021 #define KOPATTERNBACKGROUND_H
00022 
00023 #include "KoShapeBackground.h"
00024 #include "flake_export.h"
00025 #include <QtGui/QMatrix>
00026 
00027 class KoImageCollection;
00028 
00030 class FLAKE_EXPORT KoPatternBackground : public KoShapeBackground
00031 {
00032 public:
00034     enum PatternRepeat { Original, Tiled, Stretched };
00036     enum ReferencePoint { TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight };
00037 
00039     KoPatternBackground(KoImageCollection *collection);
00040 
00041     virtual ~KoPatternBackground();
00042 
00044     void setMatrix(const QMatrix &matrix);
00045 
00047     QMatrix matrix() const;
00048 
00050     void setPattern(const QImage &pattern);
00052     QImage pattern();
00053 
00055     void setRepeat(PatternRepeat repeat);
00056 
00058     PatternRepeat repeat() const;
00059 
00061     ReferencePoint referencePoint() const;
00062 
00064     void setReferencePoint(ReferencePoint referencePoint);
00065 
00067     QPointF referencePointOffset() const;
00068 
00070     void setReferencePointOffset(const QPointF &offset);
00071 
00073     QPointF tileRepeatOffset() const;
00074 
00076     void setTileRepeatOffset(const QPointF &offset);
00077 
00079     QSizeF patternDisplaySize() const;
00080 
00082     void setPatternDisplaySize(const QSizeF &size);
00083 
00085     QSizeF patternOriginalSize() const;
00086 
00088     KoPatternBackground& operator = (const KoPatternBackground &rhs);
00089 
00091     virtual void paint(QPainter &painter, const QPainterPath &fillPath) const;
00093     virtual void fillStyle(KoGenStyle &style, KoShapeSavingContext &context);
00095     virtual bool loadStyle(KoOdfLoadingContext & context, const QSizeF &shapeSize);
00096 
00098     QRectF patternRectFromFillSize(const QSizeF &size);
00099 private:
00100     class Private;
00101     Private * const d;
00102 };
00103 
00104 #endif // KOPATTERNBACKGROUND_H