-- Auto generated by RAPID
-- By: Martin C. Carlisle and W. Blair Watkinson II

with tom;
with tom;
with dick1;
with dick2;
with Ada.Strings.Unbounded;
with dick1;
with dick2;
with dick1;
with dick2;
with Mcc.Text_Entry_Types;
with dick1;
with dick2;
with Mcc.Text_Entry_Types;
with dick1;
with dick2;
with Mcc.Text_Entry_Types;
with dick1;
with dick2;
with Mcc.Text_Entry_Types;


with Mcc.Gui.Fonts;

package body test_window is

   procedure Generate_Window is
   begin

      if Mcc.Gui.Container.Window.Is_Open(Mcc.Gui.Container.Window.Window(test_window)) then
         raise Already_Open;
      end if;

      Mcc.Gui.Container.Window.Create(
         Obj    => test_window,
         X      => 0,
         Y      => 0,
         Width  => 300,
         Height => 300);

      Mcc.Gui.Container.Window.Set_Title(
         Obj   => test_window,
         Title => "test");


      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => tom,
         Parent => test_window,
         X      => 14,
         Y      => 14,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => dick,
         Parent => test_window,
         X      => 14,
         Y      => 44,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => larry,
         Parent => test_window,
         X      => 14,
         Y      => 74,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => harry,
         Parent => test_window,
         X      => 14,
         Y      => 104,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => tim1,
         Parent => test_window,
         X      => 13,
         Y      => 139,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => tim2,
         Parent => test_window,
         X      => 13,
         Y      => 169,
         Width  => 141,
         Height => 27);
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => tim3,
         Parent => test_window,
         X      => 13,
         Y      => 199,
         Width  => 141,
         Height => 27);

   end Generate_Window;


   procedure Fill_Window is
   begin
      null; -- in case there aren't any widgets to fill
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => tom,
         Text   => Integer(tom.data_item));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => dick,
         Text   => Ada.Strings.Unbounded.To_String(dick1.data_item));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => larry,
         Text   => dick2.data_type'Image(dick1.data_item));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => harry,
         Text   => Mcc.Text_Entry_Types.Image(Float(dick1.data_item), Mcc.Text_Entry_Types.FLOAT_1));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => tim1,
         Text   => Mcc.Text_Entry_Types.Image(Float(dick1.data_item), Mcc.Text_Entry_Types.FLOAT_2));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => tim2,
         Text   => Mcc.Text_Entry_Types.Image(Float(dick1.data_item), Mcc.Text_Entry_Types.FLOAT_3));
      Mcc.Gui.Widget.Text_Entry.Set_Text(
         Obj      => tim3,
         Text   => Mcc.Text_Entry_Types.Image(Float(dick1.data_item), Mcc.Text_Entry_Types.FLOAT_E));

   end Fill_Window;

   procedure Generate_and_Fill_Window is
   begin
       Generate_Window;
       Fill_Window;
   end Generate_and_Fill_Window;

   procedure Read_Window(
         Success         :    out Boolean;
         Highlight_Error : in     Boolean := True;
         Beep_On_Error   : in     Boolean := True) is
   begin
      Success := True;
      declare
         X : Integer := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => tom);
      begin
         tom.data_item := tom.data_type(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(tom);
         end if;
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => dick);
      begin
         dick1.data_item := Ada.Strings.Unbounded.To_Unbounded_String(X);
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => larry);
      begin
dick2.data_type'Value(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(larry);
         end if;
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => harry);
      begin
dick2.data_type'Value(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(harry);
         end if;
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => tim1);
      begin
dick2.data_type'Value(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(tim1);
         end if;
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => tim2);
      begin
dick2.data_type'Value(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(tim2);
         end if;
      end;
      declare
         X : String := Mcc.Gui.Widget.Text_Entry.Get_Text(
            Obj => tim3);
      begin
dick2.data_type'Value(X);
      exception when Constraint_Error =>
         if Highlight_Error then
            Mcc.Gui.Widget.Text_Entry.Highlight(tim3);
         end if;
      end;
   exception when others =>
      Success := False;
      if Beep_On_Error then
         Mcc.Gui.Beep;
      end if;
   end Read_Window;

   procedure Close_Window is
   begin
      Mcc.Gui.Destroy(Mcc.Gui.Object(test_window));
   end Close_Window;


end test_window;
