#include "A03_F01.h"

IMPLEMENT_APP(MyApp)

enum idEjemplo {
   ID_SHOW = 0,
   ID_EXIT,
   ID_STATICTEXT,
   ID_TEXTCTRL
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
   EVT_MENU(ID_SHOW, MyFrame::OnShow)
   EVT_MENU(ID_EXIT, MyFrame::OnExit)
   EVT_BUTTON(ID_SHOW, MyFrame::OnShow)
   EVT_BUTTON(ID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()

bool MyApp::OnInit()
{
   MyFrame *frame = new MyFrame(wxT("Ejemplo Capitulo 05"));
   
   frame->Show(true);
   
   return true;
}

MyFrame::MyFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
   mbMenu = new wxMenuBar;
   mnMenu = new wxMenu;
   mnMenu->Append(ID_SHOW, wxT("&Mostrar"));
   mnMenu->AppendSeparator();
   mnMenu->Append(ID_EXIT, wxT("&Salir"));
   mbMenu->Append(mnMenu,wxT("&Funcionalidades"));
   SetMenuBar(mbMenu);
   btnShow = new wxButton(this, ID_SHOW, wxT("&Mostrar"), wxPoint(100,150), wxDefaultSize);
   btnExit = new wxButton(this, ID_EXIT, wxT("&Salir"), wxPoint(200,150), wxDefaultSize);
   lblShow = new wxStaticText(this, ID_STATICTEXT, wxT(""), wxPoint(200,10), wxSize(150,100), wxALIGN_LEFT);
   tcText = new wxTextCtrl(this, ID_TEXTCTRL, wxEmptyString, wxPoint(10,10), wxSize(150,100), wxTE_NO_VSCROLL|wxTE_MULTILINE);
}


void MyFrame::OnShow(wxCommandEvent& event)
{
  lblShow->SetLabel(tcText->GetValue());
}

void MyFrame::OnExit(wxCommandEvent& event)
{
   Close();
}