xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
lcd_label.h
Go to the documentation of this file.
1
4#pragma once
5#include <codecvt>
7#include <xtd/as.h>
8#include <xtd/interface.h>
9#include "control.h"
10#include "dot_matrix_display.h"
11#include "lcd_style.h"
16
17namespace xtd {
18 namespace forms {
31 class lcd_label : public control {
32 class idigit interface_ {
33 public:
34 virtual wchar_t get_character() const = 0;
35 virtual xtd::ustring get_valid_characters() const = 0;
36 virtual int32_t get_thickness() const = 0;
37
38 virtual void set_back_digit_color(const xtd::drawing::color& value) = 0;
39 virtual void set_back_digit_opacity(double value) = 0;
40 virtual void set_character(wchar_t value) = 0;
41 virtual void set_segment_style(forms::segment_style value) = 0;
42 virtual void set_dot_matrix_style(forms::dot_matrix_style value) = 0;
43 virtual void set_show_back_digit(bool value) = 0;
44 virtual void set_thickness(int32_t value) = 0;
45 };
46
47 class dot_matrix_display_digit : public dot_matrix_display, public idigit {
48 public:
49 dot_matrix_display_digit() = default;
50
51 wchar_t get_character() const override {return character_;}
52 xtd::ustring get_valid_characters() const override {return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=+-*/%\\_°\"'[](){}<>| .,:;!?&$€";}
53 int32_t get_thickness() const override {return dot_matrix_display::thickness();}
54
55 void set_back_digit_color(const xtd::drawing::color& value) override {dot_matrix_display::back_dot_color(value);}
56 void set_back_digit_opacity(double value) override {dot_matrix_display::back_dot_opacity(value);}
57 void set_character(wchar_t value) override {
58 static std::map<wchar_t, dot_matrix_display::points_collection> characters {
59 {'0', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {4, 2}, {5, 2}, {1, 3}, {3, 3}, {5, 3}, {1, 4}, {2, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
60 {'1', {{3, 0}, {2, 1}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
61 {'2', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {5, 2}, {4, 3}, {3, 4}, {2, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
62 {'3', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {5, 2}, {2, 3}, {3, 3}, {4, 3}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
63 {'4', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {5, 4}, {5, 5}, {5, 6}}},
64 {'5', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {1, 1}, {1, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 4}, {5, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}}},
65 {'6', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {1, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
66 {'7', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {5, 1}, {5, 2}, {4, 3}, {4, 4}, {3, 5}, {3, 6}}},
67 {'8', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
68 {'9', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {2, 3}, {3, 3}, {4, 3}, {5, 4}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
69 {'A', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
70 {'B', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}}},
71 {'C', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 6}, {3, 6}, {5, 5}, {4, 6}}},
72 {'D', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}}},
73 {'E', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {1, 1}, {1, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
74 {'F', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {1, 1}, {1, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {1, 5}, {1, 6}}},
75 {'G', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {1, 2}, {1, 3}, {4, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
76 {'H', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
77 {'I', {{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
78 {'J', {{5, 0}, {5, 1}, {5, 2}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
79 {'K', {{1, 0}, {5, 0}, {1, 1}, {4, 1}, {1, 2}, {3, 2}, {1, 3}, {2, 3}, {1, 4}, {3, 4}, {1, 5}, {4, 5}, {1, 6}, {5, 6}}},
80 {'L', {{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
81 {'M', {{1, 0}, {5, 0}, {1, 1}, {2, 1}, {4, 1}, {5, 1}, {1, 2}, {3, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
82 {'N', {{1, 0}, {5, 0}, {1, 1}, {2, 1}, {5, 1}, {1, 2}, {3, 2}, {5, 2}, {1, 3}, {4, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
83 {'O', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
84 {'P', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {1, 5}, {1, 6}}},
85 {'Q', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {4, 5}, {2, 6}, {3, 6}, {5, 6}}},
86 {'R', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {1, 4}, {3, 4}, {1, 5}, {4, 5}, {1, 6}, {5, 6}}},
87 {'S', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {2, 3}, {3, 3}, {4, 3}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
88 {'T', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
89 {'U', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
90 {'V', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {2, 3}, {4, 3}, {2, 4}, {4, 4}, {3, 5}, {3, 6}}},
91 {'W', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {1, 2}, {3, 2}, {5, 2}, {1, 3}, {3, 3}, {5, 3}, {1, 4}, {3, 4}, {5, 4}, {1, 5}, {2, 5}, {4, 5}, {5, 5}, {1, 6}, {5, 6}}},
92 {'X', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {2, 2}, {4, 2}, {3, 3}, {2, 4}, {4, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
93 {'Y', {{1, 0}, {5, 0}, {1, 1}, {5, 1}, {2, 2}, {4, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
94 {'Z', {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {5, 1}, {4, 2}, {3, 3}, {2, 4}, {1, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
95 {'a', {{2, 2}, {3, 2}, {4, 2}, {5, 3}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
96 {'b', {{1, 0}, {1, 1}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}}},
97 {'c', {{2, 2}, {3, 2}, {4, 2}, {5, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
98 {'d', {{5, 0}, {5, 1}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
99 {'e', {{2, 2}, {3, 2}, {4, 2}, {1, 3}, {5, 3}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {1, 5}, {2, 6}, {3, 6}, {4, 6}}},
100 {'f', {{3, 0}, {4, 0}, {2, 1}, {2, 2}, {3, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}}},
101 {'g', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
102 {'h', {{1, 0}, {1, 1}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
103 {'i', {{3, 0}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
104 {'j', {{4, 0}, {4, 2}, {4, 3}, {4, 4}, {4, 5}, {2, 6}, {3, 6}}},
105 {'k', {{1, 0}, {1, 1}, {1, 2}, {5, 2}, {1, 3}, {4, 3}, {1, 4}, {2, 4}, {3, 4}, {1, 5}, {4, 5}, {1, 6}, {5, 6}}},
106 {'l', {{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 6}}},
107 {'m', {{2, 2}, {4, 2}, {1, 3}, {3, 3}, {5, 3}, {1, 4}, {3, 4}, {5, 4}, {1, 5}, {3, 5}, {5, 5}, {1, 6}, {3, 6}, {5, 6}}},
108 {'n', {{2, 2}, {3, 2}, {4, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {1, 6}, {5, 6}}},
109 {'o', {{2, 2}, {3, 2}, {4, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
110 {'p', {{1, 1}, {2, 1}, {3, 1}, {4, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {1, 5}, {1, 6}}},
111 {'q', {{2, 1}, {3, 1}, {4, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {5, 5}, {5, 6}}},
112 {'r', {{2, 2}, {3, 2}, {4, 2}, {5, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}}},
113 {'s', {{2, 2}, {3, 2}, {4, 2}, {5, 2}, {1, 3}, {2, 4}, {3, 4}, {4, 4}, {5, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}}},
114 {'t', {{3, 0}, {3, 1}, {2, 2}, {3, 2}, {4, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 6}, {5, 6}}},
115 {'u', {{1, 2}, {5, 2}, {1, 3}, {5, 3}, {1, 4}, {5, 4}, {1, 5}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
116 {'v', {{1, 2}, {5, 2}, {1, 3}, {5, 3}, {2, 4}, {4, 4}, {2, 5}, {4, 5}, {3, 6}}},
117 {'w', {{1, 2}, {3, 2}, {5, 2}, {1, 3}, {3, 3}, {5, 3}, {1, 4}, {3, 4}, {5, 4}, {1, 5}, {3, 5}, {5, 5}, {2, 6}, {4, 6}}},
118 {'x', {{1, 2}, {5, 2}, {2, 3}, {4, 3}, {3, 4}, {2, 5}, {4, 5}, {1, 6}, {5, 6}}},
119 {'y', {{1, 1}, {5, 1}, {1, 2}, {5, 2}, {1, 3}, {5, 3}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {5, 5}, {2, 6}, {3, 6}, {4, 6}}},
120 {'z', {{1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {4, 3}, {3, 4}, {2, 5}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
121 {'=', {{1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}}},
122 {'+', {{3, 1}, {3, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {3, 4}, {3, 5}}},
123 {'-', {{1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}}},
124 {'*', {{3, 0}, {1, 1}, {3, 1}, {5, 1}, {2, 2}, {3, 2}, {4, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {2, 4}, {3, 4}, {4, 4}, {1, 5}, {3, 5}, {5, 5}, {3, 6}}},
125 {'/', {{5, 1}, {4, 2}, {3, 3}, {2, 4}, {1, 5}}},
126 {'%', {{1, 0}, {2, 0}, {1, 1}, {2, 1}, {5, 1}, {4, 2}, {3, 3}, {2, 4}, {1, 5}, {4, 5}, {5, 5}, {4, 6}, {5, 6}}},
127 {'\\', {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}},
128 {'_', {{1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}}},
129 {L'\u00B0', {{2, 0}, {3, 0}, {1, 1}, {4, 1}, {1, 2}, {4, 2}, {2, 3}, {3, 3}}},
130 {'"', {{2, 0}, {5, 0}, {2, 1}, {5, 1}, {1, 2}, {4, 2}}},
131 {'\'', {{3, 0}, {3, 1}, {2, 2}}},
132 {'[', {{3, 0}, {4, 0}, {5, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {4, 6}, {5, 6}}},
133 {']', {{1, 0}, {2, 0}, {3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {1, 6}, {2, 6}, {3, 6}}},
134 {'(', {{4, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 6}}},
135 {')', {{2, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {2, 6}}},
136 {'{', {{4, 0}, {5, 0}, {3, 1}, {3, 2}, {2, 3}, {3, 4}, {3, 5}, {4, 6}, {5, 6}}},
137 {'}', {{1, 0}, {2, 0}, {3, 1}, {3, 2}, {4, 3}, {3, 4}, {3, 5}, {1, 6}, {2, 6}}},
138 {'<', {{4, 1}, {3, 2}, {2, 3}, {3, 4}, {4, 5}}},
139 {'>', {{2, 1}, {3, 2}, {4, 3}, {3, 4}, {2, 5}}},
140 {'|', {{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}}},
141 {' ', {}},
142 {'.', {{3, 6}}},
143 {',', {{3, 5}, {2, 6}}},
144 {':', {{3, 1}, {3, 5}}},
145 {';', {{3, 2}, {3, 5}, {2, 6}}},
146 {'!', {{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 6}}},
147 {'?', {{2, 0}, {3, 0}, {4, 0}, {1, 1}, {5, 1}, {5, 2}, {4, 3}, {3, 4}, {3, 6}}},
148 {'&', {{2, 0}, {3, 0}, {1, 1}, {4, 1}, {1, 2}, {4, 2}, {2, 3}, {3, 3}, {5, 3}, {1, 4}, {4, 4}, {1, 5}, {4, 5}, {2, 6}, {3, 6}, {5, 6}}},
149 {'$', {{3, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {1, 2}, {3, 2}, {2, 3}, {3, 3}, {4, 3}, {3, 4}, {5, 4}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {3, 6}}},
150 {L'\u20AC', {{3, 0}, {4, 0}, {5, 0}, {2, 1}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {2, 3}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {2, 5}, {3, 6}, {4, 6}, {5, 6}}},
151 };
152 if (character_ != value) {
153 auto it = characters.find(value);
154 if (it == characters.end()) throw argument_exception(ustring::format("Only characters : \"{}\" are valid"_t, get_valid_characters()), current_stack_frame_);
155 character_ = value;
157 }
158 }
159 void set_segment_style(forms::segment_style value) override {}
160 void set_dot_matrix_style(forms::dot_matrix_style value) override {dot_matrix_display::dot_matrix_style(value);}
161 void set_show_back_digit(bool value) override {dot_matrix_display::show_back_dot(value);}
162 void set_thickness(int32_t value) override {dot_matrix_display::thickness(value);}
163
164 private:
165 wchar_t character_ = ' ';
166 };
167
168 class fourteen_segment_display_digit : public fourteen_segment_display, public idigit {
169 public:
170 fourteen_segment_display_digit() = default;
171
172 wchar_t get_character() const override {return character_;}
173 xtd::ustring get_valid_characters() const override {return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=+-*/\\_°\"'[]()| .,:";}
174 int32_t get_thickness() const override {return fourteen_segment_display::thickness();}
175
176 void set_back_digit_color(const xtd::drawing::color& value) override {fourteen_segment_display::back_segment_color(value);}
177 void set_back_digit_opacity(double value) override {fourteen_segment_display::back_segment_opacity(value);}
178 void set_character(wchar_t value) override {
179 static std::map<wchar_t, forms::segments> characters {
224 {'i', forms::segments::l},
248 {'_', forms::segments::d},
251 {'\'', forms::segments::f},
258 {'.', forms::segments::dp},
259 {',', forms::segments::k},
261 };
262 if (character_ != value) {
263 auto it = characters.find(value);
264 if (it == characters.end()) throw argument_exception(ustring::format("Only characters : \"{}\" are valid"_t, get_valid_characters()), current_stack_frame_);
265 character_ = value;
267 }
268 }
270 void set_dot_matrix_style(forms::dot_matrix_style value) override {}
271 void set_show_back_digit(bool value) override {fourteen_segment_display::show_back_segment(value);}
272 void set_thickness(int32_t value) override {seven_segment_display::thickness(value);}
273
274 private:
275 wchar_t character_ = ' ';
276 };
277
278 class nine_segment_display_digit : public nine_segment_display, public idigit {
279 public:
280 nine_segment_display_digit() = default;
281
282 wchar_t get_character() const override {return character_;}
283 xtd::ustring get_valid_characters() const override {return "0123456789ABCDEFGHIJLNOPQRSTUYabcdefghijlnopqrstuy=-_°\"'[]| .,:";}
284 int32_t get_thickness() const override {return nine_segment_display::thickness();}
285
286 void set_back_digit_color(const xtd::drawing::color& value) override {nine_segment_display::back_segment_color(value);}
287 void set_back_digit_opacity(double value) override {nine_segment_display::back_segment_opacity(value);}
288 void set_character(wchar_t value) override {
289 static std::map<wchar_t, forms::segments> characters {
317 {'i', forms::segments::c},
341 {'_', forms::segments::d},
344 {'\'', forms::segments::f},
348 {'.', forms::segments::dp},
349 {',', forms::segments::dp},
351 };
352 if (character_ != value) {
353 auto it = characters.find(value);
354 if (it == characters.end()) throw argument_exception(ustring::format("Only characters : \"{}\" are valid"_t, get_valid_characters()), current_stack_frame_);
355 character_ = value;
356 nine_segment_display::value(it->second);
357 }
358 }
359 void set_segment_style(forms::segment_style value) override {nine_segment_display::segment_style(value);}
360 void set_dot_matrix_style(forms::dot_matrix_style value) override {}
361 void set_show_back_digit(bool value) override {nine_segment_display::show_back_segment(value);}
362 void set_thickness(int32_t value) override {seven_segment_display::thickness(value);}
363
364 private:
365 wchar_t character_ = ' ';
366 };
367
368 class seven_segment_display_digit : public seven_segment_display, public idigit {
369 public:
370 seven_segment_display_digit() = default;
371
372 wchar_t get_character() const override {return character_;}
373 xtd::ustring get_valid_characters() const override {return "0123456789ABCDEFGHIJLNOPQRSTUYabcdefghijlnopqrstuy=-_°\"'[]| .,:";}
374 int32_t get_thickness() const override {return seven_segment_display::thickness();}
375
376 void set_back_digit_color(const xtd::drawing::color& value) override {seven_segment_display::back_segment_color(value);}
377 void set_back_digit_opacity(double value) override {seven_segment_display::back_segment_opacity(value);}
378 void set_character(wchar_t value) override {
379 static std::map<wchar_t, forms::segments> characters {
407 {'i', forms::segments::c},
431 {'-', forms::segments::g},
432 {'_', forms::segments::d},
435 {'\'', forms::segments::f},
439 {'.', forms::segments::dp},
440 {',', forms::segments::dp},
441 {':', forms::segments::pc}};
442 if (character_ != value) {
443 auto it = characters.find(value);
444 if (it == characters.end()) throw argument_exception(ustring::format("Only characters : \"{}\" are valid"_t, get_valid_characters()), current_stack_frame_);
445 character_ = value;
447 }
448 }
449 void set_segment_style(forms::segment_style value) override {seven_segment_display::segment_style(value);}
450 void set_dot_matrix_style(forms::dot_matrix_style value) override {}
451 void set_show_back_digit(bool value) override {seven_segment_display::show_back_segment(value);}
452 void set_thickness(int32_t value) override {seven_segment_display::thickness(value);}
453
454 private:
455 wchar_t character_ = ' ';
456 };
457
458 class sixteen_segment_display_digit : public sixteen_segment_display, public idigit {
459 public:
460 sixteen_segment_display_digit() = default;
461
462 wchar_t get_character() const override {return character_;}
463 xtd::ustring get_valid_characters() const override {return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=+-*/\\_°\"'[]()| .,:";}
464 int32_t get_thickness() const override {return sixteen_segment_display::thickness();}
465
466 void set_back_digit_color(const xtd::drawing::color& value) override {sixteen_segment_display::back_segment_color(value);}
467 void set_back_digit_opacity(double value) override {sixteen_segment_display::back_segment_opacity(value);}
468 void set_character(wchar_t value) override {
469 static std::map<wchar_t, forms::segments> characters {
515 {'i', forms::segments::l},
541 {'\'', forms::segments::f},
548 {'.', forms::segments::dp},
549 {',', forms::segments::k},
551 };
552 if (character_ != value) {
553 auto it = characters.find(value);
554 if (it == characters.end()) throw argument_exception(ustring::format("Only characters : \"{}\" are valid"_t, get_valid_characters()), current_stack_frame_);
555 character_ = value;
557 }
558 }
560 void set_dot_matrix_style(forms::dot_matrix_style value) override {}
561 void set_show_back_digit(bool value) override {sixteen_segment_display::show_back_segment(value);}
562 void set_thickness(int32_t value) override {sixteen_segment_display::thickness(value);}
563
564 private:
565 wchar_t character_ = ' ';
566 };
567
568 public:
572 size_ = default_size();
573 }
574
578 xtd::drawing::color back_digit_color() const {return back_digit_color_.value_or(fore_color());}
584 if (!back_digit_color_.has_value() || back_digit_color_.value() != value) {
585 back_digit_color_ = value;
586 set_digits_params();
587 }
588 return *this;
589 }
590
593 double back_digit_opacity() const {return back_digit_opacity_;}
599 if (value < 0.0 || value > 1.0) throw argument_out_of_range_exception("value must be between 0.0 and 1.0."_t, current_stack_frame_);
600 if (back_digit_opacity_ != value) {
601 back_digit_opacity_ = value;
602 set_digits_params();
603 }
604 return *this;
605 }
606
609 bool show_back_digit() const {return show_back_digit_;}
614 if (show_back_digit_ != value) {
615 show_back_digit_ = value;
616 set_digits_params();
617 }
618 return *this;
619 }
620
623 int32_t digit_spacing() const {return digit_spacing_.value_or(lcd_style_ == lcd_style::dot_matrix_display ? 0 : thickness());}
628 lcd_label& digit_spacing(int32_t value) {
629 if (value < 0) throw argument_out_of_range_exception("value must be positive"_t, current_stack_frame_);
630 if (digit_spacing_ != value) {
631 digit_spacing_ = value;
632 set_digits_params();
633 }
634 return *this;
635 }
636
639 forms::lcd_style lcd_style() const {return lcd_style_;}
644 if (lcd_style_ != value) {
645 lcd_style_ = value;
646 xtd::ustring current_text = text();
647 text("");
648 text(current_text);
649 }
650 return *this;
651 }
652
655 forms::segment_style segment_style() const {return segment_style_;}
660 if (segment_style_ != value) {
661 segment_style_ = value;
662 for (auto& digit : digits_)
663 digit->set_segment_style(value);
664 }
665 return *this;
666 }
667
670 forms::dot_matrix_style dot_matrix_style() const {return dot_matrix_style_;}
675 if (dot_matrix_style_ != value) {
676 dot_matrix_style_ = value;
677 for (auto& digit : digits_)
678 digit->set_dot_matrix_style(value);
679 }
680 return *this;
681 }
682
685 int32_t thickness() const {return thickness_.value_or(digits_.size() ? digits_[0]->get_thickness() : 1);}
689 lcd_label& thickness(int32_t value) {
690 if (thickness_ != value) {
691 thickness_ = value;
692 set_digits_params();
693 }
694 return *this;
695 }
696
697 using control::text;
701 control& text(const xtd::ustring& value) override {
702 if (text_ != value) {
704 std::wstring str = std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>().from_bytes(value.c_str());
705 if (str.size() < digits_.size())
706 digits_.erase(digits_.begin() + value.size(), digits_.end());
707 if (str.size() > digits_.size())
708 for (size_t index = digits_.size(); index < str.size(); index++) {
709 switch (lcd_style_) {
710 case lcd_style::seven_segment_display: digits_.push_back(std::make_shared<seven_segment_display_digit>()); break;
711 case lcd_style::nine_segment_display: digits_.push_back(std::make_shared<nine_segment_display_digit>()); break;
712 case lcd_style::fourteen_segment_display: digits_.push_back(std::make_shared<fourteen_segment_display_digit>()); break;
713 case lcd_style::sixteen_segment_display: digits_.push_back(std::make_shared<sixteen_segment_display_digit>()); break;
714 case lcd_style::dot_matrix_display: digits_.push_back(std::make_shared<dot_matrix_display_digit>()); break;
715 default: throw argument_exception("lcd_style invalid", current_stack_frame_);
716 }
717 dynamic_cast<control*>(digits_[digits_.size() - 1].get())->parent(*this);
718 dynamic_cast<control*>(digits_[digits_.size() - 1].get())->click += [this] {on_click(event_args::empty);};
719 dynamic_cast<control*>(digits_[digits_.size() - 1].get())->mouse_down += [this](object& sender, const mouse_event_args& e) {on_mouse_down(mouse_event_args(e.button(), e.clicks(), e.location() + drawing::size(as<control>(sender).location()), e.delta()));};
720 dynamic_cast<control*>(digits_[digits_.size() - 1].get())->mouse_move += [this](object& sender, const mouse_event_args& e) {on_mouse_move(mouse_event_args(e.button(), e.clicks(), e.location() + drawing::size(as<control>(sender).location()), e.delta()));};
721 dynamic_cast<control*>(digits_[digits_.size() - 1].get())->mouse_up += [this](object& sender, const mouse_event_args& e) {on_mouse_up(mouse_event_args(e.button(), e.clicks(), e.location() + drawing::size(as<control>(sender).location()), e.delta()));};
722 }
723 for (size_t index = 0; index < str.size(); index++)
724 digits_[index]->set_character(str[index]);
725 set_digits_params();
726 control::text(value);
728 }
729 return *this;
730 }
731
736 switch (lcd_style_) {
737 case lcd_style::seven_segment_display: return std::make_shared<seven_segment_display_digit>()->get_valid_characters();
738 case lcd_style::nine_segment_display: return std::make_shared<nine_segment_display_digit>()->get_valid_characters();
739 case lcd_style::fourteen_segment_display: return std::make_shared<fourteen_segment_display_digit>()->get_valid_characters();
740 case lcd_style::sixteen_segment_display: return std::make_shared<sixteen_segment_display_digit>()->get_valid_characters();
741 case lcd_style::dot_matrix_display: return std::make_shared<dot_matrix_display_digit>()->get_valid_characters();
742 default: throw argument_exception("lcd_style invalid", current_stack_frame_);
743 }
744 }
745
746 protected:
747 drawing::size default_size() const override {return {100, 25};}
748
749 void on_back_color_changed(const event_args& e) override {
751 invalidate();
752 }
753
754 void on_fore_color_changed(const event_args& e) override {
756 invalidate();
757 }
758
759 void on_handle_created(const event_args& e) override {
761 set_digits_params();
762 }
763
764 void on_size_changed(const event_args& e) override {
765 set_digits_params();
767 }
768
769 void on_resize(const event_args& e) override {
770 set_digits_params();
772 }
773
775 if (digits_.size() == 0) return {0, size_.height()};
776 return drawing::size((dynamic_cast<control*>(digits_[0].get())->width() - 2 + digit_spacing()) * static_cast<int32_t>(digits_.size()) - digit_spacing() + 2, size_.height());
777 }
778
779 private:
780 void set_digits_params() {
781 int32_t offset_left = 0;
782 for (auto& digit : digits_) {
783 dynamic_cast<control*>(digit.get())->height(size_.height());
784 dynamic_cast<control*>(digit.get())->left(offset_left);
785 digit->set_back_digit_color(back_digit_color());
786 digit->set_back_digit_opacity(back_digit_opacity_);
787 digit->set_show_back_digit(show_back_digit_);
788 digit->set_segment_style(segment_style_);
789 digit->set_dot_matrix_style(dot_matrix_style_);
790 if (thickness_.has_value()) digit->set_thickness(thickness());
791 offset_left += dynamic_cast<control*>(digit.get())->width() - 2 + digit_spacing();
792 }
793 }
794
795 bool show_back_digit_ = true;
796 std::optional<xtd::drawing::color> back_digit_color_;
797 double back_digit_opacity_ = 0.95;
798 std::optional<int32_t> digit_spacing_;
802 std::vector<std::shared_ptr<idigit>> digits_;
803 std::optional<int32_t> thickness_;
804 };
805 }
806}
Contains xtd::argument_out_of_range_exception exception.
Contains xtd::as method.
The exception that is thrown when one of the arguments provided to a method is not valid.
Definition: argument_exception.h:19
The exception that is thrown when one of the arguments provided to a method is out of range.
Definition: argument_out_of_range_exception.h:18
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
int32_t height() const
Gets he vertical component of this Size Class.
Definition: size.h:57
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
static const event_args empty
Provides a value to use with events that do not have event data.
Definition: event_args.h:31
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
void suspend_layout()
Temporarily suspends the layout logic for the control.
Definition: control.h:996
virtual const xtd::ustring & text() const
Gets the text associated with this control.
Definition: control.h:650
virtual drawing::color fore_color() const
Gets the foreground color of the control.
virtual int32_t left() const
Gets the distance, in pixels, between the left edge of the control and the left edge of its container...
Definition: control.h:503
virtual std::optional< control_ref > parent() const
Gets the parent container of the control.
Definition: control.h:596
void resume_layout()
Resumes usual layout logic.
Definition: control.h:947
virtual void invalidate() const
Invalidates the entire surface of the control and causes the control to be redrawn.
Definition: control.h:883
virtual int32_t height() const
Gets the height of the control.
Definition: control.h:486
virtual int32_t width() const
Gets the width of the control.
Definition: control.h:682
Represents a dot matrix display class.
Definition: dot_matrix_display.h:23
virtual forms::dot_matrix_style dot_matrix_style() const
Gets dot matrix style.
Definition: dot_matrix_display.h:74
virtual drawing::color back_dot_color()
Gets background dot color.
Definition: dot_matrix_display.h:41
virtual void set_dots(const points_collection &points)
Sets specified dots to on.
Definition: dot_matrix_display.h:184
virtual bool show_back_dot() const
Gets a value indicate if background dots are shown.
Definition: dot_matrix_display.h:133
virtual double back_dot_opacity() const
Gets the background dot opacity.
Definition: dot_matrix_display.h:56
virtual int32_t thickness() const
Gets thickness of dot.
Definition: dot_matrix_display.h:147
Represents a nine segment display class.
Definition: fourteen_segment_display.h:18
int32_t thickness() const override
Sets thickness of segment.
Definition: fourteen_segment_display.h:27
Represents a lcd label.
Definition: lcd_label.h:31
void on_size_changed(const event_args &e) override
Raises the control::size_changed event.
Definition: lcd_label.h:764
lcd_label & segment_style(forms::segment_style value)
Sets segment style.
Definition: lcd_label.h:659
lcd_label & lcd_style(forms::lcd_style value)
Sets lcd style.
Definition: lcd_label.h:643
lcd_label & dot_matrix_style(forms::dot_matrix_style value)
Sets dot matrix style.
Definition: lcd_label.h:674
lcd_label & digit_spacing(int32_t value)
Sets the digit spacing.
Definition: lcd_label.h:628
forms::dot_matrix_style dot_matrix_style() const
Gets dot matrix style.
Definition: lcd_label.h:670
lcd_label & back_digit_color(const xtd::drawing::color &value)
Sets background digit color.
Definition: lcd_label.h:583
drawing::size default_size() const override
Gets the default size of the control.
Definition: lcd_label.h:747
xtd::drawing::color back_digit_color() const
Gets background digit color.
Definition: lcd_label.h:578
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
Definition: lcd_label.h:759
virtual const xtd::ustring & text() const
Gets the text associated with this control.
Definition: control.h:650
lcd_label & show_back_digit(bool value)
Sets a value indicate if background digits are shown.
Definition: lcd_label.h:613
xtd::ustring valid_characters()
Gets valid characters.
Definition: lcd_label.h:735
forms::lcd_style lcd_style() const
Gets lcd style.
Definition: lcd_label.h:639
void on_back_color_changed(const event_args &e) override
Raises the control::back_color_changed event.
Definition: lcd_label.h:749
drawing::size measure_control() const override
Measure this control.
Definition: lcd_label.h:774
forms::segment_style segment_style() const
Gets segment style.
Definition: lcd_label.h:655
double back_digit_opacity() const
Gets the background digit opacity.
Definition: lcd_label.h:593
lcd_label & back_digit_opacity(double value)
Sets the background digit opacity.
Definition: lcd_label.h:598
lcd_label()
Initialise a new lcd_label class.
Definition: lcd_label.h:570
void on_fore_color_changed(const event_args &e) override
Raises the control::fore_color_changed event.
Definition: lcd_label.h:754
void on_resize(const event_args &e) override
Raises the control::resize event.
Definition: lcd_label.h:769
int32_t digit_spacing() const
Gets the digit spacing.
Definition: lcd_label.h:623
control & text(const xtd::ustring &value) override
Sets the text associated with this control.
Definition: lcd_label.h:701
lcd_label & thickness(int32_t value)
Sets thickness of lcd.
Definition: lcd_label.h:689
bool show_back_digit() const
Gets a value indicate if background digits are shown.
Definition: lcd_label.h:609
int32_t thickness() const
Gets thickness of lcd.
Definition: lcd_label.h:685
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition: mouse_event_args.h:29
Represents a nine segment display class.
Definition: nine_segment_display.h:18
int32_t thickness() const override
Sets thickness of segment.
Definition: nine_segment_display.h:27
Represents a seven segment display class.
Definition: seven_segment_display.h:22
virtual drawing::color back_segment_color()
Gets background segment color.
Definition: seven_segment_display.h:33
virtual double back_segment_opacity() const
Gets the background segment opacity.
Definition: seven_segment_display.h:48
virtual forms::segments value() const
Gets seven_segment_display value.
Definition: seven_segment_display.h:106
virtual forms::segment_style segment_style() const
Gets segment style.
Definition: seven_segment_display.h:78
virtual bool show_back_segment() const
Gets a value indicate if background segments are shown.
Definition: seven_segment_display.h:64
virtual int32_t thickness() const
Gets thickness of segment.
Definition: seven_segment_display.h:92
Represents a sixteen segment display class.
Definition: sixteen_segment_display.h:18
int32_t thickness() const override
Sets thickness of segment.
Definition: sixteen_segment_display.h:27
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::forms::control control.
Contains xtd::forms::dot_matrix_display control.
Contains xtd::forms::fourteen_segment_display control.
virtual void on_click(const event_args &e)
Raises the control::click event.
virtual void on_back_color_changed(const event_args &e)
Raises the control::back_color_changed event.
virtual void on_size_changed(const event_args &e)
Raises the control::size_changed event.
virtual void on_mouse_up(const mouse_event_args &e)
Raises the control::mouse_up event.
virtual void on_handle_created(const event_args &e)
Raises the control::handle_created event.
event< control, event_handler > click
Occurs when the control is clicked.
Definition: control.h:1065
event< control, mouse_event_handler > mouse_down
Occurs when the mouse pointer is over the control and a mouse button is pressed.
Definition: control.h:1278
virtual void on_resize(const event_args &e)
Raises the control::resize event.
virtual void on_fore_color_changed(const event_args &e)
Raises the control::fore_color_changed event.
event< control, mouse_event_handler > mouse_move
Occurs when the mouse pointer is moved over the control.
Definition: control.h:1335
virtual void on_mouse_down(const mouse_event_args &e)
Raises the control::mouse_down event.
event< control, mouse_event_handler > mouse_up
Occurs when the mouse pointer is over the control and a mouse button is released.
Definition: control.h:1349
virtual void on_mouse_move(const mouse_event_args &e)
Raises the control::mouse_move event.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
#define interface_
This keyword is use to represent an interface.
Definition: interface.h:55
#define current_stack_frame_
Provides information about the current stack frame.
Definition: stack_frame.h:201
segment_style
Represent segment style used by seven_segment_display, fourteen_segment_display, nine_segment_display...
Definition: segment_style.h:17
lcd_style
Represent lcd label style used by lcd_label control.
Definition: lcd_style.h:17
dot_matrix_style
Represent dot matrix style used by dot_matrix_display control.
Definition: dot_matrix_style.h:17
@ e
The E key.
@ standard
Standard segment style.
@ grow_and_shrink
The control grows or shrinks to fit its contents. The control cannot be resized manually.
@ g1
The g1 segment.
@ a
The a segment.
@ h
The h segment.
@ l
The l segment.
@ j
The j segment.
@ c
The c segment.
@ a2
The a2 segment.
@ m
The m segment.
@ d
The d segment.
@ i
The i segment.
@ a1
The a1 segment.
@ k
The k segment.
@ f
The f segment.
@ b
The b segment.
@ dp
The dp segment (dot point).
@ d1
The d1 segment.
@ d2
The d2 segment.
@ g
The g segment.
@ pc
The cp segment (punctuation colon).
@ e
The e segment.
@ g2
The g2 segment.
@ nine_segment_display
Nine segment display style.
@ dot_matrix_display
Dot matrix display style.
@ sixteen_segment_display
Sixteen segment display style.
@ seven_segment_display
Seven segment display style.
@ fourteen_segment_display
Fourteen segment display style.
@ standard
Standard (or round) dot matrix style.
Contains xtd::interface interface.
Contains xtd::forms::lcd_style enum class.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::forms::nine_segment_display control.
Contains xtd::forms::seven_segment_display control.
Contains xtd::forms::sixteen_segment_display control.