text
stringlengths
0
234
--Double_Buffer.Draw (Buffer);
return True;
end Draw_Complex_Buffer;
----------
-- Quit --
----------
procedure Quit (Win : access Gtk_Window_Record'Class) is
pragma Warnings (Off, Win);
begin
Gnat.OS_Lib.OS_Exit(0);
--Gtk.Main.Main_Quit;
--Ada.Task_Identification.Abort_Task(Ada.Task_Identification.Current_Task);
end Quit;
------------------------------------------------------------------------
-- Procedure que inicializa el buffer de coches
------------------------------------------------------------------------
procedure Inicializar_Buffer_Coches is
coche : T_RecordCoche;
BEGIN
for carril IN T_Carril loop
FOR I IN T_RangoBufferCoches LOOP
Coche.Id := 0;
Coche.Pos.X := 0;
Coche.Pos.Y := y_carril(carril);
coche.velocidad := (VELOCIDAD_COCHE, 0);
Coche.Color:= T_ColorCoche'First;
coche.carril := carril;
Pkg_Buffer_Coches.Actualiza_Item(i, Coche, Buffer_Coches(carril));
-- Inicializamos también el buffer de coches accidentados
Pkg_Buffer_Accidentes.Actualiza_Item(i, Coche, Buffer_Accidentes(carril));
END LOOP;
END LOOP;
exception
when event: others =>
PKG_debug.Escribir("ERROR en Inicializar_Buffer_Coches: " & Exception_Name(Exception_Identity(event)));
end Inicializar_Buffer_Coches;
------------------------------------------------------------------------
-- Función que devuelve la posición de un coche dentro del buffer
-----------------------------------------------------------------------
FUNCTION Posicion_Buffer(Id : T_IdCoche;
Buffer: Pkg_Buffer_Coches.T_Buffer) RETURN T_RangoBufferCoches is
coche_aux : T_RecordCoche;
pos : T_RangoBufferCoches;
BEGIN
BEGIN
Pos := Pkg_Buffer_Coches.Posicion_Primer_Item(Buffer);
Coche_Aux := Pkg_Buffer_Coches.Consulta_Item(Pos, Buffer);
WHILE Coche_Aux.Id /= Id LOOP
Pos := Pos+1;
Coche_Aux := Pkg_Buffer_Coches.Consulta_Item(Pos, Buffer);
END LOOP;
exception
when event: others =>
PKG_debug.Escribir("ERROR en Posicion_Buffer: " & Exception_Name(Exception_Identity(event)));
Function Definition: procedure Simular_Sistema IS
Function Body: BEGIN
Gtk.Main.Main;
END Simular_Sistema;
------------------------------------------------------------------------
-- Procedure que se encarga de inicializar la interfaz gráfica
------------------------------------------------------------------------
procedure Inicializar_Interfaz_Grafica is
Win : Gtk_Window;
Buffer : Gtk_Double_Buffer;
Vbox, Hbox : Gtk_Box;
Id : G_Source_Id;--Timeout_Handler_Id;
Button : Gtk_Button;
inbuilt_font : Pango.Font.Pango_Font_Description;
--ventana : Gdk_Window;
--TAM_BUTTON_EXIT : constant GLib.Gint := 20;
alinea_button : Gtk.Alignment.Gtk_Alignment;
begin
-- ventana principal
Gtk.Window.Gtk_New (Win, Window_Toplevel);
Set_Title (Win, "PRACTICA STR: CONTROL DE TRAFICO");
Win.Set_Default_Size(CANVAS_WIDTH, CANVAS_HEIGHT);--+TAM_BUTTON_EXIT);
Void_Cb.Connect (Win, "destroy", Void_Cb.To_Marshaller (Quit'Access));
-- botón Exit
Gtk_New (Button, "EXIT");
Destroyed.Object_Connect (Button,
"clicked",
Destroyed.To_Marshaller (Quit'Access),