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
//-----------------------------------------------------------------------------
27
#include "textalign.h"
36
/// abstract base class of table rows and columns.
38
/*@Doc: {\large {\bf scope:} table} */
41
CellVector(TableViewer *v, unsigned number);
43
virtual ~CellVector();
45
/// -1,0,1 iff c1.number ==,<,> c2.number
46
friend int operator==(const CellVector &c1, const CellVector &c2);
48
/// -1,0,1 iff c1.number ==,<,> c2.number
49
friend int Compare(CellVector *c1, CellVector *c2) {
50
return operator==(*c1, *c2);}
54
/// erase cell vector.
73
void SetGrafport(Grafport *g);
75
/// Make all cells and lines (in)visible.
76
void SetVisible(bool b);
79
TableViewer *GetViewer() const {return viewer;}
82
virtual void UpdatePosition(int delta) =0;
85
virtual LinePiece *HitLinePiece(int x, int y) =0;
88
bool HasCell(Cell *c);
91
RowColumnLabel *HitLabel(int x, int y) const;
93
/// append cell to column.
94
virtual void AddCell(Cell *c, bool redraw=False)=0;
96
/// delete cell from column.
97
virtual void DeleteCell(Cell *c, bool redraw=False)=0;
99
/// insert cell in column.
100
virtual void InsertCell(Cell *c, unsigned n, bool redraw=False)=0;
103
virtual bool ContainsPt(int x, int y) const =0;
106
virtual void Write(OutputFile *f) = 0;
109
virtual void WritePartial(OutputFile *f, int i, List<int> *nrs) = 0;
112
virtual bool Read(InputFile *f, unsigned from = 0,
113
double format = 1.0) = 0;
116
TextAlign::Type GetAlignment() const {return alignment;}
119
void SetAlignment(TextAlign::Type a);
122
void UpdateAlignment(TextAlign::Type a);
125
virtual void UpdateNumber(unsigned nr);
128
virtual void SetLabelsVisible(bool s) {labelsVisible = s;}
131
void SetNumber(unsigned nr);
133
/// return first cell, 0 if cells is empty.
136
/// return next cell, 0 if cells is empty.
139
/// return n-th cell, 0 if n-th cell does not exist.
140
Cell *NthCell(unsigned n);
142
/// return first line, 0 if lines is empty.
143
LinePiece *FirstLine();
145
/// return next line, 0 if lines is empty.
146
LinePiece *NextLine();
148
/// return n-th line, 0 if n-th line does not exist.
149
LinePiece *NthLine(unsigned n);
152
unsigned GetNumber() const {return number;}
155
RowColumnLabel *GetLabel1() const {return label1;}
157
RowColumnLabel *GetLabel2() const {return label2;}
159
void UpdateLabel1(const string *txt);
161
void UpdateLabel2(const string *txt);
164
unsigned NrCells() const {return cells->count();}
167
int GetIndex(LinePiece *l) {return lines->find(l);}
169
/// return nr of cells having empty texts.
170
unsigned HasEmptyText();
172
/// return nr of cells having this text.
173
unsigned HasText(const string *s);
176
bool IsAllEmpty() {return HasEmptyText() == NrCells();}
179
void EmptyCells() {cells->empty();} // remove all from cells
182
virtual void CalcLabelPositions() = 0;
184
/// the cells in the vector.
187
/// cell boundaries between the cells in the vector.
188
List<LinePiece *> *lines;
191
Grafport *GetGrafport() const {return grafport;}
198
/// the row or column numbers.
201
/// a number label drawn near beginning of vector (like spreadsheet)
202
RowColumnLabel *label1;
204
/// a number label drawn near end of vector.
205
RowColumnLabel *label2;
207
/// is label number displayed ?
210
/// beginning=left, end=right, center=center.
211
TextAlign::Type alignment;