1
//------------------------------------------------------------------------------
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).
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.
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.
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
21
//-----------------------------------------------------------------------------
25
#include "linestyle.h"
26
#include "textshape.h"
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.
34
/// (abstract) graphical shape class, superclass of box, ellipse, line etc.
35
class GShape: public Shape {
36
/*@Doc: {\large {\bf scope:} diagram} */
38
/// constructor, creates shape at position (x,y).
39
GShape(ShapeView *v, Grafport *g, int x, int y);
41
GShape(const GShape &);
50
/// draw the shape and all child shapes
51
void DrawWithChildren();
52
/// undraw the shape and all child shapes
53
void UndrawWithChildren();
56
virtual void DrawShape() = 0;
58
virtual void UndrawShape() {DrawShape();}
61
virtual void DrawTextShapes() {name->Draw();}
63
virtual void UndrawTextShapes() {DrawTextShapes();}
65
/// update string of name text shape and redraw.
66
virtual void UpdateNameString(const string *s);
68
/// update subject's parent and redraw.
69
virtual void UpdateParent(Node *parent);
72
virtual void SetNameString(const string *s) {name->SetString(s);}
74
const string *GetNameString() {return name->GetString();}
77
TextShape *GetName() const {return name;}
79
virtual void SetTextShape();
80
/// select this shape and its text shapes are selected.
81
virtual void SetSelect(bool s);
84
unsigned GetLineWidth() const {return lineWidth;}
86
void SetLineWidth(unsigned n) {lineWidth=n;}
88
void UpdateLineWidth(unsigned n);
91
LineStyle::Type GetLineStyle() const {return lineStyle;}
93
void SetLineStyle(LineStyle::Type x) {lineStyle=x;}
95
void UpdateLineStyle(LineStyle::Type x);
98
const string *GetTextColor() const {return name->GetColor();}
100
void UpdateTextColor(const string *c);
102
/// Returns if gs is contained in the child area of this shape.
103
virtual bool ContainsChild(const GShape * /* gs */ ) const
108
/// Returns if (x,y) is in name, and if so returns name.
109
virtual TextShape *HitTextShape(int x, int y);
111
/// return if it has t as one of the text shapes.
112
virtual bool HasTextShape(TextShape *t) const {return name==t;}
114
/// refinements of those shape members.
115
virtual int GetLeftMost() const;
117
virtual int GetTopMost() const;
119
virtual int GetRightMost() const;
121
virtual int GetBottomMost() const;
124
bool IsFixedName() {return fixedName;}
126
void SetFixedName(bool b) {fixedName=b;}
128
/// set grafport of itself and its text shapes.
129
virtual void SetGrafport(Grafport *g);
131
/// set view of itself and its text shapes.
132
virtual void SetView(ShapeView *v);
134
/// update font and redraw.
135
virtual void UpdateFont(XFont *ft);
137
/// update text alignments and redraw.
138
virtual void UpdateAlignment(TextAlign::Type alignment);
140
/// return a text shape near (x,y).
141
virtual TextShape *ChooseTextShape(int, int);
143
/// react on movement of some text shape.
144
virtual void NotifyTextMove(TextShape *) {}
146
/// return font of the textshapes (all textshapes have same font).
147
XFont *GetFont() const {return name->GetFont();}
150
TextAlign::Type GetAlignment() const {return name->GetAlignment();}
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); }
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); }
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);}
165
/// Check also that name reference is ok.
166
bool CheckReferences();
169
/// set fonts of text shapes.
170
virtual void SetFont(XFont *ft) {name->SetFont(ft);}
172
/// set color of text shapes.
173
virtual void SetTextColor(const string *c) {name->SetColor(c);}
175
/// write line width and style to file.
176
void WriteGraphicsPart(OutputFile *ofile);
178
/// read line width and style from file.
179
bool ReadGraphicsPart(InputFile *ifile, double format);
181
/// write font and alignment to file.
182
void WriteTextPart(OutputFile *ofile);
184
/// read and parse font and alignment from file.
185
bool ReadTextPart(InputFile *ifile, double format);
188
virtual void SetDrawAttributes();
190
/// set alignments of text shapes.
191
virtual void SetAlignment(TextAlign::Type a) {
192
name->SetAlignment(a);}
194
/// snap at position and text shapes are moved with.
195
virtual void SnapPosition();
197
/// snap at topleft and text shapes are moved with.
198
virtual void SnapTopleft();
201
/// the name text shape of the Gshape
208
LineStyle::Type lineStyle;
210
/// is gshape filled?
214
/// can name be edited?