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 class KoPatternBackgroundPrivate;
00029 
00031 class FLAKE_EXPORT KoPatternBackground : public KoShapeBackground
00032 {
00033 public:
00035     enum PatternRepeat {
00036         Original,
00037         Tiled,
00038         Stretched
00039     };
00041     enum ReferencePoint {
00042         TopLeft,
00043         Top,
00044         TopRight,
00045         Left,
00046         Center,
00047         Right,
00048         BottomLeft,
00049         Bottom,
00050         BottomRight
00051     };
00052 
00054     KoPatternBackground(KoImageCollection *collection);
00055 
00056     virtual ~KoPatternBackground();
00057 
00059     void setMatrix(const QMatrix &matrix);
00060 
00062     QMatrix matrix() const;
00063 
00065     void setPattern(const QImage &pattern);
00067     QImage pattern();
00068 
00070     void setRepeat(PatternRepeat repeat);
00071 
00073     PatternRepeat repeat() const;
00074 
00076     ReferencePoint referencePoint() const;
00077 
00079     void setReferencePoint(ReferencePoint referencePoint);
00080 
00082     QPointF referencePointOffset() const;
00083 
00085     void setReferencePointOffset(const QPointF &offset);
00086 
00088     QPointF tileRepeatOffset() const;
00089 
00091     void setTileRepeatOffset(const QPointF &offset);
00092 
00094     QSizeF patternDisplaySize() const;
00095 
00097     void setPatternDisplaySize(const QSizeF &size);
00098 
00100     QSizeF patternOriginalSize() const;
00101 
00103     KoPatternBackground& operator=(const KoPatternBackground &other);
00104 
00106     virtual void paint(QPainter &painter, const QPainterPath &fillPath) const;
00108     virtual void fillStyle(KoGenStyle &style, KoShapeSavingContext &context);
00110     virtual bool loadStyle(KoOdfLoadingContext &context, const QSizeF &shapeSize);
00111 
00113     QRectF patternRectFromFillSize(const QSizeF &size);
00114 private:
00115     Q_DECLARE_PRIVATE(KoPatternBackground)
00116 };
00117 
00118 #endif // KOPATTERNBACKGROUND_H