2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file TextPainter.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-09-11 09:14:57 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "TextPainter.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
|
|
|
|
|
#include <ostream>
|
2002-03-18 11:45:53 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
2006-10-19 16:51:30 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-18 11:45:53 +00:00
|
|
|
|
TextPainter::TextPainter(int xmax, int ymax)
|
2002-03-19 16:55:58 +00:00
|
|
|
|
: xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
char_type & TextPainter::at(int x, int y)
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
|
|
|
|
return data_[y * xmax_ + x];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
char_type TextPainter::at(int x, int y) const
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
|
|
|
|
return data_[y * xmax_ + x];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
void TextPainter::draw(int x, int y, char_type const * str)
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
//cerr << "drawing string '" << str << "' at " << x << ',' << y << endl;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
for (int i = 0; *str && x + i < xmax_; ++i, ++str)
|
2002-03-18 11:45:53 +00:00
|
|
|
|
at(x + i, y) = *str;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
//show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
void TextPainter::horizontalLine(int x, int y, int n, char_type c)
|
2002-03-19 16:55:58 +00:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < n && i + x < xmax_; ++i)
|
|
|
|
|
at(x + i, y) = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
void TextPainter::verticalLine(int x, int y, int n, char_type c)
|
2002-03-19 16:55:58 +00:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < n && i + y < ymax_; ++i)
|
|
|
|
|
at(x, y + i) = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
void TextPainter::draw(int x, int y, char_type c)
|
2002-03-19 16:55:58 +00:00
|
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
|
//cerr << "drawing char '" << c << "' at " << x << ',' << y << endl;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
at(x, y) = c;
|
|
|
|
|
//show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void TextPainter::show(odocstream & os, int offset) const
|
2002-03-19 16:55:58 +00:00
|
|
|
|
{
|
|
|
|
|
os << '\n';
|
|
|
|
|
for (int j = 0; j <= ymax_; ++j) {
|
2002-07-11 15:04:43 +00:00
|
|
|
|
for (int i = 0; i < offset; ++i)
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << ' ';
|
2002-03-19 16:55:58 +00:00
|
|
|
|
for (int i = 0; i < xmax_; ++i)
|
|
|
|
|
os << at(i, j);
|
|
|
|
|
os << '\n';
|
|
|
|
|
}
|
2002-03-18 11:45:53 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|