diff --git a/gaudigraph.adb b/gaudigraph.adb index e69de29..3ab7a5a 100644 --- a/gaudigraph.adb +++ b/gaudigraph.adb @@ -0,0 +1,27 @@ +with p_vue_graph, p_fenbase, Forms, p_combinaisons; +use p_vue_graph, p_fenbase, Forms, p_combinaisons, p_combinaisons.p_cases_io; + +procedure gaudigraph is + fen: TR_Fenetre; + + f: p_cases_io.file_type; + V: TV_Gaudi(1..16); +begin + open(f, IN_FILE, "CarreGaudi"); + CreeVectGaudi(f, V); + triVectGaudi(V); + close(f); + + initialiserFenetres; + fen := debutFenetre("Test", 500, 500); + afficherGrille(fen, 50, 50, V); + ajouterBouton(fen, "continuer", "Next", 225, 470, 50, 50); + finFenetre(fen); + + montrerFenetre(fen); + + if attendreBouton(fen) /= "MDR" then null; end if; + cacherFenetre(fen); + delay 1.0; + +end gaudigraph; diff --git a/p_vue_graph.adb b/p_vue_graph.adb index 2864fd0..0f9a5f5 100644 --- a/p_vue_graph.adb +++ b/p_vue_graph.adb @@ -1,10 +1,38 @@ -with p_fenbase; use p_fenbase; +with p_fenbase, Forms, p_combinaisons, Ada.Strings, Ada.Strings.Fixed, text_io; +use p_fenbase, Forms, p_combinaisons, Ada.Strings, Ada.Strings.Fixed, text_io, p_combinaisons.p_int_io; package body p_vue_graph is - procedure debutModeGraph is - + function GetElement ( + Pliste : TA_Element; + NomElement : String ) + return TA_Element is + begin + if Pliste=null or else Pliste.NomElement.all>NomElement then + return null; + elsif Pliste.NomElement.all=NomElement then + return Pliste; + else + return GetElement(Pliste.Suivant,NomElement); + end if; + end GetElement; + procedure afficherGrille(fen: in out TR_Fenetre; x,y: in natural; V: in TV_Gaudi) is + -- {} => {Affiche la grille avec le bord gauche à la position (x,y)} + textX, textY: natural; + P : TA_Element; + begin + ajouterTexte(fen, "fond_grille", "", x, y, 400, 400); + changerCouleurFond(fen, "fond_grille", FL_BLACK); + for i in V'range loop + textX := x + 5 + (99 * ((i-1) / 4)); + textY := y + 5 + (99 * ((i-1) mod 4)); + ajouterTexte(fen, V(i).nom, trim(Integer'image(V(i).valeur), BOTH), textX, textY, 92, 92); + changerTailleTexte(fen, V(i).nom, FL_HUGE_SIZE); + P := GetElement(fen.PElements, V(i).nom); + fl_set_object_align(P.Pelement, FL_ALIGN_CENTER); + end loop; + end afficherGrille; end p_vue_graph; diff --git a/p_vue_graph.ads b/p_vue_graph.ads index dbf092f..3e47290 100644 --- a/p_vue_graph.ads +++ b/p_vue_graph.ads @@ -1,9 +1,9 @@ -with p_fenbase; use p_fenbase; - +with p_fenbase, p_combinaisons; +use p_fenbase, p_combinaisons; package p_vue_graph is - - + procedure afficherGrille(fen: in out TR_Fenetre; x,y: in natural; V: in TV_Gaudi); + -- {} => {Affiche la grille avec le bord gauche à la position (x,y)} end p_vue_graph; diff --git a/p_vue_text.adb b/p_vue_text.adb index d7d464a..ffaef2a 100644 --- a/p_vue_text.adb +++ b/p_vue_text.adb @@ -21,8 +21,8 @@ package body p_vue_text is -- {} => {La valeur à l'indice ind a été affichée avec sa bordure gauche} nbchar : integer := 0; begin - put(colonne); - for i in 1..taille/2 loop + put(COLONNE); + for i in 1..TAILLE/2 loop put(' '); nbchar := nbchar + 1; end loop; @@ -30,7 +30,7 @@ package body p_vue_text is put(V(ind).valeur, 1); nbchar := nbchar + (if V(ind).valeur >= 10 then 2 else 1); - while nbchar < taille loop + while nbchar < TAILLE loop put(' '); nbchar := nbchar + 1; end loop; @@ -52,18 +52,18 @@ package body p_vue_text is new_line; for i in 1..4 loop - afficheLigne(angle, ligne); - afficheLigne(colonne, ' '); afficheLigne(colonne, ' '); + afficheLigne(ANGLE, LIGNE); + afficheLigne(COLONNE, ' '); afficheLigne(COLONNE, ' '); put(i, 1); for j in 0..3 loop -- Affichage ligne avec valeurs afficheValeur(V, j * 4 + i); end loop; - put(colonne); new_line; + put(COLONNE); new_line; - afficheLigne(colonne, ' '); afficheLigne(colonne, ' '); + afficheLigne(COLONNE, ' '); afficheLigne(COLONNE, ' '); end loop; - afficheLigne(angle, ligne); + afficheLigne(ANGLE, LIGNE); end afficheGrille; diff --git a/p_vue_text.ads b/p_vue_text.ads index 8215c10..0aa7d4a 100644 --- a/p_vue_text.ads +++ b/p_vue_text.ads @@ -3,10 +3,10 @@ with p_combinaisons; use p_combinaisons; package p_vue_text is - angle : constant character := '+'; - ligne : constant character := '-'; - colonne : constant character := '|'; - taille : constant integer := 5; + ANGLE : constant character := '+'; + LIGNE : constant character := '-'; + COLONNE : constant character := '|'; + TAILLE : constant integer := 5; procedure afficheLigne(carAngle,carLigne: in character); -- {} => {Une nouvelle ligne de la grille est affichée}