kivio

kivio_painter.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program 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
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #ifndef KIVIO_PAINTER_H
00020 #define KIVIO_PAINTER_H
00021 
00022 #include <qfont.h>
00023 #include <qptrlist.h>
00024 #include <qpaintdevice.h>
00025 #include <qpixmap.h>
00026 #include <qpointarray.h>
00027 #include <qwmatrix.h>
00028 
00029 #include "kivio_fill_style.h"
00030 
00031 class KivioPoint;
00032 class KivioFillStyle;
00033 class KivioLineStyle;
00034 
00035 class KivioPainter
00036 {
00037 protected:
00038     KivioFillStyle *m_pFillStyle;
00039     KivioLineStyle *m_pLineStyle;
00040 
00041     QColor m_textColor;
00042 
00043 public:
00044     KivioPainter();
00045     virtual ~KivioPainter();
00046 
00047     virtual bool start( QPaintDevice * ) { return false;}
00048     virtual bool stop() { return false;}
00049 
00050 
00051     /*\
00052     |*|
00053     |*|
00054     |*| PROPERTY SETTINGS
00055     |*|
00056     |*| (probably don't need to reimplement -- unless you are optimizing)
00057     \*/
00058     virtual float lineWidth() const;
00059     virtual void setLineWidth( const float &f );
00060 
00061     // virtual void setClipRect( QRect * );
00062     // virtual QRect *clipRect();
00063 
00064     virtual QColor fgColor() const;
00065     virtual void setFGColor( const QColor &c );
00066 
00067     virtual QColor bgColor() const { return m_pFillStyle->color(); }
00068     virtual void setBGColor( const QColor &c ) { m_pFillStyle->setColor(c); }
00069 
00070     virtual QColor textColor() const { return m_textColor; }
00071     virtual void setTextColor( const QColor &c ) { m_textColor = c; }
00072 
00073     virtual KivioFillStyle *fillStyle() { return m_pFillStyle; }
00074 
00075     virtual void setLineStyle( KivioLineStyle * );
00076     virtual void setFillStyle( KivioFillStyle * );
00077 
00078     /*\
00079     |*|
00080     |*|
00081     |*| PRIMITIVE FUNCTIONS
00082     |*|
00083     |*| (all descendants *must* reimplement these)
00084     \*/
00085     virtual void drawLine( float, float, float, float ) {;}
00086     virtual void drawArc( float, float, float, float, float, float ) {;}
00087 
00088     virtual void drawBezier( QPtrList<KivioPoint> * ) {;}
00089     virtual void drawBezier( QPointArray & ) {;}
00090 
00091     virtual void drawRect( float, float, float, float ) {;}
00092     virtual void fillRect( float, float, float, float ) {;}
00093 
00094     virtual void drawRoundRect( float, float, float, float, float, float ) {;}
00095     virtual void fillRoundRect( float, float, float, float, float, float ) {;}
00096 
00097     virtual void drawEllipse( float, float, float, float ) {;}
00098     virtual void fillEllipse( float, float, float, float ) {;}
00099 
00100     virtual void drawPie( float, float, float, float, float, float ) {;}
00101     virtual void fillPie( float, float, float, float, float, float ) {;}
00102 
00103     virtual void drawChord( float, float, float, float, float, float ) {;}
00104     virtual void fillChord( float, float, float, float, float, float ) {;}
00105 
00106     virtual void drawOpenPath( QPtrList<KivioPoint> * ) {;}
00107     virtual void drawClosedPath( QPtrList<KivioPoint> * ) {;}
00108 
00109     virtual void drawLineArray( QPtrList<KivioPoint> * ) {;}
00110     virtual void drawPolyline( QPtrList<KivioPoint> * ) {;}
00111     virtual void drawPolygon( QPtrList<KivioPoint> * ) {;}
00112 
00113     virtual void drawLineArray( QPointArray & ) {;}
00114     virtual void drawPolyline( QPointArray & ) {;}
00115     virtual void drawPolygon( QPointArray & ) {;}
00116 
00117     virtual void setFont( const QFont & ) {;}
00118     virtual void drawText( int, int, int, int, int, const QString & ) {;}
00119     virtual QRect boundingRect( int, int, int, int, int, const QString & ) { return QRect(0,0,100,100); }
00120 
00121 
00122     // These shouldn't be used for anything except the screen painter right now...
00123     virtual void drawPixmap( float, float, const QPixmap & ) {;}
00124 
00125     /*\
00126     |*| Miscellaneous Functions
00127     |*| note: These don't need to be implemented by everything
00128     \*/
00129     // connector point flags
00130     enum {
00131        cpfConnectable=0x1,
00132        cpfStart=0x2,
00133        cpfEnd=0x4,
00134        cpfConnected=0x8,
00135        cpfLock=0x10
00136     };
00137     virtual void drawHandle( float, float, int ) { ; }
00138     virtual void drawSelectionBox( const QRect& ) { ; }
00139 
00140     virtual void saveState() {;}
00141     virtual void restoreState() {;}
00142     virtual void setTranslation(float, float) {;}
00143     virtual void translateBy(float, float) {;}
00144     virtual void setRotation(int) {;}
00145     virtual void rotateBy(int) {;}
00146     virtual int rotation() { return 0; }
00147 
00148     virtual void setWorldMatrix(QWMatrix, bool) {;}
00149 };
00150 
00151 #endif
00152 
00153 
KDE Home | KDE Accessibility Home | Description of Access Keys