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
#include "celltextbuffer.h"
23
#include "tableviewer.h"
27
CellTextBuffer::CellTextBuffer() {
30
rcPositions = new List<Point *>;
31
prevRcPositions = new List<Point *>;
34
CellTextBuffer::~CellTextBuffer() {
40
prevCellTexts->clear();
44
prevRcPositions->clear();
46
delete prevRcPositions;
49
void CellTextBuffer::PutTexts(List<CellText *> *c) {
51
prevCellTexts->clear();
54
prevCellTexts = cellTexts;
55
cellTexts = new List<CellText *>;
57
for (c->first(); !c->done(); c->next()) {
58
CellText *t1 = c->cur();
59
CellText *t2 = new CellText(*t1);
65
void CellTextBuffer::PutPositions(List<Point *> *p) {
66
prevRcPositions->clear();
67
*prevRcPositions = *rcPositions;
70
rcTopLeft = *p->cur();
72
rcTopLeft = Point(0,0);
73
for (p->first(); !p->done(); p->next()) {
74
rcPositions->add(new Point(*p->cur()));
75
rcTopLeft = Point(min(rcTopLeft.x,p->cur()->x),
76
min(rcTopLeft.y,p->cur()->y));
80
List<CellText *> *CellTextBuffer::GetTexts() {
81
if (cellTexts) { // make a copy.
82
List<CellText *> *copy = new List<CellText *>;
83
for (cellTexts->first(); !cellTexts->done();
85
CellText *t = new CellText(*cellTexts->cur());
94
void CellTextBuffer::UndoPut() {
99
cellTexts = prevCellTexts;
103
rcPositions->clear();
104
*rcPositions = *prevRcPositions;
105
prevRcPositions->empty();
108
bool CellTextBuffer::IsEmpty() {
109
return (cellTexts == 0 || cellTexts->count() == 0);
113
void CellTextBuffer::CalcSizeBuffer() {
114
int x_max=-1, x_min=-1, y_max=-1, y_min=-1;
116
List<CellText *> *texts = cellTexts;
119
for (texts->first(); !texts->done(); texts->next()) {
120
CellText *celltext = texts->cur();
121
if (!check(celltext))
123
Point pt = *celltext->GetTopLeft();
124
int wd = celltext->GetWidth();
125
int ht = celltext->GetHeight();
127
if (x>x_max || x_max == -1)
130
if (x<x_min || x_min == -1)
133
if (y>y_max || y_max == -1)
136
if (y<y_min || y_min == -1)
139
topLeft.Set(x_min, y_min);
140
bottomRight.Set(x_max, y_max);