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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
#include <stdlib.h>
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *pWindow;
GtkWidget *pTable;
float Ligne;
float Start_Collonne;
float End_Collonne;
float Feuille_largeur;
float Feuille_Hauteur;
/* valeur par defaut des variables */
Ligne = 1;
Feuille_largeur = 1680;
Feuille_Hauteur = 1050;
Start_Collonne = 0;
End_Collonne = 1;
/*
attention si le nombre est inferieur a la demande cela peux empecher
la feuille de s'afficher
*/
GtkWidget *pButton[11];
gtk_init(&argc, &argv);
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(pWindow), Feuille_largeur, Feuille_Hauteur);
gtk_window_set_title(GTK_WINDOW(pWindow), "Les GtkTable");
g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
/* Creation et insertion de la table 10 lignes 4 colonnes */
pTable=gtk_table_new(4,1,TRUE);
gtk_container_add(GTK_CONTAINER(pWindow), GTK_WIDGET(pTable));
/* Creation des boutons */
pButton[0]= gtk_button_new_with_label("Bouton 1");
pButton[1]= gtk_button_new_with_label("Bouton 2");
pButton[2]= gtk_button_new_with_label("Bouton 3");
pButton[3]= gtk_button_new_with_label("Bouton 4");
pButton[4]= gtk_button_new_with_label("Bouton 5");
pButton[5]= gtk_button_new_with_label("Bouton 6");
pButton[6]= gtk_button_new_with_label("Bouton 7");
pButton[7]= gtk_button_new_with_label("Bouton 8");
pButton[8]= gtk_button_new_with_label("Bouton 9");
pButton[9]= gtk_button_new_with_label("Bouton 10");
/* modification des lignes*/
gtk_table_set_row_spacings(GTK_TABLE (pTable), 2);
/*
Insertion des boutons
premiere colonne (depart) 2 eme colonne (arriveé) ? ligne
*/
gtk_table_attach(GTK_TABLE(pTable), pButton[0],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[1],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[2],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[3],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[4],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[5],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[6],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[7],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_EXPAND, GTK_EXPAND,
0, 1);
Start_Collonne=End_Collonne;
End_Collonne=Start_Collonne+1;
gtk_table_attach(GTK_TABLE(pTable), pButton[8],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_FILL, GTK_EXPAND,
1, 0);
Start_Collonne=0;
End_Collonne=Start_Collonne+10;
Ligne=Ligne+1 ;
gtk_table_attach(GTK_TABLE(pTable), pButton[9],
Start_Collonne, End_Collonne, 0, Ligne,
GTK_EXPAND | GTK_FILL, GTK_EXPAND,
1, 0);
gtk_widget_show_all(pWindow);
gtk_main();
return EXIT_SUCCESS;
} |
Partager