xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
sixteen_segment_display.h
Go to the documentation of this file.
1
4#pragma once
6
7namespace xtd {
8 namespace forms {
19 public:
22
27 int32_t thickness() const override {return thickness_.value_or(size_.height() < 20 ? 1 : (size_.height() / 20 + ((size_.height() / 20) % 2 ? 0 : 1)));}
28
29 protected:
30 void on_paint(paint_event_args& e) override {
32 if ((value_ & forms::segments::a1) == forms::segments::a1) draw_segment_a1(e.graphics(), fore_color());
33 if ((value_ & forms::segments::a2) == forms::segments::a2) draw_segment_a2(e.graphics(), fore_color());
34 if ((value_ & forms::segments::d1) == forms::segments::d1) draw_segment_d1(e.graphics(), fore_color());
35 if ((value_ & forms::segments::d2) == forms::segments::d2) draw_segment_d2(e.graphics(), fore_color());
36 }
37
38 void draw_back_digit(drawing::graphics& graphics) override {
44 }
45
49 virtual void draw_segment_a1(drawing::graphics& graphics, const drawing::color& color) {
50 if (segment_style_ == segment_style::standard) {
51 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
52 graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), 1 + thickness() / 2 + offset, size_.width() / 2 - 1 - abs(offset), 1 + thickness() / 2 + offset);
53 } else if (segment_style_ == segment_style::modern) {
54 for (int32_t offset = 0; offset < thickness(); offset++)
55 graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() / 2 - 1 - abs(offset / 2), 1 + offset);
56 } else if (segment_style_ == segment_style::mixed) {
57 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
58 graphics.draw_line(drawing::pen(color), 2 + offset + thickness() / 2, 1 + thickness() / 2 + offset, size_.width() / 2 - 1 - abs(offset), 1 + thickness() / 2 + offset);
59 } else if (segment_style_ == segment_style::expanded) {
60 for (int32_t offset = 0; offset < thickness(); offset++)
61 graphics.draw_line(drawing::pen(color), 2 + offset, 1 + offset, size_.width() / 2 + thickness() / 2 - 1 - (offset > thickness() / 2 ? offset : thickness() / 2), 1 + offset);
62 } else if (segment_style_ == segment_style::design) {
63 for (int32_t offset = 0; offset < thickness(); offset++)
64 graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() / 2 + thickness() / 2 - 1 - (offset > thickness() / 2 ? offset : thickness() / 2), 1 + offset);
65 } else if (segment_style_ == segment_style::stick) {
66 for (int32_t offset = 0; offset < thickness(); offset++)
67 graphics.draw_line(drawing::pen(color), 2 + thickness(), 1 + offset, size_.width() / 2 - 1, 1 + offset);
68 }
69 }
70
74 virtual void draw_segment_a2(drawing::graphics& graphics, const drawing::color& color) {
75 if (segment_style_ == segment_style::standard) {
76 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
77 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset), 1 + thickness() / 2 + offset, size_.width() - 3 - thickness() / 2 - abs(offset), 1 + thickness() / 2 + offset);
78 } else if (segment_style_ == segment_style::modern) {
79 for (int32_t offset = 0; offset < thickness(); offset++)
80 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset / 2), 1 + offset, size_.width() - 3 - offset, 1 + offset);
81 } else if (segment_style_ == segment_style::mixed) {
82 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
83 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset), 1 + thickness() / 2 + offset, size_.width() - 3 - thickness() / 2 - offset, 1 + thickness() / 2 + offset);
84 } else if (segment_style_ == segment_style::expanded) {
85 for (int32_t offset = 0; offset < thickness(); offset++)
86 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 - thickness() / 2 + (offset > thickness() / 2 ? offset : thickness() / 2), 1 + offset, size_.width() - 3 - offset, 1 + offset);
87 } else if (segment_style_ == segment_style::design) {
88 for (int32_t offset = 0; offset < thickness(); offset++)
89 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 - thickness() / 2 + (offset > thickness() / 2 ? offset : thickness() / 2), 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
90 } else if (segment_style_ == segment_style::stick) {
91 for (int32_t offset = 0; offset < thickness(); offset++)
92 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1, 1 + offset, size_.width() - 3 - thickness(), 1 + offset);
93 }
94 }
95
99 virtual void draw_segment_d1(drawing::graphics& graphics, const drawing::color& color) {
100 if (segment_style_ == segment_style::standard) {
101 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
102 graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + abs(offset), size_.height() - 2 - thickness() / 2 - offset, size_.width() / 2 - 1 - abs(offset), size_.height() - 2 - thickness() / 2 - offset);
103 } else if (segment_style_ == segment_style::modern) {
104 for (int32_t offset = 0; offset < thickness(); offset++)
105 graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() / 2 - 1 - abs(offset / 2), size_.height() - 2 - offset);
106 } else if (segment_style_ == segment_style::mixed) {
107 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
108 graphics.draw_line(drawing::pen(color), 2 + thickness() / 2 + offset, size_.height() - 2 - thickness() / 2 - offset, size_.width() / 2 - 1 - abs(offset), size_.height() - 2 - thickness() / 2 - offset);
109 } else if (segment_style_ == segment_style::expanded) {
110 for (int32_t offset = 0; offset < thickness(); offset++)
111 graphics.draw_line(drawing::pen(color), 2 + offset, size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2 - 1 - (offset > thickness() / 2 ? offset : thickness() / 2), size_.height() - 2 - offset);
112 } else if (segment_style_ == segment_style::design) {
113 for (int32_t offset = 0; offset < thickness(); offset++)
114 graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() / 2 + thickness() / 2 - 1 - (offset > thickness() / 2 ? offset : thickness() / 2), size_.height() - 2 - offset);
115 } else if (segment_style_ == segment_style::stick) {
116 for (int32_t offset = 0; offset < thickness(); offset++)
117 graphics.draw_line(drawing::pen(color), 2 + thickness(), size_.height() - 2 - offset, size_.width() / 2 - 1, size_.height() - 2 - offset);
118 }
119 }
120
124 virtual void draw_segment_d2(drawing::graphics& graphics, const drawing::color& color) {
125 if (segment_style_ == segment_style::standard) {
126 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
127 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset), size_.height() - 2 - thickness() / 2 - offset, size_.width() - 3 - thickness() / 2 - abs(offset), size_.height() - 2 - thickness() / 2 - offset);
128 } else if (segment_style_ == segment_style::modern) {
129 for (int32_t offset = 0; offset < thickness(); offset++)
130 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset / 2), size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
131 } else if (segment_style_ == segment_style::mixed) {
132 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
133 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 + abs(offset), size_.height() - 2 - thickness() / 2 - offset, size_.width() - 3 - thickness() / 2 - offset, size_.height() - 2 - thickness() / 2 - offset);
134 } else if (segment_style_ == segment_style::expanded) {
135 for (int32_t offset = 0; offset < thickness(); offset++)
136 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 - thickness() / 2 + (offset > thickness() / 2 ? offset : thickness() / 2), size_.height() - 2 - offset, size_.width() - 3 - offset, size_.height() - 2 - offset);
137 } else if (segment_style_ == segment_style::design) {
138 for (int32_t offset = 0; offset < thickness(); offset++)
139 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1 - thickness() / 2 + (offset > thickness() / 2 ? offset : thickness() / 2), size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
140 } else if (segment_style_ == segment_style::stick) {
141 for (int32_t offset = 0; offset < thickness(); offset++)
142 graphics.draw_line(drawing::pen(color), size_.width() / 2 + 1, size_.height() - 2 - offset, size_.width() - 3 - thickness(), size_.height() - 2 - offset);
143 }
144 }
145
149 void draw_segment_i(drawing::graphics& graphics, const drawing::color& color) override {
150 if (segment_style_ == segment_style::standard) {
151 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
152 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
153 } else if (segment_style_ == segment_style::modern) {
154 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
155 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + abs(2 * offset), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
156 } else if (segment_style_ == segment_style::mixed) {
157 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
158 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
159 } else if (segment_style_ == segment_style::expanded) {
160 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
161 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
162 } else if (segment_style_ == segment_style::design) {
163 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
164 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
165 } else if (segment_style_ == segment_style::stick) {
166 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
167 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, 2 + thickness(), size_.width() / 2 - offset, size_.height() / 2 - 1 - abs(offset));
168 }
169 }
170
174 void draw_segment_l(drawing::graphics& graphics, const drawing::color& color) override {
175 if (segment_style_ == segment_style::standard) {
176 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
177 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - thickness() / 2 - abs(offset));
178 } else if (segment_style_ == segment_style::modern) {
179 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
180 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - abs(2 * offset));
181 } else if (segment_style_ == segment_style::mixed) {
182 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
183 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - thickness() / 2 - abs(offset));
184 } else if (segment_style_ == segment_style::expanded) {
185 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
186 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - thickness() / 2 - abs(offset));
187 } else if (segment_style_ == segment_style::design) {
188 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
189 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - thickness() / 2 - abs(offset));
190 } else if (segment_style_ == segment_style::stick) {
191 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++)
192 graphics.draw_line(drawing::pen(color), size_.width() / 2 - offset, size_.height() / 2 + 1 - thickness() / 2 + thickness() / 2 + abs(offset), size_.width() / 2 - offset, size_.height() - 3 - thickness());
193 }
194 }
195
196 protected:
197 void draw_segment_a(drawing::graphics& graphics, const drawing::color& color) override {}
198 void draw_segment_d(drawing::graphics& graphics, const drawing::color& color) override {}
199 };
200 }
201}
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:39
static color average(const color &color1, const color &color2, double weight, bool average_alpha)
Returns the weighted average color between the two given colors.
Definition color.h:592
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:48
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.h:29
virtual drawing::color fore_color() const
Gets the foreground color of the control.
virtual drawing::color back_color() const
Gets the background color for the control.
Represents a nine segment display class.
Definition fourteen_segment_display.h:18
void draw_back_digit(drawing::graphics &graphics) override
Draw all background digit on specified graphics.
Definition fourteen_segment_display.h:42
int32_t thickness() const override
Sets thickness of segment.
Definition fourteen_segment_display.h:27
void on_paint(paint_event_args &e) override
Raises the control::paint event.
Definition fourteen_segment_display.h:30
Provides data for the paint event.
Definition paint_event_args.h:26
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
Represents a sixteen segment display class.
Definition sixteen_segment_display.h:18
void draw_back_digit(drawing::graphics &graphics) override
Draw all background digit on specified graphics.
Definition sixteen_segment_display.h:38
void draw_segment_i(drawing::graphics &graphics, const drawing::color &color) override
Draw segment i on specified graphics with specified color.
Definition sixteen_segment_display.h:149
void on_paint(paint_event_args &e) override
Raises the control::paint event.
Definition sixteen_segment_display.h:30
virtual void draw_segment_a1(drawing::graphics &graphics, const drawing::color &color)
Draw segment a1 on specified graphics with specified color.
Definition sixteen_segment_display.h:49
void draw_segment_l(drawing::graphics &graphics, const drawing::color &color) override
Draw segment l on specified graphics with specified color.
Definition sixteen_segment_display.h:174
virtual void draw_segment_a2(drawing::graphics &graphics, const drawing::color &color)
Draw segment a2 on specified graphics with specified color.
Definition sixteen_segment_display.h:74
int32_t thickness() const override
Sets thickness of segment.
Definition sixteen_segment_display.h:27
void draw_segment_d(drawing::graphics &graphics, const drawing::color &color) override
Draw segment d on specified graphics with specified color.
Definition sixteen_segment_display.h:198
sixteen_segment_display()=default
Initialize a new instance of nine_segment_display class.
virtual void draw_segment_d1(drawing::graphics &graphics, const drawing::color &color)
Draw segment d1 on specified graphics with specified color.
Definition sixteen_segment_display.h:99
virtual void draw_segment_d2(drawing::graphics &graphics, const drawing::color &color)
Draw segment d2 on specified graphics with specified color.
Definition sixteen_segment_display.h:124
void draw_segment_a(drawing::graphics &graphics, const drawing::color &color) override
Draw segment a on specified graphics with specified color.
Definition sixteen_segment_display.h:197
Contains xtd::forms::fourteen_segment_display control.
@ e
The E key.
@ expanded
Expanded segment style.
@ mixed
Mixed (mix between standard and modern) segment style.
@ design
Design segment style.
@ stick
Stick segment style.
@ modern
Modern segment style.
@ standard
Standard segment style.
@ a2
The a2 segment.
@ a1
The a1 segment.
@ d1
The d1 segment.
@ d2
The d2 segment.
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