with mcc.gui.container.window;
with mcc.gui.menu;
with mcc.gui.container.frame;
with ada.text_io;
use ada.text_io;

procedure menu_test is

   Window  : aliased mcc.gui.container.window.main_window;
   window_menu : aliased mcc.gui.menu.window_menu;
   file_menu   : aliased mcc.gui.menu.submenu;
   new_choice  : aliased mcc.gui.menu.choice;
   delete_choice  : aliased mcc.gui.menu.choice;
   frame1  : aliased mcc.gui.container.frame.frame;
   frame_menu  : aliased mcc.gui.menu.window_menu;
   frame_file  : aliased mcc.gui.menu.submenu;
   frame_edit  : aliased mcc.gui.menu.submenu;
   frame_copy  : aliased mcc.gui.menu.choice;
   frame_new   : aliased mcc.gui.menu.choice;

   procedure new_callback is
   begin
      put_line(standard_output,"new menu choice selected");
   end new_callback;

   procedure menu_callback is
   begin
      put_line(standard_output,"menu displayed");
   end menu_callback;
begin
   -- test window functions
   mcc.gui.container.window.create(window,
      100,100,300,300);
   mcc.gui.container.window.set_title(window,"Fr""ed");


   -- frame test
   mcc.gui.container.frame.create(frame1,window,5,148,170,70,1);

   -- menu tests
   mcc.gui.menu.create(window_menu,window);
   put_line(standard_output,"hello world");
   mcc.gui.menu.add_submenu(file_menu,"File",1,window_menu);
   put_line(standard_output,"added submenu");
   mcc.gui.menu.add_choice(new_choice,file_menu,"New",
      new_callback'unrestricted_access,1,"Ctrl+G");
   put_line(standard_output,"added choice");
   mcc.gui.menu.disable(new_choice);
   put_line(standard_output,"disabled choice");
   mcc.gui.menu.enable(new_choice);
   mcc.gui.menu.delete(new_choice);
   mcc.gui.menu.delete(file_menu);
   -- was testing menu_callback above, but that menu is deleted!!
   mcc.gui.menu.add_submenu(file_menu,"File",1,window_menu,
      menu_callback'unrestricted_access);
   mcc.gui.menu.add_choice(delete_choice,file_menu,"Delete",
      new_callback'unrestricted_access,1,"Del");
   -- test no accelerator here
   mcc.gui.menu.add_choice(new_choice,file_menu,"New",
      new_callback'unrestricted_access,1,0,"");
   mcc.gui.menu.delete(delete_choice);

   mcc.gui.menu.create(frame_menu,frame1);
   mcc.gui.menu.add_submenu(frame_file,"File",1,frame_menu);
   -- I get deleted
   mcc.gui.menu.add_choice(Obj => frame_new,To_Menu => frame_file,
      Text => "New",
      Action => new_callback'unrestricted_access,
      Underline => 1,
      Location => 0,Accelerator => "Ctrl+L");
   mcc.gui.menu.disable(frame_new);
   mcc.gui.menu.add_submenu(frame_edit,"Edit",1,frame_menu,
       menu_callback'unrestricted_access);
   mcc.gui.menu.add_choice(Obj => frame_copy, To_Menu => frame_edit,
      Text => "Copy", Underline => 1,
      Action => new_callback'unrestricted_access,
      Accelerator => "Ctrl+F");
   mcc.gui.menu.delete(frame_new);
   mcc.gui.menu.delete(frame_file);
   put_line(standard_output,"at event loop");
   mcc.gui.container.window.event_loop;
end menu_test;
