//---------------------------------------------------------------------------
//
// Name:        mod_code.cpp
// Author:      Standart
// Created:     14/04/07 09:40:58
// Description: mod_code class implementation
//
//---------------------------------------------------------------------------

#include "mod_code.h"

//Do not add custom headers
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// mod_code
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(mod_code,wxDialog)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(mod_code::OnClose)
	EVT_INIT_DIALOG(mod_code::mod_codeInitDialog)
	EVT_BUTTON(ID_WXBUTTON2,mod_code::WxButton2Click)
	EVT_BUTTON(ID_WXBUTTON1,mod_code::WxButton1Click)
	
	EVT_TEXT(ID_WXMEMO1,mod_code::WxMemo1Updated)
END_EVENT_TABLE()
////Event Table End

mod_code::mod_code(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
	CreateGUIControls();
}

mod_code::~mod_code()
{
} 

void mod_code::CreateGUIControls()
{
	//Do not add custom code between
        //GUI Items Creation Start and GUI Items Creation End.
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	SetTitle(wxT("Modifier le code"));
	SetIcon(wxNullIcon);
	SetSize(8,8,343,348);
	Center();
	

	/* Voulez-vous vraiment modifier cette instruction ?
	*/
	WxMessageDialog1 =  new wxMessageDialog(this, wxT("Voulez-vous vraiment modifier cette instruction ?"), wxT("Modifier et voir le code"), wxYES_NO | wxICON_EXCLAMATION);

	WxEdit1 = new wxTextCtrl(this, ID_WXEDIT1, wxT(""), wxPoint(67,7), wxSize(260,21), 0, wxDefaultValidator, wxT("WxEdit1"));

	WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Code de :"), wxPoint(5,10), wxDefaultSize, wxALIGN_CENTRE, wxT("WxStaticText1"));
	WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton2 = new wxButton(this, ID_WXBUTTON2, wxT("Ne pas modifier"), wxPoint(197,279), wxSize(107,27), 0, wxDefaultValidator, wxT("WxButton2"));

	WxButton1 = new wxButton(this, ID_WXBUTTON1, wxT("Modifier le code"), wxPoint(23,280), wxSize(105,27), 0, wxDefaultValidator, wxT("WxButton1"));

	WxMemo1 = new wxTextCtrl(this, ID_WXMEMO1, wxT(""), wxPoint(5,37), wxSize(321,237), wxHSCROLL | wxTE_MULTILINE, wxDefaultValidator, wxT("WxMemo1"));
	WxMemo1->SetMaxLength(0);
	WxMemo1->AppendText(wxT("WxMemo12"));
	WxMemo1->SetFocus();
	WxMemo1->SetInsertionPointEnd();
	////GUI Items Creation End

}

void mod_code::OnClose(wxCloseEvent& /*event*/)
{
	Destroy();
}

/*
 * WxButton1Click
 */
void mod_code::WxButton1Click(wxCommandEvent& event)
{
	if (WxMessageDialog1->ShowModal()==wxID_NO) return;
    code_m=WxMemo1->GetValue();
	nom_m=WxEdit1->GetValue();
	Destroy();
}

/*
 * mod_codeActivate
 */
void mod_code::mod_codeActivate(wxActivateEvent& event)
{
	WxMemo1->SetValue(code_m);
}

/*
 * WxButton2Click
 */
void mod_code::WxButton2Click(wxCommandEvent& event)
{
	Destroy(); // pas de modif
}

/*
 * WxButton3Click
 */
void mod_code::WxButton3Click(wxCommandEvent& event)
{
	WxMemo1->SetValue(code_m);

}

/*
 * mod_codeActivateApp
 */
void mod_code::mod_codeActivateApp(wxActivateEvent& event)
{
		WxMemo1->SetValue(code_m);

}

/*
 * mod_codeInitDialog
 */
void mod_code::mod_codeInitDialog(wxInitDialogEvent& event)
{
	WxMemo1->SetValue(code_m);
	WxEdit1->SetValue(nom_m);
}

/*
 * WxMemo1Updated
 */
void mod_code::WxMemo1Updated(wxCommandEvent& event)
{
	// insert your code here
}