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