kivio

kivio_py_stencil.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KIVIO_PY_STENCIL_H
21#define KIVIO_PY_STENCIL_H
22
23#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
27#include "kivio_stencil.h"
28
29#ifdef HAVE_PYTHON
30
31#include <tqptrlist.h>
32#include <tqcolor.h>
33#include <tqfont.h>
34
35/* slots gets defined in TQt and conflicts with python headers */
36#undef slots
37#include <Python.h>
38#define slots
39
40class KivioPyStencilSpawner;
41class KivioPainter;
42class KivioFillStyle;
43class KivioView;
44
45class KivioPyStencil : public KivioStencil
46{
47
48friend class KivioPyStencilSpawner;
49
50public:
51 KivioPyStencil();
52 virtual ~KivioPyStencil();
53
54
55 virtual bool loadXML( const TQDomElement & );
56 virtual TQDomElement saveXML( TQDomDocument & );
57 virtual void loadConnectorTargetListXML( const TQDomElement & );
58
59 virtual void updateGeometry();
60 virtual KivioStencil *duplicate();
61 virtual KivioCollisionType checkForCollision( KoPoint *pPoint, double );
62 virtual int resizeHandlePositions();
63
64 virtual void paint( KivioIntraStencilData * );
65 virtual void paintOutline( KivioIntraStencilData * );
66 virtual void paint( KivioIntraStencilData * , bool outlined);
67 virtual void paintConnectorTargets( KivioIntraStencilData * );
68 virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *p, double threshHold );
69 virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *p, int targetID );
70
71 virtual int generateIds( int );
72
73 virtual TQColor fgColor();
74 virtual void setFGColor( TQColor );
75
76 virtual void setBGColor( TQColor );
77 virtual TQColor bgColor();
78
79 virtual void setLineWidth( double );
80 virtual double lineWidth();
81
82 // FOnt stuff
83 virtual TQColor textColor();
84 virtual void setTextColor( TQColor );
85
86 virtual TQFont textFont();
87 virtual void setTextFont( const TQFont & );
88
89 virtual int hTextAlign();
90 virtual int vTextAlign();
91
92 virtual void setHTextAlign(int);
93 virtual void setVTextAlign(int);
94
95 virtual void setText( const TQString & );
96 virtual TQString text();
97
98
99protected:
100 PyObject *vars, *globals;
101 TQString resizeCode; // python code to be runed when resize
102 double old_x, old_y, old_w, old_h;
103
104 virtual void rescaleShapes( PyObject * ); // find recursive for x,y,w,h in object( dict or list ) and update them
105
109 virtual void setStyle( KivioIntraStencilData *d, PyObject *style, int &fillStyle );
110 TQColor readColor( PyObject *color ); // used by setStyle
111
112
113 TQPtrList<KivioConnectorTarget> *m_pConnectorTargets;
114
118 int init( TQString initCode);
119
120 int runPython(TQString code);
121 double getDoubleFromDict( PyObject *dict, const char* key );
122 TQString getStringFromDict( PyObject *dict, const char* key );
123
124 void PyDebug( PyObject * ); // show var
125};
126
127#else // HAVE_PYTHON
128
129 #define KivioPyStencil KivioStencil
130
131#endif // HAVE_PYTHON
132
133
134#endif // KIVIO_PY_STENCIL_H
135