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
////////////////////////////////////////////////////////////////////////////////
25
#include "inputfile.h"
26
#include "outputfile.h"
28
CellText::CellText(Grafport *g, XFont *ft, Cell *p): SimpleLabel(g, ft) {
33
CellText::CellText(const CellText &t): SimpleLabel(t) {
38
void CellText::Draw() {
39
DrawAligned(TextAlign::CENTER);
42
void CellText::DrawAligned(TextAlign::Type a) {
43
if (parent && !parent->IsVisible())
45
if (GetText()->length() > 0) {
46
GetGrafport()->SetFont(GetFont());
47
Point tl = *GetTopLeft();
48
Point pos = *GetPosition();
49
if (a == TextAlign::LEFT)
50
GetGrafport()->DrawStringsLeft(tl.x, tl.y,
51
GetText(), IsUnderlined());
52
else if (a == TextAlign::RIGHT)
53
GetGrafport()->DrawStringsRight(tl.x+GetWidth(), tl.y,
54
GetText(), IsUnderlined());
56
GetGrafport()->DrawStringsCentered(pos.x, pos.y,
57
GetText(), IsUnderlined());
61
void CellText::UndrawAligned(TextAlign::Type a) {
65
void CellText::UpdatePosition(const Point *pt) {
67
if (parent->IsVisible())
68
UndrawAligned(parent->GetColumnAlignment());
71
UndrawAligned(TextAlign::CENTER);
74
if (parent->IsVisible())
75
DrawAligned(parent->GetColumnAlignment());
78
DrawAligned(TextAlign::CENTER);
81
void CellText::UpdateText(const string *s) {
83
UndrawAligned(parent->GetColumnAlignment());
85
UndrawAligned(TextAlign::CENTER);
88
DrawAligned(parent->GetColumnAlignment());
90
DrawAligned(TextAlign::CENTER);
93
void CellText::UpdateFont(XFont *ft) {
95
UndrawAligned(parent->GetColumnAlignment());
97
UndrawAligned(TextAlign::CENTER);
100
DrawAligned(parent->GetColumnAlignment());
102
DrawAligned(TextAlign::CENTER);
105
void CellText::Write(OutputFile *ofile) {
107
GetFont()->GetXLFD(&fontString);
108
(*ofile) << "\t{ Text \"" << *GetText() << "\"}\n";
109
(*ofile) << "\t{ Font \"" << fontString << "\"}\n";
112
bool CellText::Read(InputFile *ifile, double format) {
114
if (!ifile->ReadStringAttribute("Text", &s))
118
if (format >= 1.09) {
119
if (!ifile->ReadStringAttribute("Font", &s))
121
parent->SetXLFD(s.getstr());
127
void CellText::UpdateUnderlined(bool b) {
128
if (underlined != b) {