summaryrefslogtreecommitdiff
path: root/Applications/Calculator/main.cpp
blob: f38251eb42e368c22f227cea71a08e70d6127c64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "CalculatorWidget.h"
#include <LibDraw/PNGLoader.h>
#include <LibGUI/GAboutDialog.h>
#include <LibGUI/GAction.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GMenuBar.h>
#include <LibGUI/GWindow.h>

int main(int argc, char** argv)
{
    GApplication app(argc, argv);

    auto window = GWindow::construct();
    window->set_title("Calculator");
    window->set_resizable(false);
    window->set_rect({ 300, 200, 254, 213 });

    auto calc_widget = CalculatorWidget::construct(nullptr);
    window->set_main_widget(calc_widget);

    window->show();
    window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-calculator.png"));

    auto menubar = make<GMenuBar>();

    auto app_menu = GMenu::construct("Calculator");
    app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
        GApplication::the().quit(0);
        return;
    }));
    menubar->add_menu(move(app_menu));

    auto help_menu = GMenu::construct("Help");
    help_menu->add_action(GAction::create("About", [&](const GAction&) {
        GAboutDialog::show("Calculator", load_png("/res/icons/16x16/app-calculator.png"), window);
    }));
    menubar->add_menu(move(help_menu));

    app.set_menubar(move(menubar));

    return app.exec();
}