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

demonstrates the use of xtd::forms::control::control_collection::emplace, xtd::forms::control::control_collection::emplace_at, xtd::forms::control::control_collection::emplace_back methods.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/label>
using namespace xtd::drawing;
using namespace xtd::forms;
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = xtd::forms::form::create("Emplace example");
form1.controls().emplace<xtd::forms::button>(form1.controls().begin(), "Button 1", point{50, 50}).click += [&] {
form1.controls()["label1"].value().get().text(xtd::string::format("Button 1 clicked {} times", ++button1_clicked));
};
form1.controls().emplace_at<xtd::forms::button>(1, "Button 2", point {50, 100}, size {200, 75}).auto_repeat(true).click += [&] {
form1.controls()["label2"].value().get().text(xtd::string::format("Button 2 clicked {} times", ++button2_clicked));
};
form1.controls().emplace<xtd::forms::label>(form1.controls().end(), "Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().emplace_back<xtd::forms::label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
}
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:31
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
control_t & emplace_at(size_t index, args_t &&...args)
Creates and inserts specified control at specified position.
Definition control.h:230
control_t & emplace_back(args_t &&...args)
Creates and adds a control to the end.
Definition control.h:247
event< control, event_handler > click
Occurs when the xtd::forms::control is clicked.
Definition control.h:1482
virtual control_collection & controls() noexcept
Gets the collection of controls contained within the control.
static form create()
A factory to create an xtd::forms::form.
Represents a standard Windows label.
Definition label.h:38
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12