xtd 0.2.0
Loading...
Searching...
No Matches
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});
form_border_style(forms::form_border_style::fixed_dialog);
control_box(false);
start_position(form_start_position::center_parent);
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 {});
}
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
Represents a standard Windows text box.
Definition text_box.h:31
size_t size
Represents a size of any object in bytes.
Definition size.h:23
form_border_style
Specifies the border styles for a form.
Definition form_border_style.h:22
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
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