xtd 0.2.0
popup_form.cpp

demonstrates the use of xtd::forms::form container.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
#include <xtd/forms/list_box>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Popup form example");
client_size({300, 100});
controls().push_back_range({button1, popup_form1});
list_box1.parent(popup_form1);
list_box1.dock(dock_style::fill);
list_box1.items().push_back_range({{"clear", button_images::from_name("weather-clear")}, {"clear night", button_images::from_name("weather-clear-night")}, {"few clouds", button_images::from_name("weather-few-clouds")}, {"few clouds night", button_images::from_name("weather-few-clouds-night")}, {"fog", button_images::from_name("weather-fog")}, {"overcast", button_images::from_name("weather-overcast")}, {"severe alert", button_images::from_name("weather-severe-alert")}, {"showers", button_images::from_name("weather-showers")}, {"showers scattered", button_images::from_name("weather-showers-scattered")}, {"snow", button_images::from_name("weather-snow")}, {"storm", button_images::from_name("weather-storm")}});
list_box1.selected_index(0);
list_box1.click += [&] {
button1.text(list_box1.selected_item().value());
button1.image(as<image>(list_box1.selected_item().tag()));
popup_form1.hide();
};
button1.location({10, 10});
button1.size({160, 50});
button1.text(list_box1.selected_item().value());
button1.image(as<image>(list_box1.selected_item().tag()));
button1.click += [&] {
popup_form1.location(point_to_screen(button1.location()));
popup_form1.show();
};
popup_form1.start_position(form_start_position::manual);
popup_form1.form_border_style(forms::form_border_style::none);
popup_form1.size({button1.width(), 150});
popup_form1.deactivate += [&] {
popup_form1.hide();
};
}
private:
form popup_form1;
list_box list_box1;
};
auto main() -> int {
application::run(form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
static xtd::drawing::image from_name(const xtd::string &name)
Gets image object with specified name.
Definition button_images.hpp:193
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
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ button1
The first button on the message box is the default button.
Definition message_dialog_default_button.hpp:24
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
@ manual
The position of the form is determined by the Location property.
Definition form_start_position.hpp:24
@ top_center
Content is vertically aligned at the top, and horizontally aligned at the center.
Definition content_alignment.hpp:25
@ bottom_center
Content is vertically aligned at the bottom, and horizontally aligned at the center.
Definition content_alignment.hpp:37
@ none
No border.
Definition form_border_style.hpp:24
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
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