-------------------------------------------------------------------
--           RAPID - RAPID ADA PORTABLE INTERFACE DESIGNER         
--           MCC GUI PACKAGE LIBRARY                               
--           Copyright (C) 1999 Martin C. Carlisle.                
--                                                                 
-- RAPID is free software; you can redistribute it and/or modify
-- it under terms of the GNU General Public License as published  
-- by the Free Software Foundation; either version 2, or (at your
-- option) any later version.  RAPID is distributed in the hope that 
-- it will be useful, but WITHOUT ANY WARRANTY; without even the 
-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE.  See the GNU General Public License for more details.  
-- You should have received a copy of the GNU General Public License
-- distributed with RAPID; see file COPYING.  If not, write to the 
-- Free Software Foundation,  59 Temple Place - Suite 330,  Boston, 
-- MA 02111-1307, USA.                                                 
--                                                                     
-- As a special exception, if other files instantiate generics from
-- this unit, or you link this unit with other files to produce an 
-- executable, this unit does not by itself cause the resulting 
-- executable to be covered by the GNU General Public License.  
-- This exception does not however invalidate any other reasons 
-- why the executable file might be covered by the GNU Public 
-- License.  This exception does not apply to executables which
-- are GUI design tools, or that could act as a replacement
-- for RAPID.
------------------------------------------------------------------------------
with Gdk;
with Glib;
with gtk.accel_group;
with Gtk.Box;
with Gtk.Enums;
with Gtk.Fixed;
with Gtk.Item_Factory;
with gtk.menu;
with gtk.menu_item;
with gtk.menu_bar;
with Gtk.Widget;
with Mcc.Gui.Container.Window;
with Mcc.Gui.Window_Peer;
with Peer.Frame;
use Peer.Frame;
with System;
with ada.text_io;
package body Mcc.Gui.Menu is

   ----------------
   -- Add_Choice --
   ----------------

   procedure Add_Choice(Obj         : in out Choice;
                         To_Menu     : in     Menu'Class;
                         Text        : in     String;
                         Action      : in     Menu_Callback;
                         Underline   : in     Natural;
                         Accelerator : in     String := "")is
   begin
      null;
   end Add_Choice;

   ----------------
   -- Add_Choice --
   ----------------

   procedure Add_Choice(Obj         : in out Choice;
                        To_Menu     : in     Menu'Class;
                        Text        : in     String;
                        Action      : in     Menu_Callback;
                        Underline   : in     Natural;
                        Location    : in     Natural;
                        Accelerator : in     String := "")is
   begin
      null;
   end Add_Choice;

   -----------------
   -- Add_Submenu --
   -----------------

   procedure Add_Submenu(Obj         : in out Submenu;
                         Text        : in     String;
                         Underline   : in     Natural;
                         Parent_Menu : in     Menu'Class;
                         On_Post     : in     Menu_Callback := null)is
      bob : Gtk.Item_Factory.Gtk_Item_Factory_Entry;

   begin
      gtk.item_Factory.gtk_new(bob,
          Path => "/_File", Accelerator => "",
          Callback => null,
          Item_type => gtk.item_factory.branch);
      
      Gtk.Item_Factory.create_item(bob,
        gtk.item_factory.gtk_item_factory(parent_menu.my_peer));
      gtk.item_Factory.gtk_new(bob,
          Path => "/_File/_New", Accelerator => "<control>N",
          Callback => null,
          Item_type => gtk.item_factory.item);
      
      Gtk.Item_Factory.create_item(bob,
        gtk.item_factory.gtk_item_factory(parent_menu.my_peer));
   end Add_Submenu;

   -----------------
   -- Add_Submenu --
   -----------------

   procedure Add_Submenu(Obj         : in out Submenu;
                         Text        : in     String;
                         Underline   : in     Natural;
                         Parent_Menu : in     Menu'Class;
                         Location    : in     Natural;
                         On_Post     : in     Menu_Callback := null)is
   begin
      null;
   end Add_Submenu;

   ------------
   -- Create --
   ------------

   procedure Create(Obj    : in out Window_Menu;
                    Window : in     Mcc.Gui.Container.Container'Class)is

      Item_Factory : Gtk.Item_Factory.Gtk_Item_Factory;
      Menu_Bar     : Gtk.Widget.Gtk_Widget;
      Accel_Group  : Gtk.Accel_Group.Gtk_Accel_Group;
   begin
      gtk.Accel_Group.Gtk_New(Accel_Group);
      gtk.Item_Factory.Gtk_New(
         Factory        => Item_Factory,
         Container_Type => Gtk.Enums.Menu_Factory_Menu_Bar,
         Path           => "<root>",
         Accel_Group    => Accel_Group
         );
      
      Menu_Bar := Gtk.Item_Factory.Get_Widget(
         Factory => Item_Factory,
         Path    => "<root>");
      if Window in Mcc.Gui.Container.Window.Window'Class then
         gtk.box.Pack_Start(
            In_Box  => gtk.box.Gtk_Vbox(
               Gtk.Widget.Get_Parent(Gtk.Widget.Gtk_Widget(window.my_peer))),
            Child   => menu_bar);  
         Gtk.Accel_Group.Attach(Accel_Group,
            Mcc.Gui.Window_Peer.Get_Window(Window));
      else
         gtk.box.Pack_Start(
            In_Box  => Gtk.Box.Gtk_Vbox(
               Gtk.Fixed.Get_Parent(Mcc_Frame(window.my_peer).Fixed)),
            Child   => menu_bar);  
      end if;
      Gtk.Widget.Show(Menu_Bar);
      --Have Object point to menu bar Widget
      Obj.My_Peer := gdk.root_type_access(Item_Factory);
      
   end Create;

   ------------
   -- Delete --
   ------------

   procedure Delete (Obj : in out Menu_Item) is
   begin
      null;
   end Delete;

   -------------
   -- Disable --
   -------------

   procedure Disable (Obj : in out Choice) is
   begin
      null;
   end Disable;

   ------------
   -- Enable --
   ------------

   procedure Enable (Obj : in out Choice) is
   begin
      null;
   end Enable;

   procedure Add_Separator(
      Obj         : in out Separator;
      To_Menu     : in     Menu'Class) is
   begin
      null;
   end;
      
   procedure Add_Separator(
      Obj         : in out Separator;
      To_Menu     : in     Menu'Class;
      Location    : in     Natural) is
   begin
      null;
   end;

end Mcc.Gui.Menu;

