summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/seqlinewidget.h
blob: 0d7695cb69389abb4498a8be67921b4e7cd3070d (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
/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   copyright (C) 2002-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef SETLINEWIDGET_H
#define SETLINEWIDGET_H

#include <tqcanvas.h>

class UMLView;
class ObjectWidget;

/**
 * @short Widget class for graphical representation of sequence lines
 * @author Paul Hensgen
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
 */
class SeqLineWidget : public TQCanvasLine {
public:
    /**
     * Constructor.
     */
    SeqLineWidget( UMLView * pView, ObjectWidget * pObject );

    /**
     * Destructor.
     */
    ~SeqLineWidget();

    /**
     * Return whether on seq. line.
     * Takes into account destruction box if shown.
     *
     * @param p The point to investigate.
     * @return  Non-zero if point is on this sequence line.
     */
    int onWidget(const TQPoint & p);

    /**
     * Clean up anything before deletion.
     */
    void cleanup();

    /**
     * Set up destruction box.
     */
    void setupDestructionBox();

    /**
     * Set the start point of the line.
     *
     * @param startX    X coordinate of the start point.
     * @param startY    Y coordinate of the start point.
     */
    void setStartPoint( int startX, int startY );

    /**
     * Gets the length of the line.
     *
     * @return  Length of the line.
     */
    int getLineLength() {
        return m_nLengthY;
    }

    /**
     * Returns the @ref ObjectWidget associated with this sequence line.
     *
     * @return  Pointer to the associated ObjectWidget.
     */
    ObjectWidget * getObjectWidget() {
        return m_pObject;
    }

    /**
     * Sets the y position of the bottom of the vertical line.
     *
     * @param yPosition The y coordinate for the bottom of the line.
     */
    void setEndOfLine(int yPosition);

protected:
    /**
     * Clean up destruction box.
     */
    void cleanupDestructionBox();

    /**
     * Move destruction box.
     */
    void moveDestructionBox();

    /**
     * ObjectWidget associated with this sequence line.
     */
    ObjectWidget * m_pObject;

    /**
     * View displayed on.
     */
    UMLView * m_pView;

    /// The destruction box.
    struct DestructionBox {
        TQCanvasLine * line1;
        TQCanvasLine * line2;
        void setLine1Points(TQRect rect) {
            line1->setPoints( rect.x(), rect.y(),
                              rect.x() + rect.width(), rect.y() + rect.height() );
        }
        void setLine2Points(TQRect rect) {
            line2->setPoints( rect.x(), rect.y() + rect.height(),
                              rect.x() + rect.width(), rect.y() );
        }
    } m_DestructionBox;

    /**
     * The length of the line.
     */
    int m_nLengthY;

    /**
     * Margin used for mouse clicks.
     */
    static int const m_nMouseDownEpsilonX;
};

#endif