text
stringlengths
0
234
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_exit: Gtk.Alignment.Gtk_Alignment;
A_Check_Button1, A_Check_Button2 : Gtk_Check_Button;
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),
Slot_Object => Win);
Button.Set_Size_Request(100, 20);--TAM_BUTTON_EXIT);
Gtk.Alignment.Gtk_New(alinea_button_exit, 0.5, 0.5, 0.0, 0.0);
alinea_button_exit.Add(Button);
-- Double buffer
Double_Buffer.Gtk_New(Buffer);
Buffer.Set_Size_Request(CANVAS_WIDTH, CANVAS_HEIGHT);-- -TAM_BUTTON_EXIT);
-- Botones para la generación de averías
Gtk_New (A_Check_Button1, "Averia en Carril 1");
Widget_Handler.Object_Connect(A_Check_Button1, "clicked",
Widget_Handler.To_Marshaller (Averia1_Generada'ACCESS),
Slot_Object => Win);
Gtk_New (A_Check_Button2, "Averia en Carril 2");
Widget_Handler.Object_Connect(A_Check_Button2, "clicked",
Widget_Handler.To_Marshaller (Averia2_Generada'ACCESS),
Slot_Object => Win);
-- Asociar widgets a la ventana principal y mostrarla
Gtk_New_Hbox (Hbox, Homogeneous => True, Spacing => 10);
Gtk_New_Vbox (Vbox, Homogeneous => False, Spacing => 0);
Pack_Start (Vbox, Buffer);
--Pack_Start (Vbox, Button, Expand => False, Fill => False);
Pack_Start (Vbox, alinea_button_exit);--, Expand => False, Fill => False);
Pack_Start (Vbox, A_Check_Button1);
Pack_Start (Vbox, A_Check_Button2);
Pack_Start (Hbox, Vbox);
Win.Add(Hbox);
Show_All (Win);
--ventana := Get_Window(Gtk_Widget(Buffer));
--Gdk.Window.Move(ventana, 0, 0);
Id := Main_Context_Sources.Timeout_Add (PERIODICIDAD_REDIBUJAR_MILISEGUNDOS,
Draw_Complex_Buffer'Access,
Gtk_Drawing_Area (Buffer));
Gdk_New(pangoLayout, Get_Pango_Context(Buffer));
inbuilt_font := Pango.Font.From_String("Courier");
Pango.Layout.Set_Font_Description(pangoLayout, inbuilt_font);
-- INICIALIZACIÓN DEL ESTADO DE TODOS LOS OBJETOS VISUALIZADOS
Inicializar_Buffer_Coches;
end Inicializar_Interfaz_Grafica;
------------------
-- Draw_Complex --
------------------