summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/widgetbase.h
blob: 41a7629fbb93fe221b472efa76c1cfee8bb828d3 (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/***************************************************************************
 *                                                                         *
 *   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) 2004-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef WIDGETBASE_H
#define WIDGETBASE_H

#include <tqobject.h>
#include <tqcolor.h>
#include <tqdom.h>

#include "umlnamespace.h"

// forward declarations
class UMLView;
class UMLObject;

/**
 * @short       Common base class for UMLWidget and AssociationWidget
 * @author      Oliver Kellogg <okellogg@users.sourceforge.net>
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
 */
class WidgetBase : public TQObject {
    Q_OBJECT
  
public:
    /**
     * Creates a WidgetBase object.
     *
     * @param view      The view to be displayed on.
     */
    WidgetBase(UMLView * view);

    /**
     * Standard deconstructor
     */
    virtual ~WidgetBase() {}

    /**
     * Write property of m_Type.
     */
    void setBaseType(Uml::Widget_Type type);

    /**
     * Read property of m_Type.
     */
    Uml::Widget_Type getBaseType() const;

    /**
     * Returns the @ref UMLObject set to represent.
     *
     * @return the UMLObject to represent.
     */
    UMLObject *getUMLObject();

    /**
     * Deliver a const pointer to the connected UMLView
     * ( needed esp. by event handling of LinePath )
     */
    const UMLView *getUMLView() const { return m_pView; }

    /**
     * Sets the @ref UMLObject to represent.
     *
     * @param o The object to represent.
     */
    virtual void setUMLObject(UMLObject * o);

    /**
     * Used by some child classes to get documentation.
     *
     * @return  The documentation from the UMLObject (if m_pObject is set.)
     */
    virtual TQString getDoc() const;

    /**
     * Used by some child classes to set documentation.
     *
     * @param doc       The documentation to be set in the UMLObject
     *          (if m_pObject is set.)
     */
    virtual void setDoc( const TQString &doc );

    /**
     * Sets the line colour
     *
     * @param colour the new line colour
     */
    virtual void setLineColor(const TQColor &colour);

    /**
     * Sets the line width
     *
     * @param width the new line width
     */
    virtual void setLineWidth(uint width);

    /**
     * Read property of m_LineColour.
     */
    TQColor getLineColor() const {
        return m_LineColour;
    }

    /**
     * Read property of m_LineWidth.
     */
    uint getLineWidth() const {
        return m_LineWidth;
    }

    /**
     * Returns m_bUsesDiagramLineColour
     */
    bool getUsesDiagramLineColour() const {
        return m_bUsesDiagramLineColour;
    }

    /**
     * Returns m_bUsesDiagramLineWidth
     */
    bool getUsesDiagramLineWidth() const {
        return m_bUsesDiagramLineWidth;
    }

    /**
     * Sets m_bUsesDiagramLineColour
     */
    void setUsesDiagramLineColour(bool usesDiagramLineColour) {
        m_bUsesDiagramLineColour = usesDiagramLineColour;
    }

    /**
     * Sets m_bUsesDiagramLineWidth
     */
    void setUsesDiagramLineWidth(bool usesDiagramLineWidth) {
        m_bUsesDiagramLineWidth = usesDiagramLineWidth;
    }

    /**
    * Write property of m_nId.
    */
    void setID( Uml::IDType id );

    /**
    * Read property of m_nId.
    */
    Uml::IDType getID() const;

    virtual void saveToXMI( TQDomDocument & qDoc, TQDomElement & qElement );

    virtual bool loadFromXMI( TQDomElement & qElement );

protected:
    /**
     * Initialize members.
     */
    void init(UMLView *view, Uml::Widget_Type type = Uml::wt_UMLWidget);

    /**
     * Type of widget.
     */
    Uml::Widget_Type m_Type;

    UMLView   *m_pView;
    UMLObject *m_pObject;
    TQString m_Doc;  ///< Only used if m_pObject is not set.

    /**
     * This ID is only used when the widget does not have a
     * corresponding UMLObject (i.e. the m_pObject pointer is NULL.)
     * For UMLObjects, the ID from the UMLObject is used.
     */
    Uml::IDType m_nId;

    /**
     * Color of the lines of the widget. Is saved to XMI.
     */
    TQColor m_LineColour;

    /**
     * Width of the lines of the widget. Is saved to XMI.
     */
    uint m_LineWidth;

    /**
     * true by default, false if the colours have
     * been explicitly set for this widget.
     * These are saved to XMI.
     */
    bool m_bUsesDiagramLineColour, m_bUsesDiagramLineWidth;

};

#endif