Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Show the grid with values
Browse files Browse the repository at this point in the history
  • Loading branch information
Feelzor committed Jan 22, 2019
1 parent ed33c2a commit 636014e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 19 deletions.
27 changes: 27 additions & 0 deletions gaudigraph.adb
Original file line number Diff line number Diff line change
@@ -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;
34 changes: 31 additions & 3 deletions p_vue_graph.adb
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 4 additions & 4 deletions p_vue_graph.ads
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 8 additions & 8 deletions p_vue_text.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ 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;

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;
Expand All @@ -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;


Expand Down
8 changes: 4 additions & 4 deletions p_vue_text.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 636014e

Please sign in to comment.