1
//------------------------------------------------------------------------------
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1996, 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
//-----------------------------------------------------------------------------
22
#ifndef _SIMPLELABEL_H
23
#define _SIMPLELABEL_H
30
/// abstract (simple) text label class.
32
/*@Doc: {\large {\bf scope:} table} */
35
SimpleLabel(Grafport *g, XFont *font);
37
SimpleLabel(const SimpleLabel &text);
39
virtual ~SimpleLabel();
42
friend int operator==(const SimpleLabel &t1, const SimpleLabel &t2);
44
friend int Compare(SimpleLabel *r1, SimpleLabel *r2) {return *r1==*r2;}
47
virtual void Draw() = 0;
50
virtual void Undraw();
52
/// when label is dragged only a dotted box (outline) is drawn
53
void DrawOutLine(const Point *c);
55
/// update position and redraw.
56
virtual void UpdatePosition(const Point *);
58
/// update label and redraw.
59
virtual void UpdateText(const string *);
62
void SetPosition(const Point *pt);
65
void SetText(const string *s);
68
void SetGrafport(Grafport *g) {grafport = g;}
70
/// calculate text size.
73
/// true iff (x,y) is in text.
74
bool HitText(int x, int y);
76
/// simple 'get' actions.
77
const Point *GetPosition() const {return &position;}
80
const Point *GetTopLeft() const {return &topLeft;}
82
const string *GetText() const {return &text;}
85
int GetWidth() const {return width;}
87
int GetHeight() const {return height;}
90
XFont *GetFont() const {return font;}
92
void SetFont(XFont *f);
95
virtual void UpdateFont(XFont *font);
98
int FontHeight() const {return font->GetHeight();}
100
/// minimal width of cell text outline.
101
static const int MIN_TEXT_WIDTH;
103
/// minimal height of cell text outline.
104
static const int MIN_TEXT_HEIGHT;
107
Grafport *GetGrafport() const {return grafport;}
109
/// center position of text.
112
/// topleft position of text.
115
/// text width (depends on number of characters and point size + font).
118
/// text height (depends on font).
129
void SetSize(int wd, int ht);
131
/// make sure text has positive coordinates.
132
void PositiveCoord();