xtd 0.2.0
user_dialog.cpp

demonstrates the use of xtd::forms::form as dialog.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/label>
#include <xtd/forms/text_box>
using namespace xtd;
using namespace xtd::forms;
class user_input_dialog : public form {
public:
user_input_dialog() {
accept_button(button_ok);
cancel_button(button_cancel);
client_size({200, 85});
control_box(false);
text("User input dialog");
controls().push_back_range({input, button_ok, button_cancel});
input.location({10, 10});
input.width(180);
button_cancel.dialog_result(forms::dialog_result::cancel);
button_cancel.location({10, 50});
button_cancel.text("Cancel");
button_cancel.width(85);
button_ok.dialog_result(forms::dialog_result::ok);
button_ok.location({105, 50});
button_ok.text("OK");
button_ok.width(85);
active_control(input);
}
virtual string input_text() const {return input.text();}
virtual user_input_dialog& input_text(const string& input_text) {
input.text(input_text);
return *this;
}
private:
text_box input;
button button_cancel;
button button_ok;
};
class form1 : public form {
public:
form1() {
controls().push_back_range({button_dialog, input_text});
size({800, 450});
text("User dialog exemple");
input_text.auto_size(true);
input_text.location({10, 50});
input_text.text("User input text");
button_dialog.location({10, 10});
button_dialog.text("Dialog...");
button_dialog.click += [&] {
dialog.input_text(input_text.text());
if (dialog.show_dialog(*this) == forms::dialog_result::ok)
input_text.text(dialog.input_text());
};
}
private:
user_input_dialog dialog;
button button_dialog;
label input_text;
};
auto main() -> int {
application::run(form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents a standard Windows text box.
Definition text_box.hpp:31
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition label.hpp:25
xtd::forms::style_sheets::control button
The buttton data allows you to specify the box of a button control.
Definition button.hpp:25
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
form_border_style
Specifies the border styles for a form.
Definition form_border_style.hpp:22
@ cancel
The dialog box return value is Cancel (usually sent from a button labeled Cancel).
Definition dialog_result.hpp:49
@ ok
The dialog box return value is OK (usually sent from a button labeled OK).
Definition dialog_result.hpp:47
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
Definition status_bar_panel_style.hpp:25
@ center_parent
The form is centered within the bounds of its parent form.
Definition form_start_position.hpp:32
@ fixed_dialog
A thick, fixed dialog-style border.
Definition form_border_style.hpp:30
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