module test;

import dwt.DWT;
import dwt.dwthelper.Runnable;
import dwt.events.SelectionAdapter;
import dwt.events.SelectionEvent;
import dwt.layout.FillLayout;
import dwt.widgets.Button;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import tango.io.Stdout;

class MainWindow : Shell
{
    Button startStopButton;

    this(Display display)
    {
        super(display);
        initComponents();
    }

    private void initComponents()
    {
        setLayout(new FillLayout());

        startStopButton = new Button(this, DWT.PUSH);
        startStopButton.setText("Start");
        startStopButton.addSelectionListener(new class SelectionAdapter {
            void widgetSelected(SelectionEvent evt)
            {
                startStopButton.setText("awesome!");
            }
        });

        pack();
    }
}

void main()
{
    auto display = new Display();
    final auto mainWindow = new MainWindow(display);
    mainWindow.open();

    while (!mainWindow.isDisposed())
    {
        if (!display.readAndDispatch())
        {
            display.sleep();
        }
    }

    display.dispose();
}
