/*! \file piscreentiles.h * \ingroup Console * \~\brief * \~english Various tiles for PIScreen * \~russian Различные тайлы для PIScreen */ /* PIP - Platform Independent Primitives Various tiles 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 . */ #ifndef PISCREENTILES_H #define PISCREENTILES_H #include "pip_console_export.h" #include "piscreentile.h" class PIP_CONSOLE_EXPORT TileSimple: public PIScreenTile { PIOBJECT_SUBCLASS(TileSimple, PIScreenTile); public: typedef PIPair Row; TileSimple(const PIString & n = PIString()); TileSimple(const Row & r); virtual ~TileSimple() {} PIVector content; PIScreenTypes::Alignment alignment; protected: void sizeHint(int & w, int & h) const override; void drawEvent(PIScreenDrawer * d) override; }; class TileList; class PIP_CONSOLE_EXPORT TileScrollBar: public PIScreenTile { PIOBJECT_SUBCLASS(TileScrollBar, PIScreenTile); friend class TileList; public: TileScrollBar(const PIString & n = PIString()); virtual ~TileScrollBar() {} void setMinimum(int v); void setMaximum(int v); void setValue(int v); int minimum() const { return minimum_; } int maximum() const { return maximum_; } int value() const { return value_; } int thickness; protected: void _check(); void sizeHint(int & w, int & h) const override; void drawEvent(PIScreenDrawer * d) override; bool mouseEvent(PIKbdListener::MouseEvent me) override; int minimum_, maximum_, value_; PIChar line_char; }; class PIP_CONSOLE_EXPORT TileList: public PIScreenTile { PIOBJECT_SUBCLASS(TileList, PIScreenTile); public: enum SelectionMode { NoSelection, SingleSelection, MultiSelection }; enum EventType { SelectionChanged, RowPressed }; TileList(const PIString & n = PIString(), SelectionMode sm = NoSelection); virtual ~TileList() {} typedef PIPair Row; PIDeque content; PIScreenTypes::Alignment alignment; SelectionMode selection_mode; PISet selected; int lhei, cur, offset; protected: void sizeHint(int & w, int & h) const override; void resizeEvent(int w, int h) override; void drawEvent(PIScreenDrawer * d) override; bool keyEvent(PIKbdListener::KeyEvent key) override; bool mouseEvent(PIKbdListener::MouseEvent me) override; bool wheelEvent(PIKbdListener::WheelEvent we) override; TileScrollBar * scroll; bool mouse_sel; }; class PIP_CONSOLE_EXPORT TileButton: public PIScreenTile { PIOBJECT_SUBCLASS(TileButton, PIScreenTile); public: TileButton(const PIString & n = PIString()); virtual ~TileButton() {} enum EventType { ButtonClicked }; PIScreenTypes::CellFormat format; PIString text; protected: void sizeHint(int & w, int & h) const override; void drawEvent(PIScreenDrawer * d) override; bool keyEvent(PIKbdListener::KeyEvent key) override; bool mouseEvent(PIKbdListener::MouseEvent me) override; }; class PIP_CONSOLE_EXPORT TileButtons: public PIScreenTile { PIOBJECT_SUBCLASS(TileButtons, PIScreenTile); public: TileButtons(const PIString & n = PIString()); virtual ~TileButtons() {} enum EventType { ButtonSelected }; typedef PIPair Button; PIScreenTypes::Alignment alignment; PIVector