2019-05-08 02:18:36 +03:00
|
|
|
#include <LibGUI/GApplication.h>
|
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-06-07 12:50:05 +03:00
|
|
|
#include <LibGUI/GButton.h>
|
|
|
|
#include <LibGUI/GLabel.h>
|
|
|
|
#include <LibGUI/GWidget.h>
|
|
|
|
#include <LibGUI/GWindow.h>
|
2019-05-08 02:18:36 +03:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
GApplication app(argc, argv);
|
|
|
|
|
|
|
|
auto* window = new GWindow;
|
|
|
|
window->set_rect(100, 100, 240, 160);
|
|
|
|
window->set_title("Hello World!");
|
|
|
|
|
2019-09-21 18:05:35 +03:00
|
|
|
auto main_widget = GWidget::construct();
|
2019-05-08 02:18:36 +03:00
|
|
|
window->set_main_widget(main_widget);
|
|
|
|
main_widget->set_fill_with_background_color(true);
|
|
|
|
main_widget->set_background_color(Color::White);
|
|
|
|
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
|
|
main_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
|
|
|
|
2019-09-21 15:19:05 +03:00
|
|
|
auto label = GLabel::construct(main_widget);
|
2019-07-12 20:45:10 +03:00
|
|
|
label->set_text("Hello\nWorld!");
|
2019-05-08 02:18:36 +03:00
|
|
|
|
|
|
|
auto* button = new GButton(main_widget);
|
2019-05-24 18:11:42 +03:00
|
|
|
button->set_text("Good-bye");
|
2019-05-08 02:18:36 +03:00
|
|
|
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
2019-07-20 23:39:24 +03:00
|
|
|
button->set_preferred_size(0, 20);
|
2019-06-07 12:50:05 +03:00
|
|
|
button->on_click = [&](GButton&) {
|
2019-05-08 02:18:36 +03:00
|
|
|
app.quit();
|
|
|
|
};
|
|
|
|
|
|
|
|
window->show();
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|