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

with Subwindow_Actions;
with Subwindow_Actions;
with Subwindow_Actions;
with Mcc.Text_Entry_Types;
with Mcc.Text_Entry_Types;


with Mcc.Gui.Fonts;

package body textentry_dialog_window is

   procedure Generate_Window is
   begin

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

      Mcc.Gui.Container.Window.Create(
         Obj    => textentry_dialog_window,
         X      => 0,
         Y      => 0,
         Width  => 372,
         Height => 249);

      Mcc.Gui.Container.Window.Set_Title(
         Obj   => textentry_dialog_window,
         Title => "Text Entry Properties");


      Mcc.Gui.Widget.Label.Create(
         Obj     => label1,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 5,
         Width   => 110,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Widget name");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry1,
         Parent => textentry_dialog_window,
         X      => 80,
         Y      => 5,
         Width  => 269,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => label2,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 35,
         Width   => 110,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "X");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry2,
         Parent => textentry_dialog_window,
         X      => 80,
         Y      => 35,
         Width  => 100,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => label3,
         Parent  => textentry_dialog_window,
         X       => 198,
         Y       => 35,
         Width   => 45,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Y");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry3,
         Parent => textentry_dialog_window,
         X      => 250,
         Y      => 35,
         Width  => 100,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => label4,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 65,
         Width   => 70,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Width");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry4,
         Parent => textentry_dialog_window,
         X      => 80,
         Y      => 65,
         Width  => 100,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => label5,
         Parent  => textentry_dialog_window,
         X       => 198,
         Y       => 65,
         Width   => 52,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Height");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry5,
         Parent => textentry_dialog_window,
         X      => 250,
         Y      => 65,
         Width  => 100,
         Height => 20);
      Mcc.Gui.Widget.Button.Text.Create(
         Obj    => applyButton,
         Parent => textentry_dialog_window,
         X      => 77,
         Y      => 215,
         Width  => 60,
         Height => 20,
         Text   => "Apply");
      Mcc.Gui.Widget.Button.Set_Push_Callback(
         Obj      => applyButton'access,
         Callback => Subwindow_Actions.Apply_Properties_Dialog'access);
      Mcc.Gui.Widget.Button.Text.Create(
         Obj    => okbutton,
         Parent => textentry_dialog_window,
         X      => 147,
         Y      => 215,
         Width  => 60,
         Height => 20,
         Text   => "OK");
      Mcc.Gui.Widget.Button.Set_Push_Callback(
         Obj      => okbutton'access,
         Callback => Subwindow_Actions.Done_Properties_Dialog'access);
      Mcc.Gui.Widget.Button.Text.Create(
         Obj    => cancelButton,
         Parent => textentry_dialog_window,
         X      => 217,
         Y      => 215,
         Width  => 60,
         Height => 20,
         Text   => "Cancel");
      Mcc.Gui.Widget.Button.Set_Push_Callback(
         Obj      => cancelButton'access,
         Callback => Subwindow_Actions.Cancel_Properties_Dialog'access);
      Mcc.Gui.Widget.Label.Create(
         Obj     => item_label,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 125,
         Width   => 70,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Data Item");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry6,
         Parent => textentry_dialog_window,
         X      => 80,
         Y      => 125,
         Width  => 269,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => autofill,
         Parent  => textentry_dialog_window,
         X       => 5,
         Y       => 98,
         Width   => 345,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.center,
         Text    => "Use fully qualified names or leave blank");
      Mcc.Gui.Widget.Label.Set_Background_Color(
         Obj       => autofill,
         New_Color => Mcc.Gui.Colors.Named_Color(
            Mcc.Gui.Colors.lightblue));
      Mcc.Gui.Widget.Label.Create(
         Obj     => typelabel,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 185,
         Width   => 70,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Data type");
      Mcc.Gui.Widget.Text_Entry.Create(
         Obj    => entry7,
         Parent => textentry_dialog_window,
         X      => 80,
         Y      => 185,
         Width  => 269,
         Height => 20);
      Mcc.Gui.Widget.Label.Create(
         Obj     => baselabel,
         Parent  => textentry_dialog_window,
         X       => 0,
         Y       => 155,
         Width   => 70,
         Height  => 20,
         Justify => Mcc.Gui.Widget.Label.left,
         Text    => "Base type");
      Mcc.Gui.Widget.Dropdown.Create(
         Obj                  => base_dropdown,
         Parent               => textentry_dialog_window,
         X                    => 74,
         Y                    => 154,
         Width                => 179,
         Height               => 25,
         Number_Rows          => 7);
      for E in Mcc.Text_Entry_Types.Base_Type loop
         Mcc.Gui.Widget.Dropdown.Add_Entry(
            Obj      => base_dropdown,
            Location => Mcc.Text_Entry_Types.Base_Type'Pos(E),
            Text     => Mcc.Text_Entry_Types.Base_Type'Image(E));
      end loop;

   end Generate_Window;


   procedure Fill_Window is
   begin
      null; -- in case there aren't any widgets to fill
      Mcc.Gui.Widget.Dropdown.Select_Item(
         Obj      => base_dropdown,
         Number   => Mcc.Text_Entry_Types.Base_Type'Pos(Mcc.Text_Entry_Types.Temporary)+1);

   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
         Position : Integer := Mcc.Gui.Widget.Dropdown.Get_Selected(base_dropdown) - 1;
      begin
         Mcc.Text_Entry_Types.Temporary:= Mcc.Text_Entry_Types.Base_Type'Val(Position);
      end;
   exception when others => Success := False;
   end Read_Window;

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


end textentry_dialog_window;
