Advertisement
jovalise

warborg-xborg_0.0.1g

Sep 2nd, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 92.34 KB | None | 0 0
  1. -- Warborg is Wargames playing on network
  2. -- Copyright (C) 2011 Manuel De Girardi
  3.  
  4. -- This Program is Free Software: You Can Redistribute It and/or Modify
  5. -- It Under The Terms of The GNU General Public License As Published By
  6. -- The Free Software Foundation, Either Version 3 of The License, or
  7. -- (at Your Option) Any Later Version.
  8.  
  9. -- This Program is Distributed in The Hope That It Will Be Useful,
  10. -- But WITHOUT ANY WARRANTY; Without Even The Implied Warranty of
  11. -- MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE.  See The
  12. -- GNU General Public License for More Details.
  13.  
  14. -- You Should Have Received A Copy of The GNU General Public License
  15. -- Along with This Program.  if not, See <Http://Www.Gnu.Org/Licenses/>.
  16.  
  17. with Text_Io;
  18.  
  19. --
  20.  
  21. with Gtk.Window;                        use Gtk.Window;
  22. with Gtk.Menu_Bar;                      use Gtk.Menu_Bar;
  23. with Gtk.Menu;                          use Gtk.Menu;
  24. with Gtk.Menu_Item;                     use Gtk.Menu_Item;
  25. with Gtk.Label;                         use Gtk.Label;
  26. with Gtk.Gentry;                        use Gtk.Gentry;
  27. with Gtk.Box;                           use Gtk.Box;
  28. with Gtk.Frame;                         use Gtk.Frame;
  29. with Gtk.Scrolled_Window;               use Gtk.Scrolled_Window;
  30. with Gtk.Adjustment;                    use Gtk.Adjustment;
  31. with Gdk.GC;                            use Gdk.GC;
  32. with Gtkada.Canvas;                     use Gtkada.Canvas;
  33.  
  34. with Gdk.Pixbuf;                        use Gdk.Pixbuf;
  35. with Gdk.Color;           use Gdk.Color;
  36. with Pango.Layout;        use Pango.Layout;
  37.  
  38.  
  39. with Gtk.Paned;                         use Gtk.Paned;
  40.  
  41.  
  42. with Gtk.Tree_View;            use Gtk.Tree_View;
  43. with Gtk.Tree_Store;           use Gtk.Tree_Store;
  44. with Gtk.Tree_Model;           use Gtk.Tree_Model;
  45. with Gtk.Tree_View_Column;     use Gtk.Tree_View_Column;
  46. with Gtk.Cell_Renderer_Text;   use Gtk.Cell_Renderer_Text;
  47. with Gtk.Tree_Selection;       use Gtk.Tree_Selection;
  48. with Glib.Values;               use Glib.Values;
  49.  
  50. with Gtk.Button;                        use Gtk.Button;
  51. with Gtk.Spin_Button;                   use Gtk.Spin_Button;
  52.  
  53. with Gtk.Status_Bar;                    use Gtk.Status_Bar;
  54. with Gtk.Handlers;                      use Gtk.Handlers;
  55.  
  56. pragma Elaborate_All (Gtk.Handlers);
  57.  
  58. with Gtk.Dialog;                        use Gtk.Dialog;
  59. with Gtk.Stock;                         use Gtk.Stock;
  60. with Gtk.Enums;                         use Gtk.Enums;
  61. with Gtk.Widget;                        use Gtk.Widget;
  62. with Gtk.Main;
  63.  
  64. with Gdk.Window;                        use Gdk.Window;
  65.  
  66. with Gdk.Rectangle;                     use Gdk.Rectangle;
  67. with Gtk.Style;                         use Gtk.Style;
  68. with Gdk.Drawable;                      use Gdk.Drawable;
  69. with Glib.Error;                        use Glib.Error;
  70. use Glib;
  71.  
  72.  
  73.  
  74. with Calendar;                          use Calendar;
  75. with Dates;                             use Dates;
  76.  
  77. with Gnat.MD5, Gnat.Os_Lib, Gnat.Sockets;
  78. use Gnat;
  79. with Ada.Unchecked_Deallocation;
  80.  
  81.  
  82. with Ada.Streams.Stream_Io;
  83. use Ada.Streams;
  84.  
  85. with Ada.Strings.Unbounded;             use Ada.Strings.Unbounded;
  86. with Ada.Strings.Fixed;
  87. use Ada.Strings;
  88.  
  89. with Warborg.System;                    use Warborg.System;
  90. package body Warborg.Xborg is
  91.    task type Process_Type(Main_Window : access Main_Window_Type) is
  92.       entry Login(Address : in String;
  93.                   Logname : in String;
  94.                   Passwd  : in String;
  95.                   Success : out boolean);
  96.       entry Receive(Content : in String);
  97.       entry Create_Wopr;
  98.       entry Create_Missil;
  99.       entry Launch_One(Num : in Positive);
  100.       entry Launch_All;
  101.       entry Refresh;
  102.    end Process_Type;
  103.  
  104.  
  105.    type Image_Canvas_Record is new Interactive_Canvas_Record with record
  106.       Background : Gdk_Pixbuf;
  107.       Draw_Grid  : Boolean := False;
  108.       Grid_GC    : Gdk_GC;
  109.    end record;
  110.  
  111.    type Image_Canvas is access all Image_Canvas_Record'Class;
  112.  
  113.    procedure Draw_Background
  114.      (Canvas        : access Image_Canvas_Record;
  115.       Screen_Rect   : Gdk.Rectangle.Gdk_Rectangle);
  116.  
  117.    type Display_Item_Record is new buffered_Item_Record with record
  118.       Canvas : Interactive_Canvas;
  119.       Color  : Gdk.Color.Gdk_Color;
  120.       W, H   : Gint;
  121.       Num    : Positive;
  122.       Timeout_Id : Gtk.Main.Timeout_Handler_Id;
  123.       Decalage : Duration := 0.0;
  124.    end record;
  125.    type Display_Item is access all Display_Item_Record'Class;
  126.  
  127.  
  128.    Max_Colors : constant := 20;
  129.    type Color_Type is range 1 .. Max_Colors;
  130.    Color_Names : constant array (Color_Type) of String_Access :=
  131.      (new String'("forest green"),
  132.       new String'("red"),
  133.       new String'("blue"),
  134.       new String'("yellow"),
  135.       new String'("peach puff"),
  136.       new String'("azure"),
  137.       new String'("seashell"),
  138.       new String'("lavender"),
  139.       new String'("grey"),
  140.       new String'("turquoise"),
  141.       new String'("khaki"),
  142.       new String'("tan"),
  143.       new String'("orange red"),
  144.       new String'("MediumPurple"),
  145.       new String'("ivory1"),
  146.       new String'("DeepSkyBlue1"),
  147.       new String'("burlywood1"),
  148.       new String'("wheat1"),
  149.       new String'("orange1"),
  150.       new String'("pink"));
  151.  
  152.    Colors : array (Color_Type) of Gdk_Color;
  153.  
  154.  
  155.    type Wopr_Attributes_Window is
  156.       record
  157.          Dialog : Gtk_window;
  158.  
  159.          Degr_Lat : Gtk_Spin_Button;
  160.          Minu_Lat : Gtk_Spin_Button;
  161.          Seco_Lat : Gtk_Spin_Button;
  162.          Degr_Lon : Gtk_Spin_Button;
  163.          Minu_Lon : Gtk_Spin_Button;
  164.          Seco_Lon : Gtk_Spin_Button;
  165.          Lat_Hbox : Gtk_Hbox;
  166.          Lon_Hbox : Gtk_Hbox;
  167.  
  168.          Lat_Label: Gtk_Label;
  169.          Lon_Label : Gtk_Label;
  170.          Ok_Button: Gtk_Button;
  171.          Cancel_Button: Gtk_Button;
  172.          Button_Hbox : Gtk_Hbox;
  173.          Main_Vbox : Gtk_Vbox;
  174.       end record;
  175.  
  176.  
  177.    type Missil_Attributes_Window is
  178.       record
  179.          Dialog          : Gtk_window;
  180.          Source_Label    : Gtk_Label;
  181.          Source_Degr_Lat : Gtk_Spin_Button;
  182.          Source_Minu_Lat : Gtk_Spin_Button;
  183.          Source_Seco_Lat : Gtk_Spin_Button;
  184.          Source_Degr_Lon : Gtk_Spin_Button;
  185.          Source_Minu_Lon : Gtk_Spin_Button;
  186.          Source_Seco_Lon : Gtk_Spin_Button;
  187.          Source_Lat_Hbox : Gtk_Hbox;
  188.          Source_Lon_Hbox : Gtk_Hbox;
  189.          Target_Label    : Gtk_Label;
  190.          Target_Degr_Lat : Gtk_Spin_Button;
  191.          Target_Minu_Lat : Gtk_Spin_Button;
  192.          Target_Seco_Lat : Gtk_Spin_Button;
  193.          Target_Degr_Lon : Gtk_Spin_Button;
  194.          Target_Minu_Lon : Gtk_Spin_Button;
  195.          Target_Seco_Lon : Gtk_Spin_Button;
  196.          Target_Lat_Hbox : Gtk_Hbox;
  197.          Target_Lon_Hbox : Gtk_Hbox;
  198.          Charge          : Gtk_Spin_Button;
  199.          Charge_Label    : Gtk_Label;
  200.          Charge_Hbox     : Gtk_Hbox;
  201.          Lat_Label: Gtk_Label;
  202.          Lon_Label : Gtk_Label;
  203.          Ok_Button: Gtk_Button;
  204.          Cancel_Button: Gtk_Button;
  205.          Button_Hbox : Gtk_Hbox;
  206.          Main_Vbox : Gtk_Vbox;
  207.       end record;
  208.  
  209.    type Missil_Unit_Config is
  210.       record
  211.          Source_Degr_Lat : Gtk_Spin_Button;
  212.          Source_Minu_Lat : Gtk_Spin_Button;
  213.          Source_Seco_Lat : Gtk_Spin_Button;
  214.          Source_Degr_Lon : Gtk_Spin_Button;
  215.          Source_Minu_Lon : Gtk_Spin_Button;
  216.          Source_Seco_Lon : Gtk_Spin_Button;
  217.          Target_Degr_Lat : Gtk_Spin_Button;
  218.          Target_Minu_Lat : Gtk_Spin_Button;
  219.          Target_Seco_Lat : Gtk_Spin_Button;
  220.          Target_Degr_Lon : Gtk_Spin_Button;
  221.          Target_Minu_Lon : Gtk_Spin_Button;
  222.          Target_Seco_Lon : Gtk_Spin_Button;
  223.          Charge          : Gtk_Spin_Button;
  224.  
  225.       end record;
  226.  
  227.    type Missil_Unit_Access is access all Missil_Unit_Config;
  228.  
  229.    package Missils_Config_Vectors is new Ada.Containers.Vectors(Positive, Missil_Unit_Access, "=");
  230.  
  231.    type Missil_Group_Config is
  232.       record
  233.          Dialog          : Gtk_window;
  234.          Source_Label    : Gtk_Label;
  235.          Target_Label    : Gtk_Label;
  236.          Lat_Label: Gtk_Label;
  237.          Lon_Label : Gtk_Label;
  238.          Source_Lat_Hbox : Gtk_Hbox;
  239.          Source_Lon_Hbox : Gtk_Hbox;
  240.          Target_Lat_Hbox : Gtk_Hbox;
  241.          Target_Lon_Hbox : Gtk_Hbox;
  242.          Charge_Label    : Gtk_Label;
  243.          Charge_Hbox     : Gtk_Hbox;
  244.          Ok_Button: Gtk_Button;
  245.          Cancel_Button: Gtk_Button;
  246.          Button_Hbox : Gtk_Hbox;
  247.          Main_Vbox : Gtk_Vbox;
  248.          Missil_vector : Missils_Config_Vectors.Vector;
  249.       end record;
  250.  
  251.    type Item_Table_Type is array (Positive range <>) of Canvas_Item;
  252.  
  253.  
  254.    type Main_Window_Type is limited
  255.       record
  256.          Main_Window                : Gtk_Window;
  257.          Main_Vbox                  : Gtk_Vbox;
  258.          Menu_Hbox                  : Gtk_Hbox;
  259.          Main_Menu_bar              : Gtk_Menu_Bar;
  260.          File_Menu                  : Gtk_Menu;
  261.          File_Menu_Item             : Gtk_Menu_Item;
  262.          Exit_Menu_Item             : Gtk_Menu_Item;
  263.          Zoom_Menu                  : Gtk_Menu;
  264.          Zoom_Menu_Item             : Gtk_Menu_Item;
  265.          Zoom_Backward_Item         : Gtk_Menu_Item;
  266.          Zoom_Foreward_Item         : Gtk_Menu_Item;
  267.          Canvas_Menu                : Gtk_Menu;
  268.          Canvas_Menu_Item           : Gtk_Menu_Item;
  269.          Clear_Canvas_Menu_Item     : Gtk_Menu_Item;
  270.          Search_Menu                : Gtk_Menu;
  271.          Search_Menu_Item           : Gtk_Menu_Item;
  272.          Ant_Colony_Menu_Item       : Gtk_Menu_Item;
  273.          Ant_Colony_Conf_Menu_Item  : Gtk_Menu_Item;
  274.          Missils_Menu               : Gtk_Menu;
  275.          Missils_Menu_item          : Gtk_Menu_Item;
  276.          Launch_All_item            : Gtk_Menu_Item;
  277.          Launch_One_item            : Gtk_Menu_Item;
  278.          Create_One_Item            : Gtk_Menu_Item;
  279.          Create_Group_Item          : Gtk_Menu_Item;
  280.          Config_Group_Item          : Gtk_Menu_Item;
  281.  
  282.          Host_Label                 : Gtk_Label;
  283.          Host_Entry                 : Gtk_Gentry;
  284.  
  285.          Date_Label                 : Gtk_Label;
  286.  
  287.          Main_Frame                 : Gtk_Frame;
  288.          Scrolled                   : Gtk_Scrolled_Window;
  289.          Canvas                     : Image_Canvas := new Image_Canvas_Record;
  290.  
  291.          Status_Bar                 : Gtk_Status_Bar;
  292.  
  293.          Geometry                   : Gdk_Geometry := (1, 1, 1200, 855,
  294.                                                        1200, 855, 1, 1, 1.0, 1.0,
  295.                                                        Gravity_Center);
  296.  
  297.  
  298.  
  299.          Logname                    : access String;
  300.          Login_Dialog               : Gtk_Window;
  301.          Login_Vbox                 : Gtk_Vbox;
  302.          Login_Hbox                 : Gtk_Hbox;
  303.          Login_Label                : Gtk_Label;
  304.          Login_Logname              : Gtk_Gentry;
  305.          Logname_Hbox               : Gtk_Hbox;
  306.          Logname_label              : Gtk_Label;
  307.          Login_Passwd               : Gtk_Gentry;
  308.          Passwd_Hbox                : Gtk_Hbox;
  309.          passwd_label               : Gtk_Label;
  310.          Login_Ok                   : Gtk_Button;
  311.          Login_cancel               : Gtk_Button;
  312.  
  313.          Main_Hpaned                : Gtk_Paned;
  314.          Right_Scroll               : Gtk_Scrolled_Window;
  315.  
  316.  
  317.          Tree_View_Names            : Gtk_Tree_View;
  318.          Model                      : Gtk_Tree_Store;
  319.          Col                        : Gtk_Tree_View_Column;
  320.          Num_Col                    : Gint := 0;
  321.  
  322.          Wopr_Window                : Wopr_Attributes_Window;
  323.          Missil                     : Missil_Attributes_Window;
  324.  
  325.  
  326.          Process                    : Process_Type(Main_Window_Type'Access);
  327.  
  328.          Wopr                       : Wopr_Type;
  329.  
  330.  
  331.          Items_List                 : Item_Table_type(1..500);
  332.          Num                        : Positive := 1;
  333.          External_Items_List        : Item_Table_type(1..5000);
  334.          External_Num               : Positive := 1;
  335.  
  336.          One_Missil                 : Missil_Type;
  337.  
  338.  
  339.          Enemy                      : Missils_Vectors.Vector;
  340.  
  341.          Missils_Group              : Missil_Group_Config;
  342.          One_Missil_Launch          : Gtk_Spin_Button;
  343.          Launch_Window              : Gtk_Window;
  344.       end record;
  345.  
  346.    procedure Initialize(Main_Window : out Main_Window_Access);
  347.  
  348.    Green_Gc : Gdk.GC.Gdk_GC;
  349.    Layout : Pango_Layout;
  350.  
  351.    procedure Draw_wopr (Item : access Display_Item_Record'Class) is
  352.    begin
  353.       Set_Foreground (Green_Gc, Display_Item (Item).Color);
  354.       Draw_Rectangle
  355.         (Pixmap (Item),
  356.          GC     => Green_Gc,
  357.          Filled => True,
  358.          X      => 0,
  359.          Y      => 0,
  360.          Width  => Item.W,
  361.          Height => Item.H);
  362.       Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
  363.  
  364.       Set_Text (Layout, "Wopr");
  365.       Draw_Layout
  366.         (Pixmap (Item),
  367.          Green_Gc,
  368.          10,
  369.          10,
  370.          Layout);
  371.  
  372.       Draw_Shadow
  373.         (Style       => Get_Style (Item.Canvas),
  374.          Window      => Pixmap (Item),
  375.          State_Type  => State_Normal,
  376.          Shadow_Type => Shadow_Out,
  377.          X           => 0,
  378.          Y           => 0,
  379.          Width       => Item.W,
  380.          Height      => Item.H);
  381.  
  382.  
  383.    end Draw_wopr;
  384.  
  385.  
  386.  
  387.    ----------------
  388.    -- Initialize --
  389.    ----------------
  390.  
  391.    procedure Initialize_Wopr(Main_Window : in Main_Window_Access;
  392.                              Item   : access Display_Item_Record'Class) is
  393.    begin
  394.       Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
  395.       Item.Color := Colors (13);
  396.       Item.W := 50;
  397.       Item.H := 35;
  398.       Item.Num := 1;
  399.       Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
  400.       Main_Window.Num := Main_Window.Num + 1;
  401.       Set_Screen_Size (Item, Item.W, Item.H);
  402.  
  403.       Draw_wopr (Item);
  404.    end Initialize_wopr;
  405.  
  406.    ---------------------
  407.    -- Add_Single_Item --
  408.    ---------------------
  409.  
  410.    procedure Add_Wopr_Item (Main_window : in Main_Window_Access) is
  411.  
  412.       Item : constant Display_Item := new Display_Item_Record;
  413.    begin
  414.       Initialize_wopr (Main_Window, Item);
  415.       Put (Main_Window.Canvas, Item, Gint(Main_Window.Wopr.Wopr_Attributes.Source.X), Gint(Main_Window.Wopr.Wopr_Attributes.Source.Y));
  416.  
  417.       Refresh_Canvas (Main_Window.Canvas);
  418.       Show_Item (Main_Window.Canvas, Item);
  419.    end Add_Wopr_Item;
  420.  
  421.  
  422.  
  423.  
  424.       package Date_Timeout is new Gtk.Main.Timeout(Main_Window_Access);
  425.  
  426.  
  427.  
  428.       package Main_Handlers is new Gtk.Handlers.User_Callback(Gtk.Widget.Gtk_Widget_Record, Main_Window_access);
  429.       package Main_Return_Handlers is new Gtk.Handlers.User_Return_Callback(Gtk.Widget.Gtk_Widget_Record, Boolean, Main_Window_Access);
  430.  
  431.  
  432.  
  433.  
  434.    procedure Main_Quit
  435.      (widget : access Gtk_Widget_Record'class;
  436.       Main_Window : in Main_Window_Access) is
  437.       Dialog : Gtk.Dialog.Gtk_Dialog;
  438.       Yes    : Gtk.Widget.Gtk_Widget;
  439.       No     : Gtk.Widget.Gtk_Widget;
  440.       Help   : Gtk.Widget.Gtk_Widget;
  441.    begin
  442.  
  443.       loop
  444.          Gtk.Dialog.Gtk_New(Dialog, "Quit ?", Main_Window.Main_Window, Gtk.dialog.modal);
  445.          Yes := Gtk.Dialog.Add_Button(Dialog, "Yes", Gtk.Dialog.Gtk_Response_Yes);
  446.          No := Gtk.Dialog.Add_Button(Dialog, "No", Gtk.Dialog.Gtk_Response_No);
  447.          Help := Gtk.Dialog.Add_Button(Dialog, "Help", Gtk.Dialog.Gtk_Response_Help);
  448.          case Gtk.Dialog.Run(Dialog) is
  449.             when Gtk.Dialog.Gtk_Response_Yes    =>
  450.                Gtk.Dialog.Destroy(Dialog);
  451.  
  452.                abort Main_Window.Process;
  453.                Gtk.Main.Gtk_Exit (0);
  454.                exit;
  455.             when Gtk.Dialog.Gtk_Response_No     =>
  456.                Gtk.Dialog.Destroy(Dialog);
  457.                exit;
  458.             when Gtk.Dialog.Gtk_Response_Help   =>
  459.                Gtk.Dialog.Destroy(Dialog);
  460.             when others =>
  461.                Gtk.Dialog.Destroy(Dialog);
  462.          end case;
  463.       end loop;
  464.    end Main_Quit;
  465.  
  466.  
  467.    function Main_Destroy
  468.      (widget : access Gtk_Widget_Record'class;
  469.       Main_Window : in Main_Window_Access) return Boolean is
  470.       Dialog : Gtk.Dialog.Gtk_Dialog;
  471.       Yes    : Gtk.Widget.Gtk_Widget;
  472.       No     : Gtk.Widget.Gtk_Widget;
  473.       Help   : Gtk.Widget.Gtk_Widget;
  474.    begin
  475.  
  476.       loop
  477.          Gtk.Dialog.Gtk_New(Dialog, "Quit ?", Main_Window.Main_Window, Gtk.dialog.modal);
  478.          Yes := Gtk.Dialog.Add_Button(Dialog, "Yes", Gtk.Dialog.Gtk_Response_Yes);
  479.          No := Gtk.Dialog.Add_Button(Dialog, "No", Gtk.Dialog.Gtk_Response_No);
  480.          Help := Gtk.Dialog.Add_Button(Dialog, "Help", Gtk.Dialog.Gtk_Response_Help);
  481.          case Gtk.Dialog.Run(Dialog) is
  482.             when Gtk.Dialog.Gtk_Response_Yes    =>
  483.                Gtk.Dialog.Destroy(Dialog);
  484.  
  485.                abort Main_Window.Process;
  486.                Gtk.Main.Gtk_Exit (0);
  487.                return False;
  488.             when Gtk.Dialog.Gtk_Response_No     =>
  489.                Gtk.Dialog.Destroy(Dialog);
  490.                return True;
  491.             when Gtk.Dialog.Gtk_Response_Help   =>
  492.                Gtk.Dialog.Destroy(Dialog);
  493.             when others =>
  494.                Gtk.Dialog.Destroy(Dialog);
  495.          end case;
  496.       end loop;
  497.    end Main_Destroy;
  498.  
  499.  
  500.  
  501.    procedure Draw_Background
  502.      (Canvas        : access Image_Canvas_Record;
  503.       Screen_Rect   : Gdk.Rectangle.Gdk_Rectangle)
  504.    is
  505.       X_Left : constant Glib.Gint := Left_World_Coordinates (Canvas);
  506.       Y_Top  : constant Glib.Gint := Top_World_Coordinates (Canvas);
  507.    begin
  508.       if Canvas.Background /= null then
  509.          --  This is slightly complex, since we need to properly handle zooming
  510.          --  and tiling.
  511.          declare
  512.             X, Y, W, H, Ys : Gint;
  513.             Xs : Gint := Screen_Rect.X;
  514.             Bw : constant Gint := Get_Width (Canvas.Background)
  515.               * Gint (Get_Zoom (Canvas)) / 100;
  516.             Bh : constant Gint := Get_Height (Canvas.Background)
  517.               * Gint (Get_Zoom (Canvas)) / 100;
  518.             Scaled : Gdk_Pixbuf := Canvas.Background;
  519.          begin
  520.             --  A real application would cache this scaled pixmap, and update
  521.             --  the cache when the "zoomed" signal is emitted.
  522.             if Get_Zoom (Canvas) /= 100 then
  523.                Scaled := Scale_Simple (Canvas.Background, Bw, Bh);
  524.             end if;
  525.  
  526.             while Xs < Screen_Rect.X + Screen_Rect.Width loop
  527.                Ys := Screen_Rect.Y;
  528.                X := (X_Left + Xs) mod Bw;
  529.                W := Gint'Min (Screen_Rect.Width + Screen_Rect.X - Xs, Bw - X);
  530.  
  531.                while Ys < Screen_Rect.Y + Screen_Rect.Height loop
  532.                   Y := (Y_Top  + Ys) mod Bh;
  533.                   H := Gint'Min
  534.                     (Screen_Rect.Height + Screen_Rect.Y - Ys, Bh - Y);
  535.  
  536.                   Render_To_Drawable
  537.                     (Pixbuf       => Scaled,
  538.                      Drawable     => Get_Window (Canvas),
  539.                      Gc           => Get_Black_GC (Get_Style (Canvas)),
  540.                      Src_X        => X,
  541.                      Src_Y        => Y,
  542.                      Dest_X       => Xs,
  543.                      Dest_Y       => Ys,
  544.                      Width        => W,
  545.                      Height       => H);
  546.                   Ys := Ys + H;
  547.                end loop;
  548.                Xs := Xs + W;
  549.             end loop;
  550.  
  551.             if Get_Zoom (Canvas) /= 100 then
  552.                Unref (Scaled);
  553.             end if;
  554.          end;
  555.  
  556.       else
  557.          Draw_Rectangle
  558.            (Get_Window (Canvas),
  559.             Get_Background_GC (Get_Style (Canvas), State_Normal),
  560.             Filled => True,
  561.             X      => Screen_Rect.X,
  562.             Y      => Screen_Rect.Y,
  563.             Width  => Gint (Screen_Rect.Width),
  564.             Height => Gint (Screen_Rect.Height));
  565.       end if;
  566.       if Canvas.Draw_Grid then
  567.          Draw_Grid (Interactive_Canvas (Canvas), Canvas.Grid_GC, Screen_Rect);
  568.       end if;
  569.    end Draw_Background;
  570.  
  571.  
  572.    procedure Set_Background(Widget : access Gtk_Widget_Record'Class;
  573.                             Main_window  : Main_Window_access)
  574.    is
  575.       Error : GError;
  576.    begin
  577.       Gdk_New_From_File
  578.         (Main_Window.Canvas.Background,
  579.          Filename => "./background4.jpg",
  580.          Error    => Error);
  581.       Main_Window.Canvas.Grid_GC := Get_White_GC (Get_Style (Main_Window.Canvas));
  582.       Refresh_Canvas (Main_Window.Canvas);
  583.    end Set_Background;
  584.  
  585.  
  586.  
  587.    Zoom_Levels : constant array (Positive range <>) of Guint :=
  588.      (100, 125, 150, 200, 300, 400);
  589.  
  590.    -------------
  591.    -- Zoom_In --
  592.    -------------
  593.  
  594.    procedure Zoom_In(Widget : access Gtk_Widget_Record'Class;
  595.                      Main_Window : in Main_Window_Access) is
  596.       --H_Adjustment : Gtk_Adjustment;
  597.       --V_Adjustment : Gtk_Adjustment;
  598.    begin
  599.       for J in Zoom_Levels'First .. Zoom_Levels'Last - 1 loop
  600.          if Zoom_Levels (J) = Get_Zoom (Main_Window.Canvas) then
  601.             Zoom (Main_Window.Canvas, Zoom_Levels (J + 1), 5);
  602.             --  Gtk_New(H_Adjustment,
  603. --                      0.0,
  604. --                      0.0,
  605. --                      1024.0*(Gdouble(Zoom_Levels(J+1))/100.0),
  606. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  607. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  608. --                      1024.0/(Gdouble(Zoom_Levels(J+1))/100.0));
  609. --              Gtk_New(V_Adjustment,
  610. --                      0.0,
  611. --                      0.0,
  612. --                      768.0*(Gdouble(Zoom_Levels(J+1))/100.0),
  613. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  614. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  615. --                      768.0/(Gdouble(Zoom_Levels(J+1))/100.0));
  616. --              Set_HAdjustment(Main_Window.Scrolled, H_Adjustment);
  617. --              Set_Vadjustment(Main_Window.Scrolled, V_Adjustment);
  618.          end if;
  619.       end loop;
  620.  
  621.    end Zoom_In;
  622.  
  623.    --------------
  624.    -- Zoom_Out --
  625.    --------------
  626.  
  627.    procedure Zoom_Out(Widget : access Gtk_Widget_Record'Class;
  628.                       Main_Window : in Main_Window_Access) is
  629.       --H_Adjustment : Gtk_Adjustment;
  630.       --V_Adjustment : Gtk_Adjustment;
  631.    begin
  632.       for J in Zoom_Levels'First + 1 .. Zoom_Levels'Last loop
  633.          if Zoom_Levels (J) = Get_Zoom (Main_Window.Canvas) then
  634.             Zoom (Main_Window.Canvas, Zoom_Levels (J - 1), 5);
  635.             --  Gtk_New(H_Adjustment,
  636. --                      0.0,
  637. --                      0.0,
  638. --                      1024.0*(Gdouble(Zoom_Levels(J+1))/100.0),
  639. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  640. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  641. --                      1024.0/(Gdouble(Zoom_Levels(J+1))/100.0));
  642. --              Gtk_New(V_Adjustment,
  643. --                      0.0,
  644. --                      0.0,
  645. --                      768.0*(Gdouble(Zoom_Levels(J+1))/100.0),
  646. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  647. --                      Gdouble(Zoom_Levels(J+1))/100.0,
  648. --                      768.0/(Gdouble(Zoom_Levels(J+1))/100.0));
  649.  
  650. --              Set_hadjustment(Main_Window.Scrolled, H_Adjustment);
  651. --              Set_Vadjustment(Main_Window.Scrolled, V_Adjustment);
  652.          end if;
  653.       end loop;
  654.    end Zoom_Out;
  655.  
  656.  
  657.    function UpDate(Main_Window : Main_Window_Access) return Boolean is
  658.    begin
  659.       Set_Label(Main_Window.Date_label,  "Date : " & Long_Time2string(clock));
  660.       Queue_draw(Main_Window.Date_label);
  661.       return True;
  662.    end UpDate;
  663.  
  664.  
  665.    procedure Login
  666.      (widget : access Gtk_Widget_Record'class;
  667.       Main_Window : in Main_Window_Access) is
  668.       Success : Boolean;
  669.  
  670.       Ok_dialog : Gtk_dialog;
  671.       Ok        : Gtk_Widget;
  672.  
  673.    begin
  674.       Main_Window.Process.Login(Get_Text(Main_Window.Host_entry),
  675.                           Get_Text(Main_Window.Login_Logname),
  676.                           Get_Text(Main_Window.Login_Passwd),
  677.                           success);
  678.       if Success then
  679.          Main_Window.Logname := new String ' (Get_Text(Main_Window.Login_Logname));
  680.          Destroy(Main_Window.Login_Dialog);
  681.  
  682.  
  683.       else
  684.          Gtk.Dialog.Gtk_New(Ok_Dialog, "Login failure", Main_Window.Main_Window, Gtk.dialog.modal);
  685.          Ok := Gtk.Dialog.Add_Button(Ok_Dialog, "OK", Gtk.Dialog.Gtk_Response_Ok);
  686.          case Gtk.Dialog.Run(Ok_Dialog) is
  687.             when Gtk.Dialog.Gtk_Response_Ok =>
  688.                Gtk.Dialog.Destroy(Ok_Dialog);
  689.             when others =>
  690.                Gtk.Dialog.Destroy(Ok_Dialog);
  691.          end case;
  692.       end if;
  693.  
  694.    end Login;
  695.  
  696.  
  697.    procedure Host_Entry_activate
  698.      (widget : access Gtk_Widget_Record'class;
  699.       Main_Window : in Main_Window_Access) is
  700.       Text : access String := new String ' (Get_Text(Main_Window.Host_entry));
  701.    begin
  702.       Gtk_New(Main_Window.Login_Dialog);
  703.       Set_Default_Size(Main_Window.Login_dialog, 250, 150);
  704.       Set_Position(Main_Window.Login_dialog, Win_Pos_Center);
  705.       Set_Title(Main_Window.Login_Dialog, "Login...");
  706.       Gtk_New_Vbox(Main_Window.Login_Vbox);
  707.       Gtk_New_Hbox(Main_Window.Login_Hbox);
  708.       Gtk_New(Main_Window.Login_Label, "Login to : " & Text.all);
  709.       Gtk_New(Main_Window.Login_Logname);
  710.       Gtk_New_Hbox(Main_Window.Logname_Hbox);
  711.       Gtk_New(Main_Window.Logname_Label, "Logname : ");
  712.       Gtk_New(Main_Window.Login_Passwd);
  713.       Set_visibility(Main_Window.Login_Passwd, false);
  714.       Gtk_New(Main_Window.Passwd_label, "Passowrd : ");
  715.       Gtk_New_Hbox(Main_Window.Passwd_Hbox);
  716.       Gtk_New_From_stock(Main_Window.Login_Ok, Stock_Ok);
  717.       Gtk_New_From_stock(Main_Window.Login_Cancel, Stock_Cancel);
  718.       Pack_Start(Main_Window.Logname_Hbox, Main_Window.Logname_Label);
  719.       Pack_Start(Main_Window.Logname_Hbox, Main_Window.Login_Logname, False, False, 0);
  720.       Pack_Start(Main_Window.Passwd_Hbox, Main_Window.Passwd_Label);
  721.       Pack_Start(Main_Window.Passwd_Hbox, Main_Window.Login_Passwd, False, False, 0);
  722.       Pack_Start(Main_Window.Login_Vbox, Main_Window.Login_Label);
  723.       Pack_Start(Main_Window.Login_Vbox, Main_Window.Logname_Hbox);
  724.       Pack_Start(Main_Window.Login_Vbox, Main_Window.passwd_Hbox);
  725.       Pack_Start(Main_Window.Login_Hbox, Main_Window.Login_Ok, False, False, 0);
  726.       Pack_Start(Main_Window.Login_Hbox, Main_Window.Login_Cancel, False, False, 0);
  727.       Pack_Start(Main_Window.Login_Vbox, Main_Window.Login_Hbox);
  728.       Add(Main_Window.Login_Dialog, Main_Window.Login_Vbox);
  729.       Show_All(Main_Window.Login_Dialog);
  730.  
  731.       Main_handlers.Connect
  732.         (Main_Window.Login_Ok, "clicked", Main_handlers.To_Marshaller (login'access), Main_Window);
  733.  
  734.  
  735.    end Host_Entry_Activate;
  736.  
  737.  
  738.    -----------
  739.    -- Clear --
  740.    -----------
  741.  
  742.    procedure Clear_canvas (widget : access Gtk_Widget_Record'class;
  743.                           Main_Window : in Main_Window_Access) is
  744.       function Remove_Internal
  745.         (Canvas : access Interactive_Canvas_Record'Class;
  746.          Item   : access Canvas_Item_Record'Class) return Boolean is
  747.  
  748.       begin
  749.  
  750.          Remove (Canvas, Item);
  751.          return True;
  752.       end Remove_Internal;
  753.  
  754.    begin
  755.       Text_Io.Put("Clear");
  756.       For_Each_Item (Main_Window.Canvas, Remove_Internal'Unrestricted_Access);
  757.       Text_Io.Put("Clear 1");
  758.       Refresh_Canvas (Main_Window.Canvas);
  759.    end Clear_canvas;
  760.  
  761.    package Interactive_Simple_Cb is new Gtk.Handlers.Callback
  762.      (interactive_Canvas_Record);
  763.  
  764.  
  765.    procedure On_List_Selection(widget : access Gtk_Widget_Record'class;
  766.                                Main_Window : in Main_Window_Access) is
  767.  
  768.       Selection : Gtk_Tree_Selection;
  769.       Iter      : Gtk_Tree_Iter;
  770.       Model     : Gtk_Tree_Model;
  771.       Value     : Gvalue;
  772.       Logname   : access String;
  773.    begin
  774.       Text_Io.Put("Names Selection");
  775.       Selection := Get_Selection(Main_Window.Tree_View_names);
  776.       Text_Io.Put("Get_selection");
  777.       Get_Selected(Selection, Model, iter);
  778.       if Iter /= Null_Iter then
  779.          Text_Io.Put("Get_Gvalue");
  780.          Get_Value(Model, Iter, 0, value);
  781.          Text_Io.Put("Get_String");
  782.          Logname := new String' (Get_String(Value, 128));
  783.          Text_Io.Put_Line(Logname.all);
  784.          Main_Window.Process.Receive(Logname.all);
  785.       end if;
  786.  
  787.    end On_List_Selection;
  788.  
  789.  
  790.    procedure Add_Canvas_Link
  791.      (Canvas : access Interactive_Canvas_Record'Class;
  792.       Item1, Item2 : access Canvas_Item_Record'Class; Text : String := "");
  793.    --  Add a link between Item1 and Item2
  794.  
  795.  
  796.    ---------------------------
  797.    -- Draw_To_Double_Buffer --
  798.    ---------------------------
  799.  
  800.  
  801.    procedure Draw_External_Missil (Item : access Display_Item_Record'Class) is
  802.    begin
  803.       Set_Foreground (Green_Gc, Display_Item (Item).Color);
  804.       Draw_Rectangle
  805.         (Pixmap (Item),
  806.          GC     => Green_Gc,
  807.          Filled => True,
  808.          X      => 0,
  809.          Y      => 0,
  810.          Width  => Item.W,
  811.          Height => Item.H);
  812.       Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
  813.  
  814.       Set_Text (Layout, "Missil" & Positive'Image (Display_Item (Item).Num));
  815.       Draw_Layout
  816.         (Pixmap (Item),
  817.          Green_Gc,
  818.          10,
  819.          10,
  820.          Layout);
  821.  
  822.       Draw_Shadow
  823.         (Style       => Get_Style (Item.Canvas),
  824.          Window      => Pixmap (Item),
  825.          State_Type  => State_Normal,
  826.          Shadow_Type => Shadow_Out,
  827.          X           => 0,
  828.          Y           => 0,
  829.          Width       => Item.W,
  830.          Height      => Item.H);
  831.    end Draw_External_Missil;
  832.  
  833.  
  834.    procedure Draw_Missil (Item : access Display_Item_Record'Class) is
  835.    begin
  836.       Set_Foreground (Green_Gc, Display_Item (Item).Color);
  837.       Draw_Rectangle
  838.         (Pixmap (Item),
  839.          GC     => Green_Gc,
  840.          Filled => True,
  841.          X      => 0,
  842.          Y      => 0,
  843.          Width  => Item.W,
  844.          Height => Item.H);
  845.       Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
  846.  
  847.       Set_Text (Layout, "Missil" & Positive'Image (Display_Item (Item).Num/2));
  848.       Draw_Layout
  849.         (Pixmap (Item),
  850.          Green_Gc,
  851.          10,
  852.          10,
  853.          Layout);
  854.  
  855.       Draw_Shadow
  856.         (Style       => Get_Style (Item.Canvas),
  857.          Window      => Pixmap (Item),
  858.          State_Type  => State_Normal,
  859.          Shadow_Type => Shadow_Out,
  860.          X           => 0,
  861.          Y           => 0,
  862.          Width       => Item.W,
  863.          Height      => Item.H);
  864.    end Draw_Missil;
  865.  
  866.  
  867.  
  868.    procedure Draw_Target (Item : access Display_Item_Record'Class) is
  869.    begin
  870.       Set_Foreground (Green_Gc, Display_Item (Item).Color);
  871.       Draw_Rectangle
  872.         (Pixmap (Item),
  873.          GC     => Green_Gc,
  874.          Filled => True,
  875.          X      => 0,
  876.          Y      => 0,
  877.          Width  => Item.W,
  878.          Height => Item.H);
  879.       Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
  880.  
  881.       Set_Text (Layout, "Target" & Positive'Image (Display_Item (Item).Num/2 -1));
  882.       Draw_Layout
  883.         (Pixmap (Item),
  884.          Green_Gc,
  885.          10,
  886.          10,
  887.          Layout);
  888.  
  889.       Draw_Shadow
  890.         (Style       => Get_Style (Item.Canvas),
  891.          Window      => Pixmap (Item),
  892.          State_Type  => State_Normal,
  893.          Shadow_Type => Shadow_Out,
  894.          X           => 0,
  895.          Y           => 0,
  896.          Width       => Item.W,
  897.          Height      => Item.H);
  898.  
  899.    end Draw_Target;
  900.  
  901.  
  902.    procedure Initialize_missil(Main_Window : in Main_Window_Access;
  903.                                Item   : access Display_Item_Record'Class;
  904.                                Source_X : Gint := 0;
  905.                                Source_Y : Gint := 0) is
  906.    begin
  907.       Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
  908.       Item.Color := Colors (14);
  909.       Item.W := 70;
  910.       Item.H := 35;
  911.       Item.Num := Main_Window.Num + 1;
  912.       if Main_Window.num <= Main_Window.Items_List'Last then
  913.          Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
  914.       end if;
  915.       Main_Window.Num := Main_Window.Num + 1;
  916.       Set_Screen_Size (Item, Item.W, Item.H);
  917.       Draw_missil (Item);
  918.    end Initialize_missil;
  919.  
  920.    procedure Initialize_External_Missil(Main_Window : in Main_Window_Access;
  921.                                         Item   : access Display_Item_Record'Class) is
  922.    begin
  923.       Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
  924.       Item.Color := Colors (1);
  925.       Item.W := 70;
  926.       Item.H := 35;
  927.       Item.Num := Main_Window.External_Num;
  928.       if Main_Window.External_Num <= Main_Window.External_Items_List'Last then
  929.          Main_Window.External_Items_List (Item.Num) := Canvas_Item (Item);
  930.          Main_Window.External_Num := Main_Window.External_Num + 1;
  931.       end if;
  932.       Set_Screen_Size (Item, Item.W, Item.H);
  933.       Draw_External_Missil (Item);
  934.    end Initialize_External_Missil;
  935.  
  936.  
  937.    procedure Initialize_target(Main_Window : in Main_Window_Access;
  938.                                Item   : access Display_Item_Record'Class) is
  939.    begin
  940.       Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
  941.       Item.Color := Colors (10);
  942.       Item.W := 70;
  943.       Item.H := 35;
  944.       Item.Num := Main_Window.Num + 1;
  945.       if Main_Window.num <= Main_Window.Items_List'Last then
  946.          Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
  947.       end if;
  948.       Main_Window.Num := Main_Window.Num + 1;
  949.       Set_Screen_Size (Item, Item.W, Item.H);
  950.       Draw_Target (Item);
  951.    end Initialize_target;
  952.  
  953.    ---------------------
  954.    -- Add_Single_Item --
  955.    ---------------------
  956.  
  957.    procedure Add_Missil_With_Cible(Main_window : in Main_Window_Access;
  958.                                    Source_X : Gint;
  959.                                    Source_Y : Gint;
  960.                                    Target_X : Gint;
  961.                                    Target_Y : Gint;
  962.                                    Charge   : Charge_Type) is
  963.       missil : constant Display_Item := new Display_Item_Record;
  964.       cible : constant Display_Item := new Display_Item_Record;
  965.    begin
  966.       Initialize_missil (Main_Window, missil);
  967.       Initialize_target (Main_Window, cible);
  968.       Add_Canvas_Link (Main_Window.Canvas, Main_Window.Items_List(1), missil, "");
  969.       Add_Canvas_Link (Main_Window.Canvas, missil, Cible, "Charge : " & Charge_Type'Image(Charge));
  970.  
  971.       Put (Main_Window.Canvas, Missil, Source_X, Source_Y);
  972.       Put (Main_Window.Canvas, Cible, Target_X, Target_Y);
  973.       Refresh_Canvas (Main_Window.Canvas);
  974.       Show_Item (Main_Window.Canvas, Missil);
  975.       Show_Item (Main_Window.Canvas, Cible);
  976.    end Add_Missil_With_cible;
  977.  
  978.  
  979.    procedure Add_Canvas_Link
  980.      (Canvas : access Interactive_Canvas_Record'Class;
  981.       Item1, Item2 : access Canvas_Item_Record'Class; Text : String := "")
  982.    is
  983.       Link : constant Canvas_Link := new Canvas_Link_Record;
  984.    begin
  985.       Add_Link (Canvas, Link, Item1, Item2, Both_Arrow, Text);
  986.    end Add_Canvas_Link;
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.    procedure Create_missil
  994.      (widget : access Gtk_Widget_Record'class;
  995.       Main_Window : Main_Window_access) is
  996.  
  997.       Degr_Lat : Gdouble := 0.0;
  998.       Minu_Lat : Gdouble := 0.0;
  999.       Seco_Lat : Gdouble := 0.0;
  1000.       Degr_Lon : Gdouble := 0.0;
  1001.       Minu_Lon : Gdouble := 0.0;
  1002.       Seco_Lon : Gdouble := 0.0;
  1003.  
  1004.       Lon_Unit : constant Float := 1024.0/(360.0*60.0*60.0);
  1005.       Lat_Unit : constant Float := 768.0/(180.0*60.0*60.0);
  1006.  
  1007.  
  1008.  
  1009.    begin
  1010.       Degr_Lat := Get_Value(Main_Window.Missil.Source_Degr_Lat);
  1011.       Minu_Lat := Get_Value(Main_Window.Missil.Source_Minu_Lat);
  1012.       Seco_Lat := Get_Value(Main_Window.Missil.Source_Seco_Lat);
  1013.       Degr_Lon := Get_Value(Main_Window.Missil.Source_Degr_Lon);
  1014.       Minu_Lon := Get_Value(Main_Window.Missil.Source_Minu_Lon);
  1015.       Seco_Lon := Get_Value(Main_Window.Missil.Source_Seco_Lon);
  1016.       Text_Io.New_Line;
  1017.       Text_Io.Put_Line("Initialize Missil Attributes....");
  1018.       Text_Io.New_Line;
  1019.       if Degr_Lon >= 0.0 then
  1020.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1021.            Float(Seco_Lon) * Lon_Unit));
  1022.          Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1023.            Float(Seco_Lon) * Lon_Unit;
  1024.  
  1025.       else
  1026.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1027.            Float(Seco_Lon) * Lon_Unit)));
  1028.          Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1029.            Float(Seco_Lon) * Lon_Unit);
  1030.       end if;
  1031.  
  1032.       if Degr_Lat >= 0.0 then
  1033.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1034.            Float(Seco_Lat) * Lat_Unit));
  1035.          Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1036.            Float(Seco_Lat) * Lat_Unit;
  1037.       else
  1038.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1039.            Float(Seco_Lat) * Lat_Unit)));
  1040.          Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1041.            Float(Seco_Lat) * Lat_Unit);
  1042.  
  1043.       end if;
  1044.  
  1045.  
  1046.       Degr_Lat := Get_Value(Main_Window.Missil.Target_Degr_Lat);
  1047.       Minu_Lat := Get_Value(Main_Window.Missil.Target_Minu_Lat);
  1048.       Seco_Lat := Get_Value(Main_Window.Missil.Target_Seco_Lat);
  1049.       Degr_Lon := Get_Value(Main_Window.Missil.Target_Degr_Lon);
  1050.       Minu_Lon := Get_Value(Main_Window.Missil.Target_Minu_Lon);
  1051.       Seco_Lon := Get_Value(Main_Window.Missil.Target_Seco_Lon);
  1052.       Text_Io.New_Line;
  1053.  
  1054.       Text_Io.New_Line;
  1055.       if Degr_Lon >= 0.0 then
  1056.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1057.            Float(Seco_Lon) * Lon_Unit));
  1058.          Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1059.            Float(Seco_Lon) * Lon_Unit;
  1060.  
  1061.       else
  1062.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1063.            Float(Seco_Lon) * Lon_Unit)));
  1064.          Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1065.            Float(Seco_Lon) * Lon_Unit);
  1066.       end if;
  1067.  
  1068.       if Degr_Lat >= 0.0 then
  1069.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1070.            Float(Seco_Lat) * Lat_Unit));
  1071.          Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1072.            Float(Seco_Lat) * Lat_Unit;
  1073.       else
  1074.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1075.            Float(Seco_Lat) * Lat_Unit)));
  1076.          Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1077.            Float(Seco_Lat) * Lat_Unit);
  1078.  
  1079.       end if;
  1080.  
  1081.  
  1082.       Main_Window.One_Missil.Missil_Attributes.charge := Float(Get_Value(Main_Window.Missil.Charge));
  1083.  
  1084.       Main_Window.Process.Create_Missil;
  1085.       Destroy(Main_Window.Missil.Dialog);
  1086.  
  1087.  
  1088.    end Create_Missil;
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.    procedure Get_missil_Attributes(widget : access Gtk_Widget_Record'class;
  1095.                                    Main_Window : in Main_Window_access) is
  1096.    begin
  1097.       Gtk_New(Main_Window.Missil.Dialog);
  1098.       Set_Position(Main_Window.Missil.dialog, Win_Pos_Center);
  1099.       Gtk_New(Main_Window.Missil.Source_Label, "Position : ");
  1100.       Gtk_New(Main_Window.Missil.Source_Degr_Lat, -90.0, 90.0, 1.0);
  1101.       Gtk_New(Main_Window.Missil.Source_Minu_Lat, 0.0, 60.0, 1.0);
  1102.       Gtk_New(Main_Window.Missil.Source_Seco_Lat, 0.0, 60.0, 1.0);
  1103.       Gtk_New(Main_Window.Missil.Source_Degr_Lon, -180.0, 180.0, 1.0);
  1104.       Gtk_New(Main_Window.Missil.Source_Minu_Lon, 0.0, 60.0, 1.0);
  1105.       Gtk_New(Main_Window.Missil.Source_Seco_Lon, 0.0, 60.0, 1.0);
  1106.       Gtk_New_Hbox(Main_Window.Missil.Source_Lat_Hbox);
  1107.       Gtk_New_Hbox(Main_Window.Missil.Source_Lon_Hbox);
  1108.       Gtk_New(Main_Window.Missil.Lat_Label, "Latitude  :");
  1109.       Gtk_New(Main_Window.Missil.Lon_Label, "Longitude :");
  1110.       Gtk_New(Main_Window.Missil.target_Label, "Target : ");
  1111.       Gtk_New(Main_Window.Missil.Target_Degr_Lat, -90.0, 90.0, 1.0);
  1112.       Gtk_New(Main_Window.Missil.Target_Minu_Lat, 0.0, 60.0, 1.0);
  1113.       Gtk_New(Main_Window.Missil.Target_Seco_Lat, 0.0, 60.0, 1.0);
  1114.       Gtk_New(Main_Window.Missil.Target_Degr_Lon, -180.0, 180.0, 1.0);
  1115.       Gtk_New(Main_Window.Missil.Target_Minu_Lon, 0.0, 60.0, 1.0);
  1116.       Gtk_New(Main_Window.Missil.Target_Seco_Lon, 0.0, 60.0, 1.0);
  1117.       Gtk_New(Main_Window.Missil.Charge_Label, "Charge : ");
  1118.       Gtk_New(Main_Window.Missil.charge, 0.0, Gdouble(Main_Window.Wopr.Wopr_Attributes.Charge), 0.0001);
  1119.  
  1120.       Text_Io.Put_Line("toto 0");
  1121.       Gtk_New_From_stock(Main_Window.Missil.Ok_button, Stock_Ok);
  1122.       Gtk_New_From_stock(Main_Window.Missil.Cancel_button, Stock_Cancel);
  1123.       Gtk_New_Hbox(Main_Window.Missil.Target_Lat_Hbox);
  1124.       Gtk_New_Hbox(Main_Window.Missil.Target_Lon_Hbox);
  1125.       Gtk_New_Hbox(Main_Window.Missil.Charge_Hbox);
  1126.       Gtk_New_Hbox(Main_Window.Missil.button_Hbox);
  1127.       Gtk_New_Vbox(Main_Window.Missil.Main_Vbox);
  1128.  
  1129.  
  1130.       Pack_Start(Main_Window.Missil.Main_vbox, Main_Window.Missil.Source_Label);
  1131.       Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Lat_Label);
  1132.       Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Degr_lat);
  1133.       Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Minu_lat);
  1134.       Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Seco_lat);
  1135.       Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Lon_Label);
  1136.       Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Degr_Lon);
  1137.       Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Minu_Lon);
  1138.       Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Seco_Lon);
  1139.       Gtk_New(Main_Window.Missil.Lat_Label, "Latitude  :");
  1140.       Gtk_New(Main_Window.Missil.Lon_Label, "Longitude :");
  1141.  
  1142.  
  1143.       Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Lat_Label);
  1144.       Text_Io.Put_Line("toto 1");
  1145.       Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Degr_lat);
  1146.       Text_Io.Put_Line("toto 2");
  1147.       Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Minu_lat);
  1148.       Text_Io.Put_Line("toto 3");
  1149.       Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Seco_lat);
  1150.       Text_Io.Put_Line("toto 4");
  1151.       Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Lon_Label);
  1152.       Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Degr_Lon);
  1153.       Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Minu_Lon);
  1154.       Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Seco_Lon);
  1155.       Pack_Start(Main_Window.Missil.Charge_Hbox, Main_Window.Missil.Charge_Label);
  1156.       Pack_Start(Main_Window.Missil.Charge_Hbox, Main_Window.Missil.Charge);
  1157.       Pack_Start(Main_Window.Missil.Button_Hbox, Main_Window.Missil.Ok_Button);
  1158.       Pack_Start(Main_Window.Missil.Button_Hbox, Main_Window.Missil.Cancel_button);
  1159.  
  1160.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Source_Lat_Hbox);
  1161.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Source_Lon_Hbox);
  1162.  
  1163.       Pack_Start(Main_Window.Missil.Main_vbox, Main_Window.Missil.Target_Label);
  1164.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Target_Lat_Hbox);
  1165.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Target_Lon_Hbox);
  1166.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Charge_Hbox);
  1167.       Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Button_Hbox);
  1168.       Text_Io.Put("TOTO 2");
  1169.       Main_Handlers.Connect
  1170.         (Main_Window.Missil.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Create_Missil'access), Main_Window.all'access);
  1171.       Add(Main_Window.Missil.Dialog, Main_Window.Missil.Main_Vbox);
  1172.       Show_All(Main_Window.Missil.Dialog);
  1173.    end Get_missil_Attributes;
  1174.  
  1175.  
  1176.    procedure Missil_Create_Group(widget : access Gtk_Widget_Record'class;
  1177.                                  Main_Window : in Main_Window_access) is
  1178.  
  1179.  
  1180.       Lon_Unit : constant Float := 1024.0/(360.0*60.0*60.0);
  1181.       Lat_Unit : constant Float := 768.0/(180.0*60.0*60.0);
  1182.  
  1183.    begin
  1184.       Text_Io.Put_Line("Destroy window.");
  1185.       Text_Io.Put_Line("Initialize Missils group Attributes....");
  1186.       if not Missils_Config_Vectors.Is_empty(Main_Window.Missils_Group.Missil_Vector) then
  1187.          for I in 1..Missils_Config_Vectors.Last_Index(Main_Window.Missils_Group.Missil_Vector) loop
  1188.             declare
  1189.                Degr_Lat : Gdouble := 0.0;
  1190.                Minu_Lat : Gdouble := 0.0;
  1191.                Seco_Lat : Gdouble := 0.0;
  1192.                Degr_Lon : Gdouble := 0.0;
  1193.                Minu_Lon : Gdouble := 0.0;
  1194.                Seco_Lon : Gdouble := 0.0;
  1195.                Missil : Missil_Unit_Access := Missils_Config_Vectors.Element(Main_Window.Missils_Group.Missil_Vector, I);
  1196.             begin
  1197.                Text_Io.Put_Line("Missil 0");
  1198.                Degr_Lat := Get_Value(Missil.Source_Degr_Lat);
  1199.                Text_Io.Put_Line("Missil 0.0");
  1200.                Minu_Lat := Get_Value(Missil.Source_Minu_Lat);
  1201.                Text_Io.Put_Line("Missil 0.1");
  1202.                Seco_Lat := Get_Value(Missil.Source_Seco_Lat);
  1203.                Text_Io.Put_Line("Missil 0.2");
  1204.                Degr_Lon := Get_Value(Missil.Source_Degr_Lon);
  1205.                Text_Io.Put_Line("Missil 0.3");
  1206.                Minu_Lon := Get_Value(Missil.Source_Minu_Lon);
  1207.                Text_Io.Put_Line("Missil 0.4");
  1208.                Seco_Lon := Get_Value(Missil.Source_Seco_Lon);
  1209.                Text_Io.Put_Line("Missil 1");
  1210.                if Degr_Lon >= 0.0 then
  1211.                   Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1212.                                                                    Float(Seco_Lon) * Lon_Unit));
  1213.                   Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1214.                     Float(Seco_Lon) * Lon_Unit;
  1215.  
  1216.                else
  1217.                   Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1218.                                                                             Float(Seco_Lon) * Lon_Unit)));
  1219.                   Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1220.                                                                                   Float(Seco_Lon) * Lon_Unit);
  1221.                end if;
  1222.  
  1223.                if Degr_Lat >= 0.0 then
  1224.                   Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1225.                                                                   Float(Seco_Lat) * Lat_Unit));
  1226.                   Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1227.                     Float(Seco_Lat) * Lat_Unit;
  1228.                else
  1229.                   Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1230.                                                                            Float(Seco_Lat) * Lat_Unit)));
  1231.                   Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1232.                                                                                   Float(Seco_Lat) * Lat_Unit);
  1233.  
  1234.                end if;
  1235.  
  1236.                Text_Io.Put_Line("Missil 2");
  1237.                Degr_Lat := Get_Value(Missil.Target_Degr_Lat);
  1238.                Minu_Lat := Get_Value(Missil.Target_Minu_Lat);
  1239.                Seco_Lat := Get_Value(Missil.Target_Seco_Lat);
  1240.                Degr_Lon := Get_Value(Missil.Target_Degr_Lon);
  1241.                Minu_Lon := Get_Value(Missil.Target_Minu_Lon);
  1242.                Seco_Lon := Get_Value(Missil.Target_Seco_Lon);
  1243.                Text_Io.New_Line;
  1244.  
  1245.                Text_Io.New_Line;
  1246.                if Degr_Lon >= 0.0 then
  1247.                   Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1248.                                                                    Float(Seco_Lon) * Lon_Unit));
  1249.                   Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1250.                     Float(Seco_Lon) * Lon_Unit;
  1251.  
  1252.                else
  1253.                   Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1254.                                                                             Float(Seco_Lon) * Lon_Unit)));
  1255.                   Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1256.                                                                                   Float(Seco_Lon) * Lon_Unit);
  1257.                end if;
  1258.  
  1259.                if Degr_Lat >= 0.0 then
  1260.                   Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1261.                                                                   Float(Seco_Lat) * Lat_Unit));
  1262.                   Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1263.                     Float(Seco_Lat) * Lat_Unit;
  1264.                else
  1265.                   Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1266.                                                                            Float(Seco_Lat) * Lat_Unit)));
  1267.                   Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1268.                                                                                   Float(Seco_Lat) * Lat_Unit);
  1269.  
  1270.                end if;
  1271.                Text_Io.Put_Line("Missil 3");
  1272.  
  1273.                Main_Window.One_Missil.Missil_Attributes.charge := Float(Get_Value(Missil.Charge));
  1274.                Text_Io.Put_Line("Missil 4");
  1275.  
  1276.                Main_Window.Process.Create_Missil;
  1277.             end;
  1278.          end loop;
  1279.  
  1280.       end if;
  1281.  
  1282.       Destroy(Main_Window.Missils_Group.Dialog);
  1283.  
  1284.    end Missil_Create_Group;
  1285.  
  1286.  
  1287.    procedure Missil_Config_Group(widget : access Gtk_Widget_Record'class;
  1288.                                  Main_Window : in Main_Window_access) is
  1289.  
  1290.    begin
  1291.       Gtk_New(Main_Window.Missils_group.Dialog);
  1292.       Set_Position(Main_Window.Missils_group.dialog, Win_Pos_Center);
  1293.  
  1294.       Gtk_New_Hbox(Main_Window.Missils_Group.button_Hbox);
  1295.       Text_Io.Put_Line("toto 0");
  1296.       Gtk_New_From_stock(Main_Window.Missils_group.Ok_button, Stock_Ok);
  1297.       Text_Io.Put_Line("toto -1");
  1298.       Gtk_New_From_stock(Main_Window.Missils_group.Cancel_button, Stock_Cancel);
  1299.       Text_Io.Put_Line("toto -2");
  1300.       Gtk_New_Vbox(Main_Window.Missils_Group.Main_Vbox);
  1301.       Text_Io.Put_Line("toto -3");
  1302.       Missils_Config_Vectors.Clear(Main_Window.Missils_Group.Missil_Vector);
  1303.       for I in 1..4 loop
  1304.          declare
  1305.             Missil : Missil_Unit_Access := new Missil_Unit_Config;
  1306.          begin
  1307.             Gtk_New(Main_Window.Missils_Group.Source_Label, "Position : ");
  1308.             Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude  :");
  1309.             Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
  1310.             Gtk_New(Missil.Source_Degr_Lat, -90.0, 90.0, 1.0);
  1311.             Gtk_New(Missil.Source_Minu_Lat, 0.0, 60.0, 1.0);
  1312.             Gtk_New(Missil.Source_Seco_Lat, 0.0, 60.0, 1.0);
  1313.             Gtk_New(Missil.Source_Degr_Lon, -180.0, 180.0, 1.0);
  1314.             Gtk_New(Missil.Source_Minu_Lon, 0.0, 60.0, 1.0);
  1315.             Gtk_New(Missil.Source_Seco_Lon, 0.0, 60.0, 1.0);
  1316.             Gtk_New_Hbox(Main_Window.Missils_Group.Source_Lat_Hbox);
  1317.             Gtk_New_Hbox(Main_Window.Missils_Group.Source_Lon_Hbox);
  1318.             Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude  :");
  1319.             Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
  1320.             Gtk_New(Main_Window.Missils_Group.target_Label, "Target : ");
  1321.             Gtk_New(Missil.Target_Degr_Lat, -90.0, 90.0, 1.0);
  1322.             Gtk_New(Missil.Target_Minu_Lat, 0.0, 60.0, 1.0);
  1323.             Gtk_New(Missil.Target_Seco_Lat, 0.0, 60.0, 1.0);
  1324.             Gtk_New(Missil.Target_Degr_Lon, -180.0, 180.0, 1.0);
  1325.             Gtk_New(Missil.Target_Minu_Lon, 0.0, 60.0, 1.0);
  1326.             Gtk_New(Missil.Target_Seco_Lon, 0.0, 60.0, 1.0);
  1327.             Gtk_New(Main_Window.Missils_Group.Charge_Label, "Charge : ");
  1328.             Gtk_New(Missil.charge, 0.0, Gdouble(Main_Window.Wopr.Wopr_Attributes.Charge)/4.0, 0.0001);
  1329.  
  1330.             Text_Io.Put_Line("toto -10");
  1331.  
  1332.             Gtk_New_Hbox(Main_Window.Missils_Group.Target_Lat_Hbox);
  1333.             Gtk_New_Hbox(Main_Window.Missils_Group.Target_Lon_Hbox);
  1334.             Gtk_New_Hbox(Main_Window.Missils_Group.Charge_Hbox);
  1335.  
  1336.             Text_Io.Put_Line("toto -9");
  1337.  
  1338.             Pack_Start(Main_Window.Missils_group.Main_vbox, Main_Window.Missils_group.Source_Label);
  1339.             Text_Io.Put_Line("toto -9.1");
  1340.             Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Main_Window.Missils_Group.Lat_Label);
  1341.             Text_Io.Put_Line("toto -9.2");
  1342.             Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Degr_lat);
  1343.             Text_Io.Put_Line("toto -9.3");
  1344.             Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Minu_lat);
  1345.             Text_Io.Put_Line("toto -9.4");
  1346.             Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Seco_lat);
  1347.             Text_Io.Put_Line("toto -8");
  1348.             Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Main_Window.Missils_Group.Lon_Label);
  1349.             Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Degr_Lon);
  1350.             Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Minu_Lon);
  1351.             Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Seco_Lon);
  1352.             Text_Io.Put_Line("toto -7");
  1353.             Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude  :");
  1354.             Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
  1355.  
  1356.  
  1357.             Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Main_Window.Missils_Group.Lat_Label);
  1358.             Text_Io.Put_Line("toto 1");
  1359.             Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Degr_lat);
  1360.             Text_Io.Put_Line("toto 2");
  1361.             Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Minu_lat);
  1362.             Text_Io.Put_Line("toto 3");
  1363.             Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Seco_lat);
  1364.             Text_Io.Put_Line("toto 4");
  1365.             Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Main_Window.Missils_group.Lon_Label);
  1366.             Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Degr_Lon);
  1367.             Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Minu_Lon);
  1368.             Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Seco_Lon);
  1369.             Pack_Start(Main_Window.Missils_Group.Charge_Hbox, Main_Window.Missils_Group.Charge_Label);
  1370.             Pack_Start(Main_Window.Missils_Group.Charge_Hbox, Missil.Charge);
  1371.             Text_Io.Put_Line("toto 5");
  1372.             Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Source_Lat_Hbox);
  1373.             Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Source_Lon_Hbox);
  1374.             Text_Io.Put_Line("toto 6");
  1375.             Pack_Start(Main_Window.Missils_Group.Main_vbox, Main_Window.Missils_Group.Target_Label);
  1376.             Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Target_Lat_Hbox);
  1377.             Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Target_Lon_Hbox);
  1378.             Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Charge_Hbox);
  1379.             Text_Io.Put_Line("toto 7");
  1380.             Missils_Config_Vectors.Insert(Main_Window.Missils_Group.Missil_Vector, I, Missil, 1);
  1381.          end;
  1382.       end loop;
  1383.       Pack_Start(Main_Window.Missils_Group.Button_Hbox, Main_Window.Missils_Group.Ok_Button);
  1384.       Text_Io.Put_Line("toto -30");
  1385.       Pack_Start(Main_Window.Missils_Group.Button_Hbox, Main_Window.Missils_Group.Cancel_button);
  1386.       Text_Io.Put_Line("toto -31");
  1387.       Pack_Start(Main_Window.Missils_group.Main_Vbox, Main_Window.Missils_Group.Button_Hbox);
  1388.       Text_Io.Put("TOTO 2");
  1389.       Main_Handlers.Connect
  1390.         (Main_Window.Missils_Group.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Missil_Create_group'access), Main_Window.all'access);
  1391.       Add(Main_Window.Missils_Group.Dialog, Main_Window.Missils_Group.Main_Vbox);
  1392.       Show_All(Main_Window.Missils_group.Dialog);
  1393.  
  1394.    end Missil_Config_Group;
  1395.  
  1396.  
  1397.  
  1398.    procedure Launch_One(widget : access Gtk_Widget_Record'Class;
  1399.                         Main_Window : in Main_Window_access) is
  1400.    begin
  1401.       Text_Io.Put("Launch One Missil");
  1402.       Main_Window.Process.Launch_One(Positive(Get_Value(Main_Window.One_Missil_Launch)));
  1403.       Destroy(Main_Window.Launch_Window);
  1404.    end Launch_One;
  1405.  
  1406.  
  1407.    procedure Launch_all(widget : access Gtk_Widget_Record'Class;
  1408.                         Main_Window : in Main_Window_access) is
  1409.    begin
  1410.       Text_Io.Put("Launch All Missil");
  1411.       Main_Window.Process.Launch_All;
  1412.    end Launch_All;
  1413.  
  1414.    procedure get_One(widget : access Gtk_Widget_Record'class;
  1415.                      Main_Window : in Main_Window_access) is
  1416.  
  1417.       Ok_Button: Gtk_Button;
  1418.       Cancel_Button: Gtk_Button;
  1419.       Button_Hbox : Gtk_Hbox;
  1420.       Main_Vbox : Gtk_Vbox;
  1421.    begin
  1422.       Text_Io.Put("Get Launch One Missil");
  1423.       Gtk_New(Main_Window.Launch_Window, Window_Toplevel);
  1424.       Set_Position(Main_Window.Launch_Window, Win_Pos_Center);
  1425.       Gtk_New_From_stock(Ok_button, Stock_Ok);
  1426.       Gtk_New_From_stock(Cancel_button, Stock_Cancel);
  1427.       Gtk_New_Hbox(Button_Hbox);
  1428.       Gtk_New_Vbox(Main_Vbox);
  1429.       Gtk_New(Main_Window.One_Missil_Launch, 1.0, Gdouble(Missils_Vectors.Last_Index(Main_Window.Wopr.Missils)), 1.0);
  1430.       Pack_Start(Main_Vbox, Main_Window.One_Missil_Launch);
  1431.       Pack_Start(button_Hbox, Ok_button);
  1432.       Pack_Start(button_Hbox, Cancel_button);
  1433.       Pack_Start(Main_Vbox, Button_Hbox);
  1434.       Main_Handlers.Connect
  1435.         (Ok_Button, "clicked", Main_Handlers.To_Marshaller (Launch_one'access), Main_Window.all'access);
  1436.       Add(Main_Window.Launch_Window, Main_Vbox);
  1437.       Show_All(Main_Window.Launch_Window);
  1438.    end Get_One;
  1439.  
  1440.  
  1441.  
  1442.    procedure Initialize(Main_Window : out Main_Window_Access) is
  1443.  
  1444.       Timeout_Id : Gtk.Main.Timeout_Handler_Id;
  1445.  
  1446.       Text_Render   : Gtk_Cell_Renderer_Text;
  1447.  
  1448.    begin
  1449.  
  1450.       Main_Window := new Main_Window_Type;
  1451.       Gtk_New(Main_Window.Main_Window);
  1452.  
  1453.  
  1454.       Text_Io.Put_line("TOTO 0");
  1455.       Gtkada.Canvas.initialize(Main_Window.Canvas, false);
  1456.       Text_Io.Put_line("TOTO 1");
  1457.  
  1458.       Set_Title(Main_Window.Main_Window,"Warborg - Xborg 2012 beta");
  1459.       Set_Geometry_Hints(Main_Window.Main_Window, null,
  1460.                          Main_Window.Geometry, Gdk_Hint_Max_size);
  1461.       Set_Default_Size(Main_Window.Main_Window, 1200, 855);
  1462.       Set_Position(Main_Window.Main_Window, Win_Pos_Center);
  1463.       Set_Resizable(Main_Window.Main_Window, False);
  1464.       Gtk_New_Vbox(Main_Window.Main_Vbox);
  1465.       Gtk_New_Hbox(Main_Window.Menu_Hbox);
  1466.       Gtk_New(Main_Window.Main_Menu_Bar);
  1467.       Gtk_New(Main_Window.File_Menu);
  1468.       Gtk_New(Main_Window.File_Menu_Item, "File");
  1469.       Gtk_New(Main_Window.Exit_Menu_Item, "Quit");
  1470.       Gtk_New(Main_Window.Zoom_Menu);
  1471.       Gtk_New(Main_Window.Zoom_Menu_Item, "Zoom");
  1472.       Gtk_New(Main_Window.Zoom_Foreward_Item, "Zoom avant");
  1473.       Gtk_New(Main_Window.Zoom_Backward_item, "Zoom arrière");
  1474.  
  1475.       Gtk_New(Main_Window.Search_Menu);
  1476.       Gtk_New(Main_Window.Search_Menu_Item, "Search");
  1477.       Gtk_New(Main_Window.Ant_Colony_Menu_Item, "Ant Colony");
  1478.       Gtk_New(Main_Window.Ant_Colony_Conf_Menu_Item, "Ant Colony config");
  1479.  
  1480.       -- Initialize Canvas menu
  1481.       Gtk_New(Main_Window.Canvas_Menu);
  1482.       Gtk_New(Main_Window.Canvas_Menu_Item, "Canvas");
  1483.       Gtk_New(Main_Window.Clear_Canvas_Menu_Item, "Effacer le canvas");
  1484.  
  1485.  
  1486.       Gtk_New(Main_Window.Missils_Menu);
  1487.       Gtk_New(Main_Window.Missils_Menu_Item, "Missils");
  1488.       Gtk_New(Main_Window.Launch_all_Item, "Launch All");
  1489.       Gtk_New(Main_Window.Launch_One_Item, "Launch One");
  1490.       Gtk_New(Main_Window.Create_One_Item, "Create One");
  1491.       Gtk_New(Main_Window.Create_Group_Item, "Create Group");
  1492.  
  1493.  
  1494.       Gtk_New(Main_Window.Date_Label, "Data : no date");
  1495.  
  1496.       Set_Submenu(Main_Window.File_Menu_Item, Main_Window.File_Menu);
  1497.       Append(Main_Window.File_Menu, Main_Window.Exit_Menu_Item);
  1498.       Append(Main_Window.Main_Menu_Bar, Main_Window.File_Menu_Item);
  1499.  
  1500.       Set_Submenu(Main_Window.Zoom_Menu_Item, Main_Window.Zoom_Menu);
  1501.       Append(Main_Window.Zoom_Menu, Main_Window.Zoom_Foreward_item);
  1502.       Append(Main_Window.Zoom_Menu, Main_Window.Zoom_Backward_item);
  1503.       Append(Main_Window.Main_Menu_Bar, Main_Window.Zoom_Menu_item);
  1504.  
  1505.       Set_Submenu(Main_Window.Canvas_Menu_item, Main_Window.Canvas_menu);
  1506.       Append(Main_Window.Canvas_Menu, Main_Window.Clear_Canvas_Menu_item);
  1507.       Append(Main_Window.Main_Menu_Bar, Main_Window.Canvas_Menu_Item);
  1508.  
  1509.       Set_Submenu(Main_Window.Search_Menu_Item, Main_Window.Search_Menu);
  1510.       Append(Main_Window.Search_Menu, Main_Window.Ant_Colony_Menu_Item);
  1511.       Append(Main_Window.Search_Menu, Main_Window.Ant_Colony_Conf_Menu_Item);
  1512.       Append(Main_Window.Main_Menu_Bar, Main_Window.Search_Menu_item);
  1513.  
  1514.       Set_Submenu(Main_Window.Missils_Menu_Item, Main_Window.Missils_Menu);
  1515.       Append(Main_Window.Missils_Menu, Main_Window.Launch_All_Item);
  1516.       Append(Main_Window.Missils_Menu, Main_Window.Launch_One_Item);
  1517.       Append(Main_Window.Missils_Menu, Main_Window.Create_One_Item);
  1518.       Append(Main_Window.Missils_Menu, Main_Window.Create_Group_Item);
  1519.  
  1520.       Append(Main_Window.Main_Menu_Bar, Main_Window.Missils_Menu_item);
  1521.  
  1522.       Gtk_New(Main_Window.Host_Label, "Hostname : ");
  1523.       Gtk_New(Main_Window.Host_Entry);
  1524.       Gtk_New(Main_Window.Status_Bar);
  1525.  
  1526.       Gtk_New(Main_Window.Main_Frame);
  1527.  
  1528.  
  1529.       Gtk_New(Main_Window.Scrolled);
  1530.  
  1531.       --Set_Policy (Main_Window.Scrolled, Policy_Automatic, Policy_automatic);
  1532.       Add(Main_Window.Scrolled, Main_Window.Canvas);
  1533.       Add(Main_Window.Main_frame, Main_Window.Scrolled);
  1534.  
  1535.  
  1536.       Gtk_New_Hpaned(Main_Window.Main_Hpaned);
  1537.  
  1538.       Gtk_New(Main_Window.Right_Scroll);
  1539.       --Set_Policy (Main_Window.Right_Scroll, Policy_Automatic, Policy_automatic);
  1540.       Gtk_New (Main_Window.Model,
  1541.                (0 => GType_String));
  1542.       Gtk_New(Main_Window.Tree_View_Names, Main_Window.Model);
  1543.       Gtk_New (Text_Render);
  1544.       Gtk_New (Main_Window.Col);
  1545.       Main_Window.Num_col := Append_Column (Main_Window.Tree_View_Names, Main_Window.Col);
  1546.  
  1547.       Set_Title (Main_Window.Col, "Player Names");
  1548.       Pack_Start (Main_Window.Col, Text_Render, True);
  1549.       Set_Sizing (Main_Window.Col, Tree_View_Column_Autosize);
  1550.       Add_Attribute (Main_Window.Col, Text_Render, "text", 0);
  1551.       Add_With_Viewport (Main_Window.Right_Scroll, Main_Window.Tree_View_names);
  1552.  
  1553.  
  1554.       Pack_Start(Main_Window.Menu_Hbox, Main_Window.Main_Menu_Bar, False, False, 0);
  1555.       Pack_Start(Main_Window.Menu_Hbox, Main_Window.Host_label, False, False, 5);
  1556.       Pack_Start(Main_Window.Menu_Hbox, Main_Window.Host_Entry, False, False, 0);
  1557.       Pack_Start(Main_Window.Menu_Hbox, Main_Window.Date_Label, False, False, 10);
  1558.       Pack_Start(Main_Window.Main_Vbox, Main_Window.Menu_Hbox, False, False, 0);
  1559.       Add1(Main_Window.Main_Hpaned, Main_Window.Main_Frame);
  1560.       pack2(Main_Window.Main_Hpaned, Main_Window.Right_Scroll, False, False);
  1561.       Set_Position(Main_Window.Main_Hpaned, 1024);
  1562.       Pack_Start(Main_Window.Main_Vbox, Main_Window.Main_hpaned, True, True, 5);
  1563.       Pack_Start(Main_Window.Main_Vbox, Main_Window.Status_Bar, False, False, 0);
  1564.       Add(Main_Window.Main_Window, Main_Window.Main_Vbox);
  1565.  
  1566.       Realize (Main_Window.Canvas);
  1567.  
  1568.       Gdk_New (Green_Gc, Get_Window (Main_Window.Canvas));
  1569.  
  1570.  
  1571.  
  1572.       Set_Background(null, Main_Window);
  1573.  
  1574.       for J in Color_Names'Range loop
  1575.          Colors (J) := Parse (Color_Names (J).all);
  1576.          Alloc (Gtk.Widget.Get_Default_Colormap, Colors (J));
  1577.       end loop;
  1578.  
  1579.       Layout := Create_Pango_Layout (Main_Window.Main_Frame);
  1580.  
  1581.  
  1582.       Timeout_Id := Date_Timeout.Add(1000, Update'Access, Main_Window);
  1583.  
  1584.       Main_handlers.Connect
  1585.         (Main_Window.Exit_Menu_Item, "activate", Main_handlers.To_Marshaller (Main_Quit'access), Main_Window);
  1586.  
  1587.       Main_Return_Handlers.Connect
  1588.         (Main_Window.Main_window, "delete_event", Main_Return_Handlers.To_Marshaller (Main_destroy'access), Main_Window);
  1589.  
  1590.  
  1591.  
  1592.       Main_handlers.Connect
  1593.         (Main_Window.Zoom_Foreward_item, "activate",  Main_Handlers.To_Marshaller (Zoom_In'Access), Main_Window);
  1594.  
  1595.       Main_Handlers.Connect
  1596.         (Main_Window.Zoom_Backward_item, "activate", Main_Handlers.To_Marshaller (Zoom_Out'Access), Main_Window);
  1597.  
  1598.       Main_handlers.Connect
  1599.         (Main_Window.Host_Entry, "activate",
  1600.          Main_handlers.To_Marshaller (Host_Entry_activate'access), Main_Window);
  1601.  
  1602.  
  1603.       Main_handlers.Connect
  1604.         (Main_Window.Create_One_item, "activate",  Main_Handlers.To_Marshaller (Get_Missil_attributes'Access), Main_Window);
  1605.  
  1606.       Main_handlers.Connect
  1607.         (Main_Window.Launch_One_item, "activate",  Main_Handlers.To_Marshaller (Get_one'Access), Main_Window);
  1608.  
  1609.       Main_handlers.Connect
  1610.         (Main_Window.Launch_All_item, "activate",  Main_Handlers.To_Marshaller (Launch_All'Access), Main_Window);
  1611.  
  1612.       Main_handlers.Connect
  1613.         (Main_Window.Create_Group_item, "activate",  Main_Handlers.To_Marshaller (Missil_Config_Group'Access), Main_Window);
  1614.  
  1615.  
  1616.       Main_handlers.Connect(Main_Window.Tree_View_names, "cursor_changed",
  1617.          Main_handlers.To_Marshaller (On_List_Selection'access), Main_Window);
  1618.  
  1619.       Main_handlers.Connect(Main_Window.Clear_Canvas_Menu_Item, "activate",
  1620.                             Main_Handlers.To_Marshaller (Clear_Canvas'Access), Main_Window);
  1621.  
  1622.  
  1623.       Show_All(Main_Window.Main_Window);
  1624.    end Initialize;
  1625.  
  1626.    procedure Initialize(Main_Application : out Main_Access) is
  1627.    begin
  1628.       Main_Application := new Main_Application_Type;
  1629.       Initialize(Main_Application.Main_Window);
  1630.    end Initialize;
  1631.  
  1632.  
  1633.    function Add_Line
  1634.      (Model    : access Gtk_Tree_Store_Record'Class;
  1635.       Text     : String;
  1636.       Parent   : Gtk_Tree_Iter := Null_Iter) return Gtk_Tree_Iter
  1637.    is
  1638.       Iter : Gtk_Tree_Iter;
  1639.    begin
  1640.       --  The implementation here is not the most efficient: it is often easier
  1641.       --  to import yourself the function gtk_tree_store_set with the correct
  1642.       --  set of arguments, as shown in the example in gtk-tree_store.ads
  1643.  
  1644.       Append (Model, Iter, Parent);
  1645.  
  1646.       Set (Model, Iter, 0, Text);
  1647.  
  1648.       return Iter;
  1649.    end Add_Line;
  1650.  
  1651.  
  1652.  
  1653.  
  1654.    procedure Create_wopr
  1655.      (widget : access Gtk_Widget_Record'class;
  1656.       Main_Window : Main_Window_access) is
  1657.  
  1658.       Degr_Lat : Gdouble := 0.0;
  1659.       Minu_Lat : Gdouble := 0.0;
  1660.       Seco_Lat : Gdouble := 0.0;
  1661.       Degr_Lon : Gdouble := 0.0;
  1662.       Minu_Lon : Gdouble := 0.0;
  1663.       Seco_Lon : Gdouble := 0.0;
  1664.  
  1665.       Lon_Unit : Float := 1024.0/(360.0*60.0*60.0);
  1666.       Lat_Unit : Float := 768.0/(180.0*60.0*60.0);
  1667.  
  1668.    begin
  1669.       Degr_Lat := Get_Value(Main_Window.Wopr_Window.Degr_Lat);
  1670.       Minu_Lat := Get_Value(Main_Window.Wopr_Window.Minu_Lat);
  1671.       Seco_Lat := Get_Value(Main_Window.Wopr_Window.Seco_Lat);
  1672.       Degr_Lon := Get_Value(Main_Window.Wopr_Window.Degr_Lon);
  1673.       Minu_Lon := Get_Value(Main_Window.Wopr_Window.Minu_Lon);
  1674.       Seco_Lon := Get_Value(Main_Window.Wopr_Window.Seco_Lon);
  1675.       Text_Io.New_Line;
  1676.       Text_Io.Put_Line("Initialize Wopr Attributes....");
  1677.       Text_Io.New_Line;
  1678.       if Degr_Lon >= 0.0 then
  1679.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1680.            Float(Seco_Lon) * Lon_Unit));
  1681.          Main_Window.Wopr.Wopr_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1682.            Float(Seco_Lon) * Lon_Unit;
  1683.  
  1684.       else
  1685.          Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1686.            Float(Seco_Lon) * Lon_Unit)));
  1687.          Main_Window.Wopr.Wopr_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
  1688.            Float(Seco_Lon) * Lon_Unit);
  1689.       end if;
  1690.  
  1691.       if Degr_Lat >= 0.0 then
  1692.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1693.            Float(Seco_Lat) * Lat_Unit));
  1694.          Main_Window.Wopr.Wopr_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1695.            Float(Seco_Lat) * Lat_Unit;
  1696.       else
  1697.          Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1698.            Float(Seco_Lat) * Lat_Unit)));
  1699.          Main_Window.Wopr.Wopr_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
  1700.            Float(Seco_Lat) * Lat_Unit);
  1701.  
  1702.       end if;
  1703.  
  1704.  
  1705.       Main_Window.Process.Create_Wopr;
  1706.  
  1707.       Destroy(Main_Window.Wopr_Window.Dialog);
  1708.    end Create_Wopr;
  1709.  
  1710.  
  1711.  
  1712.    procedure Get_Wopr_Attributes(Main_Window : Main_Window_access) is
  1713.  
  1714.    begin
  1715.       Gtk_New(Main_Window.Wopr_Window.Dialog, Window_toplevel);
  1716.       Set_Position(Main_Window.Wopr_Window.dialog, Win_Pos_Center);
  1717.       Gtk_New(Main_Window.Wopr_Window.Degr_Lat, -90.0, 90.0, 1.0);
  1718.       Gtk_New(Main_Window.Wopr_Window.Minu_Lat, 0.0, 60.0, 1.0);
  1719.       Gtk_New(Main_Window.Wopr_Window.Seco_Lat, 0.0, 60.0, 1.0);
  1720.       Gtk_New(Main_Window.Wopr_Window.Degr_Lon, -180.0, 180.0, 1.0);
  1721.       Gtk_New(Main_Window.Wopr_Window.Minu_Lon, 0.0, 60.0, 1.0);
  1722.       Gtk_New(Main_Window.Wopr_Window.Seco_Lon, 0.0, 60.0, 1.0);
  1723.       Gtk_New_Hbox(Main_Window.Wopr_Window.Lat_Hbox);
  1724.       Gtk_New_Hbox(Main_Window.Wopr_Window.Lon_Hbox);
  1725.       Gtk_New(Main_Window.Wopr_Window.Lat_Label, "Latitude  :");
  1726.       Gtk_New(Main_Window.Wopr_Window.Lon_Label, "Longitude :");
  1727.       Gtk_New_From_stock(Main_Window.Wopr_Window.Ok_button, Stock_Ok);
  1728.       Gtk_New_From_stock(Main_Window.Wopr_Window.Cancel_button, Stock_Cancel);
  1729.       Gtk_New_Hbox(Main_Window.Wopr_Window.Lat_Hbox);
  1730.       Gtk_New_Hbox(Main_Window.Wopr_Window.Lon_Hbox);
  1731.       Gtk_New_Hbox(Main_Window.Wopr_Window.button_Hbox);
  1732.       Gtk_New_Vbox(Main_Window.Wopr_Window.Main_Vbox);
  1733.       Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Lat_Label);
  1734.       Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Degr_lat);
  1735.       Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Minu_lat);
  1736.       Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Seco_lat);
  1737.       Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Lon_Label);
  1738.       Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Degr_Lon);
  1739.       Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Minu_Lon);
  1740.       Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Seco_Lon);
  1741.       Pack_Start(Main_Window.Wopr_Window.Button_Hbox, Main_Window.Wopr_Window.Ok_Button);
  1742.       Pack_Start(Main_Window.Wopr_Window.Button_Hbox, Main_Window.Wopr_Window.Cancel_button);
  1743.       Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Lat_Hbox);
  1744.       Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Lon_Hbox);
  1745.       Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Button_Hbox);
  1746.  
  1747.       -- Marche pas.
  1748.  
  1749.       --Main_Return_Handlers.Connect
  1750.       --  (Main_Window.Wopr_Window.dialog, "delete_event", Main_Return_Handlers.To_Marshaller (Main_Destroy'access), Main_Window.all'access);
  1751.       Main_Handlers.Connect
  1752.         (Main_Window.Wopr_Window.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Create_wopr'Access), Main_Window.all'access);
  1753.       Add(Main_Window.Wopr_Window.Dialog, Main_Window.Wopr_Window.Main_Vbox);
  1754.       Show_All(Main_Window.Wopr_Window.Dialog);
  1755.    end Get_Wopr_Attributes;
  1756.  
  1757.  
  1758.    procedure Add_Missil(Main_window : in Main_Window_Access;
  1759.                         Source_X : in Gint;
  1760.                         Source_Y : in Gint) is
  1761.  
  1762.       missil : constant Display_Item := new Display_Item_Record;
  1763.  
  1764.    begin
  1765.       Initialize_External_Missil (Main_Window, missil);
  1766.       Add_Canvas_Link (Main_Window.Canvas, missil, missil, "");
  1767.       Put (Main_Window.Canvas, Missil, Source_X, Source_Y);
  1768.       Refresh_Canvas (Main_Window.Canvas);
  1769.       Show_Item (Main_Window.Canvas, Missil);
  1770.    end Add_Missil;
  1771.  
  1772.    procedure Draw_Wopr_With_missils(Main_window : in Main_Window_Access) is
  1773.  
  1774.    begin
  1775.       Main_Window.Items_List := (others => null);
  1776.       Text_Io.Put_Line("TUTU 0");
  1777.       Main_Window.Num := 1;
  1778.       Text_Io.Put_Line("TUTU 1");
  1779.       Add_Wopr_Item(Main_Window.all'access);
  1780.       Text_Io.Put_Line("TUTU 2");
  1781.       if not Is_Empty(Main_Window.Wopr.Missils) then
  1782.          for I in 1..Last_Index(Main_Window.Wopr.Missils) loop
  1783.  
  1784.             Main_Window.One_Missil := Element(Main_Window.Wopr.Missils, I);
  1785.  
  1786.             Text_Io.Put_Line("Draw Missils");
  1787.             Text_Io.Put_Line("X : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.X)));
  1788.          Text_Io.Put_Line("Y : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y)));
  1789.  
  1790.          Text_Io.Put_Line("TUTU 3");
  1791.          Add_Missil_With_Cible(Main_Window.all'Access,
  1792.                                Gint(Main_Window.One_Missil.Missil_Attributes.Source.X),
  1793.                                Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y),
  1794.                                Gint(Main_Window.One_Missil.Missil_Attributes.Target.X),
  1795.                                Gint(Main_Window.One_Missil.Missil_Attributes.Target.Y),
  1796.                                Main_Window.One_Missil.Missil_Attributes.charge);
  1797.          Text_Io.Put_Line("TUTU 4");
  1798.  
  1799.          end loop;
  1800.       end if;
  1801.    end Draw_Wopr_With_Missils;
  1802.  
  1803.  
  1804.  
  1805.  
  1806.    type String_Access is access all String;
  1807.  
  1808.    procedure Free is
  1809.       new Ada.Unchecked_Deallocation(String, String_Access);
  1810.  
  1811.  
  1812.  
  1813.    task body Process_Type is
  1814.       task type Console_Type(Hostname : access String;
  1815.                              Logname : access String;
  1816.                              Passwd : access String) is
  1817.          entry Receive(Input : in String);
  1818.          entry Create_Wopr;
  1819.          entry Create_Missil;
  1820.          entry Launch_One(Num : in Positive);
  1821.          entry Launch_All;
  1822.          entry Refresh;
  1823.       end Console_Type;
  1824.  
  1825.  
  1826.  
  1827.       task body Console_Type is
  1828.  
  1829.  
  1830.  
  1831.          task type T_Socket_Names(Hostname : access string) is
  1832.             entry Start(Username : in String);
  1833.          end T_Socket_Names;
  1834.  
  1835.  
  1836.          task type T_Socket_Out(Hostname : access String;
  1837.                              Logname : access String;
  1838.                              Passwd : access String) is
  1839.          entry Create_Wopr;
  1840.          entry receive(Input : in String);
  1841.          entry Create_Missil;
  1842.          entry Launch_One(Num : in Positive);
  1843.          entry Launch_All;
  1844.          entry Refresh;
  1845.       end T_Socket_Out;
  1846.  
  1847.  
  1848.       task body T_Socket_Out is
  1849.  
  1850.          End_Of_Task : Boolean := False;
  1851.          Address  : Sockets.Sock_Addr_Type;
  1852.          Socket   : Sockets.Socket_type;
  1853.          Channel  : Sockets.Stream_access;
  1854.          Output   : String_Access;
  1855.          Missils_Count : Missil_Vector_Index_Type := 1;
  1856.          Missil_Attributes : Missil_Attributes_Type;
  1857.          Missils : Missils_Vectors.Vector;
  1858.          Missil : Missil_Type;
  1859.          Char : Character;
  1860.       begin
  1861.          Text_Io.Put_Line("Adresse : " & Hostname.all);
  1862.          Address.Addr :=
  1863.            Sockets.Addresses (Sockets.Get_Host_By_Name (Hostname.all), 1);
  1864.  
  1865.          Address.Port := 5876;
  1866.  
  1867.          Sockets.Create_Socket (Socket);
  1868.          Sockets.Set_Socket_Option
  1869.            (Socket,
  1870.             Sockets.Socket_Level,
  1871.             (Sockets.Reuse_Address, True));
  1872.          delay 0.2;
  1873.          Text_Io.Put("Avant connect...");
  1874.          Sockets.Connect_Socket (Socket, Address);
  1875.          Text_Io.Put("Après connect...");
  1876.          Channel := Sockets.stream(Socket);
  1877.          delay 0.2;
  1878.          Text_Io.Put_line("Socket_out started.");
  1879.          String'Output(Channel, Logname.all);
  1880.          Text_Io.Put_line("Sending logname");
  1881.          String'Output(Channel, Passwd.all);
  1882.          Text_Io.Put_line("Sending password");
  1883.          End_Of_task := not Boolean'Input(Channel);
  1884.          Text_Io.Put_line("receive status");
  1885.          Text_Io.Put_line("Debut");
  1886.          loop
  1887.  
  1888.             if Boolean'Input(Channel) then
  1889.                Clear(Main_Window.Wopr.Missils);
  1890.                Main_Window.Wopr.Wopr_Attributes := Wopr_Attributes_Type'Input(Channel);
  1891.                Add_Wopr_Item(Main_Window.all'access);
  1892.                if Boolean'Input(Channel) then
  1893.                   Text_Io.Put_Line("receive missil count");
  1894.                   Missils_Count := Missil_Vector_Index_Type'Input(Channel);
  1895.                   Text_Io.Put_Line("missil count /= 0");
  1896.                   for I in 1..Missils_Count loop
  1897.                      Text_Io.Put_Line("receive missil");
  1898.                      Missil_Attributes := Missil_Attributes_Type'Input(Channel);
  1899.                      Text_Io.Put_Line("insert missil");
  1900.                      Add_Missil_With_Cible(Main_Window.all'Access,
  1901.                                            Gint(Missil_Attributes.Source.X),
  1902.                                            Gint(Missil_Attributes.Source.Y),
  1903.                                            Gint(Missil_Attributes.Target.X),
  1904.                                            Gint(Missil_Attributes.Target.Y),
  1905.                                            Missil_Attributes.charge);
  1906.  
  1907.  
  1908.                      Missil.Missil_Attributes := Missil_Attributes;
  1909.                      Insert(Main_Window.Wopr.missils, Last_Index(Main_Window.Wopr.Missils)+ 1, Missil, 1);
  1910.                      Text_Io.Put_Line("insert done.");
  1911.                   end loop;
  1912.                end if;
  1913.             else
  1914.                Text_Io.Put_Line("Get Wopr...");
  1915.                Get_Wopr_Attributes(Main_Window.all'access);
  1916.                accept Create_Wopr do
  1917.                   Main_Window.Wopr.Wopr_Attributes.Charge := 1.0;
  1918.                end Create_Wopr;
  1919.                Text_Io.Put_Line("Send Wopr...");
  1920.                Wopr_Attributes_Type'Output(Channel, Main_Window.Wopr.Wopr_Attributes);
  1921.                Text_Io.Put_Line("Draw Wopr...");
  1922.                Add_Wopr_Item(Main_Window.all'access);
  1923.             end if;
  1924.             if End_Of_Task then
  1925.                Text_Io.Put_line("End_of_task");
  1926.             end if;
  1927.             while not End_Of_Task loop
  1928.                Text_Io.Put_Line("Debut.");
  1929.                select
  1930.                   accept Create_Missil do
  1931.                      Command_Type'Output(Channel, Missil_Create);
  1932.                      Missil_Attributes_type'Output(Channel, Main_Window.One_Missil.Missil_Attributes);
  1933.                      if Boolean'Input(Channel) then
  1934.                         Main_Window.Wopr.Wopr_Attributes.Charge :=
  1935.                           Main_Window.Wopr.Wopr_Attributes.Charge -
  1936.                           Main_Window.One_Missil.Missil_Attributes.Charge;
  1937.                         insert(Main_Window.Wopr.Missils, Last_Index(Main_Window.Wopr.Missils) + 1, Main_Window.One_Missil, 1);
  1938.                         Text_Io.Put_Line("insert missil");
  1939.                         Text_Io.Put_Line("X : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.X)));
  1940.                         Text_Io.Put_Line("Y : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y)));
  1941.                      end if;
  1942.                   end Create_Missil;
  1943.                or
  1944.  
  1945.                   accept receive(Input : in String) do
  1946.                      Command_Type'Output(Channel, Player_request);
  1947.                      Text_Io.Put("push string");
  1948.                      Free(Output);
  1949.                      Output := new String ' (Input);
  1950.                      String'Output(Channel, Output.all);
  1951.                      Clear(Main_Window.Enemy);
  1952.                      if Boolean'Input(Channel) then
  1953.                         Missils_Count := Missil_Vector_Index_Type'Input(Channel);
  1954.                         Text_Io.Put_Line("missil count /= 0");
  1955.                         for I in 1..Missils_Count loop
  1956.                            Text_Io.Put_Line("receive missil");
  1957.                            Missil_Attributes := Missil_Attributes_Type'Input(Channel);
  1958.                            Text_Io.Put_Line("Add missil");
  1959.                            Text_Io.Put_Line("X : " & Gint'image(Gint(Missil_Attributes.Source.X)));
  1960.                            Text_Io.Put_Line("Y : " & Gint'image(Gint(Missil_Attributes.Source.Y)));
  1961.                            Text_Io.Put_Line("insert missil");
  1962.                            Missil.Missil_Attributes := Missil_Attributes;
  1963.                            Insert(Main_Window.enemy, Last_Index(Main_Window.enemy)+ 1, Missil, 1);
  1964.  
  1965.                            Text_Io.Put_Line("insert done.");
  1966.  
  1967.                         end loop;
  1968.                      end if;
  1969.                   end Receive;
  1970.                or
  1971.                   accept Launch_One(Num : in Positive) do
  1972.                      Command_Type'Output(Channel, Launch_One);
  1973.                      Positive'Output(Channel, Num);
  1974.                   end Launch_One;
  1975.                or
  1976.                   accept Launch_all do
  1977.                      Text_Io.Put_Line("Launch 4");
  1978.                      Command_Type'Output(Channel, Launch_All);
  1979.                      Text_Io.Put_Line("Launch N-3");
  1980.                   end Launch_all;
  1981.                or
  1982.                   accept Refresh do
  1983.                      null;
  1984.                   end Refresh;
  1985.                   Clear(Main_Window.Enemy);
  1986.                   Clear(Main_Window.Wopr.Missils);
  1987.                   Command_Type'Output(Channel, Get_wopr);
  1988.  
  1989.                   if Boolean'Input(Channel) then
  1990.                      Main_Window.Wopr.Wopr_Attributes := Wopr_Attributes_Type'Input(Channel);
  1991.  
  1992.  
  1993.                      if Boolean'Input(Channel) then
  1994.                         Text_Io.Put_Line("receive missil count");
  1995.                         Missils_Count := Missil_Vector_Index_Type'Input(Channel);
  1996.                         Text_Io.Put_Line("missil count /= 0");
  1997.                         for I in 1..Missils_Count loop
  1998.                            Text_Io.Put_Line("receive missil");
  1999.  
  2000.  
  2001.  
  2002.                            Missil.Missil_Attributes := Missil_Attributes_Type'Input(Channel);
  2003.                            Text_Io.Put_Line("insert missil");
  2004.                            Insert(Main_Window.Wopr.missils, Last_Index(Main_Window.Wopr.Missils)+ 1, Missil, 1);
  2005.                            Text_Io.Put_Line("insert done.");
  2006.                         end loop;
  2007.                      end if;
  2008.                   else
  2009.  
  2010.                      End_Of_Task := True;
  2011.                   end if;
  2012.  
  2013.                end select;
  2014.                delay 0.5;
  2015.                Text_Io.Put_Line("clear canvas...");
  2016.                Clear_canvas(null, Main_Window.all'access);
  2017.                Text_Io.Put_Line("clear canvas done.");
  2018.                Main_Window.External_Num := 1;
  2019.                Main_Window.Num := 1;
  2020.                Main_Window.Items_List := (others => null);
  2021.                Main_Window.External_Items_List := (others => null);
  2022.                if not End_Of_Task then
  2023.                   Text_Io.Put_Line("Get char");
  2024.                   --Text_Io.Get_Immediate(Char);
  2025.                   Draw_Wopr_With_Missils(Main_Window.all'access);
  2026.                   Text_Io.Put_Line("Get char");
  2027.                   --Text_Io.Get_Immediate(Char);
  2028.                   if not Is_Empty(Main_Window.enemy) then
  2029.                      Text_Io.Put_Line("enemy not empty");
  2030.                      for I in 1..Last_Index(Main_Window.enemy) loop
  2031.                         Missil_Attributes := Element(Main_Window.enemy, I).Missil_attributes;
  2032.                         Text_Io.Put_Line("Add missil");
  2033.                         Text_Io.Put_Line("X : " & Gint'image(Gint(Missil_Attributes.Source.X)));
  2034.                         Text_Io.Put_Line("Y : " & Gint'image(Gint(Missil_Attributes.Source.Y)));
  2035.                         Add_Missil(Main_Window.all'Access,
  2036.                                    Gint(Missil_Attributes.Source.X),
  2037.                                    Gint(Missil_Attributes.Source.Y));
  2038.                         Text_Io.Put_Line("add missil done.");
  2039.                         Text_Io.Put_Line("Get char");
  2040.                         --Text_Io.Get_Immediate(Char);
  2041.                      end loop;
  2042.                   end if;
  2043.                end if;
  2044.  
  2045.             end loop;
  2046.             End_Of_Task := False;
  2047.          end loop;
  2048.          Sockets.Close_Socket(Socket);
  2049.       end T_Socket_Out;
  2050.  
  2051.  
  2052.  
  2053.  
  2054.       task body T_Socket_Names is
  2055.          Address  : Sockets.Sock_Addr_Type;
  2056.          Socket   : Sockets.Socket_type;
  2057.          Channel  : Sockets.Stream_access;
  2058.          Count    : Natural := 0;
  2059.          Logname  : String_access;
  2060.          Iter  : Gtk_Tree_Iter := Null_Iter;
  2061.       begin
  2062.  
  2063.          Text_Io.New_Line;
  2064.          Text_Io.Put_line("DEMARRAGE DU THREAD NAMES");
  2065.          Address.Addr :=
  2066.            Sockets.Addresses (Sockets.Get_Host_By_Name (Hostname.all), 1);
  2067.          Address.Port := 5874;
  2068.  
  2069.          Sockets.Create_Socket (Socket);
  2070.          Sockets.Set_Socket_Option
  2071.            (Socket,
  2072.             Sockets.Socket_Level,
  2073.             (Sockets.Reuse_Address, True));
  2074.          delay 0.2;
  2075.          Text_Io.Put_line("NAMES Avant connect...");
  2076.          Sockets.Connect_Socket (Socket, Address);
  2077.          Text_Io.Put_line("NAMES Après connect...");
  2078.          Channel := Sockets.stream(Socket);
  2079.          accept Start(Username : in String) do
  2080.                  String'Output(Channel, username);
  2081.          end Start;
  2082.          Count := Natural'Input(Channel);
  2083.          delay 0.2;
  2084.          loop
  2085.             case Command_Type'Input(Channel) is
  2086.                when Log_Lognames =>
  2087.                   Count := Natural'Input(Channel);
  2088.                   Text_Io.Put_Line("Clear list");
  2089.                   Clear(Main_Window.Model);
  2090.                   Text_Io.Put_line("input count NAMES...");
  2091.                   if Count > 0 then
  2092.                      Text_Io.Put_line("input count NAMES... /= 0");
  2093.                      for I in 1..Count loop
  2094.                         Xborg.Free(Logname);
  2095.                         Logname := new String ' (String'Input(Channel));
  2096.                         if Logname.all /= Main_Window.Logname.all then
  2097.                            Text_Io.Put_Line("Add item");
  2098.                            Iter := Add_Line(Main_Window.model, Logname.all);
  2099.                            Text_Io.Put_Line("Item added");
  2100.  
  2101.                         end if;
  2102.                      end loop;
  2103.                      Count := Count -1;
  2104.                   end if;
  2105.  
  2106.                   --Text_Io.Put_line("Avant show all");
  2107.                   --Show_All(Main_Window.Tree_View_names);
  2108.                   --Text_Io.Put_line("Après show all");
  2109.                when Refresh =>
  2110.                   Main_Window.Process.Refresh;
  2111.                when others =>
  2112.                   null;
  2113.             end case;
  2114.          end loop;
  2115.       end T_Socket_Names;
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.          Output_Deamon : T_Socket_Out(new String '(Hostname.all),
  2122.                                       Logname,
  2123.                                       new String ' (String(MD5.Digest(Passwd.all))));
  2124.          Logname_Deamon : T_Socket_names(Hostname);
  2125.          Need_All, Need_Refresh, Need_Wopr : Boolean := False;
  2126.       begin
  2127.          Logname_Deamon.start(Logname.all);
  2128.          loop
  2129.             select
  2130.                accept Create_Missil do
  2131.                   Output_Deamon.Create_Missil;
  2132.                end Create_Missil;
  2133.             or
  2134.                accept Create_Wopr do
  2135.                   Need_Wopr := True;
  2136.                   --Output_Deamon.Create_Wopr;
  2137.                end Create_Wopr;
  2138.             or
  2139.                accept Receive(Input : in String) do
  2140.                   Output_Deamon.Receive(Input);
  2141.                end Receive;
  2142.  
  2143.             or
  2144.                accept Launch_One(Num : in Positive) do
  2145.                   Output_Deamon.Launch_One(Num);
  2146.                end Launch_One;
  2147.             or
  2148.                accept Launch_All do
  2149.                   Need_All := True;
  2150.                   Text_Io.Put_Line("Launch 2");
  2151.                   --Output_Deamon.Launch_All;
  2152.                end Launch_All;
  2153.             or
  2154.                accept Refresh do
  2155.                   Need_Refresh := True;
  2156.                   --Output_Deamon.Refresh;
  2157.                end Refresh;
  2158.             end select;
  2159.             if Need_Wopr then
  2160.                Output_deamon.Create_Wopr;
  2161.                Need_Wopr := False;
  2162.             end if;
  2163.             if Need_Refresh then
  2164.                Output_deamon.Refresh;
  2165.                Need_Refresh := False;
  2166.             end if;
  2167.             if Need_All then
  2168.                Text_Io.Put_Line("Launch 3");
  2169.                Output_deamon.Launch_All;
  2170.                Text_Io.Put_Line("Launch N-2");
  2171.                Need_All := false;
  2172.             end if;
  2173.          end loop;
  2174.       end Console_Type;
  2175.  
  2176.  
  2177.       Console : access Console_Type;
  2178.  
  2179.       Need_All, Need_Refresh, Need_Wopr : Boolean := False;
  2180.    begin
  2181.       loop
  2182.          select
  2183.             accept Login(Address : in String;
  2184.                          Logname : in String;
  2185.                          Passwd  : in String;
  2186.                          Success : out boolean) do
  2187.                begin
  2188.  
  2189.                   Console := new Console_Type(new String ' (Address),
  2190.                                               new String ' (Logname),
  2191.                                               new String ' (Passwd));
  2192.                   Success := True;
  2193.                exception
  2194.                   when others =>
  2195.                      Success := False;
  2196.                end;
  2197.             end Login;
  2198.          or
  2199.             accept Receive(Content : in String) do
  2200.                begin
  2201.                   Text_Io.Put_Line("Send text from : " & Content);
  2202.                   Console.Receive(Content);
  2203.                end;
  2204.             end Receive;
  2205.          or
  2206.             accept Create_Wopr do
  2207.  
  2208.                Need_Wopr := True;
  2209.             end Create_Wopr;
  2210.          or
  2211.             accept Create_Missil do
  2212.                Console.Create_Missil;
  2213.             end Create_Missil;
  2214.          or
  2215.             accept Launch_One(Num : in Positive) do
  2216.                console.Launch_One(Num);
  2217.             end Launch_One;
  2218.          or
  2219.             accept Launch_All do
  2220.                Need_All := True;
  2221.                Text_Io.Put_Line("Launch 1");
  2222.             end Launch_all;
  2223.          or
  2224.             accept Refresh do
  2225.                Need_Refresh := True;
  2226.             end Refresh;
  2227.          end select;
  2228.          if Need_Wopr then
  2229.             Console.Create_Wopr;
  2230.             Need_Wopr := False;
  2231.          end if;
  2232.          if Need_Refresh then
  2233.             console.Refresh;
  2234.             Need_Refresh := False;
  2235.          end if;
  2236.          if Need_All then
  2237.             Text_Io.Put_Line("Launch 2");
  2238.             console.Launch_All;
  2239.             Text_Io.Put_Line("Launch N-1");
  2240.             Need_All := false;
  2241.          end if;
  2242.       end loop;
  2243.    end Process_Type;
  2244. begin
  2245.    Gtk.Main.Init;
  2246.    Sockets.Initialize;
  2247. end Warborg.Xborg;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement