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
|
int main (int argc, char *argv[])
{
gtk_init(&argc,&argv);
GtkWidget *window=NULL,*conteneur=NULL,*bouton1,*darea=NULL, *table=NULL;
GtkWidget *carre_noir,*carre_blanc;
carre_blanc = gtk_image_new_from_file("sources/carreblanc.jpg");
carre_noir = gtk_image_new_from_file("sources/carrenoir.jpg");
int tab_jeu[NB_LIGNES][NB_COLONNES];
// CREATION FENETRE
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(window, 800,500);
gtk_window_set_title(window, "Jeu");
// CREATION CONTENEUR
conteneur = gtk_fixed_new();
gtk_container_add(window,conteneur);
// CREATION GTK TABLE
table = gtk_table_new(NB_LIGNES, NB_COLONNES, TRUE);
gtk_container_add(conteneur, table);
// TEST
int init_tab_jeu (int tab_jeu[NB_LIGNES][NB_COLONNES]);
int i=0,j=0;
for (i=0;i<NB_LIGNES;i++)
{
for (j=0;j<NB_COLONNES;j++)
{
if (tab_jeu[i][j]==0)
{
gtk_table_attach_defaults(table, gtk_label_new ("0"),
j, j+1, i, i+1);
}
if (tab_jeu[i][j]==1)
{
gtk_table_attach_defaults(table, gtk_label_new ("1"),
j, j+1, i, i+1);
}
}
}
// CREATION D'UN BOUTON
bouton1 =gtk_button_new_with_label("Bouton");
gtk_widget_set_size_request(bouton1, 100,100);
gtk_container_add(conteneur,bouton1);
gtk_fixed_put(conteneur,bouton1, 650,20);
// FERME LA FENETRE
g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit), NULL );
gtk_widget_show_all(window);
gtk_main();
return 0;
} |
Partager