summaryrefslogtreecommitdiffstats
path: root/kivio/kiviopart/kiviosdk/kivio_sml_stencil.h
blob: 30e53e9364c4d5d6aa36c5a70ec92362db506d0c (plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 * Kivio - Visual Modelling and Flowcharting
 * Copyright (C) 2000-2003 theKompany.com & Dave Marotti,
 *                         Peter Simonsson
 *
 * 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_SML_STENCIL_H
#define KIVIO_SML_STENCIL_H

#include <tqptrlist.h>

#include "kivio_stencil.h"
class TQDomElement;
class TQColor;
class KivioConnectorTarget;
class KivioFillStyle;
class KivioIntraStencilData;
class KivioLineStyle;
class KivioPainter;
class KivioShape;
class KoZoomHandler;

class KivioSMLStencil : public KivioStencil
{
protected:
    friend class KivioSMLStencilSpawner;

    TQPtrList<KivioShape> *m_pShapeList;
    KivioShape *m_pSubSelection;
    TQPtrList<KivioConnectorTarget> *m_pConnectorTargets;

    // Offsets and scale which get reused in between
    // various drawing routines.  To save time and
    // stack space, we keep them around in the class
    int _xoff, _yoff;
    KoZoomHandler* m_zoomHandler;

// Drawing routines
protected:
    void drawOutlineArc( KivioShape *, KivioIntraStencilData * );
    void drawOutlineBezier( KivioShape *, KivioIntraStencilData * );
    void drawOutlineOpenPath( KivioShape *, KivioIntraStencilData * );
    void drawOutlineClosedPath( KivioShape *, KivioIntraStencilData * );
    void drawOutlinePie( KivioShape *, KivioIntraStencilData * );
    void drawOutlineEllipse( KivioShape *, KivioIntraStencilData * );
    void drawOutlineLineArray( KivioShape *, KivioIntraStencilData * );
    void drawOutlineRectangle( KivioShape *, KivioIntraStencilData * );
    void drawOutlineRoundRectangle( KivioShape *, KivioIntraStencilData * );
    void drawOutlinePolygon( KivioShape *, KivioIntraStencilData * );
    void drawOutlinePolyline( KivioShape *, KivioIntraStencilData * );
    void drawOutlineTextBox( KivioShape *, KivioIntraStencilData * );

    void drawArc( KivioShape *, KivioIntraStencilData * );
    void drawBezier( KivioShape *, KivioIntraStencilData * );
    void drawOpenPath( KivioShape *, KivioIntraStencilData * );
    void drawClosedPath( KivioShape *, KivioIntraStencilData * );
    void drawPie( KivioShape *, KivioIntraStencilData * );
    void drawEllipse( KivioShape *, KivioIntraStencilData * );
    void drawLineArray( KivioShape *, KivioIntraStencilData * );
    void drawRectangle( KivioShape *, KivioIntraStencilData * );
    void drawRoundRectangle( KivioShape *, KivioIntraStencilData * );
    void drawPolygon( KivioShape *, KivioIntraStencilData * );
    void drawPolyline( KivioShape *, KivioIntraStencilData * );
    void drawTextBox( KivioShape *, KivioIntraStencilData * );

    bool checkCollisionArc( KivioShape *, KoPoint * );
    bool checkCollisionBezier( KivioShape *, KoPoint * );
    bool checkCollisionOpenPath( KivioShape *, KoPoint * );
    bool checkCollisionClosedPath( KivioShape *, KoPoint * );
    bool checkCollisionPie( KivioShape *, KoPoint * );
    bool checkCollisionEllipse( KivioShape *, KoPoint * );
    bool checkCollisionLineArray( KivioShape *, KoPoint * );
    bool checkCollisionRectangle( KivioShape *, KoPoint * );
    bool checkCollisionRoundRectangle( KivioShape *, KoPoint * );
    bool checkCollisionPolygon( KivioShape *, KoPoint * );
    bool checkCollisionPolyline( KivioShape *, KoPoint * );
    bool checkCollisionTextBox( KivioShape *, KoPoint * );


    KivioShape *locateShape( const TQString & );
    void loadConnectorTargetListXML( const TQDomElement & );

public:
    KivioSMLStencil();
    virtual ~KivioSMLStencil();


    virtual bool loadXML( const TQDomElement & );
    virtual TQDomElement saveXML( TQDomDocument & );

    virtual TQPtrList<KivioShape> *tqshapeList() { return m_pShapeList; }
    virtual KivioShape *subSelection() { return m_pSubSelection; }

    virtual void paintOutline( KivioIntraStencilData * );
    virtual void paint( KivioIntraStencilData * );
    virtual void paintConnectorTargets( KivioIntraStencilData * );

    virtual KivioStencil *duplicate();

    virtual TQColor fgColor();
    virtual TQColor bgColor();
    virtual void setFGColor(TQColor);
    virtual void setBGColor(TQColor);
    virtual void setLineWidth(double);
    virtual double lineWidth();
    virtual void setLinePattern(int p);
    virtual int linePattern();
    virtual void setFillPattern(int p);
    virtual int fillPattern();

    virtual void setTextColor( TQColor );
    virtual void setTextFont( const TQFont & );

    virtual void setHTextAlign(int);
    virtual void setVTextAlign(int);

    virtual int hTextAlign();
    virtual int vTextAlign();

    virtual TQString text();
    virtual void setText( const TQString & );

    virtual TQFont textFont();
    virtual TQColor textColor();

    virtual KivioCollisionType checkForCollision( KoPoint *, double );

    virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *, double );
    virtual KivioConnectorTarget *connectToTarget( KivioConnectorPoint *, int );
    
    virtual KoPoint snapToTarget( const KoPoint& p, double thresh, bool& hit );

    virtual void updateGeometry();

    virtual int generateIds( int );

    virtual int resizeHandlePositions();

    virtual KivioLineStyle lineStyle();
    virtual void setLineStyle(KivioLineStyle ls);

    /**
      Returns the name of the text box that is at @param p.
      If there exist no text box at @param p then it returns TQString().
    */
    virtual TQString getTextBoxName(const KoPoint& p);

    virtual void setText(const TQString& text, const TQString& name);
    virtual TQString text(const TQString& name);

    virtual void addConnectorTarget(const KoPoint&);
    virtual void removeConnectorTarget(const KoPoint&);

    virtual bool hasTextBox() const;

    virtual TQColor textColor(const TQString& textBoxName);
    virtual void setTextColor(const TQString& textBoxName, const TQColor& color);

    virtual TQFont textFont(const TQString& textBoxName);
    virtual void setTextFont(const TQString& textBoxName, const TQFont& font);

    virtual int hTextAlign(const TQString& textBoxName);
    virtual int vTextAlign(const TQString& textBoxName);

    virtual void setHTextAlign(const TQString& textBoxName, int align);
    virtual void setVTextAlign(const TQString& textBoxName, int align);
};

#endif