9#include "windowBase.hpp"
18 const unsigned DefaultMargin = 4;
52 _ksys_draw_bar(coord.x * KolibriLib::AAANUMBER, coord.y * KolibriLib::AAANUMBER, size.x, size.y, color);
59 unsigned int GetTextSize()
72 void SetTextSize(
unsigned int newSize)
75 "int $0x40" ::
"a"(48),
"b"(12),
"c"(newSize)
87 _ksys_draw_text(text.c_str(), coord.x, coord.y, text.length(), color);
97 _ksys_draw_text(text, coord.x, coord.y, strlen(text), color);
122 TextLabel(
point coord = {0, 0},
point size = {0, 0}, std::string text =
"Text",
unsigned FontSize = 9,
bool TextScale =
true,
unsigned Margin = 0);
140 _FontSize = FontSize;
141 _TextScale = TextScale;
144 TextLabel::~TextLabel()
153 _FontSize =
_size.x / _text.length();
155 SetTextSize(_FontSize);
175 const unsigned StartButtonId = 100;
185 std::vector<ButtonsIdData> ButtonsIdList;
190 unsigned GetFreeButtonId()
192 for (
unsigned i = 0; i < ButtonsIdList.size(); i++)
194 if (!ButtonsIdList[i].use)
196 ButtonsIdList[i].use =
true;
202 a.data = StartButtonId + ButtonsIdList.size();
204 ButtonsIdList.push_back(a);
205 return ButtonsIdList.size() - 1;
210 void FreeButtonId(
unsigned id)
212 ButtonsIdList[id].use =
false;
219 unsigned GetButtonId(
unsigned id)
221 return ButtonsIdList[id].data;
229 inline unsigned autoDefineButton(point coords, point size, ksys_color_t color =
OS::sys_color_table.work_button)
231 unsigned id = GetButtonId(GetFreeButtonId());
232 _ksys_define_button(coords.x, coords.y, size.x, size.y,
id, color);
241 inline void DefineButton(point coord, point size,
unsigned id, ksys_color_t color =
OS::sys_color_table.work_button)
243 _ksys_define_button(coord.x, coord.y, size.x, size.y,
id, color);
248 inline void DeleteButton(
unsigned id)
250 _ksys_delete_button(
id);
256 inline unsigned GetPressedButton()
258 return _ksys_get_button();
271 ksys_color_t _BackgroundColor;
274 ksys_color_t _TextColor;
334 init(coord, size, text, Margin, BackgroundColor, TextColor);
350 _id = GetFreeButtonId();
364 DefineButton(
_coord,
_size, GetButtonId(_id), _BackgroundColor);
370 unsigned buff = text::GetTextSize();
372 text::DrawText(_text,
_coord, _TextColor);
373 text::SetTextSize(buff);
378 if (GetPressedButton() == _id)
400 _BackgroundColor = BackgroundColor;
401 _TextColor = TextColor;
408 _id = GetFreeButtonId();
428 std::string _BackgroundText;
431 std::string _inputText;
434 ksys_color_t _FormColor;
435 ksys_color_t _BackgroundTextColor;
462 _BackgroundText = BackgroundText;
463 _FormColor = FormColor;
464 _BackgroundTextColor = BackgroundTextColor;
466 _butt.
init(coord, size,
" ", 0);
479 if (_inputText ==
"")
484 _BackgroundTextColor);
Элемент интерфейса
Definition UI.hpp:23
unsigned _Margin
Отступы
Definition UI.hpp:33
KolibriLib::point _coord
Координаты
Definition UI.hpp:27
KolibriLib::point _size
Размер
Definition UI.hpp:30
Класс для работы с текстом
Definition UI.hpp:104
unsigned GetFontSize()
Получить Размер шрифта
Definition UI.hpp:163
void render()
Отрисовать текст
Definition UI.hpp:149
TextLabel(point coord={0, 0}, point size={0, 0}, std::string text="Text", unsigned FontSize=9, bool TextScale=true, unsigned Margin=0)
Конструктор
Definition UI.hpp:137
std::string GetText()
Получить текст
Definition UI.hpp:159
ksys_colors_table_t sys_color_table
Таблица стандартных(системных) цветов
Definition base.hpp:37
Основное пространство имён
Definition base.hpp:17
void init()
инициализация
Definition base.hpp:112
Просто точка
Definition base.hpp:22