//---------------------------------------------------------------------------
//
// Name:        ProjetzzFrm.cpp
// Author:      Standart
// Created:     24/03/07 09:35:05
// Description: ProjetzzFrm class implementation
//
//---------------------------------------------------------------------------

#include "ProjetzzFrm.h" 
#include "mod_code.h"
#include "Dlg1.h"
#include "Dlg2.h"
#include "Dlga.h"

//#include "fonctions.h" 

//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
#include "Images/Self_ProjetzzFrm_XPM.xpm"
#include "Images/ProjetzzFrm_WxToolButton4_XPM.xpm"
#include "Images/ProjetzzFrm_WxToolButton3_XPM.xpm"
#include "Images/ProjetzzFrm_WxToolButton2_XPM.xpm"
#include "Images/ProjetzzFrm_WxToolButton1_XPM.xpm"
////Header Include End

//----------------------------------------------------------------------------
// ProjetzzFrm
//----------------------------------------------------------------------------
//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(ProjetzzFrm,wxFrame)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(ProjetzzFrm::OnClose)
	EVT_MENU(ID_MNU_NOUVEAU_1027, ProjetzzFrm::Mnunouveau1027Click)
	EVT_MENU(ID_MNU_OUVRIR_1021, ProjetzzFrm::Mnuouvrir1021Click)
	EVT_MENU(ID_MNU_SAUVER_1022, ProjetzzFrm::Mnusauver1022Click)
	EVT_MENU(ID_MNU_QUITTER_1024, ProjetzzFrm::Mnuquitter1024Click)
	EVT_MENU(ID_MNU_AIDEDESOPTIONS_1037, ProjetzzFrm::Mnuaidedesoptions1037Click)
	EVT_MENU(ID_MNU_MODIFIERLECODE_1039, ProjetzzFrm::Mnumodifierlecode1039Click)
	EVT_MENU(ID_MNU_SUBMENUITEM18_1041, ProjetzzFrm::Mnusubmenuitem181041Click)
	EVT_MENU(ID_MNU_SUBMENUITEM12_1029, ProjetzzFrm::Mnusubmenuitem121029Click)
	EVT_MENU(ID_MNU_COMMANDES_1030, ProjetzzFrm::Mnucommandes1030Click)
	EVT_MENU(ID_WXTOOLBUTTON4,ProjetzzFrm::WxToolButton4Click)
	EVT_MENU(ID_WXTOOLBUTTON3,ProjetzzFrm::Mnusauver1022Click)
	EVT_MENU(ID_WXTOOLBUTTON2,ProjetzzFrm::Mnuouvrir1021Click)
	EVT_MENU(ID_WXTOOLBUTTON1,ProjetzzFrm::Mnunouveau1027Click)
	
	EVT_GRID_CELL_CHANGE(ProjetzzFrm::WxGrid1CellChange1)
	EVT_BUTTON(ID_WXBUTTON5,ProjetzzFrm::WxButton5Click)
	EVT_BUTTON(ID_WXBUTTON4,ProjetzzFrm::WxButton4Click)
	EVT_LISTBOX(ID_WXLISTBOX1,ProjetzzFrm::WxListBox1Selected)
	EVT_LISTBOX_DCLICK(ID_WXLISTBOX1,ProjetzzFrm::WxButton3Click)
	EVT_BUTTON(ID_WXBUTTON3,ProjetzzFrm::WxButton3Click)
	EVT_BUTTON(ID_WXBUTTON2,ProjetzzFrm::WxButton2Click)
	EVT_BUTTON(ID_WXBUTTON1,ProjetzzFrm::WxButton1Click)
	
	EVT_UPDATE_UI(ID_WXPANEL1,ProjetzzFrm::WxPanel1UpdateUI)
END_EVENT_TABLE()
////Event Table End

int jx=0,jx2=0,ix=0,n_liste=0,n_instr=0,maximum,nbre_texte;
int posG;
wxString phrase,phrase2,liste[300],code[300],objet[200],param1[200],param2[200],rien=wxT("");
wxString param1i,param2i,phrasex,intermede;
wxString texte1,texte2,texte3,texte4,texte5;

// liste=libellé des instructions,phrase est l'intermède
// code=contenu des instructions (code),phrase2 est l'intermède
// objet = objet selectionné
// param1 = 1er param
// param2 = autre param si necessaire

// ici on va rajouter la partie miniscript: def+fonctions
// var globales

int n=0,n2=0,i=0,j=0,k=0,fr=0,nx[8];// fr=0 pour modifier les noms (fr->angl), sinon fr=0
int nb,i9,signe_nb,resultat,valeur,total1x;
char nomfichier[50],phra[50],phr,phr2[510],phr3[250],phr4[150],phr5[90];
char phr6[90],phr7[90],phrn[300],suf[5]=".cel",ent[]="\n",nom_obj[50]="";
char encod[40],encx[40],ency[40],encz[40],obj[250],obj2[250],obj3[250],obj4[250];
static unsigned char alphabet[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
double ax,ay,az,a9,bx,by,bz,b9;
float ang,cx,cy,cz,ow,ox,oy,oz,fov1,fov2,k0;
//char obj[150],obj2[150],obj3[80],obj4[80],nom_obj[50]="";
const float coef_a=1.015; // pour le fov
wxString att1x,att2x,att3x,att4x,att5x,duree1x,duree2x,duree3x,duree4x;
wxString duree1,duree2,duree3,duree4,ph_orb;
bool valid1x,valid2x,block;
// les var de miniscript7
//char const ent[]="\n",suf[5]=".cel";
char const sel[]="select { object \"",got[]="goto { time ",wai[]="wait { duration ";
char const dis[]=" distance ",orb[]="orbit { axis [ 0 1 0 ] rate ",orb2[]=" duration ";
char const deb[]="{",fin[]=" }",rot[]="rotate { duration",fol[]="follow{}",motz[]="z ",moto[]="o";
char const tim[]="timerate { rate ",cha[]="changedistance { duration ",motx[]="x ",moty[]="y ";
char const rat[]=" rate ",rajt[]="wait { duration 2 }",dur5[]="5",gui[]="\"";
char const syn[]="synchronous {}",dur8[]="8",dur9[]="10",dur13[]="13",dur14[]="14";
char const sol[]="Soleil",sla[]="/",lab[]="labels {",ren[]="renderflags {",ou[]="|";
char const pol[]="orbit { axis [ 1 0 0 ] rate 15 duration 6 }",tim0[]="timerate { rate 0}";
char const cen[]="center {}",set[]="set { name \"FOV\" value ",dies[]="# ",timex[]="time ",jd[]="{ jd ";
char const pri[]="print { text \"",row[]="\"  row -4  column 3 }",sel2[]="select { object ";
char const setfr[]="setframe { ",gotl[]="gotoloc {",motw[]="w ";
char const wait_fov[]="wait { duration 0.05 }";
char wai2[40]="wait { duration ";

int c,cc,rep=0,rep2=0,rep3=0,rep4=0,m=0,n0,sortie=0,j01;
char recapil[300][250],recap[300],instrm[10000]; //rajout=0,,inst1[512]dans intr on mettra les lignes de codes
char lect[3],durees[50],lettre[2];  // on comptera avec j; 250 lignes de 256 caractères
FILE *fic;

// certaines sont à virer: instr[512][1020];
// fin var miniscript7
ProjetzzFrm::ProjetzzFrm(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
}
ProjetzzFrm::~ProjetzzFrm()
{
}

void mod_nom(void)
{
if (strcmp(obj,"Vénus")==0) strcpy(obj,"Venus");//
if (strcmp(obj,"vénus")==0) strcpy(obj,"Venus");
if (strcmp(obj,"VENUS")==0) strcpy(obj,"Venus");
if (strcmp(obj2,"Vénus")==0) strcpy(obj2,"Venus");//
if (strcmp(obj2,"vénus")==0) strcpy(obj2,"Venus");
if (strcmp(obj2,"VENUS")==0) strcpy(obj2,"Venus");
if (strcmp(obj3,"Vénus")==0) strcpy(obj3,"Venus");//
if (strcmp(obj3,"vénus")==0) strcpy(obj3,"Venus");
if (strcmp(obj3,"VENUS")==0) strcpy(obj3,"Venus");
if (strcmp(obj4,"Vénus")==0) strcpy(obj4,"Venus");//
if (strcmp(obj4,"vénus")==0) strcpy(obj4,"Venus");
if (strcmp(obj4,"VENUS")==0) strcpy(obj4,"Venus");
if (block==false) return;// on me met pas les noms en anglais

if (strcmp(obj,"soleil")==0) strcpy(obj,"Sol");
if (strcmp(obj,"Soleil")==0) strcpy(obj,"Sol");
if (strcmp(obj,"SOLEIL")==0) strcpy(obj,"Sol");
if (strcmp(obj,"terre")==0) strcpy(obj,"Earth");
if (strcmp(obj,"Terre")==0) strcpy(obj,"Earth");
if (strcmp(obj,"TERRE")==0) strcpy(obj,"Earth");
if (strcmp(obj,"saturne")==0) strcpy(obj,"Saturn");
if (strcmp(obj,"Saturne")==0) strcpy(obj,"Saturn");
if (strcmp(obj,"SATURNE")==0) strcpy(obj,"Saturn");
if (strcmp(obj,"Mercure")==0) strcpy(obj,"Mercury");
if (strcmp(obj,"mercure")==0) strcpy(obj,"Mercury");
if (strcmp(obj,"MERCURE")==0) strcpy(obj,"Mercury");
if (strcmp(obj,"Europe")==0) strcpy(obj,"Europa");
if (strcmp(obj,"europe")==0) strcpy(obj,"Europa");
if (strcmp(obj,"EUROPE")==0) strcpy(obj,"Europa");
if (strcmp(obj,"Lune")==0) strcpy(obj,"Moon");
if (strcmp(obj,"lune")==0) strcpy(obj,"Moon");
if (strcmp(obj,"LUNE")==0) strcpy(obj,"Moon");
if (strcmp(obj,"Pluton")==0) strcpy(obj,"Pluto");
if (strcmp(obj,"pluton")==0) strcpy(obj,"Pluto");
if (strcmp(obj,"PLUTON")==0) strcpy(obj,"Pluto");
//
if (strcmp(obj2,"soleil")==0) strcpy(obj2,"Sol");
if (strcmp(obj2,"Soleil")==0) strcpy(obj2,"Sol");
if (strcmp(obj2,"SOLEIL")==0) strcpy(obj2,"Sol");
if (strcmp(obj2,"terre")==0) strcpy(obj2,"Earth");
if (strcmp(obj2,"Terre")==0) strcpy(obj2,"Earth");
if (strcmp(obj2,"TERRE")==0) strcpy(obj2,"Earth");
if (strcmp(obj2,"saturne")==0) strcpy(obj2,"Saturn");
if (strcmp(obj2,"Saturne")==0) strcpy(obj2,"Saturn");
if (strcmp(obj2,"SATURNE")==0) strcpy(obj2,"Saturn");
if (strcmp(obj2,"Mercure")==0) strcpy(obj2,"Mercury");
if (strcmp(obj2,"mercure")==0) strcpy(obj2,"Mercury");
if (strcmp(obj2,"MERCURE")==0) strcpy(obj2,"Mercury");
if (strcmp(obj2,"Europe")==0) strcpy(obj2,"Europa");
if (strcmp(obj2,"europe")==0) strcpy(obj2,"Europa");
if (strcmp(obj2,"EUROPE")==0) strcpy(obj2,"Europa");
if (strcmp(obj2,"Lune")==0) strcpy(obj2,"Moon");
if (strcmp(obj2,"lune")==0) strcpy(obj2,"Moon");
if (strcmp(obj2,"LUNE")==0) strcpy(obj2,"Moon");
if (strcmp(obj2,"Pluton")==0) strcpy(obj2,"Pluto");
if (strcmp(obj2,"pluton")==0) strcpy(obj2,"Pluto");
if (strcmp(obj2,"PLUTON")==0) strcpy(obj2,"Pluto");
//
if (strcmp(obj3,"soleil")==0) strcpy(obj3,"Sol");
if (strcmp(obj3,"Soleil")==0) strcpy(obj3,"Sol");
if (strcmp(obj3,"SOLEIL")==0) strcpy(obj3,"Sol");
if (strcmp(obj3,"terre")==0) strcpy(obj3,"Earth");
if (strcmp(obj3,"Terre")==0) strcpy(obj3,"Earth");
if (strcmp(obj3,"TERRE")==0) strcpy(obj3,"Earth");
if (strcmp(obj3,"saturne")==0) strcpy(obj3,"Saturn");
if (strcmp(obj3,"Saturne")==0) strcpy(obj3,"Saturn");
if (strcmp(obj3,"SATURNE")==0) strcpy(obj3,"Saturn");
if (strcmp(obj3,"Mercure")==0) strcpy(obj3,"Mercury");
if (strcmp(obj3,"mercure")==0) strcpy(obj3,"Mercury");
if (strcmp(obj3,"MERCURE")==0) strcpy(obj3,"Mercury");
if (strcmp(obj3,"Europe")==0) strcpy(obj3,"Europa");
if (strcmp(obj3,"europe")==0) strcpy(obj3,"Europa");
if (strcmp(obj3,"EUROPE")==0) strcpy(obj3,"Europa");
if (strcmp(obj3,"Lune")==0) strcpy(obj3,"Moon");
if (strcmp(obj3,"lune")==0) strcpy(obj3,"Moon");
if (strcmp(obj3,"LUNE")==0) strcpy(obj3,"Moon");
if (strcmp(obj3,"Pluton")==0) strcpy(obj3,"Pluto");
if (strcmp(obj3,"pluton")==0) strcpy(obj3,"Pluto");
if (strcmp(obj3,"PLUTON")==0) strcpy(obj3,"Pluto");
//
if (strcmp(obj4,"soleil")==0) strcpy(obj4,"Sol");
if (strcmp(obj4,"Soleil")==0) strcpy(obj4,"Sol");
if (strcmp(obj4,"SOLEIL")==0) strcpy(obj4,"Sol");
if (strcmp(obj4,"terre")==0) strcpy(obj4,"Earth");
if (strcmp(obj4,"Terre")==0) strcpy(obj4,"Earth");
if (strcmp(obj4,"TERRE")==0) strcpy(obj4,"Earth");
if (strcmp(obj4,"saturne")==0) strcpy(obj4,"Saturn");
if (strcmp(obj4,"Saturne")==0) strcpy(obj4,"Saturn");
if (strcmp(obj4,"SATURNE")==0) strcpy(obj4,"Saturn");
if (strcmp(obj4,"Mercure")==0) strcpy(obj4,"Mercury");
if (strcmp(obj4,"mercure")==0) strcpy(obj4,"Mercury");
if (strcmp(obj4,"MERCURE")==0) strcpy(obj4,"Mercury");
if (strcmp(obj4,"Europe")==0) strcpy(obj4,"Europa");
if (strcmp(obj4,"europe")==0) strcpy(obj4,"Europa");
if (strcmp(obj4,"EUROPE")==0) strcpy(obj4,"Europa");
if (strcmp(obj4,"Lune")==0) strcpy(obj4,"Moon");
if (strcmp(obj4,"lune")==0) strcpy(obj4,"Moon");
if (strcmp(obj4,"LUNE")==0) strcpy(obj4,"Moon");
if (strcmp(obj4,"Pluton")==0) strcpy(obj4,"Pluto");
if (strcmp(obj4,"pluton")==0) strcpy(obj4,"Pluto");
if (strcmp(obj4,"PLUTON")==0) strcpy(obj4,"Pluto");
}


void enleveraccent(void)// enlever les éàèî...pour e,a,i...
{
//pour obj
for(unsigned int tail=0;tail<strlen(obj);tail++) 
    {        
        if ((obj[tail]=='é')|(obj[tail]=='è')|(obj[tail]=='ê')|(obj[tail]=='ë')) 
            obj[tail]='e';
        if (obj[tail]=='à')
            obj[tail]='a';
        if ((obj[tail]=='î')|(obj[tail]=='ï'))
            obj[tail]='i';
        if (obj[tail]=='ù')
            obj[tail]='u';        
        if (obj[tail]=='ô')
            obj[tail]='o';
        if (obj[tail]=='ç')
            obj[tail]='c';
    }
//pour obj2
for(unsigned int tail=0;tail<strlen(obj2);tail++)
    {
        if ((obj2[tail]=='é')|(obj2[tail]=='è')|(obj2[tail]=='ê')|(obj2[tail]=='ë'))
            obj2[tail]='e';
        if (obj2[tail]=='à')
            obj2[tail]='a';
        if ((obj2[tail]=='î')|(obj2[tail]=='ï'))
            obj2[tail]='i';
        if (obj2[tail]=='ù')
            obj2[tail]='u';
        if (obj2[tail]=='ô')
            obj2[tail]='o';
        if (obj2[tail]=='ç')
            obj2[tail]='c';
    }
// pour obj3
for(unsigned int tail=0;tail<strlen(obj3);tail++)
    {
        if ((obj3[tail]=='é')|(obj3[tail]=='è')|(obj3[tail]=='ê')|(obj3[tail]=='ë'))
            obj3[tail]='e';
        if (obj3[tail]=='à')
            obj3[tail]='a';
        if ((obj3[tail]=='î')|(obj3[tail]=='ï'))
            obj3[tail]='i';
        if (obj3[tail]=='ù')
            obj3[tail]='u';
        if (obj3[tail]=='ô')
            obj3[tail]='o';
        if (obj3[tail]=='ç')
            obj3[tail]='c';
    }
// pour obj4
for(unsigned int tail=0;tail<strlen(obj4);tail++)
    {
        if ((obj4[tail]=='é')|(obj4[tail]=='è')|(obj4[tail]=='ê')|(obj4[tail]=='ë'))
            obj4[tail]='e';
        if (obj4[tail]=='à')
            obj4[tail]='a';
        if ((obj4[tail]=='î')|(obj4[tail]=='ï'))
            obj4[tail]='i';
        if (obj4[tail]=='ù')
            obj4[tail]='u';
        if (obj4[tail]=='ô')
            obj4[tail]='o';
        if (obj4[tail]=='ç')
            obj4[tail]='c';
    }
}

void accent(unsigned int i7,unsigned int i8)
{
unsigned int z0;

char obi[150]="",obf[150]="";
for (z0=0;z0<i7;z0++)
    {
         obi[z0]=obj[z0];
    }
for (z0=i7+1;z0<=strlen(obj);z0++)
    {
         obf[z0-i7-1]=obj[z0];
    }
if (i8==233)   strcat(obi,"\\u00e9"); //é
if (i8==232)   strcat(obi,"\\u00e8"); //è
if (i8==234)   strcat(obi,"\\u00ea"); //ê
if (i8==235)   strcat(obi,"\\u00eb"); //ë
if (i8==224)   strcat(obi,"\\u00e0"); //à
if (i8==238)   strcat(obi,"\\u00ee"); //î
if (i8==239)   strcat(obi,"\\u00ef"); //ï
if (i8==249)   strcat(obi,"\\u00f9"); //ù
if (i8==244)   strcat(obi,"\\u00f4"); //ô
if (i8==231)   strcat(obi,"\\u00e7"); //ç
strcat(obi,obf);
strcpy(obj,obi);
}

//  double en nx[8]
void codage(double d,double d2)
{
double d3;
for (int i = 0; i < 8; i++)
    nx[i] = 0;

int sign = 1;

if (d < 0)
    {
        sign = -1;
        d = -d;
        //+
        d2 = -d2;
        if(d2<0) d3=-d2;
         else d3=d2;
    }

    double e = floor(d / (65536.0 * 65536.0 * 65536.0));

    // Check for overflow
    if (e < 32767)
    {
        nx[7] = (unsigned short) e;
        d -= nx[7] * 65536.0 * 65536.0 * 65536.0;
        nx[6] = (unsigned short) (d / (65536.0 * 65536.0));
        d -= nx[6] * 65536.0 * 65536.0;
        nx[5] = (unsigned short) (d / 65536.0);
        d -= nx[5] * 65536.0;
        nx[4] = (unsigned short) d;
        d -= nx[4];
        //if (d>10000000000000.0) d+=d2;
        if (d3>0.0001) d+=d2;
        nx[3] = (unsigned short) (d * 65536.0);
        d -= nx[3] / 65536.0;
        //if ((d>100000000)&&(d<10000000000000.0)) d+=d2;
        if ((d3>0.0000001)&&(d3<0.0001)) d+=d2;

        nx[2] = (unsigned short) (d * 65536.0 * 65536.0);
        d -= nx[2] / (65536.0 * 65536.0);
        //if ((d>100000)&&(d<100000000)) d+=d2;
        if ((d3>0.00000000001)&&(d3<0.0000001)) d+=d2;

        nx[1] = (unsigned short) (d * 65536.0 * 65536.0 * 65536.0);
        d -= nx[1] / (65536.0 * 65536.0 * 65536.0);
        //if (d<100000) d+=d2;
        if (d3<0.00000000001) d+=d2;
        //d+=d2;
        nx[0] = (unsigned short) (d * 65536.0 * 65536.0 * 65536.0 * 65536.0);
    }

//    if (sign < 0) // il faut prendre les opposés binaires des nx: 10010110 devient 01101001
//        on va faire non(nx) donc nx=!(nx)
if (sign==-1)
  {for (int i7=0;i7<8;i7++)
          {
           nx[i7]^=0xffff;
          }
  }
}

// base 64
void encodage(void)
{
strcpy(encod,"");
int bits, c, char_count, started, i, j, k=0;

    char_count = 0;
    bits = 0;
    started = 0;

    // Find first significant (non null) byte
    i = 16;
    do {
        i--;
        c = nx[i/2];
        if (i & 1) c >>= 8;
        c &= 0xff;
    } while ((c == 0) && (i != 0));

    if (i == 0)
        {
        encod[k]=0;
        return; }

    // Then we encode starting by the LSB (i+1 bytes to encode)
    j = 0;
    while (j <= i)
    {
        c = nx[j/2];
        if ( j & 1 ) c >>= 8;
        c &= 0xff;
        j++;
        bits += c;
        char_count++;
        if (char_count == 3)
        {
//            strcat(encod[k++],alphabet[bits >> 18]);
            encod[k++]=alphabet[bits >> 18];
            encod[k++]=alphabet[(bits >> 12) & 0x3f];
            encod[k++]=alphabet[(bits >> 6) & 0x3f];
            encod[k++]=alphabet[bits & 0x3f];
            bits = 0;
            char_count = 0;
        }
        else
        {
            bits <<= 8;
        }
    }

    if (char_count != 0)
    {
        bits <<= 16 - (8 * char_count);
        encod[k++]=alphabet[bits >> 18];
        encod[k++]=alphabet[(bits >> 12) & 0x3f];
        if (char_count != 1)
            encod[k++]=alphabet[(bits >> 6) & 0x3f];
    }
encod[k]=0;
    return;
}// fin du codage dans encod[]


void modif_texte_suppl(int numero_ph)
{
// cas n_instr=3 pour tourner autour
if (n_instr!=3)
    strcpy(wai2,wai);
//on va modifier obj=texte1,2,3 ou 4

      // cas où la phrase dépasse 60 caractères
      strcpy(obj2,obj);
      unsigned int longueur=strlen(obj);
      if (longueur>61)
      {
            for(j=60;j>32;j--)
               if (obj[j]==32)
                {
                    strcat(obj,"+");
                    for(i=longueur-1;i>j;i--)
                        obj[i+1]=obj[i];
                    obj[j]=92;
                    obj[j+1]=110;
                    break;
                }
      }
      // cas où la phrase dépasse 120 caractères
      longueur=strlen(obj);
      if (longueur>126)
      {
            for(j=125;j>100;j--)
               if (obj[j]==32)
                {
                    strcat(obj,"+");
                    for(i=longueur-1;i>j;i--)
                        obj[i+1]=obj[i];
                    obj[j]=92;
                    obj[j+1]=110;
                    break;
                }
      }
      i=0;

      while(i<strlen(obj))
          {
              j=obj[i];
              if (j<0) j=256+j;
              if ((j==233)|(j==232)|(j==234)|(j==235)|(j==224)|(j==238)|(j==239)|(j==249)|(j==244)|(j==231))
                  accent(i,j);
              i++;
          }
     
      // menu suppl
     strcpy(durees,"3");
     
      // on va rajouter du texte à instrm
      // d'abord l'attente avant
      if(numero_ph==1)
        if(att1x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,att1x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==2)
        if(att2x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,att2x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==3)
        if(att3x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,att3x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==4)
        if(att4x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,att4x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
        
      if (strlen(obj)>0)
      {
            strcat(instrm,pri);// print { text "
            strcat(instrm,obj);// texte à écrire
            //strcat(instrm,row);//  "  row -3  column 3 }
            strcat(instrm,gui);
            strcat(instrm," row -3 column 3 duration ");
            if(numero_ph==0)
                strcat(instrm,durees);//3
            else
            {
                if(numero_ph==1)
                    strcat(instrm,duree1x.c_str());
                if(numero_ph==2)
                    strcat(instrm,duree2x.c_str());
                if(numero_ph==3)
                    strcat(instrm,duree3x.c_str());
                if(numero_ph==4)
                    strcat(instrm,duree4x.c_str());
            }
            strcat(instrm,fin); //}
            strcat(instrm,ent);// entrée
      }
      // les durées
      if(numero_ph==0)                
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,durees);//3
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==1)
        if(duree1x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,duree1x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==2)
        if(duree2x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,duree2x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==3)
        if(duree3x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,duree3x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
      if(numero_ph==4)
        if(duree4x!=wxT("0"))
        {
            strcat(instrm,wai2);// wai2t { duration
            strcat(instrm,duree4x.c_str());
            strcat(instrm,fin);//}
            strcat(instrm,ent); // entrée
        }
   
}

wxString mod_phrase(wxString wxph)
{
    char obj_int[250],obj_fin[250];
    strcpy(obj_int,obj);
    strcpy(obj,wxph.c_str());
    // cas où la phrase dépasse 60 caractères
    unsigned int longueur=strlen(obj);
    if (longueur>61)
    {
        for(j=60;j>32;j--)
           if (obj[j]==32)
            {
                strcat(obj,"+");
                for(i=longueur-1;i>j;i--)
                    obj[i+1]=obj[i];
                obj[j]=92;
                obj[j+1]=110;
                break;
            }
    }
    // cas où la phrase dépasse 120 caractères
    longueur=strlen(obj);
    if (longueur>126)
    {
        for(j=125;j>100;j--)
           if (obj[j]==32)
            {
                strcat(obj,"+");
                for(i=longueur-1;i>j;i--)
                    obj[i+1]=obj[i];
                obj[j]=92;
                obj[j+1]=110;
                break;
            }
    }
    i=0;
    
    while(i<strlen(obj))
    {
        j=obj[i];
        if (j<0) j=256+j;
        if ((j==233)|(j==232)|(j==234)|(j==235)|(j==224)|(j==238)|(j==239)|(j==249)|(j==244)|(j==231))
            accent(i,j);
        i++;
    }
strcpy(obj_fin,obj);
strcpy(obj,obj_int);
return wxT(obj_fin);
}

void ProjetzzFrm::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

	WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(2,6), wxSize(619,378));
	WxPanel1->SetForegroundColour(wxColour(128,0,0));
	WxPanel1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton1 = new wxButton(WxPanel1, ID_WXBUTTON1, wxT("Supprimer"), wxPoint(271,272), wxSize(65,25), 0, wxDefaultValidator, wxT("WxButton1"));
	WxButton1->SetToolTip(wxT("Supprimer une instruction"));
	WxButton1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton2 = new wxButton(WxPanel1, ID_WXBUTTON2, wxT("Remonter"), wxPoint(361,272), wxSize(65,25), 0, wxDefaultValidator, wxT("WxButton2"));
	WxButton2->SetToolTip(wxT("Remonter d'un rang une instruction"));
	WxButton2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton3 = new wxButton(WxPanel1, ID_WXBUTTON3, wxT("Valider"), wxPoint(88,285), wxSize(60,25), 0, wxDefaultValidator, wxT("WxButton3"));
	WxButton3->SetToolTip(wxT("Valider une instruction"));
	WxButton3->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	/* listes
	*/
	wxArrayString arrayStringFor_WxListBox1;
	WxListBox1 = new wxListBox(WxPanel1, ID_WXLISTBOX1, wxPoint(9,33), wxSize(235,246), arrayStringFor_WxListBox1, wxLB_SINGLE);
	WxListBox1->SetToolTip(wxT("Choisir une instruction"));
	WxListBox1->Append(wxT("Aller vers un objet"));
	WxListBox1->Append(wxT("Attendre quelques secondes"));
	WxListBox1->Append(wxT("Aller vers un signet"));
	WxListBox1->Append(wxT("Tourner autour"));
	WxListBox1->Append(wxT("Changer la vitesse du temps"));
	WxListBox1->Append(wxT("S'approcher ou s'éloigner"));
	WxListBox1->Append(wxT("Suivre"));
	WxListBox1->Append(wxT("Se synchroniser avec"));
	WxListBox1->Append(wxT("Modifier l'affichage"));
	WxListBox1->Append(wxT("Se placer au-dessus d'un pôle"));
	WxListBox1->Append(wxT("Regarder vers un objet"));
	WxListBox1->Append(wxT("Changer le champ de vision"));
	WxListBox1->Append(wxT("Faire un travelling arrière / avant"));
	WxListBox1->Append(wxT("Ajouter du texte"));
	WxListBox1->Append(wxT("Aller à une longitude/lattitude"));
	WxListBox1->SetBackgroundColour(wxColour(255,255,128));
	WxListBox1->SetFont(wxFont(10, wxSWISS, wxNORMAL,wxBOLD, false));

	WxStaticText1 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT1, wxT("instructions à choisir"), wxPoint(50,10), wxDefaultSize, 0, wxT("WxStaticText1"));
	WxStaticText1->SetFont(wxFont(10, wxSWISS, wxNORMAL,wxBOLD, false));

	WxStaticText2 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT2, wxT("Liste du script"), wxPoint(363,10), wxDefaultSize, 0, wxT("WxStaticText2"));
	WxStaticText2->SetFont(wxFont(10, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton4 = new wxButton(WxPanel1, ID_WXBUTTON4, wxT("Descendre"), wxPoint(452,272), wxSize(70,25), 0, wxDefaultValidator, wxT("WxButton4"));
	WxButton4->SetToolTip(wxT("Descendre d'un rang une instruction"));
	WxButton4->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	WxButton5 = new wxButton(WxPanel1, ID_WXBUTTON5, wxT("Insérer"), wxPoint(547,272), wxSize(62,25), 0, wxDefaultValidator, wxT("WxButton5"));
	WxButton5->SetToolTip(wxT("Insérer une instruction à l'emplacement souhaité"));
	WxButton5->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));

	/* liste des opérations du script
	*/
	WxGrid1 = new wxGrid(WxPanel1, ID_WXGRID1, wxPoint(267,34), wxSize(348,229), wxDOUBLE_BORDER);
	WxGrid1->SetToolTip(wxT("Liste des instructions du script"));
	WxGrid1->SetHelpText(wxT("liste des instructions"));
	WxGrid1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxBOLD, false));
	WxGrid1->SetDefaultColSize(450);
	WxGrid1->SetDefaultRowSize(20);
	WxGrid1->SetRowLabelSize(25);
	WxGrid1->SetColLabelSize(0);
	WxGrid1->CreateGrid(1,1,wxGrid::wxGridSelectCells);

	WxToolBar1 = new wxToolBar(this, ID_WXTOOLBAR1, wxPoint(0,0), wxSize(627,29));

	wxBitmap WxToolButton1_BITMAP (ProjetzzFrm_WxToolButton1_XPM);
	wxBitmap WxToolButton1_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON1, wxT("nouveau script"), WxToolButton1_BITMAP, WxToolButton1_DISABLE_BITMAP, wxITEM_NORMAL, wxT("Nouveau script"), wxT("nouveau script ?"));

	wxBitmap WxToolButton2_BITMAP (ProjetzzFrm_WxToolButton2_XPM);
	wxBitmap WxToolButton2_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON2, wxT("ouvrir"), WxToolButton2_BITMAP, WxToolButton2_DISABLE_BITMAP, wxITEM_NORMAL, wxT("Ouvrir un script"), wxT("ouvrir un script ?"));

	wxBitmap WxToolButton3_BITMAP (ProjetzzFrm_WxToolButton3_XPM);
	wxBitmap WxToolButton3_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON3, wxT("Sauver"), WxToolButton3_BITMAP, WxToolButton3_DISABLE_BITMAP, wxITEM_NORMAL, wxT("Sauver un script"), wxT("Sauver le scipt ?"));

	wxBitmap WxToolButton4_BITMAP (ProjetzzFrm_WxToolButton4_XPM);
	wxBitmap WxToolButton4_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON4, wxT("celestia"), WxToolButton4_BITMAP, WxToolButton4_DISABLE_BITMAP, wxITEM_NORMAL, wxT("Lancer CELESTIA"), wxT("Lancer Celestia"));

	WxSaveFileDialog1 =  new wxFileDialog(this, wxT("Sauver un fichier"), wxT(""), wxT(""), wxT("*.cel"), wxSAVE | wxOVERWRITE_PROMPT);

	WxTextEntryDialog3 =  new wxTextEntryDialog( this,wxT("Donnez le nom de la lune ou du satellite"), wxT("Choisir..."), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog19 =  new wxTextEntryDialog( this,wxT("Donner la vitesse angulaire (degré par seconde) :"), wxT("Valeur supplémentaire"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	/* Aller vers un signet
	*/
	signetDialog1 =  new wxTextEntryDialog( this,wxT("Aller vers quel signet ? (attention aux majuscules)"), wxT("Aller vers un signet"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog9 =  new wxTextEntryDialog( this,wxT("Donnez le nom du satellite ou de la lune :"), wxT("Un satellite ou une lune d'une planète"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog5 =  new wxTextEntryDialog( this,wxT("Donner le coefficient multiplicateur du temps : (1=temps réel)"), wxT("Changer la vitesse du temps"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	/* Attendre quelques secondes
	*/
	AttendreDialog1 =  new wxTextEntryDialog( this,wxT("Attendre combien de secondes ?"), wxT("Attendre quelques secondes"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog15 =  new wxTextEntryDialog( this,wxT("Donner le champ de vision (FOV) initial (annulez s'il est inconnu) :"), wxT("Changer le champ de vision"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog2 =  new wxTextEntryDialog( this,wxT("Donnez le nom de l'étoile ou de la galaxie"), wxT("Choisir..."), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxMessageDialog1 =  new wxMessageDialog(this, wxT("Voulez-vous supprimer cette instruction ?"), wxT("Supprimer"), wxYES_NO | wxICON_EXCLAMATION);

	/* Choisir un cas :
	*/
	wxArrayString arrayStringFor_WxSingleChoiceDialog4;
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("notre soleil"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("une autre étoile ou une galaxie"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("une planète du système solaire"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("une planète d'un autre système"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("une comète, un astéroïde ou une sonde"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("un satellite ou une lune d'une planète"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("un satellite d'une lune"));
	arrayStringFor_WxSingleChoiceDialog4.Add(wxT("un autre cas"));
	WxSingleChoiceDialog4 =  new wxSingleChoiceDialog(this, wxT("Choisir le bon cas :"), wxT("Aller vers :"), arrayStringFor_WxSingleChoiceDialog4,NULL, wxOK | wxCANCEL);

	WxOpenFileDialog1 =  new wxFileDialog(this, wxT("Ouvrir un fichier"), wxT(""), wxT(""), wxT("*.cel"), wxOPEN);

	WxMessageDialog6 =  new wxMessageDialog(this, wxT("Valider ?"), wxT("Synchronisation avec l'objet"), wxYES_NO);

	WxTextEntryDialog11 =  new wxTextEntryDialog( this,wxT("Donnez le nom de la lune :"), wxT("Un satellite d'une lune"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog24 =  new wxTextEntryDialog( this,wxT("Combien de temps rajoutez-vous à ces textes ? (en secondes)"), wxT("Durée supplementaire"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	wxcommandesDialog =  new wxMessageDialog(this, wxT("1 - choisir une instruction dans le rectangle jaune\n2 - Cliquer sur \"valider\"\n3 - répondre aux messages affichés\n4 - La nouvelle instruction s'affiche à droite\n\nPour tester le script : \n1 - l'enregistrer (Sauver)\n2 - Lancer CELESTIA en cliquant sur l'icône \"planète\"\n3 - Dans CELESTIA, faire Fichier/ouvrir un script et choisir votre script"), wxT("Liste des commandes"));

	WxTextEntryDialog1 =  new wxTextEntryDialog( this,wxT("Donnez le nom de la planète"), wxT("Aller vers ..."), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog18 =  new wxTextEntryDialog( this,wxT("Durée en seconde :"), wxT("Valeur supplémentaire"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxMenuBar1 = new wxMenuBar();
	wxMenu *ID_MNU_MENUITEM1_1014_Mnu_Obj = new wxMenu(0);
	ID_MNU_MENUITEM1_1014_Mnu_Obj->Append(ID_MNU_NOUVEAU_1027, wxT("&Nouveau"), wxT(""), wxITEM_NORMAL);
	ID_MNU_MENUITEM1_1014_Mnu_Obj->Append(ID_MNU_OUVRIR_1021, wxT("&Ouvrir"), wxT(""), wxITEM_NORMAL);
	ID_MNU_MENUITEM1_1014_Mnu_Obj->Append(ID_MNU_SAUVER_1022, wxT("&Sauver"), wxT(""), wxITEM_NORMAL);
	ID_MNU_MENUITEM1_1014_Mnu_Obj->AppendSeparator();
	ID_MNU_MENUITEM1_1014_Mnu_Obj->Append(ID_MNU_QUITTER_1024, wxT("&Quitter"), wxT(""), wxITEM_NORMAL);
	
	m_fileHistory = new wxFileHistory(9,wxID_FILE1);
	m_fileHistory->UseMenu( ID_MNU_MENUITEM1_1014_Mnu_Obj );
	m_fileConfig = new wxConfig("Projetzz2");
	wxConfigBase::Set( m_fileConfig );
	m_fileConfig->SetPath(wxT("/RecentFiles"));
	m_fileHistory->Load(*m_fileConfig);
	m_fileConfig->SetPath(wxT(".."));
	WxMenuBar1->Append(ID_MNU_MENUITEM1_1014_Mnu_Obj, wxT("&Fichier"));
	
	wxMenu *ID_MNU_MENUITEM2_1015_Mnu_Obj = new wxMenu(0);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_SUBMENUITEM3_1016, wxT("Pl&us de paramètres"), wxT(""), wxITEM_CHECK);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Check(ID_MNU_SUBMENUITEM3_1016,false);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_TEXTEDURANTVOYAGE_1038, wxT("&Texte durant le voyage"), wxT(""), wxITEM_CHECK);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Check(ID_MNU_TEXTEDURANTVOYAGE_1038,false);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_NOMSENFRAN_AIS_1026, wxT("&Noms en français"), wxT(""), wxITEM_CHECK);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Check(ID_MNU_NOMSENFRAN_AIS_1026,false);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->AppendSeparator();
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_AIDEDESOPTIONS_1037, wxT("Aide des options"), wxT(""), wxITEM_NORMAL);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_MODIFIERLECODE_1039, wxT("&Modifier le code"), wxT(""), wxITEM_NORMAL);
	ID_MNU_MENUITEM2_1015_Mnu_Obj->Append(ID_MNU_SUBMENUITEM18_1041, wxT("Enregistrer les configurations"), wxT(""), wxITEM_NORMAL);
	WxMenuBar1->Append(ID_MNU_MENUITEM2_1015_Mnu_Obj, wxT("O&ptions"));
	
	wxMenu *ID_MNU_APROPOS_1025_Mnu_Obj = new wxMenu(0);
	ID_MNU_APROPOS_1025_Mnu_Obj->Append(ID_MNU_SUBMENUITEM12_1029, wxT("A propos"), wxT(""), wxITEM_NORMAL);
	ID_MNU_APROPOS_1025_Mnu_Obj->Append(ID_MNU_COMMANDES_1030, wxT("Commandes"), wxT(""), wxITEM_NORMAL);
	WxMenuBar1->Append(ID_MNU_APROPOS_1025_Mnu_Obj, wxT("Aide"));
	SetMenuBar(WxMenuBar1);

	wxArrayString arrayStringFor_WxSingleChoiceDialog2;
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("apparaître des noms"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("disparaître des noms"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("apparaître les orbites"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("disparaître les orbites"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("apparaître les limites des constellations"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("disparaître les limites des constellations"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("apparaître le dessin des constellations"));
	arrayStringFor_WxSingleChoiceDialog2.Add(wxT("disparaître le dessin des constellations"));
	WxSingleChoiceDialog2 =  new wxSingleChoiceDialog(this, wxT("Que voulez-vous faire ?"), wxT("Modifier l'affichage"), arrayStringFor_WxSingleChoiceDialog2,NULL, wxOK | wxCANCEL);

	wxArrayString arrayStringFor_WxSingleChoiceDialog6;
	arrayStringFor_WxSingleChoiceDialog6.Add(wxT("Faire un travelling avant (touche HOME)"));
	arrayStringFor_WxSingleChoiceDialog6.Add(wxT("Faire un travelling arrière (touche FIN)"));
	WxSingleChoiceDialog6 =  new wxSingleChoiceDialog(this, wxT("Choisir le type de travelling :"), wxT("Faire un travelling avant/arrière"), arrayStringFor_WxSingleChoiceDialog6,NULL);

	wxArrayString arrayStringFor_WxSingleChoiceDialog3;
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des vaisseaux, satellites artificiels et sondes"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des planètes"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des astéroïdes"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des lunes"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des comètes"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des étoiles"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des constellations"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Les noms des galaxies"));
	arrayStringFor_WxSingleChoiceDialog3.Add(wxT("Tous les noms"));
	WxSingleChoiceDialog3 =  new wxSingleChoiceDialog(this, wxT("ela concerne :"), wxT("Modifier l'affichage (suite)"), arrayStringFor_WxSingleChoiceDialog3,NULL, wxOK | wxCANCEL);

	WxTextEntryDialog17 =  new wxTextEntryDialog( this,wxT("Ecrire le texte à faire apparaitre :"), wxT("Ajouter du texte"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog14 =  new wxTextEntryDialog( this,wxT("Pendant combien de secondes ?"), wxT("Faire un travelling avant/arrière"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxMessageDialog3 =  new wxMessageDialog(this, wxT("Voulez-vous remplacer cette instruction ?"), wxT("Remplacement"), wxYES_NO | wxICON_QUESTION);

	WxTextEntryDialog20 =  new wxTextEntryDialog( this,wxT("Phrase  : ( Annuler pour ne rien écrire)"), wxT("Texte supplémentaire"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog10 =  new wxTextEntryDialog( this,wxT("Donnez le nom du satellite :"), wxT("Un satellite d'une lune"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	/* choisir une instruction à gauche
	cliquer sur VALIDER
	Une fois validée, l'instruction apparait
	à droite.
	Vous pouvez monter, descendre, supprimer
	et insérer une instruction.
	*/
	WxMessageDialog7 =  new wxMessageDialog(this, wxT("Voulez-vous effacer l'ancien script ?"), wxT("Nouveau script"), wxOK | wxCANCEL | wxICON_QUESTION);

	WxMessageDialog4 =  new wxMessageDialog(this, wxT("Suivre l'objet ?"), wxT("Suivre"), wxYES_NO);

	/* Choisir un cas :
	*/
	wxArrayString arrayStringFor_WxSingleChoiceDialog1;
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("notre soleil"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("une autre étoile ou une galaxie"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("une planète du système solaire"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("une planète d'un autre système"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("une comète, un astéroïde ou une sonde"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("un satellite ou une lune d'une planète"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("un satellite d'une lune"));
	arrayStringFor_WxSingleChoiceDialog1.Add(wxT("un autre cas"));
	WxSingleChoiceDialog1 =  new wxSingleChoiceDialog(this, wxT("Choisir le bon cas :"), wxT("Aller vers :"), arrayStringFor_WxSingleChoiceDialog1,NULL, wxOK | wxCANCEL);

	WxTextEntryDialog8 =  new wxTextEntryDialog( this,wxT("Donnez le nom de la comète, de l'astéroïde ou de la sonde :"), wxT("Une comète, un astéroïde ou une sonde"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	wxArrayString arrayStringFor_WxSingleChoiceDialog5;
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("notre soleil"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("une autre étoile ou une galaxie"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("une planète du système solaire"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("une planète d'un autre système"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("une comète, un astéroïde ou une sonde"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("un satellite ou une lune d'une planète"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("un satellite d'une lune"));
	arrayStringFor_WxSingleChoiceDialog5.Add(wxT("un autre cas"));
	WxSingleChoiceDialog5 =  new wxSingleChoiceDialog(this, wxT("Choisir le bon cas :"), wxT("Regarder vers (centrer) :"), arrayStringFor_WxSingleChoiceDialog5,NULL);

	WxTextEntryDialog6 =  new wxTextEntryDialog( this,wxT("Donnez le nom de l'étoile ou de la galaxie"), wxT("une autre étoile ou une galaxie"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxMessageDialog8 =  new wxMessageDialog(this, wxT("Ce fichier existe déjà : continuer ou abandonner ?"), wxT("Sauver un fichier"), wxYES_NO | wxICON_QUESTION);

	/* Sur de quitter ?
	*/
	WxMessageDialog2 =  new wxMessageDialog(this, wxT("Voulez-vous vraiment quitter ?"), wxT("Quitter Miniscript"), wxYES_NO | wxICON_EXCLAMATION);

	aproposDialog =  new wxMessageDialog(this, wxT("Miniscript -  Licence libre GPL\n B. JUBIN\n avril 2007"), wxT("A propos"), wxICON_INFORMATION);

	WxMessageDialog5 =  new wxMessageDialog(this, wxT("Valider ?"), wxT("mise au niveau d'un pole"), wxYES_NO);

	WxTextEntryDialog13 =  new wxTextEntryDialog( this,wxT("Tourner pendant combien de secondes ?\n(1 tour en 18 s à 30°/s)"), wxT("Tourner autour d'un objet"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog7 =  new wxTextEntryDialog( this,wxT("Donnez le nom de son étoile :"), wxT("Une planète d'un autre système"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog4 =  new wxTextEntryDialog( this,wxT("Donner le rapport entre la distance et le rayon de l'objet : ( 5 initial)"), wxT("S'approcher ou s'éloigne"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog12 =  new wxTextEntryDialog( this,wxT("Donnez le nom de l'objet :"), wxT("Un autre cas"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog16 =  new wxTextEntryDialog( this,wxT("Donner le champ de vision (FOV) voulu :"), wxT("Changer le champ de vision"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog21 =  new wxTextEntryDialog( this,wxT("Lattitude (entre - 180 et 180, pas d'espace après le -)"), wxT("Aller à une longidute/lattitude"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog22 =  new wxTextEntryDialog( this,wxT("Longitude (entre - 90 et 90,pas d'espace après le - )"), wxT("Aller à une longidute/lattitude"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxTextEntryDialog23 =  new wxTextEntryDialog( this,wxT("Durée du voyage ? (en secondes)"), wxT("Aller à une longidute/lattitude"), wxT("") ,wxOK | wxCANCEL | wxCENTRE);

	WxToolBar1->SetToolBitmapSize(wxSize(32,32));
	WxToolBar1->Realize();
	SetToolBar(WxToolBar1);
	SetTitle(wxT("Miniscript pour CELESTIA"));
	SetIcon(Self_ProjetzzFrm_XPM);
	SetSize(8,8,635,417);
	Center();
	
	////GUI Items Creation End
    WxGrid1->EnableCellEditControl(false);
    WxGrid1->DisableDragRowSize();
    //WxMenuBar1->Check(1016,false);
    //WxMenuBar1->Check(1038,true);
    //WxMenuBar1->Check(1026,false);
    	
// pour lire miniscript.cfg: config des options
    fic=fopen("miniscript.cfg","r");  //ouverture du fichier en lecture
    if( fic!=NULL )
    {
        fread(&lettre,1,1,fic);
        if (lettre[0]==48)
            WxMenuBar1->Check(1016,false);
        else
            WxMenuBar1->Check(1016,true);
        fread(&lettre,1,1,fic);
        if (lettre[0]==48)
            WxMenuBar1->Check(1038,false);
        else
            WxMenuBar1->Check(1038,true);
        fread(&lettre,1,1,fic);
        if (lettre[0]==48)
            WxMenuBar1->Check(1026,false);
        else
            WxMenuBar1->Check(1026,true);
        if (feof(fic)==0)
        {
            fread(&lettre,1,1,fic);
            if (lettre[0]=='B')
                block=false;// si 'B' alors jamais nom-en fr (1026)
            else
                block=true;
        }
        fclose(fic);
    }
}

void ProjetzzFrm::OnClose(wxCloseEvent& event)
{
	if(WxMessageDialog2->ShowModal()==wxID_YES)
        Destroy();
}

/*
 * WxEdit1Updated
 */
void ProjetzzFrm::WxEdit1Updated(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * WxButton3Click
 */
void ProjetzzFrm::WxButton3Click(wxCommandEvent& event)
{
/////////////////////////////////////////////////////////
	          // Bouton valider //
///////////////////////////////////////////////////////
if (jx==1)// cas où on a sélectionné une instruction
  {
   int pos1=WxGrid1->GetGridCursorRow();
   // ici on va adapter la partie prg de miniscript7
   switch (n_instr)
   {
   case 0:// aller vers
   {
        if(WxSingleChoiceDialog1->ShowModal()==wxID_OK)
        {
            rep2=WxSingleChoiceDialog1->GetSelection()+1;
            switch (rep2)
            {
                case 1: //notre soleil
                {    strcpy(obj,sol);
                    strcpy(nom_obj,"soleil"); // copie dans nom_obj pour savoir de quoi on parle
                    break;
                }
                case 2: //une autre étoile ou une galaxie
                {    //cprintf(" ->Donnez le nom de l\'%stoile ou de la galaxie : ",e1);
                    //gets(obj);
                    if(WxTextEntryDialog6->ShowModal()==wxID_OK)
                    {
                       //strcpy(obj,WxTextEntryDialog6->GetValue().c_str);
                       phrasex=WxTextEntryDialog6->GetValue();
                       strcpy(obj,phrasex.c_str());
                       strcpy(nom_obj,obj); // copie dans nom_obj pour savoir de quoi on parle
                    }
                    else
                        rep2=0;
                    break;
                }
                case 3: //une planète du système solaire
                {    //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                    //gets(obj2);
                    if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                        strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                        strcpy(obj,sol);
                    }
                    else
                        rep2=0;
                    break;
                }
                case 4: //une planète d'un autre système
                {    //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                    //gets(obj2);
                    if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                        //cprintf("\n ->Donnez le nom de son %stoile : ",e1);
                        //gets(obj);
                        if(WxTextEntryDialog7->ShowModal()==wxID_OK)
                        {
                            strcpy(obj,WxTextEntryDialog7->GetValue().c_str());
                            strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                        }
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 5: //une comète, un astéroïde ou une sonde
                {    //cprintf("\n ->Donnez le nom de la com%ste, de l\'ast%sro%sde ou de la sonde : ",e2,e1,i2);
                    //gets(obj2);
                    if(WxTextEntryDialog8->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog8->GetValue().c_str());
                    strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                    strcpy(obj,sol);
                    }
                    else
                        rep2=0;
                    break;
                }
                case 6: //un satellite ou une lune d'une planète
                {    //cprintf("\n ->Donnez le nom du satellite ou de la lune: ");
                    //gets(obj3);
                    if(WxTextEntryDialog9->ShowModal()==wxID_OK)
                    {
                        strcpy(obj3,WxTextEntryDialog9->GetValue().c_str());
                        //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                        if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                        {
                            strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());   //gets(obj2);                        
                            strcpy(nom_obj,obj3); // copie dans nom_obj pour savoir de quoi on parle
                            strcpy(obj,sol);
                        }                        
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 7: //un satellite d'une lune
                {    //cprintf("\n ->Donnez le nom du satellite : ");
                    if(WxTextEntryDialog10->ShowModal()==wxID_OK)
                    {
                        strcpy(obj4,WxTextEntryDialog10->GetValue().c_str());   //gets(obj4);
                        //cprintf("\n ->Donnez le nom de la lune : ");
                        if(WxTextEntryDialog11->ShowModal()==wxID_OK)
                        {
                            strcpy(obj3,WxTextEntryDialog11->GetValue().c_str());//gets(obj3);
                            //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                            if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                            {
                                strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                                //gets(obj2);
                                strcpy(nom_obj,obj4); // copie dans nom_obj pour savoir de quoi on parle
                                strcpy(obj,sol);
                            }
                            else
                                rep2=0;
                        }
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 8: //un autre cas
                {    //cprintf("\n ->Donnez le nom de l\'objet : ");
                    //gets(obj);
                    if(WxTextEntryDialog12->ShowModal()==wxID_OK)
                    {
                       strcpy(obj,WxTextEntryDialog12->GetValue().c_str());
                       strcpy(nom_obj,obj); // copie dans nom_obj pour savoir de quoi on parle
                    }
                    else
                        rep2=0;
                    break; 
                }
            }         
            // fin switch(rep2)
             
            if (rep2==0) break;  // sortie si 0
            // rep2 est le numéro de la réponse
            
            // modif des obj
            //if (fr==0) mod_nom();
            if (!WxMenuBar1->IsChecked(1026)) mod_nom();
            
            // menu suppl            
            strcpy(durees,dur13);// durees=13
            if(WxMenuBar1->IsChecked(1038))//texte durant voyage
            {
                if (WxMenuBar1->IsChecked(1016))
                {
                    Dlg1* Wxdlg1 = new Dlg1(this);
                    Wxdlg1->ShowModal();
                    att1x=Wxdlg1->att1;
                    att2x=Wxdlg1->att2;
                    att3x=Wxdlg1->att3;
                    att4x=Wxdlg1->att4;
                    att5x=Wxdlg1->att5;
                    duree1x=Wxdlg1->duree1;
                    duree2x=Wxdlg1->duree2;
                    duree3x=Wxdlg1->duree3;
                    duree4x=Wxdlg1->duree4;
                    total1x=Wxdlg1->total1;                
                    texte1=Wxdlg1->text1;
                    texte2=Wxdlg1->text2;
                    texte3=Wxdlg1->text3;
                    texte4=Wxdlg1->text4;   
                    valid1x=Wxdlg1->valid1;                 
                    // en retour
                    //att1,att2,att3,att4,att5;
	                //text1,text2,text3,text4;
	                //duree1,duree2,duree3,duree4; et total1
	                // bool valid1=true si modif
                }
                else
                {
                    Dlg2* Wxdlg2 = new Dlg2(this);
                    Wxdlg2->ShowModal();
                    texte1=Wxdlg2->text01;
                    texte2=Wxdlg2->text02;
                    texte3=Wxdlg2->text03;
                    texte4=Wxdlg2->text04;
                    valid2x=Wxdlg2->valid2;
                    // en retour :
                    // valid2 et text01 à 04
                }
            }
            else
            {
                 if (WxMenuBar1->IsChecked(1016))
                 {
                    if(WxTextEntryDialog18->ShowModal()==wxID_OK)
                        {
                            intermede=WxTextEntryDialog18->GetValue();
                            if (intermede!=rien)
                                strcpy(durees,intermede.c_str());
                        }
                 }
            }
            // partie écriture dans le fichier
            enleveraccent();
            strcpy(instrm,"");
            strcat(instrm,sel);// select { objet"
            strcat(instrm,obj);// nom de l'objet
            
            if ((rep2>2)&(rep2<8))
                 {
                        strcat(instrm,sla); //   antislash /
                        strcat(instrm,obj2);// nom de l'objet2 (planete, comete, satellite)

                        if ((rep2>5)&(rep2<8))
                        {
                           strcat(instrm,sla); //   antislash /
                           strcat(instrm,obj3);// nom de l'objet3 (lune)

                           if (rep2==7)
                           {
                              strcat(instrm,sla); //   antislash /
                              strcat(instrm,obj4);// nom de l'objet4 (satellite de lune)

                           }
                        }
                 }
                 // suite et fin de l'écriture dans le fichier

                 strcat(instrm,gui);// "
                 strcat(instrm,fin);// }
                 strcat(instrm,ent);// entrée

                 // rajout de follow {}

                 strcat(instrm,fol);// follow {}
                 strcat(instrm,ent);// entrée

                 // goto
                 // si on rajoute de l'écrit, c'est ici
                 strcat(instrm,got);  // goto { time
                 if(WxMenuBar1->IsChecked(1038))
                    if (WxMenuBar1->IsChecked(1016))
                        if (valid1x)
                            sprintf(durees,"%d",total1x);
                            
                 strcat(instrm,durees);// valeur dur13
                 if (WxMenuBar1->IsChecked(1016))                    
                    if(WxTextEntryDialog4->ShowModal()==wxID_OK)
                    {
                        strcat(instrm," distance ");
                        strcat(instrm,WxTextEntryDialog4->GetValue().c_str());
                    }
                 strcat(instrm,fin);  // }
                 strcat(instrm,ent);  // entrée
                 // wai2t
                 
                 if(WxMenuBar1->IsChecked(1038))
                 {
                        if (WxMenuBar1->IsChecked(1016))
                        {
                            if (valid1x)
                            {
                                strcpy(obj,texte1.c_str());
                                modif_texte_suppl(1);

                                strcpy(obj,texte2.c_str());
                                modif_texte_suppl(2);

                                strcpy(obj,texte3.c_str());
                                modif_texte_suppl(3);

                                strcpy(obj,texte4.c_str());
                                modif_texte_suppl(4);
                            
                                strcpy(durees,att5x.c_str());
                            }
                        }
                        else
                        {
                            if (valid2x)
                            {
                                strcpy(obj,texte1.c_str());
                                modif_texte_suppl(0);
                        
                                strcpy(obj,texte2.c_str());
                                modif_texte_suppl(0);
                        
                                strcpy(obj,texte3.c_str());
                                modif_texte_suppl(0);
                        
                                strcpy(obj,texte4.c_str());
                                modif_texte_suppl(0);
                                
                                strcpy(durees,"1");
                            }
                        }                        
                 }               
                 if (strcmp(durees,"0"))
                 {
                    strcat(instrm,wai2);  // wai2t { duration
                    //strcat(instrm,dur14);// valeur dur14
                    strcat(instrm,durees); // en remplacement
                    strcat(instrm,fin);  // }
                    strcat(instrm,ent);  // entrée
                 }
                 // mise dans recap
                 strcpy(recap,"");
                 strcat(recap,"Aller vers : ");
                 strcat(recap,nom_obj);
                 if(WxMenuBar1->IsChecked(1038))                 
		 	     {   
                    if (WxMenuBar1->IsChecked(1016))
			        {
				        if (valid1x)
					       sprintf(durees,"%d",total1x);
        			}
			        else
			        {
				        if (valid2x)
					       strcpy(durees,"13");
			        }		      
                 } 
                 strcat(recap," (en ");
                 strcat(recap,durees);
                 strcat(recap," s)");
                                    
                 phrase2=wxT(instrm);
                 phrase=wxT(recap);
                 sortie=1;                   
            } 
            break;      
    } 
    // fin : Aller vers
//////////////////////////////    
   case 1:// attendre qq sec
   {
        if(AttendreDialog1->ShowModal()==wxID_OK)
        {
            //if(AttendreDialog1->GetValue()->Trim(true)==rien) break;
            strcpy(obj,AttendreDialog1->GetValue().c_str());
            
            strcpy(instrm,"");
            strcat(instrm,wai);// wait { duration
            strcat(instrm,obj);// temps
            strcat(instrm,fin);// }
            strcat(instrm,ent);// entrée

            // mise dans recap
            strcpy(recap,"");
            strcat(recap,"Attendre ");
            strcat(recap,obj);
            strcat(recap," secondes");
            //strcpy(recapil[m++],recap);
            phrase2=wxT(instrm);
            phrase=wxT(recap);
            sortie=1;
        }
        break;
   }
/////////////////////////////////////////   
   case 2: // Aller vers un signet
   {
        if(signetDialog1->ShowModal()==wxID_OK)
        {                          
            strcpy(obj,signetDialog1->GetValue().c_str());
            strcpy(obj2,gui);// "
            strcat(obj2,obj);// obj
            strcat(obj2,gui);// "
            strcat(obj2," {\n");// { et entrée

            // ouverture de favorites.cel
            fic=fopen("favorites.cel","r");  //ouverture du fichier en lecture
            if( fic==NULL )
                  {
                    wxMessageBox("fichier introuvable", _T("Aller vers un signet"),wxOK | wxICON_INFORMATION, this);
                    return;
                  }
            // on utilise phr2
            cc=0;
            //fgets(phr2,strlen(phr2),fic);
            while ((feof(fic)==0)&&(cc==0))
            {
              fgets(phr2,sizeof(phr2),fic);

              if (strcmp(phr2,obj2)==0)
              {
                  //cprintf("Signet %s trouv%s",obj,e1);
                  wxMessageBox("Signet trouvé", _T("Aller vers un signet"),wxOK | wxICON_INFORMATION, this);
    
                  fgets(phr3,sizeof(phr3),fic);  // isfolder
                  fgets(phr3,sizeof(phr3),fic);  // parentfolder
    
                  //base
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
    
                  sscanf(phrn,"%lf",&ax);
                  fscanf(fic,"%s",phrn);
    
                  sscanf(phrn,"%lf",&ay);
                  fscanf(fic,"%s",phrn);
                  sscanf(phrn,"%lf",&az);
    
                  fgets(phr2,sizeof(phr2),fic); // fin base
                  //cprintf("\n-%s- ,x=%.16e,y=%.16e,z=%.16e",phr2,ax,ay,az);
    
                  // offset
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
                  
                  sscanf(phrn,"%lf",&bx);
                  fscanf(fic,"%s",phrn);
                  
                  sscanf(phrn,"%lf",&by);
                  fscanf(fic,"%s",phrn);
                  
                  sscanf(phrn,"%lf",&bz);
                  fgets(phr2,sizeof(phr2),fic); // fin offset
                  
                  // axis
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
    
                  sscanf(phrn,"%f",&cx);
                  fscanf(fic,"%s",phrn);
    
                  sscanf(phrn,"%f",&cy);
                  fscanf(fic,"%s",phrn);
    
                  sscanf(phrn,"%f",&cz);
                  fgets(phr2,sizeof(phr2),fic); // fin axis
                  
                  // angle
                  fscanf(fic,"%s",phrn);
                  fscanf(fic,"%s",phrn);
                  sscanf(phrn,"%f",&ang);
                  fgets(phr2,sizeof(phr2),fic); // fin angle
                  
                  // time
                  for (cc=0; cc<8 ;++cc)
                  phr=fgetc(fic);
                  fscanf(fic,"%s",phr4);
                  fgets(phr2,sizeof(phr2),fic); // fin time =phr4
    
                  // selection
                  for (cc=0; cc<10 ;++cc)
                  phr=fgetc(fic);
                  fscanf(fic,"%s",phr5);
                  fgets(phr2,sizeof(phr2),fic); // fin selection =phr5
                  
                  // coordsys
                  phr=fgetc(fic);
                  fscanf(fic,"%s",phr6);// fin coordsys = phr6
                  fscanf(fic,"%s",phr2);
                  strcat(phr6," ");
                  strcat(phr6,phr2);
                  cc=1;// pour arrêter la recherche
              } // fin if

              } // fin while
              if (cc==0)
              {
                wxMessageBox("Signet non trouvés", _T("Aller vers un signet"),wxOK | wxICON_INFORMATION, this);
                return; // pas trouvé
              }
            
            // calculs des quaternions
            ow=cos(ang/2);
            ox=cx*sin(ang/2);
            oy=cy*sin(ang/2);
            oz=cz*sin(ang/2);
            //cprintf("\now=%f ox=%f oy=%f oz=%f",ow,ox,oy,oz);
            
            //calcul en base 64 de la position
            //ax=ax*1000000+bx;
            ax*=1000000;
            ay*=1000000;
            az*=1000000; // pos=base*10e6+offset
            //cprintf("\n ax=%.16e,ay=%.16e,az=%.16e",ax,ay,az);

            // tranformation en base 64 d'après le fichier source bigfix.cpp
            //codage(ax); // mise en nx[i] de ax
            codage(ax,bx);
            encodage();
            strcpy(encx,encod);
            codage(ay,by); // mise en nx[i] de ay
            encodage();
            strcpy(ency,encod);

            codage(az,bz); // mise en nx[i] de az
            encodage();
            strcpy(encz,encod);
            
            // menu suppl
            strcpy(durees,dur13);// durees=13
            if(WxMenuBar1->IsChecked(1038))//texte durant voyage
            {
                if (WxMenuBar1->IsChecked(1016))
                {
                    Dlg1* Wxdlg1 = new Dlg1(this);
                    Wxdlg1->ShowModal();
                    att1x=Wxdlg1->att1;
                    att2x=Wxdlg1->att2;
                    att3x=Wxdlg1->att3;
                    att4x=Wxdlg1->att4;
                    att5x=Wxdlg1->att5;
                    duree1x=Wxdlg1->duree1;
                    duree2x=Wxdlg1->duree2;
                    duree3x=Wxdlg1->duree3;
                    duree4x=Wxdlg1->duree4;
                    total1x=Wxdlg1->total1;
                    texte1=Wxdlg1->text1;
                    texte2=Wxdlg1->text2;
                    texte3=Wxdlg1->text3;
                    texte4=Wxdlg1->text4;
                    valid1x=Wxdlg1->valid1;
                    // en retour
                    //att1,att2,att3,att4,att5;
	                //text1,text2,text3,text4;
	                //duree1,duree2,duree3,duree4; et total1
	                // bool valid1=true si modif
                }
                else
                {
                    Dlg2* Wxdlg2 = new Dlg2(this);
                    Wxdlg2->ShowModal();
                    texte1=Wxdlg2->text01;
                    texte2=Wxdlg2->text02;
                    texte3=Wxdlg2->text03;
                    texte4=Wxdlg2->text04;
                    valid2x=Wxdlg2->valid2;
                    // en retour :
                    // valid2 et text01 à 04
                }
            }
            else
            {
                 if (WxMenuBar1->IsChecked(1016))
                 {
                    if(WxTextEntryDialog18->ShowModal()==wxID_OK)
                        {
                            intermede=WxTextEntryDialog18->GetValue();
                            if (intermede!=rien)
                                strcpy(durees,intermede.c_str());
                        }
                 }
            } 
              
            // les coord en base 64 sont les char encx, ency et encz
            strcpy(instrm,"");
            strcat(instrm,sel2);// select { objet"
            strcat(instrm,phr5);// nom de l'objet
            strcat(instrm,fin); // }
            strcat(instrm,ent); // entrée
            strcat(instrm,cen); // center {}
            strcat(instrm,ent); // entrée
            strcat(instrm,fol); // follow {}
            strcat(instrm,ent); // entrée
            strcat(instrm,timex);// time
            strcat(instrm,jd);  // { jd
            strcat(instrm,phr4);// durée
            strcat(instrm,fin); // }
            strcat(instrm,ent); // entrée

            strcat(instrm,setfr);//setframe {
            strcat(instrm,phr6);// coordsys "..."
            strcat(instrm,fin); // }
            strcat(instrm,ent); // entrée
            
            
            // a modif
            strcat(instrm,gotl);// gotoloc {
            strcat(instrm,ent);// entrée
            strcat(instrm,timex);// time
            /////////////////////////////
            // si on rajoute de l'écrit, c'est ici                 
             if(WxMenuBar1->IsChecked(1038))
                if (WxMenuBar1->IsChecked(1016))
                    if (valid1x)
                        sprintf(durees,"%d",total1x);

             strcat(instrm,durees);// valeur dur13             
             strcat(instrm,ent);  // entrée
                 
            /////////////////////////////
            strcat(instrm,motx);// x
            strcat(instrm,gui);//  "
            strcat(instrm,encx);// x en base 64
            strcat(instrm,gui);//  "
            strcat(instrm,ent);// entrée
            strcat(instrm,moty);// y
            strcat(instrm,gui);//  "
            strcat(instrm,ency);// y en base 64
            strcat(instrm,gui);//  "
            strcat(instrm,ent);// entrée
            strcat(instrm,motz);// z
            strcat(instrm,gui);//  "
            strcat(instrm,encz);// z en base 64
            strcat(instrm,gui);//  "
            strcat(instrm,ent);// entrée

            // les quaternions
            strcat(instrm,moto);// o
            strcat(instrm,motw);// w
            sprintf(obj2,"%f",ow);
            strcat(instrm,obj2);// valeur
            strcat(instrm,ent);// entrée
            strcat(instrm,moto);// o
            strcat(instrm,motx);// x
            sprintf(obj2,"%f",ox);
            strcat(instrm,obj2);// valeur
            strcat(instrm,ent);// entrée
            strcat(instrm,moto);// o
            strcat(instrm,moty);// y
            sprintf(obj2,"%f",oy);
            strcat(instrm,obj2);// valeur
            strcat(instrm,ent); // entrée
            strcat(instrm,moto);// o
            strcat(instrm,motz);// z
            sprintf(obj2,"%f",oz);
            strcat(instrm,obj2);// valeur
            strcat(instrm," "); // espace
            strcat(instrm,fin);// }
            strcat(instrm,ent);// entrée
            
            // wait
            strcpy(obj3,obj);
             if(WxMenuBar1->IsChecked(1038))
             {
                    if (WxMenuBar1->IsChecked(1016))
                    {
                        if (valid1x)
                        {
                            strcpy(obj,texte1.c_str());
                            modif_texte_suppl(1);

                            strcpy(obj,texte2.c_str());
                            modif_texte_suppl(2);

                            strcpy(obj,texte3.c_str());
                            modif_texte_suppl(3);

                            strcpy(obj,texte4.c_str());
                            modif_texte_suppl(4);

                            strcpy(durees,att5x.c_str());
                        }
                    }
                    else
                    {
                        if (valid2x)
                        {
                            strcpy(obj,texte1.c_str());
                            modif_texte_suppl(0);

                            strcpy(obj,texte2.c_str());
                            modif_texte_suppl(0);

                            strcpy(obj,texte3.c_str());
                            modif_texte_suppl(0);

                            strcpy(obj,texte4.c_str());
                            modif_texte_suppl(0);

                            strcpy(durees,"1");
                        }
                    }
             }
             if (strcmp(durees,"0"))
             {
                strcat(instrm,wai);  // wait { duration
                //strcat(instrm,dur14);// valeur dur14
                strcat(instrm,durees); // en remplacement
                strcat(instrm,fin);  // }
                strcat(instrm,ent);  // entrée
             }
            
            ///////////
            // mise dans recap
            strcpy(obj,obj3);
            strcpy(recap,"");
            strcat(recap,"Aller au signet : ");
            strcat(recap,obj);
            if(WxMenuBar1->IsChecked(1038))
                    if (WxMenuBar1->IsChecked(1016))
                    {
                        if (valid1x)
                            sprintf(durees,"%d",total1x);
                    }
                    else
                    {
                        if (valid2x)
                            strcpy(durees,"13");
                    }
            strcat(recap," (en ");
            strcat(recap,durees);
            strcat(recap," s)");              
            ////////////
            phrase2=wxT(instrm);
            phrase=wxT(recap);
            // nouvel objet sélectionné
            strcpy(nom_obj,phr5);
            nom_obj[sizeof(phr5)-1]=0;
        sortie=1;
      }
      break;      
   }  
/////////////////////////////////////////        
   case 3:// tourner pendant combien de secondes (1 tour = 18 secondes) ?
    {
        valid1x=false;
        if (WxMenuBar1->IsChecked(1038))
        {
            if (WxMenuBar1->IsChecked(1016))
            {            
                Dlg1* Wxdlg1 = new Dlg1(this);
                Wxdlg1->ShowModal();
                att1x=Wxdlg1->att1;
                att2x=Wxdlg1->att2;
                att3x=Wxdlg1->att3;
                att4x=Wxdlg1->att4;
                att5x=Wxdlg1->att5;
                duree1x=Wxdlg1->duree1;
                duree2x=Wxdlg1->duree2;
                duree3x=Wxdlg1->duree3;
                duree4x=Wxdlg1->duree4;
                total1x=Wxdlg1->total1;
                texte1=Wxdlg1->text1;
                texte2=Wxdlg1->text2;
                texte3=Wxdlg1->text3;
                texte4=Wxdlg1->text4;
                valid1x=Wxdlg1->valid1;
            }                    
        }        
        if (!valid1x) // dans ce cas on revient à la base
        {
            if(WxTextEntryDialog13->ShowModal()==wxID_CANCEL)
                break;
            strcpy(obj,WxTextEntryDialog13->GetValue().c_str()); //nbre de secondes
        }
        else            
            sprintf(obj,"%d",total1x);
            
        // menu suppl
        strcpy(durees,"30");
         if (WxMenuBar1->IsChecked(1016))
         {
            if(WxTextEntryDialog19->ShowModal()==wxID_OK)
                {
                    intermede=WxTextEntryDialog19->GetValue();                    
                    if (intermede!=rien)
                        strcpy(durees,intermede.c_str());
                }
         }
        strcpy(instrm,"");
        // texte simple en plus
        if (WxMenuBar1->IsChecked(1038))        
            if (!WxMenuBar1->IsChecked(1016))
                if(WxTextEntryDialog20->ShowModal()==wxID_OK)
                        if (WxTextEntryDialog20->GetValue()!=rien)
                        {
                            strcat(instrm,pri);// print { text "
                            strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                            strcat(instrm,row);//  "  row -3  column 3 }
                            strcat(instrm,ent);// entrée
                        }                                   
        if (!valid1x)
        {     
            strcat(instrm,orb);//  orbit { axis [ 0 1 0 ] rate  
            strcat(instrm,durees);// 30
            strcat(instrm,orb2);// duration
            strcat(instrm,obj);//   secondes
        
            strcat(instrm,fin);// }
            strcat(instrm,ent);// entrée
        }
        else
        {                       
            strcpy(wai2,orb);
            strcat(wai2,durees);
            strcat(wai2,orb2);
            strcpy(obj3,durees);//en attendant
            strcpy(obj,texte1.c_str());
            modif_texte_suppl(1);

            strcpy(obj,texte2.c_str());
            modif_texte_suppl(2);

            strcpy(obj,texte3.c_str());
            modif_texte_suppl(3);

            strcpy(obj,texte4.c_str());
            modif_texte_suppl(4);
            
            if (strcmp(att5x.c_str(),"0"))
                 {
                    strcat(instrm,wai2);  // wai2t { duration
                    //strcat(instrm,dur14);// valeur dur14
                    strcat(instrm,att5x.c_str()); // en remplacement
                    strcat(instrm,fin);  // }
                    strcat(instrm,ent);  // entrée
                 }
            strcpy(durees,obj3);
        }
        
        // mise dans recap
        strcpy(recap,"");
        strcat(recap,"Tourner autour pendant ");
        strcat(recap,obj);
        strcat(recap," secondes");
        if (strcmp("30",durees))
         {
            strcat(recap," (à ");
            strcat(recap,durees);
            strcat(recap,"° par sec)");
         }
        phrase2=wxT(instrm);
        phrase=wxT(recap);
        sortie=1;
        break;
   }
////////////////////
   case 4 :  // Changer la vitesse du temps
   {
        if(WxTextEntryDialog5->ShowModal()==wxID_CANCEL)
            break;
            
         strcpy(obj,WxTextEntryDialog5->GetValue().c_str());
         strcpy(instrm,"");
         strcat(instrm,tim); //timerate { rate
         strcat(instrm,obj); // coef x
         strcat(instrm,fin); // }
         strcat(instrm,ent); // entrée
         strcat(instrm,rajt);// wait { duration 1 }
         strcat(instrm,ent); // entrée

         // mise dans recap
         strcpy(recap,"");
         strcat(recap,"Le temps va  ");
         strcat(recap,obj);
         strcat(recap," fois plus vite ");
         //strcpy(recapil[m++],recap);
         phrase2=wxT(instrm);
         phrase=wxT(recap);
         sortie=1;
         break;
     }
//////////////////////////
     case 5 :  //S'approcher ou s'eloigner  
     {
         if(WxTextEntryDialog4->ShowModal()==wxID_CANCEL)
            break;
         strcpy(obj,WxTextEntryDialog4->GetValue().c_str());
         // menu suppl
         strcpy(durees,dur5);
         if (WxMenuBar1->IsChecked(1016))
         {
            if(WxTextEntryDialog18->ShowModal()==wxID_OK)
                {
                    intermede=WxTextEntryDialog18->GetValue();
                    //if(intermede->ToDouble(double *val)==true)
                    if (intermede!=rien)
                        strcpy(durees,intermede.c_str());                       
                }
         }         
         strcpy(instrm,"");
         strcat(instrm,got); // goto { time
         strcat(instrm,durees);// valeur dur5
         strcat(instrm,dis); // distance
         strcat(instrm,obj); // rapport dist/rayon
         strcat(instrm,fin); // }
         strcat(instrm,ent); // entrée
         if (WxMenuBar1->IsChecked(1038))// ajout texte simple
         {
            if(WxTextEntryDialog20->ShowModal()==wxID_OK)
            {                    
                if (WxTextEntryDialog20->GetValue()!=rien)
                {
                    strcat(instrm,pri);// print { text "
                    strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                    strcat(instrm,row);//  "  row -3  column 3 }
                    strcat(instrm,ent);// entrée
                }
            }
         }         
         strcat(instrm,wai); // wait { duration
         strcat(instrm,durees);// valeur dur5
         strcat(instrm,fin); // }
         strcat(instrm,ent); // entrée

         // mise dans recap
         strcpy(recap,"");
         strcat(recap,"La distance est de ");
         strcat(recap,obj);
         strcat(recap," fois le rayon de l\'objet");
         if (strcmp(dur5,durees)) 
         {
            strcat(recap," (en ");
            strcat(recap,durees);
            strcat(recap," s)");
         }
         //strcpy(recapil[m++],recap);
         phrase2=wxT(instrm);
         phrase=wxT(recap);
         sortie=1;
         break;
    }   
///////////////////////////////
    case 6 : // suivre
    {
        if (WxMessageDialog4->ShowModal()==wxID_NO)
            break;
        //if (WxMenuBar1->IsChecked(1016))pour rajouter si instr suppl
        strcpy(instrm,"");
        strcat(instrm,fol); // follow {}
        strcat(instrm,ent); // entrée

         // mise dans recap
        strcpy(recap,"");
        strcat(recap,"Suivre : ");
        strcat(recap,nom_obj);
        //strcpy(recapil[m++],recap);
        phrase2=wxT(instrm);
        phrase=wxT(recap);
        sortie=1;
        break;
   }
    
/////////////////////////////////    
    case 7 :  //7 : Synchronisation avec l'objet
    {     if (WxMessageDialog6->ShowModal()==wxID_NO)
            break;
         strcpy(instrm,"");
         strcat(instrm,syn);//  Synchonous{}
         strcat(instrm,ent);// entrée

         // mise dans recap
         strcpy(recap,"");
         strcat(recap,"Synchronisation avec : ");
         strcat(recap,nom_obj);
         //strcpy(recapil[m++],recap);
         phrase2=wxT(instrm);
         phrase=wxT(recap);                  
         sortie=1;
         break;
    }
////////////////////////
    case 8 :  //8 : Modifier l\'affichage
    {
        rep2=0;
             if(WxSingleChoiceDialog2->ShowModal()==wxID_OK)
                rep2=WxSingleChoiceDialog2->GetSelection()+1;
             if (rep2==0)
                         break;  // sortie
             if ((rep2==1)|(rep2==3)|(rep2==5)|(rep2==7))     // cas apparaitre->set
                strcpy(obj," set ");
             if ((rep2==2)|(rep2==4)|(rep2==6)|(rep2==8))     // cas disparaitre->clear
                strcpy(obj," clear ");
             if ((rep2==1)|(rep2==2))
             {
                rep3=0;
                if(WxSingleChoiceDialog3->ShowModal()==wxID_OK)
                    rep3=WxSingleChoiceDialog3->GetSelection()+1;
                switch (rep3)
                {
                    case 0 :
                         break;  // sortie
                    case 1 :
                         strcpy(obj2,"spacecraft");
                         break;
                    case 2 :
                         strcpy(obj2,"planets");
                         break;
                    case 3 :
                         strcpy(obj2,"asteroids");
                         break;
                    case 4 :
                         strcpy(obj2,"moons");
                         break;
                    case 5 :
                         strcpy(obj2,"comets");
                         break;
                    case 6 :
                         strcpy(obj2,"stars");
                         break;
                    case 7 :
                         strcpy(obj2,"constellations");
                         break;
                    case 8 :
                         strcpy(obj2,"galaxies");
                         break;
                    case 9 :
                         strcpy(obj2,"planets|spacecraft|asteroids|moons|comets|stars|contellations|galaxies");
                         break;
                }
                if (rep3!=0)  // ecriture dans fichier .cel
                {
                            strcpy(instrm,"");
                            strcat(instrm,lab);// labels {
                            strcat(instrm,obj);// set ou clear
                            strcat(instrm,gui);// "
                            strcat(instrm,obj2);// truc choisi
                            strcat(instrm,gui);// "
                            strcat(instrm,fin);// }
                            strcat(instrm,ent);// entrée

                            // mise dans recap
                            strcpy(recap,"");
                            strcat(recap,"Faire ");
                            if ((rep2==1)|(rep2==3)|(rep2==5)|(rep2==7))     // cas apparaitre->set
                               strcat(recap," apparaitre les noms ");
                            else   // cas disparaitre->clear
                               strcat(recap," disparaitre les noms ");
                            switch (rep3)
                            {
                                  case 1 :
                                       strcat(recap,"des vaisseaux et des sondes");
                                       break;
                                  case 2 :
                                       strcat(recap,"des planetes");
                                       break;
                                  case 3 :
                                       strcat(recap,"des asteroides");
                                       break;
                                  case 4 :
                                       strcat(recap,"des lunes");
                                       break;
                                  case 5 :
                                       strcat(recap,"des cometes");
                                       break;
                                  case 6 :
                                       strcat(recap,"des etoiles");
                                       break;
                                  case 7 :
                                       strcat(recap,"des constellations");
                                       break;
                                  case 8 :
                                       strcat(recap,"des galaxies");
                                       break;
                                  case 9 :
                                       strcat(recap,"de tout");
                                       break;
                            }
                            //strcpy(recapil[m++],recap);
                            phrase2=wxT(instrm);
                            phrase=wxT(recap);
                            sortie=1;
                }
             }   //  fin des cas 1 et 2 : changement noms

             if ((rep2==3)|(rep2==4))  // cas des orbites
             {
                strcpy(obj2,"orbits");

                strcpy(instrm,"");
                strcat(instrm,ren);// renderflags {
                strcat(instrm,obj);// set ou clear
                strcat(instrm,gui);// "
                strcat(instrm,obj2);// truc choisi
                strcat(instrm,gui);// "
                strcat(instrm,fin);// }
                strcat(instrm,ent);// entrée

                // mise dans recap
                strcpy(recap,"");
                strcat(recap,"Faire ");
                if ((rep2==1)|(rep2==3)|(rep2==5)|(rep2==7))     // cas apparaitre->set
                    strcat(recap," apparaitre les orbites");
                else   // cas disparaitre->clear
                    strcat(recap," disparaitre les orbites");

                //strcpy(recapil[m++],recap);
                phrase2=wxT(instrm);
                phrase=wxT(recap);
                sortie=1;
             }

             if ((rep2==5)|(rep2==6))  // cas des limites des constellations
             {
                strcpy(obj2,"boundaries");

                strcpy(instrm,"");
                strcat(instrm,ren);// renderflags {
                strcat(instrm,obj);// set ou clear
                strcat(instrm,gui);// "
                strcat(instrm,obj2);// truc choisi
                strcat(instrm,gui);// "
                strcat(instrm,fin);// }
                strcat(instrm,ent);// entrée

                // mise dans recap
                strcpy(recap,"");
                strcat(recap,"Faire ");
                if ((rep2==1)|(rep2==3)|(rep2==5)|(rep2==7))     // cas apparaitre->set
                    strcat(recap," apparaitre les limites des constellations");
                else   // cas disparaitre->clear
                    strcat(recap," disparaitre les limites des constellations");

                //strcpy(recapil[m++],recap);
                phrase2=wxT(instrm);
                phrase=wxT(recap);
                sortie=1;
             }

             if ((rep2==7)|(rep2==8))  // cas des dessins des constellations
             {
                strcpy(obj2,"constellations");

                strcpy(instrm,"");
                strcat(instrm,ren);// renderflags {
                strcat(instrm,obj);// set ou clear
                strcat(instrm,gui);// "
                strcat(instrm,obj2); // truc choisi
                strcat(instrm,gui);// "
                strcat(instrm,fin);// }
                strcat(instrm,ent);// entrée

                // mise dans recap
                strcpy(recap,"");
                strcat(recap,"Faire ");
                if ((rep2==1)|(rep2==3)|(rep2==5)|(rep2==7))     // cas apparaitre->set
                    strcat(recap," apparaitre les constellations");
                else   // cas disparaitre->clear
                    strcat(recap," disparaitre les constellations");

                //strcpy(recapil[m++],recap);
                phrase2=wxT(instrm);
                phrase=wxT(recap);
                sortie=1;
             }
             break;
    }
//////////////////////
    case 9 :  //9 : mise au niveau d'un pole 
    {
         if (WxMessageDialog5->ShowModal()==wxID_NO)
            break;
         strcpy(instrm,"");
         if (WxMenuBar1->IsChecked(1038))// ajout texte simple
         {
            if(WxTextEntryDialog20->ShowModal()==wxID_OK)
            {
                if (WxTextEntryDialog20->GetValue()!=rien)
                {
                    strcat(instrm,pri);// print { text "
                    strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                    strcat(instrm,row);//  "  row -3  column 3 }
                    strcat(instrm,ent);// entrée
                }
            }
         }         
         strcat(instrm,pol);// orbit { axis [ 1 0 0 ] rate 15 duration 6 }
         strcat(instrm,ent);// entrée

         // mise dans recap
         strcpy(recap,"");
         strcat(recap,"mise au niveau d'un pole de : ");
         strcat(recap,nom_obj);
         //strcpy(recapil[m++],recap);
         phrase2=wxT(instrm);
         phrase=wxT(recap);
         sortie=1;
         break;
    }
/////////////////////
   case 10:  // centrer sur (comme aller)
   { 
    if(WxSingleChoiceDialog5->ShowModal()==wxID_OK)
        {
            rep2=WxSingleChoiceDialog5->GetSelection()+1;
            switch (rep2)
            {
                case 1: //notre soleil
                {    strcpy(obj,sol);
                    strcpy(nom_obj,"soleil"); // copie dans nom_obj pour savoir de quoi on parle
                    break;
                }
                case 2: //une autre étoile ou une galaxie
                {    //cprintf(" ->Donnez le nom de l\'%stoile ou de la galaxie : ",e1);
                    //gets(obj);
                    if(WxTextEntryDialog6->ShowModal()==wxID_OK)
                    {
                       //strcpy(obj,WxTextEntryDialog6->GetValue().c_str);
                       phrasex=WxTextEntryDialog6->GetValue();
                       strcpy(obj,phrasex.c_str());
                       strcpy(nom_obj,obj); // copie dans nom_obj pour savoir de quoi on parle
                    }
                    else
                        rep2=0;
                    break;
                }
                case 3: //une planète du système solaire
                {    //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                    //gets(obj2);
                    if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                        strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                        strcpy(obj,sol);
                    }
                    else
                        rep2=0;
                    break;
                }
                case 4: //une planète d'un autre système
                {    //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                    //gets(obj2);
                    if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                        //cprintf("\n ->Donnez le nom de son %stoile : ",e1);
                        //gets(obj);
                        if(WxTextEntryDialog7->ShowModal()==wxID_OK)
                        {
                            strcpy(obj,WxTextEntryDialog7->GetValue().c_str());
                            strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                        }
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 5: //une comète, un astéroïde ou une sonde
                {    //cprintf("\n ->Donnez le nom de la com%ste, de l\'ast%sro%sde ou de la sonde : ",e2,e1,i2);
                    //gets(obj2);
                    if(WxTextEntryDialog8->ShowModal()==wxID_OK)
                    {
                        strcpy(obj2,WxTextEntryDialog8->GetValue().c_str());
                    strcpy(nom_obj,obj2); // copie dans nom_obj pour savoir de quoi on parle
                    strcpy(obj,sol);
                    }
                    else
                        rep2=0;
                    break;
                }
                case 6: //un satellite ou une lune d'une planète
                {    //cprintf("\n ->Donnez le nom du satellite ou de la lune: ");
                    //gets(obj3);
                    if(WxTextEntryDialog9->ShowModal()==wxID_OK)
                    {
                        strcpy(obj3,WxTextEntryDialog9->GetValue().c_str());
                        //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                        if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                        {
                            strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());   //gets(obj2);
                            strcpy(nom_obj,obj3); // copie dans nom_obj pour savoir de quoi on parle
                            strcpy(obj,sol);
                        }
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 7: //un satellite d'une lune
                {    //cprintf("\n ->Donnez le nom du satellite : ");
                    if(WxTextEntryDialog10->ShowModal()==wxID_OK)
                    {
                        strcpy(obj4,WxTextEntryDialog10->GetValue().c_str());   //gets(obj4);
                        //cprintf("\n ->Donnez le nom de la lune : ");
                        if(WxTextEntryDialog11->ShowModal()==wxID_OK)
                        {
                            strcpy(obj3,WxTextEntryDialog11->GetValue().c_str());//gets(obj3);
                            //cprintf("\n ->Donnez le nom de la plan%ste : ",e2);
                            if(WxTextEntryDialog1->ShowModal()==wxID_OK)
                            {
                                strcpy(obj2,WxTextEntryDialog1->GetValue().c_str());
                                //gets(obj2);
                                strcpy(nom_obj,obj4); // copie dans nom_obj pour savoir de quoi on parle
                                strcpy(obj,sol);
                            }
                            else
                                rep2=0;
                        }
                        else
                            rep2=0;
                    }
                    else
                        rep2=0;
                    break;
                }
                case 8: //un autre cas
                {    //cprintf("\n ->Donnez le nom de l\'objet : ");
                    //gets(obj);
                    if(WxTextEntryDialog12->ShowModal()==wxID_OK)
                    {
                       strcpy(obj,WxTextEntryDialog12->GetValue().c_str());
                       strcpy(nom_obj,obj); // copie dans nom_obj pour savoir de quoi on parle
                    }
                    else
                        rep2=0;
                    break;
                }
            }
            // fin switch(rep2)

            if (rep2==0) break;  // sortie si 0
            // rep2 est le numéro de la réponse

            // modif des obj
            //if (fr==0) mod_nom();
            if (!WxMenuBar1->IsChecked(1026)) mod_nom();
            
            // partie écriture dans le fichier
            enleveraccent();
            strcpy(instrm,"");
            strcat(instrm,sel);// select { objet"
            strcat(instrm,obj);// nom de l'objet

            if ((rep2>2)&(rep2<8))
                 {
                        strcat(instrm,sla); //   antislash /
                        strcat(instrm,obj2);// nom de l'objet2 (planete, comete, satellite)

                        if ((rep2>5)&(rep2<8))
                        {
                           strcat(instrm,sla); //   antislash /
                           strcat(instrm,obj3);// nom de l'objet3 (lune)

                           if (rep2==7)
                           {
                              strcat(instrm,sla); //   antislash /
                              strcat(instrm,obj4);// nom de l'objet4 (satellite de lune)

                           }
                        }
                 }
                 // menu suppl
                 strcpy(durees,"3");
                 if (WxMenuBar1->IsChecked(1016))
                 {
                    if(WxTextEntryDialog18->ShowModal()==wxID_OK)
                        {
                            intermede=WxTextEntryDialog18->GetValue();
                            if (intermede!=rien)
                                strcpy(durees,intermede.c_str());
                        }
                 }
                 // suite et fin de l'écriture dans le fichier

                 strcat(instrm,gui); // "
                 strcat(instrm,fin); // }
                 strcat(instrm,ent); // entrée
                 strcat(instrm,cen); // center {}
                 strcat(instrm,ent); // entrée
                 //strcat(instrm,rajt);// wait { duration 2 }
                 if (WxMenuBar1->IsChecked(1038))// ajout texte simple
                 {
                    if(WxTextEntryDialog20->ShowModal()==wxID_OK)
                    {
                        if (WxTextEntryDialog20->GetValue()!=rien)
                        {
                            strcat(instrm,pri);// print { text "
                            strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                            strcat(instrm,row);//  "  row -3  column 3 }
                            strcat(instrm,ent);// entrée
                        }
                    }
                 }
                 strcat(instrm,wai);
                 strcat(instrm,durees);
                 strcat(instrm,fin);
                 strcat(instrm,ent); // entrée
                 // mise dans recap
                 strcpy(recap,"");
                 strcat(recap,"Centrer vers : ");
                 strcat(recap,nom_obj);
                 //strcpy(recapil[m++],recap);
                 phrase2=wxT(instrm);
                 phrase=wxT(recap);
                 sortie=1;
        }
        break;
    }

////////////////////////////////////////////
    case 11 :  // Changer le champ de vision (FOV)
    {
        rep2=0;
        if(WxTextEntryDialog15->ShowModal()==wxID_OK)
            rep2=1;
        if(WxTextEntryDialog16->ShowModal()==wxID_OK)
        {
            phrasex=WxTextEntryDialog16->GetValue();
            strcpy(obj,WxTextEntryDialog16->GetValue().c_str());
            sscanf(obj,"%f",&fov2);
            if (rep2==1)
            {
                phrasex=WxTextEntryDialog15->GetValue();
                strcpy(obj2,WxTextEntryDialog15->GetValue().c_str());
                sscanf(obj2,"%f",&fov1);
                   
                k0=fov2/fov1;
                nb=(int)floor(log(k0)/log(coef_a));  // nombre d'opérations
                
                signe_nb=1;
                if (nb<0)
                {    
                    nb=-nb;
                    signe_nb=-1; 
                }
                //fov(i9)=fov1*pow(coef_a,i9)
                // il faut faire une boucle avec i9 de 0 à nb
                strcpy(instrm,"");
                phrase2=wxT(instrm);
                for (i9=0;i9<=nb;++i9)
                {
                  strcat(instrm,set);// set { name "FOV" value
                  a9=fov1*pow(coef_a,i9*signe_nb);
                  //cprintf("  i9=%d",i9);
                  sprintf(obj2,"%f",a9);
                  strcat(instrm,obj2);// angle
                  strcat(instrm,fin);// }
                  strcat(instrm,ent);// entrée
                  strcat(instrm,wait_fov); // wait {duration 0.05 }
                  strcat(instrm,ent);// entrée
                  // modif pour éviter un char trop gd  
                  phrase2+=wxT(instrm);
                  strcpy(instrm,"");
                }
                  strcpy(recap,"");
                  strcat(recap,"Nouvel angle du champ de vision (FOV) : ");
                  strcat(recap,obj);
                  //strcat(recap,ent);                   
                
                //phrase2=wxT(instrm);
                phrase=wxT(recap);
                sortie=1;
            }// fin cas avec 2 fov
            else // cas 1 seul fov(2)
            {
                strcpy(instrm,"");
                strcat(instrm,set);// set { name "FOV" value
                strcat(instrm,obj);// angle
                strcat(instrm,fin);// }
                strcat(instrm,ent);// entrée
                // mise dans recap
                strcpy(recap,"");
                strcat(recap,"Nouvel angle du champ de vision (FOV) : ");
                strcat(recap,obj);
                //strcat(recap,ent);                  
                phrase2=wxT(instrm);
                phrase=wxT(recap);                  
                sortie=1;

             }
        break;
        }
    }
////////////////////////////////////////////
    case 12 :  // faire un travelling arrière / avant
    {
        WxSingleChoiceDialog6->ShowModal();
        {                   
          if(WxTextEntryDialog14->ShowModal()==wxID_OK)
          {     
               strcpy(obj2,WxTextEntryDialog14->GetValue().c_str());
               strcpy(instrm,"");
               if (WxMenuBar1->IsChecked(1038))// ajout texte simple
                 {
                    if(WxTextEntryDialog20->ShowModal()==wxID_OK)
                    {
                        if (WxTextEntryDialog20->GetValue()!=rien)
                        {
                            strcat(instrm,pri);// print { text "
                            strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                            strcat(instrm,row);//  "  row -3  column 3 }
                            strcat(instrm,ent);// entrée
                        }
                    }
                 }
               strcat(instrm,cha);   //changedistance { duration
               strcat(instrm,obj2);  // durée obj2
               strcat(instrm,rat);  // rate

               if (WxSingleChoiceDialog6->GetSelection()==1)
                    strcpy(obj,"0.8");
               else
                    strcpy(obj,"-0.8");

               strcat(instrm,obj);// coef x
               strcat(instrm,fin);// }
               strcat(instrm,ent);// entrée

               // mise dans recap
               strcpy(recap,"");
               strcat(recap,"Faire un travelling ");
               if (WxSingleChoiceDialog5->GetSelection()==1)
                    strcat(recap,"arriere pendant ");
               else
                    strcat(recap,"avant pendant ");
               strcat(recap,obj2);
               strcat(recap," secondes");
               //strcpy(recapil[m++],recap);
               phrase2=wxT(instrm);
               phrase=wxT(recap);
               sortie=1;
            }
        }
        break;
    }
////////////////////////////////////////////
    case 13 :  // ecrire texte
    {
        if(WxTextEntryDialog17->ShowModal()==wxID_OK)
        {                     
           strcpy(obj,WxTextEntryDialog17->GetValue().c_str());
          // cas où la phrase dépasse 60 caractères
          strcpy(obj2,obj);
          unsigned int longueur=strlen(obj);
          if (longueur>61)
          {
                for(j=60;j>32;j--)
                   if (obj[j]==32)
                    {
                        strcat(obj,"+");
                        for(i=longueur-1;i>j;i--)
                            obj[i+1]=obj[i];
                        obj[j]=92;
                        obj[j+1]=110;
                        break;
                    }
          }
          // cas où la phrase dépasse 120 caractères
          longueur=strlen(obj);
          if (longueur>126)
          {
                for(j=125;j>100;j--)
                   if (obj[j]==32)
                    {
                        strcat(obj,"+");
                        for(i=longueur-1;i>j;i--)
                            obj[i+1]=obj[i];
                        obj[j]=92;
                        obj[j+1]=110;
                        break;
                    }
          }
          i=0;
          
          while(i<strlen(obj))
              {
                  j=obj[i];
                  if (j<0) j=256+j;
                  if ((j==233)|(j==232)|(j==234)|(j==235)|(j==224)|(j==238)|(j==239)|(j==249)|(j==244)|(j==231))                  
                      accent(i,j);
                  i++;
              }
          
          // menu suppl
         strcpy(durees,"2");
          if (WxMenuBar1->IsChecked(1016))
          {
             if(WxTextEntryDialog18->ShowModal()==wxID_OK)
                {
                    intermede=WxTextEntryDialog18->GetValue();
                    if (intermede!=rien)
                        strcpy(durees,intermede.c_str());
                }
          }
              
          strcpy(instrm,"");
          strcat(instrm,pri);// print { text "
          strcat(instrm,obj);// texte à écrire
          strcat(instrm,row);//  "  row -3  column 3 }
          strcat(instrm,ent);// entrée
          //strcat(instrm,rajt);//  wait { duration 2 }
          strcat(instrm,wai);
          strcat(instrm,durees);// }
          strcat(instrm,fin);// }
          strcat(instrm,ent);// entrée
          
          // mise dans recap
          strcpy(recap,"");
          strcat(recap,"Ecrire le texte ");
          if (strcmp("2",durees))
            {
                strcat(recap," (");
                strcat(recap,durees);
                strcat(recap," s)");
            }
         strcat(recap,": ");
          strcat(recap,obj2);
          //strcat(recap,ent);
          //strcpy(recapil[m++],recap);
          phrase2=wxT(instrm);
          phrase=wxT(recap);
          sortie=1;
        }
           
        break;
    }
////////////////////////////////////////////
 case 14 :  //Choisir une lattitude/longitude  
     {
         if(WxTextEntryDialog21->ShowModal()==wxID_CANCEL)
            break;//lattitude
         if (WxTextEntryDialog21->GetValue()==rien)
            break;
         strcpy(obj2,WxTextEntryDialog21->GetValue().c_str());
         if(WxTextEntryDialog22->ShowModal()==wxID_CANCEL)
            break;//longitude    
         if (WxTextEntryDialog22->GetValue()==rien)
            break;     
         strcpy(obj3,WxTextEntryDialog22->GetValue().c_str());
         //if (WxMenuBar1->IsChecked(1038))
           // if(WxTextEntryDialog23->ShowModal()==wxID_OK)
           // break;
         //strcpy(obj,WxTextEntryDialog4->GetValue().c_str());
         // menu suppl
         strcpy(durees,dur5);
         if (WxMenuBar1->IsChecked(1016))
         {
            if(WxTextEntryDialog23->ShowModal()==wxID_OK)
                {
                    intermede=WxTextEntryDialog23->GetValue();
                    //if(intermede->ToDouble(double *val)==true)
                    if (intermede!=rien)
                        strcpy(durees,intermede.c_str());                       
                }
         }         
         strcpy(instrm,"");
         strcat(instrm,"gotolonglat{ time "); // gotolonglat { time
         strcat(instrm,durees);// valeur dur5
         //strcat(instrm,dis); // distance
         //strcat(instrm,obj); // rapport dist/rayon
         if (WxMenuBar1->IsChecked(1016))
                    if(WxTextEntryDialog4->ShowModal()==wxID_OK)
                    {
                        strcat(instrm," distance ");
                        strcat(instrm,WxTextEntryDialog4->GetValue().c_str());
                    }
         
         strcat(instrm," latitude ");
         strcat(instrm,obj2);
         strcat(instrm," longitude ");
         strcat(instrm,obj3);
         strcat(instrm,fin); // }
         strcat(instrm,ent); // entrée
         if (WxMenuBar1->IsChecked(1038))// ajout texte simple
         {
            if(WxTextEntryDialog20->ShowModal()==wxID_OK)
            {                    
                if (WxTextEntryDialog20->GetValue()!=rien)
                {
                    strcat(instrm,pri);// print { text "
                    strcat(instrm,mod_phrase(WxTextEntryDialog20->GetValue()).c_str());// texte à écrire
                    strcat(instrm,row);//  "  row -3  column 3 }
                    strcat(instrm,ent);// entrée
                }
            }
         }         
         strcat(instrm,wai); // wait { duration
         strcat(instrm,durees);// valeur dur5
         strcat(instrm,fin); // }
         strcat(instrm,ent); // entrée

         // mise dans recap
         strcpy(recap,"");
         strcat(recap,"Position : latitude=");
         strcat(recap,obj2);
         strcat(recap,"° longitude=");
         strcat(recap,obj3);
         strcat(recap,"°");
         if (strcmp(dur5,durees)) 
         {
            strcat(recap," (en ");
            strcat(recap,durees);
            strcat(recap," s)");
         }
         //strcpy(recapil[m++],recap);
         phrase2=wxT(instrm);
         phrase=wxT(recap);
         sortie=1;
         break;
    }   

}// fin des case
if (sortie==1)
{

   if (n_liste==pos1)
   {
        code[n_liste]=phrase2;
        liste[n_liste]=phrase;// rajout à la fin
        //en +
        WxGrid1->SetCellValue(n_liste,0,phrase);

        n_liste++;
        WxGrid1->AppendRows(1,true);     //WxGrid1->SetGridCursor(pos1+2,0);
        WxGrid1->MoveCursorDown(false);    //WxGrid1->SelectRow(pos1+1,false);
   }
   else
   {
        // remplacement à l'emplacement sélectionné
        if(liste[pos1]==rien)
        {
            code[pos1]=phrase2;
            liste[pos1]=phrase;
            WxGrid1->SetCellValue(pos1,0,phrase);            
        }   
        else        
            if(WxMessageDialog3->ShowModal()==wxID_YES)
            {
                code[pos1]=phrase2;
                liste[pos1]=phrase;
                WxGrid1->SetCellValue(pos1,0,phrase);
            }              
   } 
  for(int t=0;t<n_liste;t++)
     WxGrid1->SetCellValue(t,0,liste[t]);
WxGrid1->EnableCellEditControl(false);

}
sortie=0;    
  }      
}

/*
 * WxListBox1Selected
 */
void ProjetzzFrm::WxListBox1Selected(wxCommandEvent& event)
{
	jx=0;
    for(int k=0;k<15;k++)
	{ if (WxListBox1->IsSelected(k))
	    { jx=1;
	      phrase.Printf(wxT("instruction n° %d"), k);
          n_instr=k;
          //i++;
        }
    }    
}

/*
 * WxButton1Click
 */
void ProjetzzFrm::WxButton1Click(wxCommandEvent& event)
{
	// bouton supprimer
int pos1=WxGrid1->GetGridCursorRow();

if(pos1<n_liste)
 {    
	/*wxString msg;
	msg.Printf(wxT("instruction n° %d et %d"), pos1,n_liste);
    wxMessageBox(msg, _T("Numéro :"),wxOK | wxICON_INFORMATION, this); */
    // suppression de l'instruction selectionnée n° WxGrid1->GetGridCursorRow()
    if (WxMessageDialog1->ShowModal()==wxID_YES)
      {  
        WxGrid1->DeleteRows(pos1,1,true);
        for (int k1=pos1;k1<n_liste;k1++)
        {    
            liste[k1]=liste[k1+1];
            code[k1]=code[k1+1];
        }        
        liste[n_liste]=rien;
        code[n_liste]=rien;
        n_liste--;
      }
   for(int t=0;t<n_liste;t++)
    {
        WxGrid1->SetCellValue(t,0,liste[t]);
    } 
 }
 posG=WxGrid1->GetGridCursorRow();

 WxGrid1->EnableCellEditControl(false);
}

/*
 * WxButton2Click
 */
void ProjetzzFrm::WxButton2Click(wxCommandEvent& event)
{
    // bouton remonter
    int pos1=WxGrid1->GetGridCursorRow();// position du curseur
    if ((pos1>0)&(pos1<n_liste))
    {
        wxString phrase3=liste[pos1-1];
        liste[pos1-1]=liste[pos1];
        liste[pos1]=phrase3;
        phrase3=code[pos1-1];
        code[pos1-1]=code[pos1];
        code[pos1]=phrase3;

        WxGrid1->MoveCursorUp(false);
    }   
    // mise à jour des 2 cellules
    //WxGrid1->SetCellValue(pos1-1,0,liste[pos1-1]); 
    //WxGrid1->SetCellValue(pos1,0,liste[pos1]);
    for(int t=0;t<n_liste;t++)
        WxGrid1->SetCellValue(t,0,liste[t]);
    posG=WxGrid1->GetGridCursorRow();

WxGrid1->EnableCellEditControl(false);
}

/*
 * WxButton5Click
 */
void ProjetzzFrm::WxButton5Click(wxCommandEvent& event)
{
	// Bouton insérer
	int pos1=WxGrid1->GetGridCursorRow();
    if(pos1<n_liste)
	{
        WxGrid1->InsertRows(pos1,1,true);
        for (int k1=n_liste;k1>=pos1;k1--)
        {
            liste[k1+1]=liste[k1];
            code[k1+1]=code[k1];
        }
        n_liste++;
        liste[pos1]=rien;
        code[pos1]=rien;
    }
    //WxGrid1->ForceRefresh();
   for(int t=0;t<n_liste;t++)
        WxGrid1->SetCellValue(t,0,liste[t]);
posG=WxGrid1->GetGridCursorRow();

WxGrid1->EnableCellEditControl(false);
}

/*
 * WxButton4Click
 */
void ProjetzzFrm::WxButton4Click(wxCommandEvent& event)
{
	// Bouton descendre
	int pos1=WxGrid1->GetGridCursorRow();// position du curseur
    if (pos1<(n_liste-1))
    {
        wxString phrase3=liste[pos1+1];
        liste[pos1+1]=liste[pos1];
        liste[pos1]=phrase3;
        phrase3=code[pos1+1];
        code[pos1+1]=code[pos1];
        code[pos1]=phrase3;
        //WxGrid1->SetGridCursor(pos+1,0);
        WxGrid1->MoveCursorDown(false);
    }
    // mise à jour des 2 cellules
    //WxGrid1->SetCellValue(pos1+1,0,liste[pos1+1]);
    //WxGrid1->SetCellValue(pos1,0,liste[pos1]);
    for(int t=0;t<n_liste;t++)
        WxGrid1->SetCellValue(t,0,liste[t]);
    //WxGrid1->EnableCellEditControl(false);
    posG=WxGrid1->GetGridCursorRow();
}

/*
 * WxListBox2Selected
 */
void ProjetzzFrm::WxListBox2Selected(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * WxListBox2Selected1
 */
void ProjetzzFrm::WxListBox2Selected1(wxCommandEvent& event)
{
jx=0;
    for(int k=0;k<15;k++)
	{ if (WxListBox1->IsSelected(k))
	    { jx2=1;
	      phrase.Printf(wxT("instruction n° %d"), k);
        }
    }
	// insert your code here
}

/*
 * Mnuquitter1024Click
 */
void ProjetzzFrm::Mnuquitter1024Click(wxCommandEvent& event)
{
if(WxMessageDialog2->ShowModal()==wxID_YES)
   Destroy();
// insert your code here
}

/*
 * Mnuouvrir1021Click
 */
void ProjetzzFrm::Mnuouvrir1021Click(wxCommandEvent& event)
{
	bool testlect;
	if(WxOpenFileDialog1->ShowModal()==wxID_OK)
	{
        strcpy(nomfichier,WxOpenFileDialog1->GetFilename().c_str());
        // lecture d'un fichier et mise dans des tableaux+valeur de m
        i=0;
        k=0;  // compteur à 0
        // on doit verifier si le fichier existe
        // ajout du suffixe .cel
        fic=fopen(nomfichier,"r");  //ouverture du fichier existant
        if( fic==NULL )
              {
                	//msg.Printf(wxT("instruction n° %d et %d"), pos1,n_liste);
                    wxMessageBox("fichier introuvable", _T("Ouvrir un fichier"),wxOK | wxICON_INFORMATION, this);
                    return;            
              }
        wxMessageBox("fichier trouvé", _T("Ouvrir un fichier"),wxOK | wxICON_INFORMATION, this);
        WxGrid1->DeleteRows(0,n_liste,false);
        
        do
        {
            fread(&lect,1,1,fic); // enlever les espaces, tab et entrée
        }
        while (((lect[0]==10)|(lect[0]=='\t')|(lect[0]=='\n')|(lect[0]==32))&(feof(fic)==0));
        
        /*do
        {// aller jusqu'au caractère { au début du script
            fread(&lect,1,1,fic); 
        }
        while ((lect[0]!=123)&(feof(fic)==0));
        */
        // cas fin
        if (feof(fic)!=0) 
        {    
            wxMessageBox("fichier vide", _T("Ouvrir un fichier"),wxOK | wxICON_EXCLAMATION, this);
            return;
        }
        if (lect[0]!=123)
        {    
            wxMessageBox("Mauvais fichier", _T("Ouvrir un fichier"),wxOK | wxICON_EXCLAMATION, this);
            return;
        }
        do
        {
            fread(&lect,1,1,fic); // enlever les espaces, tab et entrée
        }
        while (((lect[0]==10)|(lect[0]=='\t')|(lect[0]=='\n')|(lect[0]==32))&(feof(fic)==0));

        // premier caractère : ce doit être #
        if (feof(fic)==1)   
            {
                return;
                i=1;
            }
        //if (lect[0]!='#')   i=2;
        
        if (i==0)
        {  // le premier caractère est #
            do
            {
               if (lect[0]=='#')
               {
                    do
                        fread(&lect,1,1,fic); // enlever les espaces
                    while ((lect[0]==' ')&(feof(fic)==0));
                    j=0;
                    while ((feof(fic)==0)&(lect[0]!='\n'))
                         {   // mise dans recapil
                             recapil[k][j]=lect[0];
                             instrm[j++]=lect[0];
                             fread(&lect,1,1,fic);
                         }                                   
               // mise de 0 fin de chaine
               instrm[j]=0;
               liste[k]=wxT(instrm);
               }
               else
               {
                    liste[k]=wxT("Liste d'instructions");
               }
               strcpy(instrm,"");
               
               if (feof(fic)==0)  // on a donc entrée comme caract
               {                 
		 do
                     fread(&lect,1,1,fic); // enlever les espaces, tab et entrée
                 while (((lect[0]==10)|(lect[0]=='\t')|(lect[0]=='\n')|(lect[0]==32))&(feof(fic)==0));
                 j=0;
		 
		         testlect=true;
                 while ((feof(fic)==0)&((lect[0]!='#')|(testlect==false)))
                    {   // mise dans instr
                       //instr[k][j++]=lect[0];
                       instrm[j++]=lect[0];
			         // en +
                       if ((lect[0]!=32)&(lect[0]!=10)&(lect[0]!=9))// 9 = \t (tab)
			             testlect=false;
		               if (lect[0]=='\n')
			           testlect=true;		       
		              // fin en+
		              fread(&lect,1,1,fic);
                    }
                 //instr[k++][j-1]=0; // mise de 0 et elimination de entrée
                 instrm[j-1]=0;
                 code[k++]=wxT(instrm);
                 // le caract est #
               } // fin if

            }
            while (feof(fic)==0);
            {
                //instr[k-1][j-2]=0; // mise de 0 et elimination de entrée et }
                strcpy(instrm,code[k-1].c_str());
                instrm[j-2]=0;
                code[k-1]=wxT(instrm);
                //code[k-1][j-2]=wxT("/0");            
            }
            n_liste=k;
            //
          }
          fclose(fic);
          
          // maintenant il faut retrouver nom_obj
          strcpy(nom_obj,""); // mise à NULL de nom_obj
          i=n_liste;
          do
          {
              i--; // on commence à m-1
              j01=strlen(recapil[i]);
              if (strncmp(recapil[i],"Aller",5)==0)
                  {
                  for (j=13;j<j01;j++)
                      nom_obj[j-13]=recapil[i][j];
                  }
              else
              if (strncmp(recapil[i],"Centrer",7)==0)
                  {
                  for (j=15;j<j01;j++)
                      nom_obj[j-15]=recapil[i][j];
                  }
          }
          while((i>0)&(strlen(nom_obj)<1));
          
          // mise à 0 de la grille
          WxGrid1->ClearGrid();
          WxGrid1->InsertRows(0,n_liste,false);  
          for(int t=0;t<n_liste;t++)
          {             
             WxGrid1->MoveCursorDown(false);
             WxGrid1->SetCellValue(t,0,liste[t]);
          }
    }    
}

/*
 * Mnusauver1022Click
 */
void ProjetzzFrm::Mnusauver1022Click(wxCommandEvent& event)
{
	if(WxSaveFileDialog1->ShowModal()==wxID_OK)
	{
        strcpy(nomfichier,WxSaveFileDialog1->GetFilename().c_str());
	    // si le fichier existe déjà :
        //if(WxSaveFileDialog1->Exists(nomfichier))
        //    if(WxMessageDialog8->ShowModal()==wxID_NO)
        //        return;
        
        // nom du script
	    //strcat(nomfichier,suf); // ajout du suffixe .cel
        fic=fopen(nomfichier,"w");  //ouverture ou création du fichier
        fwrite(&deb,strlen(deb),1,fic); // caractère { au début du script
        fwrite(&ent,strlen(ent),1,fic); // caractère entrée au début du script
        for (k=0;k<n_liste;k++)
        {
            fwrite(&ent,strlen(ent),1,fic); // caractère entrée
            fwrite(&dies,strlen(dies),1,fic); // #
            strcpy(instrm,liste[k].c_str());
            //fwrite(&recapil[k],strlen(recapil[k]),1,fic); // recapitulatif de l'instruction
            fwrite(&instrm,strlen(instrm),1,fic);
            
            fwrite(&ent,strlen(ent),1,fic); // caractère entrée
            strcpy(instrm,code[k].c_str());
            fwrite(&instrm,strlen(instrm),1,fic);   // code
        }
        fwrite(&fin,strlen(fin),1,fic);  // écriture de  }        
        fclose(fic);
    }
}

/*
 * Mnunouveau1027Click
 */
void ProjetzzFrm::Mnunouveau1027Click(wxCommandEvent& event)
{
	if (n_liste>0)
    {
        if(WxMessageDialog7->ShowModal()==wxID_OK)
        {
            WxGrid1->ClearGrid();
            WxGrid1->DeleteRows(0,n_liste,false);            
            n_liste=0;
        }
    }
}

/*
 * Mnuaide1028Click
 */
void ProjetzzFrm::Mnuaide1028Click(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * Mnuaide1028Click1
 */
void ProjetzzFrm::Mnuaide1028Click1(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * Mnucommandes1030Click
 */
void ProjetzzFrm::Mnucommandes1030Click(wxCommandEvent& event)
{
	wxcommandesDialog->ShowModal();
}

/*
 * Mnusubmenuitem121029Click
 */
void ProjetzzFrm::Mnusubmenuitem121029Click(wxCommandEvent& event)
{
	aproposDialog->ShowModal();
}

/*
 * WxToolButton4Click
 */
void ProjetzzFrm::WxToolButton4Click(wxCommandEvent& event)
{
    // lancer celestia
	wxExecute(wxT("celestia.exe"),wxEXEC_NOHIDE,NULL);
}

/*
 * Mnuaidedesoptions1037Click
 */
void ProjetzzFrm::Mnuaidedesoptions1037Click(wxCommandEvent& event)
{
	//WxaideoptionsDialog->ShowModal();
	Dlga* Wxdlga = new Dlga(this);
    Wxdlga->ShowModal();
}

/*
 * WxPanel1UpdateUI
 */
void ProjetzzFrm::WxPanel1UpdateUI(wxUpdateUIEvent& event)
{
	// insert your code here
}

/*
 * Mnumodifierlecode1039Click
 */
void ProjetzzFrm::Mnumodifierlecode1039Click(wxCommandEvent& event)
{
	int pos1=WxGrid1->GetGridCursorRow();
	if (pos1==n_liste) return;
	mod_code* wxmod_code = new mod_code(this);
    wxmod_code->code_m=code[pos1];
    wxmod_code->nom_m=liste[pos1];
    wxmod_code->ShowModal();
    code[pos1]=wxmod_code->code_m;   
    liste[pos1]=wxmod_code->nom_m;
    WxGrid1->SetCellValue(pos1,0,liste[pos1]);
}

/*
 * WxGrid1SelectCell
 */
void ProjetzzFrm::WxGrid1SelectCell(wxGridEvent& event)
{
	    for(int t=0;t<n_liste;t++)
        WxGrid1->SetCellValue(t,0,liste[t]);
}

/*
 * WxGrid1CellChange1
 */
void ProjetzzFrm::WxGrid1CellChange1(wxGridEvent& event)
{
	for(int t=0;t<n_liste;t++)
        WxGrid1->SetCellValue(t,0,liste[t]);
    posG=WxGrid1->GetGridCursorRow();
}


/*
 * Mnusubmenuitem181041Click
 */
void ProjetzzFrm::Mnusubmenuitem181041Click(wxCommandEvent& event)
{
	// écriture de miniscript.cfg
	char const vrai[]="1",faux[]="0",bloc[]="B";	
	fic=fopen("miniscript.cfg","w");  //ouverture du fichier en écriture        
    if (WxMenuBar1->IsChecked(1016))
        fwrite(&vrai,1,1,fic);
    else
        fwrite(&faux,1,1,fic);
    
    if (WxMenuBar1->IsChecked(1038))
        fwrite(&vrai,1,1,fic);
    else
        fwrite(&faux,1,1,fic);
    
    if (WxMenuBar1->IsChecked(1026))
        fwrite(&vrai,1,1,fic);
    else
        fwrite(&faux,1,1,fic);      
    if (block==false)
        fwrite(&bloc,1,1,fic); 
    // permet de garder le blocage
    fclose(fic);
}