157 lines
5.7 KiB
C++
157 lines
5.7 KiB
C++
//! \file piscreendrawer.h
|
|
//! \ingroup Console
|
|
//! \brief
|
|
//! \~english Drawer for PIScreen
|
|
//! \~russian Отрисовщик для PIScreen
|
|
//! \details
|
|
//! \~english Provides drawing primitives for console screen rendering.
|
|
//! \~russian Обеспечивает примитивы отрисовки для рендеринга консольного экрана.
|
|
/*
|
|
PIP - Platform Independent Primitives
|
|
Drawer for PIScreen
|
|
Ivan Pelipenko peri4ko@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef PISCREENDRAWER_H
|
|
#define PISCREENDRAWER_H
|
|
|
|
#include "pip_console_export.h"
|
|
#include "piscreentypes.h"
|
|
#include "pistring.h"
|
|
|
|
//! \brief Screen drawer for console rendering
|
|
//! \~english Console screen drawer for rendering graphics
|
|
//! \~russian Отрисовщик консольного экрана для рендеринга графики
|
|
|
|
class PIP_CONSOLE_EXPORT PIScreenDrawer {
|
|
friend class PIScreen;
|
|
PIScreenDrawer(PIVector<PIVector<PIScreenTypes::Cell>> & c);
|
|
|
|
public:
|
|
//! \brief ASCII art characters
|
|
enum ArtChar {
|
|
LineVertical = 1, //!< Vertical line / Вертикальная линия
|
|
LineHorizontal, //!< Horizontal line / Горизонтальная линия
|
|
Cross, //!< Cross / Крест
|
|
CornerTopLeft, //!< Top-left corner / Угол сверху-слева
|
|
CornerTopRight, //!< Top-right corner / Угол сверху-справа
|
|
CornerBottomLeft, //!< Bottom-left corner / Угол снизу-слева
|
|
CornerBottomRight, //!< Bottom-right corner / Угол снизу-справа
|
|
Unchecked, //!< Unchecked box / Неотмеченная клетка
|
|
Checked //!< Checked box / Отмеченная клетка
|
|
};
|
|
|
|
//! \brief
|
|
//! \~english Clears the screen
|
|
//! \~russian Очищает экран
|
|
void clear();
|
|
|
|
//! \brief
|
|
//! \~english Clears rectangle
|
|
//! \~russian Очищает прямоугольник
|
|
void clearRect(int x0, int y0, int x1, int y1) { fillRect(x0, y0, x1, y1, ' '); }
|
|
|
|
//! \brief
|
|
//! \~english Draws pixel
|
|
//! \~russian Рисует пиксель
|
|
void drawPixel(int x,
|
|
int y,
|
|
const PIChar & c,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Draws line
|
|
//! \~russian Рисует линию
|
|
void drawLine(int x0,
|
|
int y0,
|
|
int x1,
|
|
int y1,
|
|
const PIChar & c,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Draws rectangle
|
|
//! \~russian Рисует прямоугольник
|
|
void drawRect(int x0,
|
|
int y0,
|
|
int x1,
|
|
int y1,
|
|
const PIChar & c,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Draws frame
|
|
//! \~russian Рисует рамку
|
|
void drawFrame(int x0,
|
|
int y0,
|
|
int x1,
|
|
int y1,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Draws text
|
|
//! \~russian Рисует текст
|
|
void drawText(int x,
|
|
int y,
|
|
const PIString & s,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Transparent,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Fills rectangle
|
|
//! \~russian Заполняет прямоугольник
|
|
void fillRect(int x0,
|
|
int y0,
|
|
int x1,
|
|
int y1,
|
|
const PIChar & c,
|
|
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
|
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
|
PIScreenTypes::CharFlags flags_char = 0);
|
|
|
|
//! \brief
|
|
//! \~english Fills rectangle with content
|
|
//! \~russian Заполняет прямоугольник содержимым
|
|
void fillRect(int x0, int y0, int x1, int y1, PIVector<PIVector<PIScreenTypes::Cell>> & content);
|
|
|
|
//! \brief
|
|
//! \~english Returns art character by type
|
|
//! \~russian Возвращает символ искусства по типу
|
|
PIChar artChar(const ArtChar type) const { return arts_.value(type, PIChar(' ')); }
|
|
|
|
//! \brief
|
|
//! \~english Clears cell matrix
|
|
//! \~russian Очищает матрицу ячеек
|
|
static void clear(PIVector<PIVector<PIScreenTypes::Cell>> & cells);
|
|
|
|
private:
|
|
PIVector<PIVector<PIScreenTypes::Cell>> & cells;
|
|
int width, height;
|
|
PIMap<ArtChar, PIChar> arts_;
|
|
};
|
|
|
|
|
|
#endif // PISCREENDRAWER_H
|