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

First we create the very basic xtd::forms program.

Windows

macOS

Gnome

#include <xtd/xtd>
namespace tutorial {
class panel_right : public xtd::forms::panel {
public:
panel_right() {
controls().push_back(label_);
size({150, 100});
label_.auto_size(true);
label_.location({65, 45});
label_.text("0");
}
};
class panel_left : public xtd::forms::panel {
public:
panel_left() {
controls().push_back_range({button_plus_, button_minus_});
size({150, 100});
button_plus_.auto_repeat(true);
button_plus_.location({30, 10});
button_plus_.text("+");
button_plus_.click += [&] {
count++;
control& form = parent().value().get();
xtd::as<panel_right&>(form.controls()[0].get()).label_.text(xtd::ustring::format("{}", count));
};
button_minus_.auto_repeat(true);
button_minus_.location({30, 60});
button_minus_.text("-");
button_minus_.click += [&] {
count--;
control& form = parent().value().get();
xtd::as<panel_right&>(form.controls()[0].get()).label_.text(xtd::ustring::format("{}", count));
};
}
xtd::forms::button button_plus_;
xtd::forms::button button_minus_;
int count = 0;
};
class communicate : public xtd::forms::form {
public:
communicate() {
client_size({300, 100});
controls().push_back_range({panel_right_, panel_left_});
text("communicate");
}
static auto main() {
}
panel_left panel_left_;
panel_right panel_right_;
};
}
startup_(tutorial::communicate::main);
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.h:49
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
Used to group collections of controls.
Definition panel.h:32
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1068
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:175
@ fixed_3d
A three-dimensional border. Same as xtd::forms::border_style::inset.
@ left
The control's left edge is docked to the left edge of its containing control.
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...