~ubuntu-branches/ubuntu/utopic/tcm/utopic

« back to all changes in this revision

Viewing changes to src/dg/gshape.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------------
 
2
// 
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#ifndef _GSHAPE_H
 
23
#define _GSHAPE_H
 
24
 
 
25
#include "linestyle.h"
 
26
#include "textshape.h"
 
27
#include "shape.h"
 
28
class Node;
 
29
 
 
30
// Each GShape has a name TextShape. Some derived classes of GShape
 
31
// can have additional TextShapes. Therefore, sometimes, in the comments
 
32
// we speak about text shapes.
 
33
 
 
34
/// (abstract) graphical shape class, superclass of box, ellipse, line etc.
 
35
class GShape: public Shape {
 
36
/*@Doc: {\large {\bf scope:} diagram} */
 
37
public:
 
38
        /// constructor, creates shape at position (x,y).
 
39
        GShape(ShapeView *v, Grafport *g, int x, int y); 
 
40
        /// 
 
41
        GShape(const GShape &);
 
42
        ///
 
43
        virtual ~GShape();
 
44
 
 
45
        ///
 
46
        void Draw();
 
47
        ///
 
48
        void Undraw();
 
49
 
 
50
        /// draw the shape and all child shapes
 
51
        void DrawWithChildren();
 
52
        /// undraw the shape and all child shapes
 
53
        void UndrawWithChildren();
 
54
 
 
55
        /// draw the shape.
 
56
        virtual void DrawShape() = 0;
 
57
        ///
 
58
        virtual void UndrawShape() {DrawShape();}
 
59
 
 
60
        /// 
 
61
        virtual void DrawTextShapes() {name->Draw();}
 
62
        ///
 
63
        virtual void UndrawTextShapes() {DrawTextShapes();}
 
64
 
 
65
        /// update string of name text shape and redraw.
 
66
        virtual void UpdateNameString(const string *s);
 
67
 
 
68
        /// update subject's parent and redraw.
 
69
        virtual void UpdateParent(Node *parent);
 
70
 
 
71
        /// 
 
72
        virtual void SetNameString(const string *s) {name->SetString(s);}
 
73
        /// 
 
74
        const string *GetNameString() {return name->GetString();}
 
75
 
 
76
        ///
 
77
        TextShape *GetName() const {return name;}
 
78
        /// 
 
79
        virtual void SetTextShape(); 
 
80
        /// select this shape and its text shapes are selected.
 
81
        virtual void SetSelect(bool s);
 
82
 
 
83
        ///
 
84
        unsigned GetLineWidth() const {return lineWidth;}
 
85
        ///
 
86
        void SetLineWidth(unsigned n) {lineWidth=n;}
 
87
        ///     
 
88
        void UpdateLineWidth(unsigned n);
 
89
 
 
90
        ///
 
91
        LineStyle::Type GetLineStyle() const {return lineStyle;}
 
92
        ///
 
93
        void SetLineStyle(LineStyle::Type x) {lineStyle=x;}
 
94
        ///
 
95
        void UpdateLineStyle(LineStyle::Type x);
 
96
 
 
97
        ///
 
98
        const string *GetTextColor() const {return name->GetColor();}
 
99
        ///
 
100
        void UpdateTextColor(const string *c);
 
101
 
 
102
        /// Returns if gs is contained in the child area of this shape.
 
103
        virtual bool ContainsChild(const GShape * /* gs */ ) const
 
104
        {
 
105
                return False;
 
106
        }
 
107
 
 
108
        /// Returns if (x,y) is in name, and if so returns name.
 
109
        virtual TextShape *HitTextShape(int x, int y);
 
110
 
 
111
        /// return if it has t as one of the text shapes.
 
112
        virtual bool HasTextShape(TextShape *t) const {return name==t;}
 
113
 
 
114
        /// refinements of those shape members.
 
115
        virtual int GetLeftMost() const; 
 
116
        ///
 
117
        virtual int GetTopMost() const;
 
118
        ///
 
119
        virtual int GetRightMost() const;
 
120
        ///
 
121
        virtual int GetBottomMost() const;
 
122
 
 
123
        ///
 
124
        bool IsFixedName() {return fixedName;}
 
125
        ///
 
126
        void SetFixedName(bool b) {fixedName=b;}
 
127
        
 
128
        /// set grafport of itself and its text shapes.
 
129
        virtual void SetGrafport(Grafport *g);
 
130
 
 
131
        /// set view of itself and its text shapes.
 
132
        virtual void SetView(ShapeView *v);
 
133
 
 
134
        /// update font and redraw.
 
135
        virtual void UpdateFont(XFont *ft);
 
136
 
 
137
        /// update text alignments and redraw.
 
138
        virtual void UpdateAlignment(TextAlign::Type alignment);
 
139
 
 
140
        /// return a text shape near (x,y).
 
141
        virtual TextShape *ChooseTextShape(int, int);
 
142
 
 
143
        /// react on movement of some text shape.
 
144
        virtual void NotifyTextMove(TextShape *) {}
 
145
 
 
146
        /// return font of the textshapes (all textshapes have same font).
 
147
        XFont *GetFont() const {return name->GetFont();}
 
148
 
 
149
        ///
 
150
        TextAlign::Type GetAlignment() const {return name->GetAlignment();}
 
151
 
 
152
        /// return if name text shape contains 's'.
 
153
        virtual bool HasNameString(const string *s, bool c1, bool c2) const {
 
154
                return fixedName? 0:name->HasString(s, c1, c2); }
 
155
 
 
156
        /// return if some text shape contains 's'.
 
157
        virtual bool HasString(const string *s, bool c1, bool c2) const {
 
158
                return fixedName?0:name->HasString(s, c1, c2); }
 
159
 
 
160
        /// put all textshapes containing 's' in the list l.
 
161
        virtual bool HasString(const string *s, bool cI, bool aS, 
 
162
                List<TextShape *> *l) {
 
163
                        return fixedName? 0:name->HasString(s, cI, aS, l);}
 
164
 
 
165
        /// Check also that name reference is ok.
 
166
        bool CheckReferences();
 
167
protected:
 
168
 
 
169
        /// set fonts of text shapes.
 
170
        virtual void SetFont(XFont *ft) {name->SetFont(ft);}
 
171
 
 
172
        /// set color of text shapes.
 
173
        virtual void SetTextColor(const string *c) {name->SetColor(c);}
 
174
 
 
175
        /// write line width and style to file.
 
176
        void WriteGraphicsPart(OutputFile *ofile);
 
177
 
 
178
        /// read line width and style from file.
 
179
        bool ReadGraphicsPart(InputFile *ifile, double format);
 
180
 
 
181
        /// write font and alignment to file.
 
182
        void WriteTextPart(OutputFile *ofile);
 
183
 
 
184
        /// read and parse font and alignment from file.
 
185
        bool ReadTextPart(InputFile *ifile, double format);
 
186
 
 
187
        ///
 
188
        virtual void SetDrawAttributes();
 
189
 
 
190
        /// set alignments of text shapes.
 
191
        virtual void SetAlignment(TextAlign::Type a) {
 
192
                name->SetAlignment(a);}
 
193
 
 
194
        /// snap at position and text shapes are moved with.
 
195
        virtual void SnapPosition(); 
 
196
 
 
197
        /// snap at topleft and text shapes are moved with.
 
198
        virtual void SnapTopleft(); 
 
199
 
 
200
private:
 
201
        /// the name text shape of the Gshape
 
202
        TextShape *name;
 
203
 
 
204
        /// line width.
 
205
        unsigned lineWidth;
 
206
 
 
207
        /// line style.
 
208
        LineStyle::Type lineStyle;
 
209
 
 
210
        /// is gshape filled?
 
211
//      bool filled;
 
212
        // (not used. dj)
 
213
 
 
214
        /// can name be edited?
 
215
        bool fixedName;
 
216
};
 
217
#endif