kpresenter

KPrGradient.h

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@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; either
00008    version 2 of the License, or (at your option) any later version.
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 kpgradient_h
00022 #define kpgradient_h
00023 
00024 #include <qcolor.h>
00025 #include <KoBrush.h>
00026 #include <kpixmap.h>
00027 #include "global.h"
00028 
00029 class QPainter;
00030 class KoTextZoomHandler;
00031 
00040 class KPrGradient
00041 {
00042 public:
00043     KPrGradient( const QColor &_color1, const QColor &_color2, BCType _bcType,
00044                 bool _unbalanced, int _xfactor, int _yfactor );
00045     ~KPrGradient() {}
00046 
00047     QColor getColor1() const { return color1; }
00048     QColor getColor2() const { return color2; }
00049     BCType getBackColorType() const { return bcType; }
00050     bool getUnbalanced() const { return unbalanced; }
00051     int getXFactor() const { return xFactor; }
00052     int getYFactor() const { return yFactor; }
00053 
00054     void setColor1( const QColor &_color ) { color1 = _color; m_bDirty = true; }
00055     void setColor2( const QColor &_color ) { color2 = _color; m_bDirty = true; }
00056     void setBackColorType( BCType _type ) { bcType = _type; m_bDirty = true; }
00057     void setUnbalanced( bool b ) { unbalanced = b; m_bDirty = true; }
00058     void setXFactor( int i ) { xFactor = i; m_bDirty = true; }
00059     void setYFactor( int i ) { yFactor = i; m_bDirty = true; }
00060     void setSize( const QSize& _size )
00061         {
00062             if ( size() != _size ) {
00063                 m_pixmap.resize( _size );
00064                 m_bDirty = true;
00065             }
00066         }
00067 
00068     // Sets all of the above at once. Used when loading.
00069     void setParameters(const QColor &c1, const QColor &c2, BCType _type,
00070                        bool _unbalanced, int xf, int yf);
00071 
00075     const QPixmap& pixmap() const;
00076     QSize size() const { return m_pixmap.size(); }
00077 
00078     void addRef();
00079     bool removeRef();
00080 
00081 protected:
00083     void paint();
00084 
00085     KPrGradient() {}
00086 
00087     QColor color1, color2;
00088     BCType bcType;
00089 
00090     KPixmap m_pixmap;
00091     int refCount;
00092     int xFactor, yFactor;
00093     bool unbalanced;
00094     bool m_bDirty;
00095 };
00096 
00097 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys