kpresenter

KPrPBPreview.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) 2004 Thorsten Zachmann <zachmann@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 PBPREVIEW_H
00022 #define PBPREVIEW_H
00023 
00024 #include "global.h"
00025 
00026 #include <qframe.h>
00027 
00028 #include "KPrGradient.h"
00029 #include <KoBrush.h>
00030 #include <KoPen.h>
00031 
00032 class KoTextZoomHandler;
00033 
00034 /******************************************************************/
00035 /* class Pen and Brush preview                                    */
00036 /******************************************************************/
00037 
00038 class KPrPBPreview : public QFrame
00039 {
00040     Q_OBJECT
00041 
00042 public:
00043     enum PaintType {
00044         Pen,
00045         Brush,
00046         Gradient
00047     };
00048 
00049     KPrPBPreview( QWidget* parent, const char* name, PaintType _paintType = Pen );
00050     ~KPrPBPreview();
00051     void setPen( const KoPen &_pen ) { pen = _pen; repaint( true ); }
00052     void setBrush( const QBrush &_brush ) { brush = _brush; repaint( true ); }
00053     void setLineBegin( LineEnd lb ) { lineBegin = lb; repaint( true ); }
00054     void setLineEnd( LineEnd le ) { lineEnd = le; repaint( true ); }
00055     void setGradient( KPrGradient *g ) { if ( g ) { gradient = g; } repaint( true ); }
00056     void setPaintType( PaintType pt ) { paintType = pt; repaint(true); }
00057 
00058     void setGradient( const QColor &_c1, const QColor &_c2, BCType _t,
00059                       bool _unbalanced, int _xfactor, int _yfactor );
00060     void setColor1( const QColor &_color ) { gradient->setColor1( _color ); repaint( false ); }
00061     void setColor2( const QColor &_color ) { gradient->setColor2( _color ); repaint( false ); }
00062     void setBackColorType( BCType _type ) { gradient->setBackColorType( _type ); repaint( false ); }
00063     void setUnbalanced( bool b ) { gradient->setUnbalanced( b ); repaint( false ); }
00064     void setXFactor( int i ) { gradient->setXFactor( i ); repaint( false ); }
00065     void setYFactor( int i ) { gradient->setYFactor( i ); repaint( false ); }
00066 
00067 protected:
00068     void drawContents( QPainter *p );
00069     void resizeEvent( QResizeEvent *e );
00070 
00071 private:
00072     PaintType paintType;
00073     KoPen pen;
00074     QBrush brush;
00075     LineEnd lineBegin, lineEnd;
00076     KPrGradient *gradient;
00077     KPrGradient *savedGradient;
00078     KoTextZoomHandler *_zoomHandler;
00079 };
00080 
00081 
00082 #endif  /* PBPREVIEW_H */
KDE Home | KDE Accessibility Home | Description of Access Keys