-- This program is the last attempt of artificial intelligency with Ada.
-- Elhoim is Copyright (C) 2023 Manuel ; 
--
--   This program is free software; you can redistribute it and/or modify
--   it under the terms of the GNU General Public License as published by
--   the Free Software Foundation; either version 2 of the License, or
--   (at your option) any later version.
--
--   This program is distributed in the hope that it will be useful,
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--   GNU General Public License for more details.
--
--   You should have received a copy of the GNU General Public License
--   along with this program; if not, write to the Free Software
--   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
--
-- Date := "2023-05-05 17:57:22"
-- Version := "0.1.4b"
generic
   Pro_Path : String := ".";
   Ada_Path : String := "/usr/lib/gcc/x86_64-linux-gnu/6/adainclude/";
   Gtk_Path : String := "/usr/share/ada/adainclude/gtkada/";
   Aws_Path : String := "/usr/share/ada/adainclude/aws/";
package Lib.Graphs is
   type Gnose_Record;
   type Gnose_Access is access all Gnose_Record;
   function Gnose_Initialize
     (Gnose_Context : access Gnose_Context_Record;
      Gnose_Params : access Gnose_Parameters_Type)
          return Gnose_Access;
   type Common_Paned_Frame_Type is abstract tagged
      record
	 Frame  : Gtk_Frame;
	 Box    : Gtk_Vbox;
	 Scroll : Gtk_Scrolled_Window;
      end record;
   
   type Machine_Language_Frame_Type is new Common_Paned_Frame_Type with null record;
   
   type Machine_Access is access Machine_Language_Frame_Type;
   
   type Machine_Set is array (Machine_Lang_Enum) of Machine_Access;
   
   type Human_Language_Frame_Type is new Common_Paned_Frame_Type with null record;
   
   type Human_Language_Frame_Access is access all Human_Language_Frame_Type;
   
   
   type Parmeters_Frame_Type is new Common_Paned_Frame_Type with null record;
   
   type Image_Canvas_Record is new Interactive_Canvas_Record with null record;
      
   type Image_Canvas is access all Image_Canvas_Record'Class;
   
   type Display_Item_Record is new Canvas_Item_Record with record
      Canvas : Interactive_Canvas;
      Color  : Gdk.Color.Gdk_Color;
      Title  : Gdk.Color.Gdk_Color;
      W, H   : Gint;
      Num    : Positive;
      Name     : Name_type := (others => ' ');
      Filename : Name_Type := (others => ' ');
   end record;
   
   type Display_Item is access all Display_Item_Record'Class;
   
   
   procedure Draw
     (Item   : access Display_Item_Record;
      Cr     : Cairo_Context);
   --  Draw the item to the double-buffer   
   
   function On_Button_click(Item   : access Display_Item_Record;
			    Event  : Gdk.Event.Gdk_Event_Button) return Boolean;
   
   type Item_Array_Type is array (Positive range <>) of Display_Item;         
   
   
   Item_Max : constant Positive := 8192;
   
   type Canvas_Record_Type is
      record
	 Frame      : Gtk_Frame;
	 Box        : Gtk_Vbox;
	 Scroll     : Gtk_Scrolled_Window;
	 Canvas     : Image_Canvas;
	 Item_Array : Item_Array_Type(1..Item_Max);
	 Item_Last  : Natural := 0;	 
	 ----------------------
	 -- The layout.      --
	 ----------------------
	 Layout : Pango_Layout;
	 X_ads : Gint := 400;
	 Y_ads : Gint := 50;
	 
	 X_adb : Gint := 200;
	 Y_adb : Gint := 100;	 
      end record;
   
   type Canvas_Record_Access is access Canvas_Record_Type;
   
   type Canvas_Set is array (Machine_Lang_Enum) of Canvas_Record_Access;
   
   
   
   type Gnose_Interface_Record is new Gtk_Window_Record with
      record
	 UI            : Gtk_UI_Manager;
	 Actions       : Gtk_Action_Group;
	 Gnostic       : Gnose_Access;	 
	 End_Of_Task   : Boolean := False;
	 
	 Main_Vbox     : Gtk_Vbox;
	 
	 Language_Set   : Machine_Set;
	 
	 System_Frame           : Human_Language_Frame_Type;
	 System_Text_view       : Gtk_Text_view;	
	 System_Text_buffer     : Gtk_Text_buffer;	
	 System_Scroll          : Gtk_Scrolled_Window;	 
	 
	 User_Frame           : Human_Language_Frame_Type;	 	 
	 User_Text_View       : Gtk.Text_View.Gtk_Text_View;	 
	 User_Text_Buffer     : Gtk.Text_Buffer.Gtk_Text_Buffer;
	 User_Handler         : Handler_Id;
	 User_Position        : Natural := 0;
	 User_Scroll          : Gtk_Scrolled_Window;
	 
	 Parmeters_Frame : Parmeters_Frame_Type;
	 
	 
	 Main_Pan : Gtk_Vpaned;
	 Bot_Main_Pan : Gtk_Hpaned;
	 Bot_Second_Pan : Gtk_Hpaned;
	 
	 First_Machines_Left_Pan : Gtk_Vpaned;
	 Second_Machines_Left_Pan : Gtk_Vpaned;
	 
	 Human_Pan : Gtk_Vpaned;
	 
	 Project_Pan : Gtk_Vpaned;
	 
	 Graph_Book : Gtk_Notebook;
	 Book_Index : Natural := 0;
	 Graph_Set  : Canvas_Set;	 	 
	 
   end record;      
   
   type Gnose_Interface_Access is access Gnose_Interface_Record;
   
   type System_Step_Enum is (List, Prepare, Computation, Reload, Update, Clean, Arch, Build, Restart, At_Limit, On_Error);
   
   -- Message Timeout Enumeration :
   type Message_Enum is (Automation_Message,
			 On_Error_Message,
			 System_Step_Message,
			 Computation_message);
   
   type Planning_Enum is (Spec, Impl);

   type Gnose_Record is limited
      record
	 Context              : access Agnose.Gnose_Context_Record;
	 System               : Agnose.Neural.Neural_System;
	 Process              : Gnose_Process(Gnose_Record'Access);	 
	 Gnose_Interface      : Gnose_Interface_Access;
	 Id                   : Process_Id;	 
	 Self_Execute_Timeout : Glib.Main.G_Source_Id;
	 Exit_Result          : Results.Spawn_Result_Type;
	 System_Step          : System_Step_Enum := List;
	 System_Error         : System_Step_Enum := List;
	 Plan                 : Planning_Enum := Spec;
      end record;
      
   package Window_Conversions is new Address_To_Access_Conversions(Gnose_Record);
   
   use Window_Conversions;
   
end Lib.Graphs ;