1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
void Creation_matrice(void)
{
//Variables
int taille,i,j;
GtkWidget *pChoix;
GtkWidget *pCadre;
GtkWidget *pSelect;
GtkWidget *pHbox;
GtkWidget *pMatrice;
GtkWidget *pFrame[3];
GtkWidget *pTable[3];
GtkWidget *pEntryVec[taille];
GtkWidget *pEntrySol[taille];
GtkWidget *pEntryMat[taille*taille];
//Creation de Frame
pCadre = gtk_frame_new("Choix de la taille");
//creation de la fenetre de dialogue de choix de la taille;
pChoix=gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(pChoix),"Taille de la matrice");
gtk_window_set_transient_for(GTK_WINDOW(pChoix),GTK_WINDOW(pWindow));
gtk_window_set_resizable(GTK_WINDOW(pChoix),FALSE);
//Insertion de boutons dans la fenetre de dialogue
gtk_dialog_add_buttons(GTK_DIALOG(pChoix),"OK",GTK_RESPONSE_OK,
"Annuler",GTK_RESPONSE_CANCEL,
NULL);
//Creation de la zone de selection+insertion dans la frame
pSelect = gtk_spin_button_new_with_range(1,10,1);
gtk_container_add(GTK_CONTAINER(pCadre),pSelect);
//Insertion du cadre dans la fenetre de dialogue de choix de taille
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pChoix)->vbox),pCadre,TRUE,TRUE,0);
//on limite les actions à cette fenêtre
gtk_window_set_modal(GTK_WINDOW(pChoix),TRUE);
//affichage de la fenetre
gtk_widget_show_all(pChoix);
//Récupération des réponses des boutons:
if (gtk_dialog_run(GTK_DIALOG(pChoix))== GTK_RESPONSE_OK)
{
taille=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pSelect));
gtk_widget_destroy(pChoix);
//Creation de la fenetre+Insertion boutons
pMatrice=gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(pMatrice),g_locale_to_utf8("Insertion des données",-1,NULL,NULL,NULL));
gtk_window_set_transient_for(GTK_WINDOW(pMatrice),GTK_WINDOW(pWindow));
gtk_dialog_add_buttons(GTK_DIALOG(pMatrice),g_locale_to_utf8("Résolution",-1,NULL,NULL,NULL),GTK_RESPONSE_OK,
"Nouveau",GTK_RESPONSE_APPLY,
g_locale_to_utf8("Arrêter",-1,NULL,NULL,NULL),GTK_RESPONSE_CANCEL
,NULL);
//Création de la Hbox + Insertion dans la Vbox de la boite de dialogue
pHbox=gtk_hbox_new(FALSE,0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pMatrice)->vbox),pHbox,FALSE,TRUE,0);
//Création des frames
pFrame[0]=gtk_frame_new("Matrice");
pFrame[1]=gtk_frame_new("Vecteur");
pFrame[2]=gtk_frame_new("Solution");
//Création des tables pour la matrice, le vecteur et la solution
pTable[0]= gtk_table_new(taille,taille,TRUE);
pTable[1]= gtk_table_new(taille,1,TRUE);
pTable[2]= gtk_table_new(taille,1,TRUE);
//Creation des zones d'entree des nombres+definition de leur taille
/*Pour les vecteurs*/
for(i=0;i<taille;i++)
{
pEntryVec[i]=gtk_entry_new();
pEntrySol[i]=gtk_entry_new();
}
/*Pour la matrice*/
for(i=0;i<taille*taille;i++)
{
pEntryMat[i]=gtk_entry_new();
}
//Attachement des zones d'entrées aux différentes tables
/*Pour la table Matricielle*/
for(i=0;i<taille;i++)
{
for(j=0;j<taille;j++)
{
gtk_table_attach_defaults(GTK_TABLE(pTable[0]),pEntryMat[i*taille+j],i,i+1,j,j+1);
}
}
/*Pour la table Vectorielle*/
for(i=0;i<taille;i++)
{
gtk_table_attach_defaults(GTK_TABLE(pTable[1]),pEntryVec[i],0,1,i,i+1);
}
/*Pour la table Solution*/
for(i=0;i<taille;i++)
{
gtk_table_attach_defaults(GTK_TABLE(pTable[2]),pEntrySol[i],0,1,i,i+1);
}
//Insertion des tables dans les frames
for(i=0;i<3;i++)
{
gtk_container_add(GTK_CONTAINER(pFrame[i]),pTable[i]);
}
//Insertion des frames dans la Hbox
for(i=0;i<3;i++)
{
gtk_box_pack_start(GTK_BOX(pHbox),pFrame[i],FALSE,FALSE,15);
}
//limitaion des actions à cette fenêtre
gtk_window_set_modal(GTK_WINDOW(pMatrice),TRUE);
//Affichage fenêtre
gtk_widget_show_all(pMatrice);
}
else
{
gtk_widget_destroy(pChoix);
}
}
|