// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <wx/wx.h>

#include "demo1.h"

Demo1Dialog::Demo1Dialog(wxWindow *parent) : wxDialog(parent, -1, "Dette er en dialog", wxPoint(-1,-1), wxSize(275, 100), wxDEFAULT_DIALOG_STYLE)
{
    btnok = new wxButton(this, wxID_OK, "OK", wxPoint(25,25), wxSize(100,25));
    btncan = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(150,25), wxSize(100,25));
}

void Demo1Dialog::OnOK(wxCommandEvent& event)
{
    wxDialog::OnOK(event);
    printf("OK\n");
}

void Demo1Dialog::OnCancel(wxCommandEvent& event)
{
    wxDialog::OnCancel(event);
    printf("Cancel\n");
}

BEGIN_EVENT_TABLE(Demo1Dialog, wxDialog)
EVT_BUTTON(wxID_OK, Demo1Dialog::OnOK)
EVT_BUTTON(wxID_CANCEL, Demo1Dialog::OnCancel)
END_EVENT_TABLE()

Demo1Frame::Demo1Frame() : wxFrame(NULL, -1, "Dette er titel", wxPoint(-1,-1), wxSize(300,350))
{
    CreateStatusBar();
    SetStatusText("Dette er status text");
    tc1 = new wxTextCtrl(this, -1, wxString("Dette er en single line tekst kontrol"), wxPoint(25,25), wxSize(200,25));
    tc2 = new wxTextCtrl(this, -1, wxString("Dette er en\r\nmulti line tekst kontrol"), wxPoint(25,75), wxSize(200,50), wxTE_MULTILINE);
    mb = new wxMenuBar();
    m = new wxMenu();
    m->Append(MENU_DIALOG, "&Dialog");
    m->Append(MENU_EXIT, "E&xit");
    mb->Append(m, "&Menu");
    SetMenuBar(mb);
    Show(TRUE);
}

void Demo1Frame::OnMenuDialog(wxCommandEvent &event)
{
    Demo1Dialog *dlg = new Demo1Dialog(this);
    dlg->Show(TRUE);
}

void Demo1Frame::OnMenuExit(wxCommandEvent &event)
{
    Close(false);
}

BEGIN_EVENT_TABLE(Demo1Frame, wxFrame)
EVT_MENU(MENU_DIALOG, Demo1Frame::OnMenuDialog)
EVT_MENU(MENU_EXIT, Demo1Frame::OnMenuExit)
END_EVENT_TABLE()

bool Demo1App::OnInit()
{
    d1f = new Demo1Frame;
    SetTopWindow(d1f);
    return true;
}

IMPLEMENT_APP(Demo1App)
