xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
lcd_label.h
Go to the documentation of this file.
1 #pragma once
5 #include <codecvt>
7 #include <xtd/convert_string.h>
8 #include <xtd/as.h>
9 #include <xtd/interface.h>
10 #include "control.h"
11 #include "dot_matrix_display.h"
12 #include "lcd_style.h"
13 #include "nine_segment_display.h"
14 #include "seven_segment_display.h"
17 
18 namespace xtd {
19  namespace forms {
32  class lcd_label : public control {
33  class idigit interface_ {
34  public:
35  virtual wchar_t get_character() const = 0;
36  virtual xtd::ustring get_valid_characters() const = 0;
37  virtual int32_t get_thickness() const = 0;
38 
39  virtual void set_back_digit_color(const xtd::drawing::color& value) = 0;
40  virtual void set_back_digit_opacity(double value) = 0;
41  virtual void set_character(wchar_t value) = 0;
42  virtual void set_segment_style(forms::segment_style value) = 0;
43  virtual void set_dot_matrix_style(forms::dot_matrix_style value) = 0;
44  virtual void set_show_back_digit(bool value) = 0;
45  virtual void set_thickness(int32_t value) = 0;
46  };
47 
48  class dot_matrix_display_digit : public dot_matrix_display, public idigit {
49  public:
50  dot_matrix_display_digit() = default;
51 
52  wchar_t get_character() const override;
53  xtd::ustring get_valid_characters() const override;
54  int32_t get_thickness() const override;
55 
56  void set_back_digit_color(const xtd::drawing::color& value) override;
57  void set_back_digit_opacity(double value) override;
58  void set_character(wchar_t value) override;
59  void set_segment_style(forms::segment_style value) override;
60  void set_dot_matrix_style(forms::dot_matrix_style value) override;
61  void set_show_back_digit(bool value) override;
62  void set_thickness(int32_t value) override;
63 
64  private:
65  wchar_t character_ = ' ';
66  };
67 
68  class fourteen_segment_display_digit : public fourteen_segment_display, public idigit {
69  public:
70  fourteen_segment_display_digit() = default;
71 
72  wchar_t get_character() const override;
73  xtd::ustring get_valid_characters() const override;
74  int32_t get_thickness() const override;
75 
76  void set_back_digit_color(const xtd::drawing::color& value) override;
77  void set_back_digit_opacity(double value) override;
78  void set_character(wchar_t value) override;
79  void set_segment_style(forms::segment_style value) override;
80  void set_dot_matrix_style(forms::dot_matrix_style value) override;
81  void set_show_back_digit(bool value) override;
82  void set_thickness(int32_t value) override;
83 
84  private:
85  wchar_t character_ = ' ';
86  };
87 
88  class nine_segment_display_digit : public nine_segment_display, public idigit {
89  public:
90  nine_segment_display_digit() = default;
91 
92  wchar_t get_character() const override;
93  xtd::ustring get_valid_characters() const override;
94  int32_t get_thickness() const override;
95 
96  void set_back_digit_color(const xtd::drawing::color& value) override;
97  void set_back_digit_opacity(double value) override;
98  void set_character(wchar_t value) override;
99  void set_segment_style(forms::segment_style value) override;
100  void set_dot_matrix_style(forms::dot_matrix_style value) override;
101  void set_show_back_digit(bool value) override;
102  void set_thickness(int32_t value) override;
103 
104  private:
105  wchar_t character_ = ' ';
106  };
107 
108  class seven_segment_display_digit : public seven_segment_display, public idigit {
109  public:
110  seven_segment_display_digit() = default;
111 
112  wchar_t get_character() const override;
113  xtd::ustring get_valid_characters() const override;
114  int32_t get_thickness() const override;
115 
116  void set_back_digit_color(const xtd::drawing::color& value) override;
117  void set_back_digit_opacity(double value) override;
118  void set_character(wchar_t value) override;
119  void set_segment_style(forms::segment_style value) override;
120  void set_dot_matrix_style(forms::dot_matrix_style value) override;
121  void set_show_back_digit(bool value) override;
122  void set_thickness(int32_t value) override;
123 
124  private:
125  wchar_t character_ = ' ';
126  };
127 
128  class sixteen_segment_display_digit : public sixteen_segment_display, public idigit {
129  public:
130  sixteen_segment_display_digit() = default;
131 
132  wchar_t get_character() const override;
133  xtd::ustring get_valid_characters() const override;
134  int32_t get_thickness() const override;
135 
136  void set_back_digit_color(const xtd::drawing::color& value) override;
137  void set_back_digit_opacity(double value) override;
138  void set_character(wchar_t value) override;
139  void set_segment_style(forms::segment_style value) override;
140  void set_dot_matrix_style(forms::dot_matrix_style value) override;
141  void set_show_back_digit(bool value) override;
142  void set_thickness(int32_t value) override;
143 
144  private:
145  wchar_t character_ = ' ';
146  };
147 
148  public:
150  lcd_label();
151 
161 
164  double back_digit_opacity() const;
169  lcd_label& back_digit_opacity(double value);
170 
173  bool show_back_digit() const;
177  lcd_label& show_back_digit(bool value);
178 
181  int32_t digit_spacing() const;
186  lcd_label& digit_spacing(int32_t value);
187 
190  forms::lcd_style lcd_style() const;
195 
203 
211 
214  int32_t thickness() const;
218  lcd_label& thickness(int32_t value);
219 
220  using control::text;
224  control& text(const xtd::ustring& value) override;
225 
230 
231  protected:
232  drawing::size default_size() const override;
233 
234  void on_back_color_changed(const event_args& e) override;
235 
236  void on_fore_color_changed(const event_args& e) override;
237 
238  void on_handle_created(const event_args& e) override;
239 
240  void on_size_changed(const event_args& e) override;
241 
242  void on_resize(const event_args& e) override;
243 
244  drawing::size measure_control() const override;
245 
246  private:
247  void on_digit_click(object& sender, const event_args& e);
248  void on_digit_mouse_down(object& sender, const mouse_event_args& e);
249  void on_digit_mouse_move(object& sender, const mouse_event_args& e);
250  void on_digit_mouse_up(object& sender, const mouse_event_args& e);
251  void set_digits_params();
252 
253  bool show_back_digit_ = true;
254  std::optional<xtd::drawing::color> back_digit_color_;
255  double back_digit_opacity_ = 0.95;
256  std::optional<int32_t> digit_spacing_;
260  std::vector<std::shared_ptr<idigit>> digits_;
261  std::optional<int32_t> thickness_;
262  };
263  }
264 }
lcd_label()
Initialise a new lcd_label class.
Contains xtd::forms::seven_segment_display control.
Represents a nine segment display class.
Definition: nine_segment_display.h:18
Represents a sixteen segment display class.
Definition: sixteen_segment_display.h:18
Contains xtd::argument_out_of_range_exception exception.
Represents a dot matrix display class.
Definition: dot_matrix_display.h:23
int32_t digit_spacing() const
Gets the digit spacing.
Represents a nine segment display class.
Definition: fourteen_segment_display.h:18
void on_size_changed(const event_args &e) override
Raises the control::size_changed event.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
segment_style
Represent segment style used by seven_segment_display, fourteen_segment_display, nine_segment_display...
Definition: segment_style.h:17
forms::lcd_style lcd_style() const
Gets lcd style.
void on_handle_created(const event_args &e) override
Raises the control::handle_created event.
double back_digit_opacity() const
Gets the background digit opacity.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
Represents a lcd label.
Definition: lcd_label.h:32
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
drawing::size default_size() const override
Gets the default size of the control.
lcd_style
Represent lcd label style used by lcd_label control.
Definition: lcd_style.h:17
Contains xtd::as method.
xtd::ustring valid_characters()
Gets valid characters.
void on_back_color_changed(const event_args &e) override
Raises the control::back_color_changed event.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::forms::lcd_style enum class.
Contains xtd::interface interface.
Contains xtd::forms::fourteen_segment_display control.
xtd::drawing::color back_digit_color() const
Gets background digit color.
dot_matrix_style
Represent dot matrix style used by dot_matrix_display control.
Definition: dot_matrix_style.h:17
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Contains xtd::forms::dot_matrix_display control.
drawing::size measure_control() const override
Measure this control.
Standard style dialog.
Contains xtd::convert_string class.
forms::segment_style segment_style() const
Gets segment style.
int32_t thickness() const
Gets thickness of lcd.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:68
void on_resize(const event_args &e) override
Raises the control::resize event.
bool show_back_digit() const
Gets a value indicate if background digits are shown.
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down, and xtd::forms::control::mouse_move events.
Definition: mouse_event_args.h:29
Contains xtd::forms::control control.
forms::dot_matrix_style dot_matrix_style() const
Gets dot matrix style.
Contains xtd::forms::nine_segment_display control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Represents a seven segment display class.
Definition: seven_segment_display.h:23
virtual const xtd::ustring & text() const
Gets the text associated with this control.
Contains xtd::forms::sixteen_segment_display control.
void on_fore_color_changed(const event_args &e) override
Raises the control::fore_color_changed event.