add doxygen via opencode
This commit is contained in:
@@ -29,12 +29,12 @@
|
||||
#include "pithread.h"
|
||||
#include "pitime.h"
|
||||
|
||||
#define WAIT_FOR_EXIT \
|
||||
while (!PIKbdListener::exiting) \
|
||||
piMSleep(PIP_MIN_MSLEEP * 5); \
|
||||
if (PIKbdListener::instance()) { \
|
||||
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
||||
}
|
||||
#define WAIT_FOR_EXIT \
|
||||
while (!PIKbdListener::exiting) \
|
||||
piMSleep(PIP_MIN_MSLEEP * 5); \
|
||||
if (PIKbdListener::instance()) { \
|
||||
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
||||
}
|
||||
|
||||
|
||||
class PIP_EXPORT PIKbdListener: public PIThread {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreen.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Console tiling manager
|
||||
* \~russian Консольный тайловый менеджер
|
||||
*/
|
||||
//! \file piscreen.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Console tiling manager
|
||||
//! \~russian Консольный тайловый менеджер
|
||||
//! \details
|
||||
//! \~english Main console screen manager providing tile-based UI rendering and keyboard input.
|
||||
//! \~russian Основной менеджер консольного экрана, обеспечивающий отрисовку UI на основе тайлов и ввод с клавиатуры.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Console GUI
|
||||
@@ -38,46 +40,126 @@ class PIP_CONSOLE_EXPORT PIScreen
|
||||
class SystemConsole;
|
||||
|
||||
public:
|
||||
//! Constructs %PIScreen with key handler "slot" and if "startNow" start it
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreen
|
||||
//! \~russian Создает PIScreen
|
||||
//! \param startNow Start immediately / Запустить немедленно
|
||||
//! \param slot Keyboard handler function / Обработчик клавиатуры
|
||||
PIScreen(bool startNow = true, PIKbdListener::KBFunc slot = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~PIScreen();
|
||||
|
||||
//! Directly call function from \a PIKbdListener
|
||||
//! \brief
|
||||
//! \~english Enables exit capture with key
|
||||
//! \~russian Включает захват выхода по клавише
|
||||
void enableExitCapture(int key = 'Q') { listener->enableExitCapture(key); }
|
||||
|
||||
//! Directly call function from \a PIKbdListener
|
||||
//! \brief
|
||||
//! \~english Disables exit capture
|
||||
//! \~russian Отключает захват выхода
|
||||
void disableExitCapture() { listener->disableExitCapture(); }
|
||||
|
||||
//! Directly call function from \a PIKbdListener
|
||||
//! \brief
|
||||
//! \~english Checks if exit is captured
|
||||
//! \~russian Проверяет, захвачен ли выход
|
||||
bool exitCaptured() const { return listener->exitCaptured(); }
|
||||
|
||||
//! Directly call function from \a PIKbdListener
|
||||
//! \brief
|
||||
//! \~english Returns exit key
|
||||
//! \~russian Возвращает клавишу выхода
|
||||
int exitKey() const { return listener->exitKey(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns window width
|
||||
//! \~russian Возвращает ширину окна
|
||||
int windowWidth() const { return console.width; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns window height
|
||||
//! \~russian Возвращает высоту окна
|
||||
int windowHeight() const { return console.height; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if mouse is enabled
|
||||
//! \~russian Проверяет, включена ли мышь
|
||||
bool isMouseEnabled() const { return mouse_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets mouse enabled state
|
||||
//! \~russian Устанавливает состояние мыши
|
||||
void setMouseEnabled(bool on);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns root tile
|
||||
//! \~russian Возвращает корневой тайл
|
||||
PIScreenTile * rootTile() { return &root; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Finds tile by name
|
||||
//! \~russian Находит тайл по имени
|
||||
PIScreenTile * tileByName(const PIString & name);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets dialog tile
|
||||
//! \~russian Устанавливает диалоговый тайл
|
||||
void setDialogTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns current dialog tile
|
||||
//! \~russian Возвращает текущий диалоговый тайл
|
||||
PIScreenTile * dialogTile() const { return tile_dialog; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns screen drawer
|
||||
//! \~russian Возвращает отрисовщик экрана
|
||||
PIScreenDrawer * drawer() { return &drawer_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Clears the screen
|
||||
//! \~russian Очищает экран
|
||||
void clear() { drawer_.clear(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Resizes screen
|
||||
//! \~russian Изменяет размер экрана
|
||||
void resize(int w, int h) { console.resize(w, h); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Waits for finish
|
||||
//! \~russian Ожидает завершения
|
||||
EVENT_HANDLER0(void, waitForFinish);
|
||||
|
||||
//! \brief
|
||||
//! \~english Starts screen
|
||||
//! \~russian Запускает экран
|
||||
EVENT_HANDLER0(void, start) { start(false); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Starts screen
|
||||
//! \~russian Запускает экран
|
||||
EVENT_HANDLER1(void, start, bool, wait);
|
||||
|
||||
//! \brief
|
||||
//! \~english Stops screen
|
||||
//! \~russian Останавливает экран
|
||||
EVENT_HANDLER0(void, stop) { stop(false); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Stops screen
|
||||
//! \~russian Останавливает экран
|
||||
EVENT_HANDLER1(void, stop, bool, clear);
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised on key pressed
|
||||
//! \~russian Вызывается при нажатии клавиши
|
||||
EVENT2(keyPressed, PIKbdListener::KeyEvent, key, void *, data);
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised on tile event
|
||||
//! \~russian Вызывается при событии тайла
|
||||
EVENT2(tileEvent, PIScreenTile *, tile, PIScreenTypes::TileEvent, e);
|
||||
|
||||
//! \handlers
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreenconsole.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Tile for PIScreen with PIConsole API
|
||||
* \~russian Тайл для PIScreen с API PIConsole
|
||||
*/
|
||||
//! \file piscreenconsole.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Tile for PIScreen with PIConsole API
|
||||
//! \~russian Тайл для PIScreen с API PIConsole
|
||||
//! \details
|
||||
//! \~english Provides tiles for displaying variable data and console-like content.
|
||||
//! \~russian Обеспечивает тайлы для отображения данных переменных и консольного контента.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Tile for PIScreen with PIConsole API
|
||||
@@ -32,17 +34,30 @@
|
||||
/// NOTE: incomplete class
|
||||
/// TODO: write TileVars
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying variable data
|
||||
//! \~russian Тайл для отображения данных переменных
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileVars: public PIScreenTile {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileVars
|
||||
//! \~russian Создает TileVars
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileVars(const PIString & n = PIString());
|
||||
|
||||
protected:
|
||||
//! \brief Variable data structure
|
||||
struct PIP_CONSOLE_EXPORT Variable {
|
||||
Variable() {
|
||||
nx = ny = type = offset = bitFrom = bitCount = size = 0;
|
||||
format = PIScreenTypes::CellFormat();
|
||||
ptr = 0;
|
||||
}
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if variable is empty
|
||||
//! \~russian Проверяет, пустая ли переменная
|
||||
bool isEmpty() const { return (ptr == 0); }
|
||||
PIString name;
|
||||
PIScreenTypes::CellFormat format;
|
||||
@@ -67,15 +82,34 @@ protected:
|
||||
ptr = src.ptr;
|
||||
}*/
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns variables
|
||||
//! \~russian Возвращает переменные
|
||||
PIVector<Variable> variables;
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Console-style tile for PIScreen
|
||||
//! \~russian Консольный тайл для PIScreen
|
||||
|
||||
class PIP_CONSOLE_EXPORT PIScreenConsoleTile: public PIScreenTile {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenConsoleTile
|
||||
//! \~russian Создает PIScreenConsoleTile
|
||||
PIScreenConsoleTile();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreendrawer.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Drawer for PIScreen
|
||||
* \~russian Отрисовщик для PIScreen
|
||||
*/
|
||||
//! \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
|
||||
@@ -30,31 +32,51 @@
|
||||
#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,
|
||||
LineHorizontal,
|
||||
Cross,
|
||||
CornerTopLeft,
|
||||
CornerTopRight,
|
||||
CornerBottomLeft,
|
||||
CornerBottomRight,
|
||||
Unchecked,
|
||||
Checked
|
||||
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,
|
||||
@@ -63,6 +85,10 @@ public:
|
||||
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,
|
||||
@@ -71,6 +97,10 @@ public:
|
||||
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,
|
||||
@@ -78,12 +108,20 @@ public:
|
||||
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,
|
||||
@@ -92,10 +130,20 @@ public:
|
||||
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:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreentile.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Basic PIScreen tile
|
||||
* \~russian Базовый тайл для PIScreen
|
||||
*/
|
||||
//! \file piscreentile.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Basic PIScreen tile
|
||||
//! \~russian Базовый тайл для PIScreen
|
||||
//! \details
|
||||
//! \~english Base class for all screen tiles providing layout and event handling.
|
||||
//! \~russian Базовый класс для всех экранных тайлов, обеспечивающий компоновку и обработку событий.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
@@ -32,27 +34,89 @@
|
||||
|
||||
class PIScreenDrawer;
|
||||
|
||||
//! \brief
|
||||
//! \~english Base tile class for console screen
|
||||
//! \~russian Базовый класс тайла для консольного экрана
|
||||
|
||||
class PIP_CONSOLE_EXPORT PIScreenTile: public PIObject {
|
||||
friend class PIScreen;
|
||||
PIOBJECT_SUBCLASS(PIScreenTile, PIObject);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenTile
|
||||
//! \~russian Создает PIScreenTile
|
||||
//! \param n Tile name / Имя тайла
|
||||
//! \param d Layout direction / Направление компоновки
|
||||
//! \param p Size policy / Политика размера
|
||||
PIScreenTile(const PIString & n = PIString(),
|
||||
PIScreenTypes::Direction d = PIScreenTypes::Vertical,
|
||||
PIScreenTypes::SizePolicy p = PIScreenTypes::Preferred);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIScreenTile();
|
||||
|
||||
//! \brief
|
||||
//! \~english Adds child tile
|
||||
//! \~russian Добавляет дочерний тайл
|
||||
void addTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Takes ownership of tile
|
||||
//! \~russian Забирает владение тайла
|
||||
void takeTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Removes child tile
|
||||
//! \~russian Удаляет дочерний тайл
|
||||
void removeTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns parent tile
|
||||
//! \~russian Возвращает родительский тайл
|
||||
PIScreenTile * parentTile() const { return parent; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns child tiles
|
||||
//! \~russian Возвращает дочерние тайлы
|
||||
//! \param only_visible Only visible tiles / Только видимые тайлы
|
||||
PIVector<PIScreenTile *> children(bool only_visible = false);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns child under mouse position
|
||||
//! \~russian Возвращает тайл под мышью
|
||||
PIScreenTile * childUnderMouse(int x, int y);
|
||||
|
||||
//! \brief
|
||||
//! \~english Shows tile
|
||||
//! \~russian Показывает тайл
|
||||
void show() { visible = true; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Hides tile
|
||||
//! \~russian Скрывает тайл
|
||||
void hide() { visible = false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets focus to this tile
|
||||
//! \~russian Устанавливает фокус на этот тайл
|
||||
void setFocus();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if tile has focus
|
||||
//! \~russian Проверяет, имеет ли тайл фокус
|
||||
bool hasFocus() const { return has_focus; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets all margins
|
||||
//! \~russian Устанавливает все отступы
|
||||
void setMargins(int m) { marginLeft = marginRight = marginTop = marginBottom = m; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets individual margins
|
||||
//! \~russian Устанавливает отдельные отступы
|
||||
void setMargins(int l, int r, int t, int b) {
|
||||
marginLeft = l;
|
||||
marginRight = r;
|
||||
@@ -60,9 +124,24 @@ public:
|
||||
marginBottom = b;
|
||||
}
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile X position
|
||||
//! \~russian Возвращает позицию X тайла
|
||||
int x() const { return x_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile Y position
|
||||
//! \~russian Возвращает позицию Y тайла
|
||||
int y() const { return y_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile width
|
||||
//! \~russian Возвращает ширину тайла
|
||||
int width() const { return width_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile height
|
||||
//! \~russian Возвращает высоту тайла
|
||||
int height() const { return height_; }
|
||||
|
||||
PIScreenTypes::Direction direction;
|
||||
@@ -77,29 +156,64 @@ public:
|
||||
bool visible;
|
||||
|
||||
protected:
|
||||
//! Returns desired tile size in "w" and "h"
|
||||
//! \brief
|
||||
//! \~english Returns desired tile size in "w" and "h"
|
||||
//! \~russian Возвращает желаемый размер тайла в "w" и "h"
|
||||
virtual void sizeHint(int & w, int & h) const;
|
||||
|
||||
//! Tile has been resized to "w"x"h"
|
||||
//! \brief
|
||||
//! \~english Tile has been resized to "w"x"h"
|
||||
//! \~russian Тайл был изменен на "w"x"h"
|
||||
virtual void resizeEvent(int w, int h) {}
|
||||
|
||||
//! Draw tile with drawer "d" in world-space coordinates
|
||||
//! \brief
|
||||
//! \~english Draw tile with drawer "d" in world-space coordinates
|
||||
//! \~russian Рисует тайл отрисовщиком "d" в мировых координатах
|
||||
virtual void drawEvent(PIScreenDrawer * d) {}
|
||||
|
||||
//! Return "true" if you process key
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process key
|
||||
//! \~russian Возвращает "true" если вы обрабатываете клавишу
|
||||
virtual bool keyEvent(PIKbdListener::KeyEvent key) { return false; }
|
||||
|
||||
//! Return "true" if you process event
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process event
|
||||
//! \~russian Возвращает "true" если вы обрабатываете событие
|
||||
virtual bool mouseEvent(PIKbdListener::MouseEvent me) { return false; }
|
||||
|
||||
//! Return "true" if you process wheel
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process wheel
|
||||
//! \~russian Возвращает "true" если вы обрабатываете колесо
|
||||
virtual bool wheelEvent(PIKbdListener::WheelEvent we) { return false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Raises tile event
|
||||
//! \~russian Вызывает событие тайла
|
||||
void raiseEvent(PIScreenTypes::TileEvent e);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets screen reference
|
||||
//! \~russian Устанавливает ссылку на экран
|
||||
void setScreen(PIScreenTypes::PIScreenBase * s);
|
||||
|
||||
//! \brief
|
||||
//! \~english Deletes all children
|
||||
//! \~russian Удаляет всех потомков
|
||||
void deleteChildren();
|
||||
|
||||
//! \brief
|
||||
//! \~english Internal draw event
|
||||
//! \~russian Внутреннее событие отрисовки
|
||||
void drawEventInternal(PIScreenDrawer * d);
|
||||
|
||||
//! \brief
|
||||
//! \~english Performs layout
|
||||
//! \~russian Выполняет компоновку
|
||||
void layout();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if layout is needed
|
||||
//! \~russian Проверяет, нужна ли компоновка
|
||||
bool needLayout() { return size_policy != PIScreenTypes::Ignore; }
|
||||
|
||||
PIVector<PIScreenTile *> tiles;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreentiles.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Various tiles for PIScreen
|
||||
* \~russian Различные тайлы для PIScreen
|
||||
*/
|
||||
//! \file piscreentiles.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Various tiles for PIScreen
|
||||
//! \~russian Различные тайлы для PIScreen
|
||||
//! \details
|
||||
//! \~english Provides ready-to-use tile implementations for common UI elements.
|
||||
//! \~russian Обеспечивает готовые к использованию реализации тайлов для общих элементов UI.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
@@ -30,125 +32,326 @@
|
||||
#include "piscreentile.h"
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying simple text content
|
||||
//! \~russian Тайл для отображения простого текстового контента
|
||||
class PIP_CONSOLE_EXPORT TileSimple: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileSimple, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief Row type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileSimple
|
||||
//! \~russian Создает TileSimple
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileSimple(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileSimple with row
|
||||
//! \~russian Создает TileSimple со строкой
|
||||
//! \param r Row content / Содержимое строки
|
||||
TileSimple(const Row & r);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileSimple() {}
|
||||
|
||||
//! \brief Tile content rows
|
||||
PIVector<Row> content;
|
||||
|
||||
//! \brief Text alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
class TileList;
|
||||
|
||||
//! \brief
|
||||
//! \~english Scrollbar for list containers
|
||||
//! \~russian Полоса прокрутки для списков
|
||||
class PIP_CONSOLE_EXPORT TileScrollBar: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileScrollBar, PIScreenTile);
|
||||
friend class TileList;
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileScrollBar
|
||||
//! \~russian Создает TileScrollBar
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileScrollBar(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileScrollBar() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets minimum value
|
||||
//! \~russian Устанавливает минимальное значение
|
||||
void setMinimum(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets maximum value
|
||||
//! \~russian Устанавливает максимальное значение
|
||||
void setMaximum(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets current value
|
||||
//! \~russian Устанавливает текущее значение
|
||||
void setValue(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns minimum value
|
||||
//! \~russian Возвращает минимальное значение
|
||||
int minimum() const { return minimum_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns maximum value
|
||||
//! \~russian Возвращает максимальное значение
|
||||
int maximum() const { return maximum_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns current value
|
||||
//! \~russian Возвращает текущее значение
|
||||
int value() const { return value_; }
|
||||
|
||||
//! \brief Scrollbar thickness
|
||||
int thickness;
|
||||
|
||||
protected:
|
||||
//! \brief Validates scrollbar state
|
||||
//! \~english Validates scrollbar state
|
||||
//! \~russian Проверяет состояние полосы прокрутки
|
||||
void _check();
|
||||
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
int minimum_, maximum_, value_;
|
||||
PIChar line_char;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Scrollable list tile
|
||||
//! \~russian Прокручиваемый список
|
||||
class PIP_CONSOLE_EXPORT TileList: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileList, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief Selection mode
|
||||
enum SelectionMode {
|
||||
NoSelection,
|
||||
SingleSelection,
|
||||
MultiSelection
|
||||
};
|
||||
enum EventType {
|
||||
SelectionChanged,
|
||||
RowPressed
|
||||
NoSelection, //!< No selection / Без выделения
|
||||
SingleSelection, //!< Single item selection / Выделение одного элемента
|
||||
MultiSelection //!< Multiple items selection / Выделение нескольких элементов
|
||||
};
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
SelectionChanged, //!< Selection changed / Выделение изменено
|
||||
RowPressed //!< Row pressed / Строка нажата
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileList
|
||||
//! \~russian Создает TileList
|
||||
//! \param n Tile name / Имя тайла
|
||||
//! \param sm Selection mode / Режим выделения
|
||||
TileList(const PIString & n = PIString(), SelectionMode sm = NoSelection);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileList() {}
|
||||
|
||||
//! \brief Row type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||
|
||||
//! \brief List content
|
||||
PIDeque<Row> content;
|
||||
|
||||
//! \brief Text alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief Selection mode
|
||||
SelectionMode selection_mode;
|
||||
|
||||
//! \brief Selected indices
|
||||
PISet<int> selected;
|
||||
|
||||
//! \brief Line height
|
||||
int lhei, cur, offset;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when resized
|
||||
//! \~russian Вызывается при изменении размера
|
||||
void resizeEvent(int w, int h) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles wheel events
|
||||
//! \~russian Обрабатывает события колеса
|
||||
bool wheelEvent(PIKbdListener::WheelEvent we) override;
|
||||
TileScrollBar * scroll;
|
||||
bool mouse_sel;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Clickable button tile
|
||||
//! \~russian Кликабельная кнопка
|
||||
class PIP_CONSOLE_EXPORT TileButton: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileButton, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileButton
|
||||
//! \~russian Создает TileButton
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileButton(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileButton() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
ButtonClicked
|
||||
ButtonClicked //!< Button clicked / Кнопка нажата
|
||||
};
|
||||
|
||||
//! \brief Button format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Button text
|
||||
PIString text;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Group of buttons with selection
|
||||
//! \~russian Группа кнопок с выбором
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileButtons: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileButtons, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileButtons
|
||||
//! \~russian Создает TileButtons
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileButtons(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileButtons() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
ButtonSelected
|
||||
ButtonSelected //!< Button selected / Кнопка выбрана
|
||||
};
|
||||
|
||||
//! \brief Button type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Button;
|
||||
|
||||
//! \brief Button alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief Button content
|
||||
PIVector<Button> content;
|
||||
|
||||
//! \brief Current selection
|
||||
int cur;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
|
||||
//! \brief Button rectangle
|
||||
struct Rect {
|
||||
Rect(int _x0 = 0, int _y0 = 0, int _x1 = 0, int _y1 = 0): x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
|
||||
int x0, y0, x1, y1;
|
||||
@@ -157,74 +360,192 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Checkbox with toggle state
|
||||
//! \~russian Флажок с переключаемым состоянием
|
||||
class PIP_CONSOLE_EXPORT TileCheck: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileCheck, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileCheck
|
||||
//! \~russian Создает TileCheck
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileCheck(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileCheck() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
Toggled
|
||||
Toggled //!< State toggled / Состояние переключено
|
||||
};
|
||||
|
||||
//! \brief Checkbox format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Checkbox text
|
||||
PIString text;
|
||||
|
||||
//! \brief Checkbox state
|
||||
bool toggled;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Progress bar for displaying progress
|
||||
//! \~russian Индикатор прогресса
|
||||
class PIP_CONSOLE_EXPORT TileProgress: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileProgress, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileProgress
|
||||
//! \~russian Создает TileProgress
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileProgress(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileProgress() {}
|
||||
|
||||
//! \brief Progress format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Prefix text
|
||||
PIString prefix;
|
||||
|
||||
//! \brief Suffix text
|
||||
PIString suffix;
|
||||
|
||||
//! \brief Maximum value
|
||||
double maximum;
|
||||
|
||||
//! \brief Current value
|
||||
double value;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying console output
|
||||
//! \~russian Тайл для отображения консольного вывода
|
||||
|
||||
class PIP_CONSOLE_EXPORT TilePICout: public TileList {
|
||||
PIOBJECT_SUBCLASS(TilePICout, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TilePICout
|
||||
//! \~russian Создает TilePICout
|
||||
//! \param n Tile name / Имя тайла
|
||||
TilePICout(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TilePICout() {}
|
||||
|
||||
//! \brief Output format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Maximum lines
|
||||
int max_lines;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Text input tile
|
||||
//! \~russian Тайл текстового ввода
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileInput: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileInput, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileInput
|
||||
//! \~russian Создает TileInput
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileInput(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileInput() {}
|
||||
|
||||
//! \brief Input format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Input text
|
||||
PIString text;
|
||||
|
||||
//! \brief Maximum text length
|
||||
int max_length;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Resets cursor position
|
||||
//! \~russian Сбрасывает позицию курсора
|
||||
void reserCursor();
|
||||
int cur, offset;
|
||||
bool inv;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piscreentypes.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Types for PIScreen
|
||||
* \~russian Типы для PIScreen
|
||||
*/
|
||||
//! \file piscreentypes.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Types for PIScreen
|
||||
//! \~russian Типы для PIScreen
|
||||
//! \details
|
||||
//! \~english Provides common types used by screen tiles and drawer.
|
||||
//! \~russian Обеспечивает общие типы, используемые тайлами и отрисовщиком экрана.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Types for PIScreen
|
||||
@@ -34,7 +36,9 @@ class PIScreenTile;
|
||||
|
||||
namespace PIScreenTypes {
|
||||
|
||||
//! Color for chars or background
|
||||
//! \brief Color for chars or background
|
||||
//! \~english Console color values
|
||||
//! \~russian Значения цветов консоли
|
||||
enum Color {
|
||||
Default /** Default */,
|
||||
Black /** Black */,
|
||||
@@ -48,7 +52,9 @@ enum Color {
|
||||
Transparent /** Save previous color */
|
||||
};
|
||||
|
||||
//! Flags for chars
|
||||
//! \brief Flags for chars
|
||||
//! \~english Character formatting flags
|
||||
//! \~russian Флаги форматирования символов
|
||||
enum CharFlag {
|
||||
Bold /** Bold or bright */ = 0x1,
|
||||
Blink /** Blink text */ = 0x2,
|
||||
@@ -56,14 +62,18 @@ enum CharFlag {
|
||||
Inverse = 0x08
|
||||
};
|
||||
|
||||
//! Alignment
|
||||
//! \brief Alignment
|
||||
//! \~english Text alignment modes
|
||||
//! \~russian Режимы выравнивания текста
|
||||
enum Alignment {
|
||||
Left /** Left */,
|
||||
Center /** Center */,
|
||||
Right /** Right */
|
||||
};
|
||||
|
||||
//! Size policy
|
||||
//! \brief Size policy
|
||||
//! \~english Tile sizing policies
|
||||
//! \~russian Политики размеров тайлов
|
||||
enum SizePolicy {
|
||||
Fixed /** Fixed size */,
|
||||
Preferred /** Preferred size */,
|
||||
@@ -71,13 +81,17 @@ enum SizePolicy {
|
||||
Ignore /** Ignore layout logic */
|
||||
};
|
||||
|
||||
//! Direction
|
||||
//! \brief Direction
|
||||
//! \~english Layout directions
|
||||
//! \~russian Направления компоновки
|
||||
enum Direction {
|
||||
Horizontal /** Horizontal */,
|
||||
Vertical /** Vertical */
|
||||
};
|
||||
|
||||
//! Focus flags
|
||||
//! \brief Focus flags
|
||||
//! \~english Tile focus behavior flags
|
||||
//! \~russian Флаги поведения фокуса тайла
|
||||
enum FocusFlag {
|
||||
CanHasFocus /** Tile can has focus */ = 0x1,
|
||||
NextByTab /** Focus passed to next tile by tab key */ = 0x2,
|
||||
@@ -92,8 +106,19 @@ enum FocusFlag {
|
||||
typedef PIFlags<CharFlag> CharFlags;
|
||||
typedef PIFlags<FocusFlag> FocusFlags;
|
||||
|
||||
//! \brief Cell format union
|
||||
//! \~english Packed cell formatting data
|
||||
//! \~russian Упакованные данные форматирования ячейки
|
||||
|
||||
union PIP_CONSOLE_EXPORT CellFormat {
|
||||
//! \brief
|
||||
//! \~english Constructs CellFormat from raw value
|
||||
//! \~russian Создает CellFormat из сырого значения
|
||||
CellFormat(ushort f = 0) { raw_format = f; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs CellFormat from color and flags
|
||||
//! \~russian Создает CellFormat из цвета и флагов
|
||||
CellFormat(Color col_char, Color col_back = Default, CharFlags flags_ = 0) {
|
||||
color_char = col_char;
|
||||
color_back = col_back;
|
||||
@@ -105,19 +130,49 @@ union PIP_CONSOLE_EXPORT CellFormat {
|
||||
ushort color_back: 4;
|
||||
ushort flags : 8;
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Equality operator
|
||||
//! \~russian Оператор равенства
|
||||
bool operator==(const CellFormat & c) const { return raw_format == c.raw_format; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Inequality operator
|
||||
//! \~russian Оператор неравенства
|
||||
bool operator!=(const CellFormat & c) const { return raw_format != c.raw_format; }
|
||||
};
|
||||
|
||||
//! \brief Screen cell
|
||||
//! \~english Single character cell with formatting
|
||||
//! \~russian Одна символьная ячейка с форматированием
|
||||
struct PIP_CONSOLE_EXPORT Cell {
|
||||
//! \brief
|
||||
//! \~english Constructs Cell
|
||||
//! \~russian Создает Cell
|
||||
Cell(PIChar c = PIChar(' '), CellFormat f = CellFormat()) {
|
||||
symbol = c;
|
||||
format = f;
|
||||
}
|
||||
|
||||
//! \brief Cell format
|
||||
CellFormat format;
|
||||
|
||||
//! \brief Cell character
|
||||
PIChar symbol;
|
||||
|
||||
//! \brief
|
||||
//! \~english Equality operator
|
||||
//! \~russian Оператор равенства
|
||||
bool operator==(const Cell & c) const { return format == c.format && symbol == c.symbol; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Inequality operator
|
||||
//! \~russian Оператор неравенства
|
||||
bool operator!=(const Cell & c) const { return format != c.format || symbol != c.symbol; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Assignment operator
|
||||
//! \~russian Оператор присваивания
|
||||
Cell & operator=(const Cell & c) {
|
||||
symbol = c.symbol;
|
||||
if (c.format.color_back == Transparent) {
|
||||
@@ -129,18 +184,52 @@ struct PIP_CONSOLE_EXPORT Cell {
|
||||
}
|
||||
};
|
||||
|
||||
//! \brief Tile event data
|
||||
//! \~english Event data passed to tiles
|
||||
//! \~russian Данные события, передаваемые тайлам
|
||||
struct PIP_CONSOLE_EXPORT TileEvent {
|
||||
//! \brief
|
||||
//! \~english Constructs TileEvent
|
||||
//! \~russian Создает TileEvent
|
||||
//! \param t Event type / Тип события
|
||||
//! \param d Event data / Данные события
|
||||
TileEvent(int t = -1, const PIVariant & d = PIVariant()): type(t), data(d) {}
|
||||
|
||||
//! \brief Event type
|
||||
int type;
|
||||
|
||||
//! \brief Event data
|
||||
PIVariant data;
|
||||
};
|
||||
|
||||
//! \brief Base screen interface
|
||||
//! \~english Base interface for screen tiles
|
||||
//! \~russian Базовый интерфейс для экранных тайлов
|
||||
class PIP_CONSOLE_EXPORT PIScreenBase {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenBase
|
||||
//! \~russian Создает PIScreenBase
|
||||
PIScreenBase() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIScreenBase() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles internal tile event
|
||||
//! \~russian Обрабатывает внутреннее событие тайла
|
||||
virtual void tileEventInternal(PIScreenTile *, TileEvent) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles tile removal
|
||||
//! \~russian Обрабатывает удаление тайла
|
||||
virtual void tileRemovedInternal(PIScreenTile *) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles tile focus change
|
||||
//! \~russian Обрабатывает изменение фокуса тайла
|
||||
virtual void tileSetFocusInternal(PIScreenTile *) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*! \file piterminal.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Virtual terminal
|
||||
* \~russian Виртуальный терминал
|
||||
*/
|
||||
//! \file piterminal.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Virtual terminal
|
||||
//! \~russian Виртуальный терминал
|
||||
//! \details
|
||||
//! \~english Provides terminal emulation for reading console input and output.
|
||||
//! \~russian Обеспечивает эмуляцию терминала для чтения ввода и вывода консоли.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Virtual terminal
|
||||
@@ -35,22 +37,66 @@ class PIP_CONSOLE_EXPORT PITerminal: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PITerminal, PIThread);
|
||||
|
||||
public:
|
||||
//! Constructs %PITerminal
|
||||
//! \brief
|
||||
//! \~english Constructs PITerminal
|
||||
//! \~russian Создает PITerminal
|
||||
PITerminal();
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~PITerminal();
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of columns
|
||||
//! \~russian Возвращает количество колонок
|
||||
int columns() const { return size_x; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of rows
|
||||
//! \~russian Возвращает количество строк
|
||||
int rows() const { return size_y; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Resizes terminal
|
||||
//! \~russian Изменяет размер терминала
|
||||
//! \param cols Number of columns / Количество колонок
|
||||
//! \param rows Number of rows / Количество строк
|
||||
bool resize(int cols, int rows);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes data to terminal
|
||||
//! \~russian Записывает данные в терминал
|
||||
void write(const PIByteArray & d);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes special key to terminal
|
||||
//! \~russian Записывает специальную клавишу в терминал
|
||||
void write(PIKbdListener::SpecialKey k, PIKbdListener::KeyModifiers m);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes key event to terminal
|
||||
//! \~russian Записывает событие клавиши в терминал
|
||||
void write(PIKbdListener::KeyEvent ke);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns terminal content
|
||||
//! \~russian Возвращает содержимое терминала
|
||||
PIVector<PIVector<PIScreenTypes::Cell>> content();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if key is special
|
||||
//! \~russian Проверяет, является ли клавиша специальной
|
||||
static bool isSpecialKey(int k);
|
||||
|
||||
//! \brief
|
||||
//! \~english Initializes terminal
|
||||
//! \~russian Инициализирует терминал
|
||||
bool initialize();
|
||||
|
||||
//! \brief
|
||||
//! \~english Destroys terminal
|
||||
//! \~russian Уничтожает терминал
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user