xtd 0.2.0
lcd_label_appearance.cpp

demonstrates how to use xtd::forms::lcd_label control.

Windows

macOS

Gnome

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace lcd_label_appearance_example {
class form_lcd_label : public form {
public:
form_lcd_label() {
auto_scroll(true);
client_size({870, 240});
text("LCD label example");
controls().push_back_range({group_box_properties, label_lcd_label});
group_box_properties.controls().push_back(panel_properties);
group_box_properties.location({10, 10});
group_box_properties.size({340, 220});
group_box_properties.text("properties");
panel_properties.auto_scroll(true);
panel_properties.controls().push_back_range({lcd_style_label, lcd_style_choice, segment_style_label, segment_style_choice, height_label, height_numeric_up_down, fore_color_label, fore_color_color_picker, show_digit_background_label, show_digit_background_togle_button});
panel_properties.dock(dock_style::fill);
lcd_style_label.auto_size(true);
lcd_style_label.location({10, 13});
lcd_style_label.text("Lcd style: ");
lcd_style_choice.location({120, 10});
lcd_style_choice.width(180);
lcd_style_choice.items().push_back_range({{"Seven segment display", lcd_style::seven_segment_display}, {"Nine segment display", lcd_style::nine_segment_display}, {"Fourteen segment display", lcd_style::fourteen_segment_display}, {"Sixteen segment display", lcd_style::sixteen_segment_display}, {"Dot matrix display", lcd_style::dot_matrix_display}});
lcd_style_choice.selected_value_changed += [&] {
label_lcd_label.lcd_style(std::any_cast<lcd_style>(lcd_style_choice.selected_item().tag()));
segment_style_choice.items().clear();
if (lcd_style_choice.selected_item().value() == "Dot matrix display") {
segment_style_choice.items().push_back_range({{"Standard (or round)", dot_matrix_style::standard}, {"Square", dot_matrix_style::square}});
segment_style_choice.selected_index(as<int>(label_lcd_label.dot_matrix_style()));
} else {
segment_style_choice.items().push_back_range({{"Standard", segment_style::standard}, {"Modern", segment_style::modern}, {"Mixed", segment_style::mixed}, {"expanded", segment_style::expanded}, {"Design", segment_style::design}, {"Stick", segment_style::stick}});
segment_style_choice.selected_index(as<int>(label_lcd_label.segment_style()));
}
};
lcd_style_choice.selected_index(0);
segment_style_label.auto_size(true);
segment_style_label.location({10, 48});
segment_style_label.text("Segment style: ");
segment_style_choice.location({120, 45});
segment_style_choice.width(180);
segment_style_choice.selected_value_changed += [&] {
auto style = segment_style_choice.selected_item().tag();
if (std::any_cast<dot_matrix_style>(&style))
label_lcd_label.dot_matrix_style(std::any_cast<forms::dot_matrix_style>(segment_style_choice.selected_item().tag()));
else
label_lcd_label.segment_style(std::any_cast<forms::segment_style>(segment_style_choice.selected_item().tag()));
};
segment_style_choice.selected_index(0);
height_label.auto_size(true);
height_label.location({10, 83});
height_label.text("Height: ");
height_numeric_up_down.location({120, 80});
height_numeric_up_down.width(180);
height_numeric_up_down.set_range(1, 400);
height_numeric_up_down.value_changed += [&] {
label_lcd_label.height(as<int>(height_numeric_up_down.value()));
};
height_numeric_up_down.value(50);
fore_color_label.auto_size(true);
fore_color_label.location({10, 118});
fore_color_label.text("Foreground: ");
fore_color_color_picker.location({120, 115});
fore_color_color_picker.width(180);
fore_color_color_picker.color(label_lcd_label.fore_color());
fore_color_color_picker.color_picker_changed += [&] {
label_lcd_label.fore_color(fore_color_color_picker.color());
};
show_digit_background_label.auto_size(true);
show_digit_background_label.location({10, 153});
show_digit_background_label.text("Show digit: ");
show_digit_background_togle_button.location({120, 150});
show_digit_background_togle_button.width(180);
show_digit_background_togle_button.auto_size(true);
show_digit_background_togle_button.checked(true);
show_digit_background_togle_button.text("true");
show_digit_background_togle_button.checked_changed += [&] {
show_digit_background_togle_button.text(show_digit_background_togle_button.checked() ? "True" : "False");
label_lcd_label.show_back_digit(show_digit_background_togle_button.checked());
};
label_lcd_label.location({380, 30});
label_lcd_label.text("1234567890");
label_lcd_label.auto_size(true);
}
private:
group_box group_box_properties;
panel panel_properties;
label lcd_style_label;
choice lcd_style_choice;
label segment_style_label;
choice segment_style_choice;
label height_label;
numeric_up_down height_numeric_up_down;
label fore_color_label;
color_picker fore_color_color_picker;
label show_digit_background_label;
toggle_button show_digit_background_togle_button;
lcd_label label_lcd_label;
};
}
auto main() -> int {
application::run(lcd_label_appearance_example::form_lcd_label());
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a choice control.
Definition choice.hpp:37
Represents a picker control that displays available colors along with controls that enable the user t...
Definition color_picker.hpp:32
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents a Windows control that displays a frame around a group of controls with an optional captio...
Definition group_box.hpp:37
Represents a standard Windows label.
Definition label.hpp:38
Represents a lcd label.
Definition lcd_label.hpp:40
Represents a standard Windows numeric up down.
Definition numeric_up_down.hpp:34
Used to group collections of controls.
Definition panel.hpp:32
Represents a Windows toggle_button.
Definition toggle_button.hpp:44
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ expanded
Expanded segment style.
Definition segment_style.hpp:29
@ mixed
Mixed (mix between standard and modern) segment style.
Definition segment_style.hpp:27
@ design
Design segment style.
Definition segment_style.hpp:31
@ stick
Stick segment style.
Definition segment_style.hpp:33
@ modern
Modern segment style.
Definition segment_style.hpp:25
@ standard
Standard segment style.
Definition segment_style.hpp:23
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
@ nine_segment_display
Nine segment display style.
Definition lcd_style.hpp:25
@ dot_matrix_display
Dot matrix display style.
Definition lcd_style.hpp:31
@ sixteen_segment_display
Sixteen segment display style.
Definition lcd_style.hpp:29
@ seven_segment_display
Seven segment display style.
Definition lcd_style.hpp:23
@ fourteen_segment_display
Fourteen segment display style.
Definition lcd_style.hpp:27
@ bottom
Bind control edges to the bottom of its container.
Definition anchor_styles.hpp:25
@ left
Bind control edges to the left of its container.
Definition anchor_styles.hpp:27
@ top
Bind control edges to the top of its container.
Definition anchor_styles.hpp:23
@ square
Square dot matrix style.
Definition dot_matrix_style.hpp:25
@ standard
Standard (or round) dot matrix style.
Definition dot_matrix_style.hpp:27
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8