//---------------------------------------------------------------------------
//
// Name:        Dlg1.cpp
// Author:      Standart
// Created:     06/04/07 23:15:13
// Description: Dlg1 class implementation
//
//---------------------------------------------------------------------------

#include "Dlg1.h"
int total,ed[11];
char tot[20];
wxString nombb[10];

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

//----------------------------------------------------------------------------
// Dlg1
//----------------------------------------------------------------------------
//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(Dlg1,wxDialog)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(Dlg1::OnClose)
	EVT_INIT_DIALOG(Dlg1::Dlg1InitDialog)
	EVT_CHOICE(ID_WXCHOICE9,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE8,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE7,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE6,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE5,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE4,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE3,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE2,Dlg1::WxChoice1Selected)
	EVT_CHOICE(ID_WXCHOICE1,Dlg1::WxChoice1Selected)
	EVT_BUTTON(ID_WXBUTTON2,Dlg1::WxButton2Click)
	EVT_BUTTON(ID_WXBUTTON1,Dlg1::WxButton1Click)
END_EVENT_TABLE()
////Event Table End

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

Dlg1::~Dlg1()
{
} 

void Dlg1::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("Rajouter du texte pendant un voyage"));
	SetIcon(wxNullIcon);
	SetSize(8,8,525,344);
	Center();
	

	wxArrayString arrayStringFor_WxChoice9;
	arrayStringFor_WxChoice9.Add(wxT("0"));
	arrayStringFor_WxChoice9.Add(wxT("1"));
	arrayStringFor_WxChoice9.Add(wxT("2"));
	arrayStringFor_WxChoice9.Add(wxT("3"));
	arrayStringFor_WxChoice9.Add(wxT("4"));
	arrayStringFor_WxChoice9.Add(wxT("5"));
	arrayStringFor_WxChoice9.Add(wxT("6"));
	arrayStringFor_WxChoice9.Add(wxT("7"));
	arrayStringFor_WxChoice9.Add(wxT("8"));
	arrayStringFor_WxChoice9.Add(wxT("9"));
	WxChoice9 = new wxChoice(this, ID_WXCHOICE9, wxPoint(106,254), wxSize(35,21), arrayStringFor_WxChoice9, 0, wxDefaultValidator, wxT("WxChoice9"));
	WxChoice9->SetSelection(1);

	wxArrayString arrayStringFor_WxChoice8;
	arrayStringFor_WxChoice8.Add(wxT("0"));
	arrayStringFor_WxChoice8.Add(wxT("1"));
	arrayStringFor_WxChoice8.Add(wxT("2"));
	arrayStringFor_WxChoice8.Add(wxT("3"));
	arrayStringFor_WxChoice8.Add(wxT("4"));
	arrayStringFor_WxChoice8.Add(wxT("5"));
	arrayStringFor_WxChoice8.Add(wxT("6"));
	arrayStringFor_WxChoice8.Add(wxT("7"));
	arrayStringFor_WxChoice8.Add(wxT("8"));
	arrayStringFor_WxChoice8.Add(wxT("9"));
	WxChoice8 = new wxChoice(this, ID_WXCHOICE8, wxPoint(320,201), wxSize(42,21), arrayStringFor_WxChoice8, 0, wxDefaultValidator, wxT("WxChoice8"));
	WxChoice8->SetSelection(3);

	wxArrayString arrayStringFor_WxChoice7;
	arrayStringFor_WxChoice7.Add(wxT("0"));
	arrayStringFor_WxChoice7.Add(wxT("1"));
	arrayStringFor_WxChoice7.Add(wxT("2"));
	arrayStringFor_WxChoice7.Add(wxT("3"));
	arrayStringFor_WxChoice7.Add(wxT("4"));
	arrayStringFor_WxChoice7.Add(wxT("5"));
	arrayStringFor_WxChoice7.Add(wxT("6"));
	arrayStringFor_WxChoice7.Add(wxT("7"));
	arrayStringFor_WxChoice7.Add(wxT("8"));
	arrayStringFor_WxChoice7.Add(wxT("9"));
	WxChoice7 = new wxChoice(this, ID_WXCHOICE7, wxPoint(98,201), wxSize(40,21), arrayStringFor_WxChoice7, 0, wxDefaultValidator, wxT("WxChoice7"));
	WxChoice7->SetSelection(0);

	wxArrayString arrayStringFor_WxChoice6;
	arrayStringFor_WxChoice6.Add(wxT("0"));
	arrayStringFor_WxChoice6.Add(wxT("1"));
	arrayStringFor_WxChoice6.Add(wxT("2"));
	arrayStringFor_WxChoice6.Add(wxT("3"));
	arrayStringFor_WxChoice6.Add(wxT("4"));
	arrayStringFor_WxChoice6.Add(wxT("5"));
	arrayStringFor_WxChoice6.Add(wxT("6"));
	arrayStringFor_WxChoice6.Add(wxT("7"));
	arrayStringFor_WxChoice6.Add(wxT("8"));
	arrayStringFor_WxChoice6.Add(wxT("9"));
	WxChoice6 = new wxChoice(this, ID_WXCHOICE6, wxPoint(318,133), wxSize(40,21), arrayStringFor_WxChoice6, 0, wxDefaultValidator, wxT("WxChoice6"));
	WxChoice6->SetSelection(3);

	wxArrayString arrayStringFor_WxChoice5;
	arrayStringFor_WxChoice5.Add(wxT("0"));
	arrayStringFor_WxChoice5.Add(wxT("1"));
	arrayStringFor_WxChoice5.Add(wxT("2"));
	arrayStringFor_WxChoice5.Add(wxT("3"));
	arrayStringFor_WxChoice5.Add(wxT("4"));
	arrayStringFor_WxChoice5.Add(wxT("5"));
	arrayStringFor_WxChoice5.Add(wxT("6"));
	arrayStringFor_WxChoice5.Add(wxT("7"));
	arrayStringFor_WxChoice5.Add(wxT("8"));
	arrayStringFor_WxChoice5.Add(wxT("9"));
	WxChoice5 = new wxChoice(this, ID_WXCHOICE5, wxPoint(97,134), wxSize(40,21), arrayStringFor_WxChoice5, 0, wxDefaultValidator, wxT("WxChoice5"));
	WxChoice5->SetSelection(0);

	wxArrayString arrayStringFor_WxChoice4;
	arrayStringFor_WxChoice4.Add(wxT("0"));
	arrayStringFor_WxChoice4.Add(wxT("1"));
	arrayStringFor_WxChoice4.Add(wxT("2"));
	arrayStringFor_WxChoice4.Add(wxT("3"));
	arrayStringFor_WxChoice4.Add(wxT("4"));
	arrayStringFor_WxChoice4.Add(wxT("5"));
	arrayStringFor_WxChoice4.Add(wxT("6"));
	arrayStringFor_WxChoice4.Add(wxT("7"));
	arrayStringFor_WxChoice4.Add(wxT("8"));
	arrayStringFor_WxChoice4.Add(wxT("9"));
	WxChoice4 = new wxChoice(this, ID_WXCHOICE4, wxPoint(319,68), wxSize(40,21), arrayStringFor_WxChoice4, 0, wxDefaultValidator, wxT("WxChoice4"));
	WxChoice4->SetSelection(3);

	wxArrayString arrayStringFor_WxChoice3;
	arrayStringFor_WxChoice3.Add(wxT("0"));
	arrayStringFor_WxChoice3.Add(wxT("1"));
	arrayStringFor_WxChoice3.Add(wxT("2"));
	arrayStringFor_WxChoice3.Add(wxT("3"));
	arrayStringFor_WxChoice3.Add(wxT("4"));
	arrayStringFor_WxChoice3.Add(wxT("5"));
	arrayStringFor_WxChoice3.Add(wxT("6"));
	arrayStringFor_WxChoice3.Add(wxT("7"));
	arrayStringFor_WxChoice3.Add(wxT("8"));
	arrayStringFor_WxChoice3.Add(wxT("9"));
	WxChoice3 = new wxChoice(this, ID_WXCHOICE3, wxPoint(100,68), wxSize(41,21), arrayStringFor_WxChoice3, 0, wxDefaultValidator, wxT("WxChoice3"));
	WxChoice3->SetSelection(0);

	wxArrayString arrayStringFor_WxChoice2;
	arrayStringFor_WxChoice2.Add(wxT("0"));
	arrayStringFor_WxChoice2.Add(wxT("1"));
	arrayStringFor_WxChoice2.Add(wxT("2"));
	arrayStringFor_WxChoice2.Add(wxT("3"));
	arrayStringFor_WxChoice2.Add(wxT("4"));
	arrayStringFor_WxChoice2.Add(wxT("5"));
	arrayStringFor_WxChoice2.Add(wxT("6"));
	arrayStringFor_WxChoice2.Add(wxT("7"));
	arrayStringFor_WxChoice2.Add(wxT("8"));
	arrayStringFor_WxChoice2.Add(wxT("9"));
	WxChoice2 = new wxChoice(this, ID_WXCHOICE2, wxPoint(318,6), wxSize(39,21), arrayStringFor_WxChoice2, 0, wxDefaultValidator, wxT("WxChoice2"));
	WxChoice2->SetSelection(3);

	wxArrayString arrayStringFor_WxChoice1;
	arrayStringFor_WxChoice1.Add(wxT("0"));
	arrayStringFor_WxChoice1.Add(wxT("1"));
	arrayStringFor_WxChoice1.Add(wxT("2"));
	arrayStringFor_WxChoice1.Add(wxT("3"));
	arrayStringFor_WxChoice1.Add(wxT("4"));
	arrayStringFor_WxChoice1.Add(wxT("5"));
	arrayStringFor_WxChoice1.Add(wxT("6"));
	arrayStringFor_WxChoice1.Add(wxT("7"));
	arrayStringFor_WxChoice1.Add(wxT("8"));
	arrayStringFor_WxChoice1.Add(wxT("9"));
	WxChoice1 = new wxChoice(this, ID_WXCHOICE1, wxPoint(101,6), wxSize(41,21), arrayStringFor_WxChoice1, 0, wxDefaultValidator, wxT("WxChoice1"));
	WxChoice1->SetSelection(0);

	WxStaticText16 = new wxStaticText(this, ID_WXSTATICTEXT16, wxT("secondes"), wxPoint(147,257), wxDefaultSize, 0, wxT("WxStaticText16"));

	WxStaticText15 = new wxStaticText(this, ID_WXSTATICTEXT15, wxT("Pour finir, attendre"), wxPoint(11,258), wxDefaultSize, 0, wxT("WxStaticText15"));

	WxEdit13 = new wxTextCtrl(this, ID_WXEDIT13, wxT(""), wxPoint(158,283), wxSize(34,21), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("WxEdit13"));
	WxEdit13->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxStaticText14 = new wxStaticText(this, ID_WXSTATICTEXT14, wxT("secondes"), wxPoint(197,287), wxDefaultSize, 0, wxT("WxStaticText14"));
	WxStaticText14->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxStaticText13 = new wxStaticText(this, ID_WXSTATICTEXT13, wxT("Durée totale du voyage : "), wxPoint(12,287), wxDefaultSize, 0, wxT("WxStaticText13"));
	WxStaticText13->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxStaticLine3 = new wxStaticLine(this, ID_WXSTATICLINE3, wxPoint(16,189), wxSize(489,-1), wxLI_HORIZONTAL);

	WxStaticLine2 = new wxStaticLine(this, ID_WXSTATICLINE2, wxPoint(13,122), wxSize(494,-1), wxLI_HORIZONTAL);

	WxStaticLine1 = new wxStaticLine(this, ID_WXSTATICLINE1, wxPoint(3,56), wxSize(503,-1), wxLI_HORIZONTAL);

	WxEdit12 = new wxTextCtrl(this, ID_WXEDIT12, wxT(""), wxPoint(8,228), wxSize(500,22), 0, wxDefaultValidator, wxT("WxEdit12"));

	WxStaticText12 = new wxStaticText(this, ID_WXSTATICTEXT12, wxT("secondes ; puis phrase 4 : pendant"), wxPoint(141,204), wxDefaultSize, 0, wxT("WxStaticText12"));

	WxStaticText11 = new wxStaticText(this, ID_WXSTATICTEXT11, wxT("secondes ; puis phrase 3 : pendant"), wxPoint(142,136), wxDefaultSize, 0, wxT("WxStaticText11"));

	WxStaticText10 = new wxStaticText(this, ID_WXSTATICTEXT10, wxT("Attendre pendant"), wxPoint(8,205), wxDefaultSize, 0, wxT("WxStaticText10"));

	WxStaticText9 = new wxStaticText(this, ID_WXSTATICTEXT9, wxT("secondes apparait le texte :"), wxPoint(367,204), wxDefaultSize, 0, wxT("WxStaticText9"));

	WxStaticText8 = new wxStaticText(this, ID_WXSTATICTEXT8, wxT("secondes apparait le texte :"), wxPoint(362,136), wxDefaultSize, 0, wxT("WxStaticText8"));

	WxStaticText7 = new wxStaticText(this, ID_WXSTATICTEXT7, wxT("secondes apparait le texte :"), wxPoint(362,72), wxDefaultSize, 0, wxT("WxStaticText7"));

	WxStaticText6 = new wxStaticText(this, ID_WXSTATICTEXT6, wxT("secondes ; puis phrase 2 : pendant"), wxPoint(144,72), wxDefaultSize, 0, wxT("WxStaticText6"));

	WxStaticText5 = new wxStaticText(this, ID_WXSTATICTEXT5, wxT("secondes apparait le texte :"), wxPoint(360,8), wxDefaultSize, 0, wxT("WxStaticText5"));

	WxStaticText4 = new wxStaticText(this, ID_WXSTATICTEXT4, wxT("secondes ; puis phrase 1 : pendant"), wxPoint(144,8), wxDefaultSize, 0, wxT("WxStaticText4"));

	WxStaticText3 = new wxStaticText(this, ID_WXSTATICTEXT3, wxT("Attendre pendant"), wxPoint(8,136), wxDefaultSize, 0, wxT("WxStaticText3"));

	WxStaticText2 = new wxStaticText(this, ID_WXSTATICTEXT2, wxT("Attendre pendant"), wxPoint(8,72), wxDefaultSize, 0, wxT("WxStaticText2"));

	WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Attendre pendant "), wxPoint(8,8), wxDefaultSize, 0, wxT("WxStaticText1"));

	WxEdit3 = new wxTextCtrl(this, ID_WXEDIT3, wxT(""), wxPoint(8,160), wxSize(501,22), 0, wxDefaultValidator, wxT("WxEdit3"));

	WxEdit2 = new wxTextCtrl(this, ID_WXEDIT2, wxT(""), wxPoint(8,96), wxSize(502,21), 0, wxDefaultValidator, wxT("WxEdit2"));

	WxEdit1 = new wxTextCtrl(this, ID_WXEDIT1, wxT(""), wxPoint(8,32), wxSize(502,21), 0, wxDefaultValidator, wxT("WxEdit1"));

	WxButton2 = new wxButton(this, ID_WXBUTTON2, wxT("voyage sans texte"), wxPoint(399,277), wxSize(107,25), 0, wxDefaultValidator, wxT("WxButton2"));

	WxButton1 = new wxButton(this, ID_WXBUTTON1, wxT("Valider ces phrases"), wxPoint(270,276), wxSize(114,26), 0, wxDefaultValidator, wxT("WxButton1"));
	////GUI Items Creation End
}

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

/*
 * WxButton2Click
 */
void Dlg1::WxButton2Click(wxCommandEvent& event)
{
	valid1=false;
	Destroy();// fin sans texte
}

/*
 * WxButton1Click
 */
void Dlg1::WxButton1Click(wxCommandEvent& event)
{
	valid1=true;
	text1=WxEdit1->GetValue();
    text2=WxEdit2->GetValue();
    text3=WxEdit3->GetValue();
    text4=WxEdit12->GetValue();
    duree1=nombb[ed[1]];
    att1=nombb[ed[0]];
    duree2=nombb[ed[3]];
    att2=nombb[ed[2]];
    duree3=nombb[ed[5]];
    att3=nombb[ed[4]];
    duree4=nombb[ed[7]];
    att4=nombb[ed[6]];
    att5=nombb[ed[8]];
    total1=total;
	Destroy();
}

/*
 * Dlg1InitDialog
 */
void Dlg1::Dlg1InitDialog(wxInitDialogEvent& event)
{
    nombb[0]=wxT("0");
    nombb[1]=wxT("1");
    nombb[2]=wxT("2");
    nombb[3]=wxT("3");
    nombb[4]=wxT("4");
    nombb[5]=wxT("5");
    nombb[6]=wxT("6");
    nombb[7]=wxT("7");
    nombb[8]=wxT("8");
    nombb[9]=wxT("9");
    ed[0]=WxChoice1->GetCurrentSelection();
    ed[1]=WxChoice2->GetCurrentSelection();
    ed[2]=WxChoice3->GetCurrentSelection();
    ed[3]=WxChoice4->GetCurrentSelection();
    ed[4]=WxChoice5->GetCurrentSelection();
    ed[5]=WxChoice6->GetCurrentSelection();
    ed[6]=WxChoice7->GetCurrentSelection();
    ed[7]=WxChoice8->GetCurrentSelection();
    ed[8]=WxChoice9->GetCurrentSelection();
    total=ed[0]+ed[1]+ed[2]+ed[3]+ed[4]+ed[5]+ed[6]+ed[7]+ed[8];
    sprintf(tot,"%d",total);
    WxEdit13->SetValue(wxT(tot));
    
}



/*
 * WxChoice1Selected
 */
void Dlg1::WxChoice1Selected(wxCommandEvent& event )
{
    ed[0]=WxChoice1->GetCurrentSelection();
    ed[1]=WxChoice2->GetCurrentSelection();
    ed[2]=WxChoice3->GetCurrentSelection();
    ed[3]=WxChoice4->GetCurrentSelection();
    ed[4]=WxChoice5->GetCurrentSelection();
    ed[5]=WxChoice6->GetCurrentSelection();
    ed[6]=WxChoice7->GetCurrentSelection();
    ed[7]=WxChoice8->GetCurrentSelection();
    ed[8]=WxChoice9->GetCurrentSelection();
    total=ed[0]+ed[1]+ed[2]+ed[3]+ed[4]+ed[5]+ed[6]+ed[7]+ed[8];
    sprintf(tot,"%d",total);
    WxEdit13->SetValue(wxT(tot));
}