16#include "windowBase.hpp"
19#include "checkbox.hpp"
53 unsigned DrawPrioritet;
80 unsigned int activeForm;
87 std::vector<Element> _Elements;
228 for(
unsigned i = 0; i < _Elements.size(); i++)
230 if (!_Elements[i].use)
234 case UI::buttons::Button::Type::Image:
235 _Elements[i].btn = btn;
237 case UI::buttons::Button::Type::Text:
243 _Elements[i]._type = Element::Type::Button;
244 _Elements[i].use =
true;
251 case UI::buttons::Button::Type::Image:
252 a.btn.init(btn.GetCoord(), btn.GetSize(), btn.
GetImage(), btn.GetMargin(), btn.
GetColor());
254 case UI::buttons::Button::Type::Text:
260 _Elements.push_back(a);
261 return _Elements.size();
264 unsigned Window::AddNewTextLabel(UI::text::TextLabel text)
266 _ksys_debug_puts(
"AddNewText:");
267 for (
unsigned i = 0; i < _Elements.size(); i++)
269 char *a =
"find, try №";
270 char *b = (
char*)(
'0' + (
char)i);
274 if (!_Elements[i].use)
276 _Elements[i].txt = text;
277 _Elements[i]._type = Element::Type::TextLabel;
278 _Elements[i].use =
true;
279 _ksys_debug_puts(
"done\n");
283 _ksys_debug_puts(
"\n\n==>Element:");
285 _ksys_debug_puts(
"\na.use = true");
287 _ksys_debug_puts(
"\ntxt.init()");
288 a.txt.init(text.GetCoord(), text.GetSize(), text.GetText(), text.GetFontSize(), text.GetColor());
289 _ksys_debug_puts(
"\n\nDONE!!!\n\n");
290 _Elements.push_back(a);
293 unsigned Window::AddNewForm(UI::Form form)
295 for (
unsigned i = 0; i < _Elements.size(); i++)
297 if (!_Elements[i].use)
299 _Elements[i].frm.init(form.GetCoord(), form.GetSize(), NULL, form.GetColor(), form.GetBackgroundColor(), form.GetMargin());
300 _Elements[i]._type = Element::Type::Form;
301 _Elements[i].use =
true;
306 a.frm.init(form.GetCoord(), form.GetSize(), NULL, form.GetColor(), form.GetBackgroundColor(), form.GetMargin());
308 a._type = Element::Type::Form;
309 _Elements.push_back(a);
310 return _Elements.size();
315 _ksys_debug_puts(
"window:");
335 for(
unsigned i = 0; i < _Elements.size(); i++)
337 _Elements[i].use =
false;
338 _Elements[i].btn.~Button();
339 _Elements[i].ChckBx.~CheckBox();
340 _Elements[i].txt.~TextLabel();
341 _Elements[i].frm.~Form();
342 _Elements[i].img.~image();
348 _colors = colorTable;
368 _ksys_create_window(coord.x, coord.y, _size.x, _size.y, _title.c_str(), _colors.work_area, _style);
374 _ksys_change_window(coord.x, coord.y, size.x, size.y);
379 _ksys_set_window_title(newTitle.c_str());
391 for (
unsigned i = 0; i < _Elements.size(); i++)
393 if (_Elements[i].use)
395 switch (_Elements[i]._type)
397 case Element::Type::Button:
398 _Elements[i].btn.Render();
400 case Element::Type::TextLabel:
401 _Elements[i].txt.Render();
403 case Element::Type::CheckBox:
404 _Elements[i].ChckBx.Render();
406 case Element::Type::Image:
407 _Elements[i].img.Render();
432 color = _colors.work_button;
433 TextColor = _colors.work_button_text;
436 return AddNewButton(b);
443 _ksys_debug_puts(
"CreateText:");
446 color = _colors.work_text;
450 return AddNewTextLabel(t);
462 _Elements[id].use =
false;
470 case OS::Events::Redraw:
473 case OS::Events::Button:
476 return OS::Events::Exit;
479 for (
unsigned i = 0; i < _Elements.size(); i++)
481 if (_Elements[i].use)
483 switch(_Elements[i]._type)
485 case Element::Type::Form:
487 _Elements[i].frm.ButtonHandler();
488 case Element::CheckBox:
489 _Elements[i].ChckBx.Handler();
490 case Element::Button:
491 _Elements[i].btn.Handler();
496 case OS::Events::Key:
497 for(
unsigned i = 0; i < _Elements.size(); i++)
501 if(_Elements[i]._type == Element::Type::Form)
503 _Elements[activeForm].frm.Handler();
514 for(
unsigned i = 0; i < _Elements.size(); i++)
516 if(_Elements[i]._type == Element::Type::Button)
520 return _Elements[i].btn.GetId();
527 if(_Elements[form]._type == Element::Type::Form)
529 return _Elements[form].frm.GetInput();
535 return _Elements[id].btn;
542 if(
Handler() == OS::Events::Exit)
Класс для работы с чекбоксами
Definition checkbox.hpp:21
Картинка как элемент интерфейса
Definition image.hpp:23
Color::Color GetColor()
Получить осносной цвет элемента
Definition UI.hpp:69
Текстовая метка
Definition text.hpp:66
Класс для работы с окном
Definition window.hpp:63
void HandlerThread()
Обработчик окна в отдельном потоке
Definition window.hpp:538
void EndRedraw()
Закончить перересовку окна
Definition window.hpp:357
Window(std::string Title="Window", UI::Size size=DefaultWindowSize, int style=0x14, Color::ColorsTable colors=Color::DefaultColorTable, unsigned Margin=0)
Конструктор
Definition window.hpp:313
unsigned CreateButton(const UI::buttons::Button &btn)
Создать кнопку
OS::Event Handler()
Обработчик окна
Definition window.hpp:464
UI::buttons::Button GetButton(unsigned id)
Получить кнопку
Definition window.hpp:533
void StartRedraw()
Начать перересовку окна
Definition window.hpp:351
UI::Size GetWindowSize()
Получить размер окна
Definition window.hpp:382
void ChangeWindow(UI::Coord coord, UI::Size size)
Изменить окно
Definition window.hpp:371
void ChangeTilte(std::string newTitle)
Изменить заголовок окна
Definition window.hpp:377
void SetTextLabel(unsigned N, const UI::text::TextLabel &text)
Изменить текст
void DeleteElement(unsigned id)
Удалить элемент
Definition window.hpp:460
unsigned CreateText(UI::Coord coord={0, 0}, UI::Size size={16, 16}, std::string text="Text", unsigned FontSize=9, bool UseWindowColors=true, Color::Color color=OS::sys_color_table.work_text)
Создать текст в окне
Definition window.hpp:441
void SetWindowColors(Color::ColorsTable colorTable)
Задать стандартные цвета окна
Definition window.hpp:346
unsigned CreateButton(UI::Coord coord={0, 0}, UI::Size size={16, 16}, std::string Text=" ", unsigned margin=UI::DefaultMargin, bool UseWindowColors=true, Color::Color color=OS::sys_color_table.work_button, Color::Color TextColor=OS::sys_color_table.work_button_text)
Создать кнопку
Definition window.hpp:428
std::string GetInputFromFrom(unsigned form)
Получить текст введённый в форму
Definition window.hpp:525
unsigned GetMargin()
Получить рамер отступов в этом окне
Definition window.hpp:418
void DrawWindow(UI::Coord coord=mouse::GetMousePositionOnSreen())
Отрисовать окно
Definition window.hpp:366
UI::Size GetSize()
Получить размер окна
Definition window.hpp:423
void Render()
Отрисовать окно
Definition window.hpp:386
UI::buttons::ButtonID GetPressedButton()
Проверить какая нажата
Definition window.hpp:512
unsigned CreateForm(UI::Form form)
Создать форму
ksys_color_t Color
Цвет
Definition color.hpp:13
bool ComparisonColorsTables(const ColorsTable &a, const ColorsTable &b)
Сравнить две таблица цветов
Definition color.hpp:26
const ColorsTable DefaultColorTable
Таблица цветов по умолчанию
Definition color.hpp:19
ksys_colors_table_t ColorsTable
Таблица цветов
Definition color.hpp:16
Event WaitEvent()
Ждать ивента
Definition os.hpp:43
Color::ColorsTable sys_color_table
Таблица стандартных(системных) цветов
Definition os.hpp:15
unsigned int Event
Ивент
Definition os.hpp:27
Color::ColorsTable GetSystemColors()
Получить системные цвета
Definition os.hpp:20
point< int > GetMousePositionOnSreen()
Получить позицияю курсора на экране
Definition mouse.hpp:15
const UI::Coord DefaultWindowCoord
Соординаты окна по умолчанию
Definition windowBase.hpp:19
const UI::Size DefaultWindowSize
Размер окна поумолчанию
Definition windowBase.hpp:16
Основное пространство имён
Definition base.hpp:18