/*
 * Java-Gnome Bindings Library
 *
 * Copyright 1998-2004 the Java-Gnome Team, all rights reserved.
 *
 * The Java-Gnome bindings library is free software distributed under
 * the terms of the GNU Library General Public License version 2.
 */

package org.gnu.gnome;
import org.gnu.glib.GObject;
import org.gnu.gtk.Menu;
import org.gnu.gtk.*;
/**
 * @deprecated
 */
public class PopupMenu extends Menu {
	
	/**
	 * Construct a new PopupMenu object.
	 */
	public PopupMenu(UIInfo [] uiinfos) {
		super(init1(uiinfos));
	}
	
	private static int init1(UIInfo[] uiinfos) {
		int [] hndls= new int[uiinfos.length];
		for (int i = 0; i < uiinfos.length; i++) {
			hndls[i] = uiinfos[i].getHandle();
		}
		return gnome_popup_menu_new(hndls);
	}
	
	/**
	 * Construct a new PopupMenu object.
	 */
	public PopupMenu(UIInfo [] uiinfos, AccelGroup accelGroup) {
		super(init2(uiinfos, accelGroup));
	}
	
	private static int init2(UIInfo [] uiinfos, AccelGroup accelGroup) {
		int [] hndls= new int[uiinfos.length];
		for (int i = 0; i < uiinfos.length; i++) {
			hndls[i] = uiinfos[i].getHandle();
		}
		return gnome_popup_menu_new_with_accelgroup(hndls, accelGroup.getHandle());
	}
	
	/**
	 * Return the AccelGroup associated with this PopupMenu.
	 */
	public AccelGroup getAccelGroup() {
		int hndl = gnome_popup_menu_get_accel_group(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (AccelGroup)obj;
		return new AccelGroup(hndl);
	}
	
	/**
	 * Attach this menu to a Widget.
	 */
	public void attach(Widget widget) {
		gnome_popup_menu_attach(getHandle(), widget.getHandle(), 0);
	}
	
	/**
	 * Append new menu items to the PopupMenu.
	 */
	public void append(UIInfo [] uiinfos) {
		int [] hndls= new int[uiinfos.length];
		for (int i = 0; i < uiinfos.length; i++) {
			hndls[i] = uiinfos[i].getHandle();
		}
		gnome_popup_menu_append(getHandle(), hndls);
	}

	/****************************************
	 * BEGINNING OF GENERATED CODE
	 ****************************************/
	native static final protected int gnome_popup_menu_new(int[] uiinfo);
	native static final protected int gnome_popup_menu_new_with_accelgroup(int[] uiinfo, int accelgroup);
    native static final protected int gnome_popup_menu_get_accel_group (int menu);
    native static final protected void gnome_popup_menu_attach (int menu, int widget, int userData);
    native static final protected void gnome_popup_menu_append (int menu, int [] uiinfo);
	/****************************************
	 * END OF GENERATED CODE
	 ****************************************/
}
