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
nine_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::h) == forms::segments::h) draw_segment_h(e.graphics(), fore_color());
33 if ((value_ & forms::segments::i) == forms::segments::i) draw_segment_i(e.graphics(), fore_color());
34 }
35
36 void draw_back_digit(drawing::graphics& graphics) override {
40 }
41
45 virtual void draw_segment_h(drawing::graphics& graphics, const drawing::color& color) {
46 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++) {
47 graphics.draw_line(drawing::pen(color), size_.width() - 3 - thickness() - abs(offset), 2 + thickness(), 2 + thickness(), size_.height() / 2 - 2 - thickness() / 2 - abs(offset));
48 graphics.draw_line(drawing::pen(color), size_.width() - 3 - thickness(), 2 + thickness() + abs(offset), 2 + thickness() + abs(offset), size_.height() / 2 - 2 - thickness() / 2);
49 }
50 }
51
55 virtual void draw_segment_i(drawing::graphics& graphics, const drawing::color& color) {
56 for (int32_t offset = -thickness() / 2; offset < thickness() - thickness() / 2; offset++) {
57 graphics.draw_line(drawing::pen(color), size_.width() - 3 - thickness() - abs(offset), size_.height() / 2 + 2 + thickness() / 2, 2 + thickness(), size_.height() - 3 - thickness() - abs(offset));
58 graphics.draw_line(drawing::pen(color), size_.width() - 3 - thickness(), size_.height() / 2 + 2 + thickness() / 2 + abs(offset), 2 + thickness() + abs(offset), size_.height() - 3 - thickness());
59 }
60 }
61 };
62 }
63}
64
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 nine_segment_display.h:18
void draw_back_digit(drawing::graphics &graphics) override
Draw all background digit on specified graphics.
Definition nine_segment_display.h:36
nine_segment_display()=default
Initialize a new instance of nine_segment_display class.
virtual void draw_segment_h(drawing::graphics &graphics, const drawing::color &color)
Draw segment h on specified graphics with specified color.
Definition nine_segment_display.h:45
int32_t thickness() const override
Sets thickness of segment.
Definition nine_segment_display.h:27
void on_paint(paint_event_args &e) override
Raises the control::paint event.
Definition nine_segment_display.h:30
virtual void draw_segment_i(drawing::graphics &graphics, const drawing::color &color)
Draw segment ion specified graphics with specified color.
Definition nine_segment_display.h:55
Provides data for the paint event.
Definition paint_event_args.h:26
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
void on_paint(paint_event_args &e) override
Raises the control::paint event.
Definition seven_segment_display.h:144
virtual void draw_back_digit(drawing::graphics &graphics)
Draw all background digit on specified graphics.
Definition seven_segment_display.h:191
virtual int32_t thickness() const
Gets thickness of segment.
Definition seven_segment_display.h:92
@ e
The E key.
@ h
The h segment.
@ i
The i 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
Contains xtd::forms::seven_segment_display control.