kivio

kivio_py_stencil.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 
00020 #ifndef KIVIO_PY_STENCIL_H
00021 #define KIVIO_PY_STENCIL_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include "kivio_stencil.h"
00028 
00029 #ifdef HAVE_PYTHON
00030 
00031 #include <qptrlist.h>
00032 #include <qcolor.h>
00033 #include <qfont.h>
00034 
00035 /* slots gets defined in Qt 3.2 and conflicts with python 2.3 headers */
00036 #undef slots
00037 #include <Python.h>
00038 #define slots
00039 
00040 class KivioPyStencilSpawner;
00041 class KivioPainter;
00042 class KivioFillStyle;
00043 class KivioView;
00044 
00045 class KivioPyStencil : public KivioStencil
00046 {
00047 
00048 friend class KivioPyStencilSpawner;
00049 
00050 public:
00051     KivioPyStencil();
00052     virtual ~KivioPyStencil();
00053 
00054 
00055     virtual bool loadXML( const QDomElement & );
00056     virtual QDomElement saveXML( QDomDocument & );
00057     virtual void loadConnectorTargetListXML( const QDomElement & );
00058 
00059     virtual void updateGeometry();
00060     virtual KivioStencil *duplicate();
00061     virtual KivioCollisionType checkForCollision( KoPoint *pPoint, double );
00062     virtual int resizeHandlePositions();
00063 
00064     virtual void paint( KivioIntraStencilData * );
00065     virtual void paintOutline( KivioIntraStencilData * );
00066     virtual void paint( KivioIntraStencilData * , bool outlined);
00067     virtual void paintConnectorTargets( KivioIntraStencilData * );
00068     virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *p, double threshHold );
00069     virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *p, int targetID );
00070 
00071     virtual int generateIds( int );
00072 
00073     virtual QColor fgColor();
00074     virtual void setFGColor( QColor );
00075 
00076     virtual void setBGColor( QColor );
00077     virtual QColor bgColor();
00078 
00079     virtual void setLineWidth( double );
00080     virtual double lineWidth();
00081 
00082     // FOnt stuff
00083     virtual QColor textColor();
00084     virtual void setTextColor( QColor );
00085 
00086     virtual QFont textFont();
00087     virtual void setTextFont( const QFont & );
00088 
00089     virtual int hTextAlign();
00090     virtual int vTextAlign();
00091 
00092     virtual void setHTextAlign(int);
00093     virtual void setVTextAlign(int);
00094 
00095     virtual void setText( const QString & );
00096     virtual QString text();
00097 
00098 
00099 protected:
00100     PyObject *vars, *globals;
00101     QString resizeCode; // python code to be runed when resize
00102     double old_x, old_y, old_w, old_h;
00103 
00104     virtual void rescaleShapes( PyObject * ); // find recursive for x,y,w,h in object( dict or list ) and update them
00105 
00109     virtual void setStyle( KivioIntraStencilData *d, PyObject *style, int &fillStyle );
00110     QColor readColor( PyObject *color ); // used by setStyle
00111 
00112 
00113     QPtrList<KivioConnectorTarget> *m_pConnectorTargets;
00114 
00118     int init( QString initCode);
00119 
00120     int runPython(QString code);
00121     double getDoubleFromDict( PyObject *dict, const char* key );
00122     QString getStringFromDict( PyObject *dict, const char* key );
00123 
00124     void PyDebug( PyObject * ); // show var
00125 };
00126 
00127 #else // HAVE_PYTHON
00128 
00129   #define KivioPyStencil KivioStencil
00130 
00131 #endif // HAVE_PYTHON
00132 
00133 
00134 #endif // KIVIO_PY_STENCIL_H
00135 
KDE Home | KDE Accessibility Home | Description of Access Keys