summaryrefslogtreecommitdiffstats
path: root/kivio/kiviopart/kiviosdk/kivio_1d_stencil.h
blob: b42d650b2aa562bcd20c1624639fe450ca6d9616 (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
#ifndef _KIVIO_1D_STENCIL_H
#define _KIVIO_1D_STENCIL_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqdom.h>
#include <tqptrlist.h>

#include <koffice_export.h>

#include "kivio_stencil.h"
#include "kivio_text_style.h"

class KivioArrowHead;
class KivioConnectorPoint;
class KivioCustomDragData;
class KivioFillStyle;
class KivioLineStyle;
class KivioIntraStencilData;
class KivioStencil;


class KIVIO_EXPORT Kivio1DStencil : public KivioStencil
{
protected:
    TQPtrList <KivioConnectorPoint> *m_pConnectorPoints;

    KivioConnectorPoint *m_pStart, *m_pEnd;
    KivioConnectorPoint *m_pLeft, *m_pRight;
    KivioConnectorPoint *m_pTextConn;

    double m_connectorWidth;
    bool m_needsWidth;
    bool m_needsText;

    KivioFillStyle *m_pFillStyle;
    KivioLineStyle *m_pLineStyle;
    KivioTextStyle *m_pTextStyle;

    // Utility routines
    bool boolAllTrue( bool *, int );
    bool boolContainsFalse( bool *, int );

    virtual TQDomElement createRootElement( TQDomDocument & );

    virtual bool saveCustom( TQDomElement &, TQDomDocument & );
    TQDomElement saveConnectors( TQDomDocument &doc );
    TQDomElement saveProperties( TQDomDocument &doc );

    virtual bool loadCustom( const TQDomElement & );
    bool loadConnectors( const TQDomElement & );
    bool loadProperties( const TQDomElement & );

    // For easier duplication
    void copyBasicInto( Kivio1DStencil * );
    void drawText( KivioIntraStencilData * );

public:
    Kivio1DStencil();
    virtual ~Kivio1DStencil();

    virtual bool connected();

    // fg color functions
    virtual void setFGColor( TQColor c );
    virtual TQColor fgColor();


    // bg color functions
    virtual void setBGColor( TQColor c );
    virtual TQColor bgColor();

    virtual void setText( const TQString & t ) { m_pTextStyle->setText(t); }
    virtual TQString text() { return m_pTextStyle->text(); }

    virtual void setTextColor( TQColor c ) { m_pTextStyle->setColor(c); }
    virtual TQColor textColor() { return m_pTextStyle->color(); }

    virtual TQFont textFont() { return m_pTextStyle->font(); }
    virtual void setTextFont( const TQFont &f ) { m_pTextStyle->setFont(f); }

    virtual int hTextAlign() { return m_pTextStyle->hTextAlign(); }
    virtual int vTextAlign() { return m_pTextStyle->vTextAlign(); }

    virtual void setHTextAlign(int i) { m_pTextStyle->setHTextAlign(i); }
    virtual void setVTextAlign(int i) { m_pTextStyle->setVTextAlign(i); }


    // line width functions
    virtual void setLineWidth( double f );
    virtual double lineWidth();

    virtual void setLinePattern(int p);
    virtual int linePattern();

    virtual void setFillPattern(int p);
    virtual int fillPattern();

    // position functions
    virtual void setX( double );
    virtual void setY( double );
    virtual void setPosition( double, double );


    // required for connector tool
    virtual void setStartPoint( double, double );
    virtual void setEndPoint( double, double );


    // painting functions
    virtual void paint( KivioIntraStencilData * );
    virtual void paintOutline( KivioIntraStencilData * );
    virtual void paintConnectorTargets( KivioIntraStencilData * );
    virtual void paintSelectionHandles( KivioIntraStencilData * );


    // collision detection
    virtual KivioCollisionType checkForCollision( KoPoint *, double );


    // custom dragging
    virtual void customDrag( KivioCustomDragData * );


    // tqgeometry management
    virtual void updateGeometry();
    virtual void updateConnectorPoints( KivioConnectorPoint *, double, double );


    // file i/o routines
    virtual bool loadXML( const TQDomElement & );
    virtual TQDomElement saveXML( TQDomDocument & );


    // duplication routines
    virtual KivioStencil* duplicate();


    // connection search routines
    virtual void searchForConnections( KivioPage * );
    virtual void searchForConnections( KivioPage *pPage, double threshold );


    // returns which resize handles are valid
    virtual int resizeHandlePositions();

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

    virtual void setCustomIDPoint(int customID, const KoPoint& point, KivioPage* page);
    virtual KoPoint customIDPoint(int customID);
};


#endif