/*
 * hworld.cpp
 * Hello world sample by Robert Roebling
 * Adapted for unicode by Max Berger
 */
 
#include "wx/wx.h" 
 

class MyApp: public wxApp
{
    virtual bool OnInit();
};

 
class MyFrame: public wxFrame
{
private:
    wxStaticText *someText;
    wxBoxSizer *sizer;
public:
 
    MyFrame(const wxString& title, 
           const wxPoint& pos, const wxSize& size);

    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    void OnOk(wxCommandEvent& event);
    void OnYes(wxCommandEvent& event);
 
    DECLARE_EVENT_TABLE()
};

enum
{
    ID_Quit = 1,
    ID_About,

};
 
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Quit, MyFrame::OnQuit)
    EVT_MENU(ID_About, MyFrame::OnAbout)
    EVT_BUTTON(wxID_OK, MyFrame::OnOk)
    EVT_BUTTON(wxID_YES, MyFrame::OnYes)
END_EVENT_TABLE()
 
IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame( wxT("Hello World"), 
         wxPoint(50,50), wxSize(450,340) );
    frame->Show(TRUE);
    SetTopWindow(frame);
    return TRUE;
} 
 
MyFrame::MyFrame(const wxString& title, 
       const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
    wxMenu *menuFile = new wxMenu;
    menuFile->Append( ID_About, wxT("&About...") );
    menuFile->AppendSeparator();
    menuFile->Append( ID_Quit, wxT("E&xit") );
 
    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( menuFile, wxT("&File") );
 
    SetMenuBar( menuBar );

    CreateStatusBar();
    SetStatusText( wxT("Welcome to wxWindows!") );
    
    /*
    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
    sizer->Add(new wxButton(this,wxID_YES),0,wxALL,10);
    sizer->Add(new wxButton(this,wxID_NO),0,wxALL,10);
    SetSizer(sizer);
    */

	/*
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(new wxButton(this,wxID_OK),0,wxALL,2);
    sizer->Add(new wxButton(this,wxID_CANCEL),0,wxALL,2);
    SetSizer(sizer);
    */
    
    /*
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(new wxButton(this,wxID_OK),0,wxALL,2);
    sizer->Add(new wxButton(this,wxID_CANCEL),0,wxALL,2);
    
    wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL);
    vsizer->Add(sizer,0,wxGROW | wxALL,2);
    vsizer->Add(new wxButton(this,wxID_YES),0,wxGROW | wxALL,2);
    SetSizer(vsizer);
    */
    
    /*
    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
	someText = new wxStaticText(this,wxID_ANY,wxT("This is a Text"));
	sizer->Add(someText,0,wxALL,2);
	sizer->Add(new wxButton(this,wxID_OK),0,wxALL,2);
	SetSizer(sizer);
	*/
	
	
    sizer = new wxBoxSizer(wxVERTICAL);
	sizer->Add(new wxStaticText(this,wxID_ANY,wxT("Confucius says:")),0,wxALL,2);
	someText = new wxStaticText(this,wxID_ANY,wxT("Click the button!"));
	sizer->Add(someText,1,wxALL,2);
	sizer->Add(new wxStaticText(this,wxID_ANY,wxT("Are you ready?")),0,wxALL,2);
	sizer->Add(new wxButton(this,wxID_YES),0,wxALL,2);
	SetSizer(sizer);
    sizer->Fit(this);
    
}

  
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(TRUE);
}
 
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{

    wxMessageBox(wxT("This is a wxWindows Hello world sample"),
        wxT("About Hello World"), wxOK | wxICON_INFORMATION, this);
}

void MyFrame::OnOk(wxCommandEvent& WXUNUSED(event))
{
	someText->SetLabel(wxT("Ok, Ok, i give up!"));
}

void MyFrame::OnYes(wxCommandEvent& WXUNUSED(event))
{
	someText->SetLabel(wxT("Do you really think I could tell you your fortune?\n"
	"You do?\n"
	"You're in luck then!\n"
	"I see a bright future ahead of you.....\n"
	"No, sorry, that was just the headlights of an oncoming car."
	));
	sizer->Layout();
    sizer->Fit(this);
}
