KolibriLib
Loading...
Searching...
No Matches
checkbox.hpp
1#ifndef __CHECKBOX_H__
2#define __CHECKBOX_H__
3
4#include <sys/ksys.h>
5
6#include <string>
7
8#include "small.hpp"
9#include "UI.hpp"
10#include "button.hpp"
11#include "graphic.hpp"
12#include "color.hpp"
13
14namespace KolibriLib
15{
16 namespace UI
17 {
21 {
22 private:
23 int _style;
24 bool _status;
25
26 public:
28 enum style
29 {
37 };
38
39 CheckBox(const Coord& coord = {0, 0}, const Size& size = {32, 16}, const int& style = 0, const Color::Color& CheckBoxBorderColor = OS::sys_color_table.work_text, const Color::Color& BackgroundColor = OS::sys_color_table.work_area, const unsigned& Margin = DefaultMargin);
40 ~CheckBox();
41
42 void Render();
43
45 bool Handler();
46 };
47
48 CheckBox::CheckBox(const Coord& coord, const Size& size, const int& style, const Color::Color& CheckBoxBorderColor, const Color::Color& BackgroundColor, const unsigned& Margin) : Button(coord, size, CheckBoxBorderColor, Margin)
49 {
50 _ksys_debug_puts("CheckBox");
51 _style = style;
52 }
53
54 CheckBox::~CheckBox()
55 {
56 }
57
58 void CheckBox::Render()
59 {
60 switch (_style)
61 {
62 case Default:
63 graphic::DrawRectangleLines(_coord, {_coord.x + (int)_size.x, _coord.y + (int)_size.y}, _MainColor);
64 break;
65 case Circle:
66 graphic::DrawCircle(_coord, _size.x / 2, 36, _MainColor);
67 default:
68 break;
69 }
70
71 if (_status)
72 {
73 switch (_style)
74 {
75 case Default:
76 graphic::DrawRectangleFill({_coord.x + (int)_Margin, _coord.y + (int)_Margin}, {(unsigned)_size.x - (2 * _Margin), _size.y + (2 * _Margin)}, _MainColor);
77 break;
78 case Circle:
79 graphic::DrawCircle({_coord.x + (int)_Margin, _coord.y + (int)_Margin}, _size.x / 2 - _Margin, 36, _MainColor);
80 break;
81 case Smoth:
82 break;
83 default:
84 break;
85 }
86 }
87 }
88
90 {
91 if (Button::Handler()) // Если кнопка была нажата
92 {
93 _status != _status;
94 }
95 return _status;
96 }
97 } // namespace UI
98
99} // namespace KolibriLib
100
101
102#endif // __CHECKBOX_H__
Класс для работы с чекбоксами
Definition checkbox.hpp:21
bool Handler()
Обработчик кнопки
Definition checkbox.hpp:89
style
Стиль Чекбокса
Definition checkbox.hpp:29
@ Circle
В виде круга
Definition checkbox.hpp:33
@ Smoth
Квадрат с со сглаженными углами
Definition checkbox.hpp:36
@ Default
По вид умолчанию, квадрат
Definition checkbox.hpp:31
unsigned _Margin
Отступы
Definition UI.hpp:41
Size _size
Размер
Definition UI.hpp:36
Coord _coord
Координаты
Definition UI.hpp:33
Класс для работы с кнопками
Definition button.hpp:127
ksys_color_t Color
Цвет
Definition color.hpp:13
Color::ColorsTable sys_color_table
Таблица стандартных(системных) цветов
Definition os.hpp:15
Основное пространство имён
Definition base.hpp:18