xtd 0.2.0
Loading...
Searching...
No Matches
switch_button.cpp

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

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/label>
#include <xtd/forms/switch_button>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Switch button example");
switch_button1.auto_check(false);
switch_button1.parent(*this);
switch_button1.location({50, 30});
switch_button1.click += [&] {
//switch_button1.checked(!switch_button1.checked());
};
switch_button2.parent(*this);
switch_button2.location({50, 70});
switch_button2.checked_changed += [&] {
label1.text(string::format("rounded switch: {}", switch_button2.checked() ? "On" : "Off"));
};
switch_button2.checked(true);
label1.parent(*this);
label1.location({110, 72});
label1.auto_size(true);
switch_button3.parent(*this);
switch_button3.location({50, 110});
switch_button3.rounded(false);
switch_button3.checked_changed += [&] {
label2.text(string::format("square switch: {}", switch_button3.checked() ? "On" : "Off"));
};
switch_button3.checked(true);
label2.parent(*this);
label2.location({110, 112});
label2.auto_size(true);
}
private:
switch_button switch_button1;
switch_button switch_button2;
switch_button switch_button3;
label label1;
label label2;
};
auto main() -> int {
application::run(form1 {});
}
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Represents a standard Windows label.
Definition label.h:38
Represents a standard Windows switch button.
Definition switch_button.h:32
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10