-- computerman is multiway user tools.
-- Computerman is Copyright (C) 2024 Manuel De Girardi ; 
--
--   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 := "2024-05-10 09:03:04"
-- Version := "0.0.0r"
with Computer.Strings;
use Computer.Strings;
with Computer.Ansi.Windows;
with Computer.Ansi.Console;
with Computer.Windows;
with Computer.Interfaces;
use Computer.Interfaces;
with Computer.Midi.Sequencer;
use Computer.Midi;
with Computer.Project;
use Computer.Project;
with Computer.Projects_Manager;
use Computer.Projects_Manager;

use Computer;
use Computer.Ansi.Console;
with Computer.Accountant;
use Computer.Accountant;

package Computer.Main is
   Lines : constant Line_Range := 67;
   Columns : constant Column_Range := 240;
   Style   : constant Style_Enum := Color_And_Color;
   
   package Ansi_Windows is new Computer.Ansi.Windows (Lines, Columns);
   package Windows is new Computer.Windows (Lines, Columns, Style, Ansi_Windows);
   
   type Mode_Enum is (None, Shell, Games, Midictrl, 
		      Editor, Moneybox, Manager, Activity,
		      Contacts, Planning, Stocks,
		      Accounting, Dialog, Quit);
   
   
   type Computer_Type;
   
   task type Computer_Process (This : access Computer_Type) is
      entry Initialize;
      entry Halt;
      entry Receive (Wchar : in Wide_Character);
      entry Mode(Mode : out Mode_Enum);
      entry Reset;
      entry Switch (Mode : in Mode_Enum);
      entry Set_On_Esc(Is_Escape : in Boolean);
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;
      entry Screen_Print;
   end Computer_Process ;
   
task type Shell_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Shell_Process;

   task type Game_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Game_Process;
   
   
   task type Midictrl_Process(This : access Computer_Type) is
      entry Initialize;
      entry Start(Tempo : in Tempo_Type);
      entry Stop;
      entry Mod_Rec;
      entry Mod_Play;
      entry Mod_Reset;
      entry Halt;
   end Midictrl_Process;
   
   
   

   
   task type Midiconsole_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Midiconsole_Process;
   
   task type Editor_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Editor_Process;
   
   task type Moneybox_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Moneybox_Process;
   
   task type Manager_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Manager_Process;
   
   
   task type Activity_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Activity_Process;
   
   task type contacts_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end contacts_Process;

   task type planning_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end planning_Process;

   task type stocks_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end stocks_Process;
   
   
   task type Accounting_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Accounting_Process;

      task type Dialog_Process (This : access Computer_Type) is
      --entry Initialize;
      entry Halt;
      entry Suspend;
      entry Wake_Up;
      entry Receive(Wchar : in Wide_Character);
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      entry Screen_Print;
   end Dialog_Process;
   
   
   
   
   use Windows;
   type Accounting_Windows_Type is
      record
	 Voice_Num_Win     : Window_Record;
	 Acc_Num_Win       : Window_Record;
	 Total_Ht_Win      : Window_Record;
	 Total_TVA_Win     : Window_Record;
	 Total_TTC_Win     : Window_Record;
	 Date_Win          : Window_Record;
	 Peer_Win          : Window_Record;	 
      end record;   
   
   type Ticket_Windows_Type is
      record
	 Line_Num_Win      : Window_Record;
	 Description_Win   : Window_Record;
	 Unit_Ht_Win       : Window_Record;
	 Quantity_Win      : Window_Record;
	 Total_Ht_Win      : Window_Record;
	 TVA_Win           : Window_Record;
	 Total_TVA_Win     : Window_Record;
	 Total_TTC_Win     : Window_Record;
      end record;   
   
   type stock_Windows_Type is
      record
	 stock_Num_Win     : Window_Record;
	 Name_Win          : Window_Record;
	 Quantity_Win      : Window_Record;
	 Unit_Ht_Win       : Window_Record;
	 TVA_Win           : Window_Record;

      end record;   

   
   
   
   procedure Initialize(Wins : out Accounting_Windows_Type;
			Space_Left : in Line_Range;
			Width      : in Column_Range;
			L          : in Line_Range;
			C          : in Column_Range);
   
   procedure Initialize(Wins : out Ticket_Windows_Type;
			Space_Left : in Line_Range;
			Width      : in Column_Range;
			L          : in Line_Range;
			C          : in Column_Range);
   
   

   
   type Computer_Type is new Interface_Record with
      record
	 Lines         : Line_Range := 67;
	 Columns       : Column_Range := 240;
	 Term_Name     : Term_Enum := None;
	 
	 Proc          : Computer_Process (Computer_Type'Access);
	 Mode_Cur      : Mode_Enum := None;
	 Mode_Prev     : Mode_Enum := None;
	 
	 Shell         : Shell_Process (Computer_Type'Access);
	 
	 
	 Midiconsole   : Midiconsole_Process (Computer_Type'Access);
	 Game          : Game_Process (Computer_Type'Access);
	 Editor        : Editor_Process (Computer_Type'Access);
	 Moneybox      : Moneybox_Process (Computer_Type'Access);
	 Manager       : Manager_Process (Computer_Type'Access);
	 Activity      : Activity_Process (Computer_Type'Access);
	 Contacts      : Contacts_Process (Computer_Type'Access);
	 Planning      : Planning_Process (Computer_Type'Access);
	 Stocks        : Stocks_Process (Computer_Type'Access);
	 Accounting    : Accounting_Process (Computer_Type'Access);
	 Dialog        : Dialog_Process (Computer_Type'Access);
	 
	 Midictrl      : Midictrl_Process(Computer_Type'Access);
	 Instruments       : access Sequencer.Bandmaster_Record;
	 
	 Ticket_Wins       : Ticket_Windows_Type;
	 
	 Activity_Wins     : Accounting_Windows_Type;
	 Accounting_Wins   : Accounting_Windows_Type;
	 Stocks_Wins       : Stock_Windows_Type;
	 
	 Initialized       : Boolean := False;
	 
	 Projects          : Projects_Record(Project_Num_Range'Last);
	 Archives          : Projects_Record(Project_Num_Range'Last);
	 
      end record;
   
   procedure Initialize (This : in out Computer_Type);
   procedure Run (This : in out Computer_Type);
   procedure Finalize (This : in out Computer_Type);

end Computer.Main ;