/*
 * 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.glib.Type;
import org.gnu.gtk.Button;
import org.gnu.gtk.Container;
import org.gnu.gtk.Widget;
import org.gnu.gtk.Window;
/**
 * The GNOME druid is a system for assisting the user with installing a
 * service. It is roughly equivalent in functionality to the Wizards
 * available in Windows.
 */
public class Druid extends Container {
	
	/**
	 * Construct a new Druid object.
	 */
	public Druid() {
		super(gnome_druid_new());
	}
	
	/**
	 * Construct a new Druid from a handle to a native resource.
	 */
	public Druid(int handle) {
	    super(handle);
	}
	
	/**
	 * Construct a new Druid object that already contains a window.
	 */
	public Druid(String title, Window parent, boolean closeOnCancel, Widget window) {
		super(gnome_druid_new_with_window(title, parent.getHandle(), closeOnCancel, window.getHandle()));
	}
	
	/**
	 * Sets the sensitivity of the buttons on the Druid dialog.
	 * @param backSensitive Determines if the "Back" button is sensitive.
	 * @param nextSensitive Determines if the "Next" button is sensitive.
	 * @param cancelSensitive Determines if the "Cancel" button is sensitive.
	 * @param helpSensitive Determines if the "Help" button is sensitive.
	 */
	public void setButtonsSensitive(boolean backSensitive, boolean nextSensitive, boolean cancelSensitive, boolean helpSensitive) {
		gnome_druid_set_buttons_sensitive(getHandle(), backSensitive, nextSensitive, cancelSensitive, helpSensitive);
	}
	
	/**
	 * Sets the text on the last button of the dialog.  If <i>showFinish</i> is true the text
	 * becomes "Finish".  Otherwise the text is set to "Cancel".
	 * @param showFinish Determines the text of the last button on the dialog.
	 */
	public void setShowFinish(boolean showFinish) {
		gnome_druid_set_show_finish(getHandle(), showFinish);
	}

	/**
	 * Sets whether the help button should be displayed 
	 */
	public void setShowHelp( boolean showHelp ){
		gnome_druid_set_show_help( getHandle(), showHelp );
	}
	
	/**
	 * Prepends a DruidPage into the list of pages for this dialog.
	 * @param page The page to prepend.
	 */
	public void prependPage(DruidPage page) {
		gnome_druid_prepend_page(getHandle(), page.getHandle());
	}
	
	/**
	 * Append a DruidPage into the list of pages for this dialog.
	 * @param page The page to append.
	 */
	public void appendPage(DruidPage page) {
		gnome_druid_append_page(getHandle(), page.getHandle());
	}
	
	/**
	 * Insert <i>page</i> after <i>backPage</i> into the list of pages for
	 * this dialog.  If </i>backPage is not present or null, </i>page</i> will
	 * be prepended.
	 * @param backPage
	 * @param page
	 */
	public void insertPage(DruidPage backPage, DruidPage page) {
		gnome_druid_insert_page(getHandle(), backPage.getHandle(), page.getHandle());
	}
	
	/**
	 * Set the currently displayed page to <i>page</i>.
	 * @param page The page to make the current page.
	 */
	public void setPage(DruidPage page) {
		gnome_druid_set_page(getHandle(), page.getHandle());
	}
	
	/**
	 * Retrieve the "Help" button.
	 */
	public Button getHelpButton() {
		int hndl = getHelp(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (Button)obj;
		return new Button(hndl);
	}
	
	/**
	 * Retrieve the "Back" button.
	 */
	public Button getBackButton() {
		int hndl = getBack(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (Button)obj;
		return new Button(hndl);
	}
	
	/**
	 * Retrieve the "Next" button.
	 */
	public Button getNextButton() {
		int hndl = getNext(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (Button)obj;
		return new Button(hndl);
	}
	
	/**
	 * Retrieve the "Cancel" button.
	 */
	public Button getCancelButton() {
		int hndl = getCancel(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (Button)obj;
		return new Button(hndl);
	}
	
	/**
	 * Retrieve the "Finish" button.
	 */
	public Button getFinishButton() {
		int hndl = getFinish(getHandle());
		GObject obj = retrieveGObject(hndl);
		if (null != obj)
			return (Button)obj;
		return new Button(hndl);
	}
	
	/**
	 * Retrieve the runtime type used by the GLib library.
	 */
	public static Type getType() {
		return new Type(gnome_druid_get_type());
	}
	/****************************************
	 * BEGINNING OF GENERATED CODE
	 ****************************************/
	native static final protected int getHelp(int cptr);
	native static final protected int getBack(int cptr);
	native static final protected int getNext(int cptr);
	native static final protected int getCancel(int cptr);
	native static final protected int getFinish(int cptr);
	native static final protected int gnome_druid_get_type();
	native static final protected int gnome_druid_new();
	native static final protected void gnome_druid_set_buttons_sensitive(int druid, boolean backSensitive, boolean nextSensitive, boolean cancelSensitive, boolean helpSensitive);
	native static final protected void gnome_druid_set_show_finish(int druid, boolean showFinish);
	native static final protected void gnome_druid_set_show_help(int druid, boolean showHelp);
	native static final protected void gnome_druid_prepend_page(int druid, int page);
	native static final protected void gnome_druid_insert_page(int druid, int backPage, int page);
	native static final protected void gnome_druid_append_page(int druid, int page);
	native static final protected void gnome_druid_set_page(int druid, int page);
	native static final protected int gnome_druid_new_with_window(String title, int parent, boolean closeOnCancel, int window);
	/****************************************
	 * END OF GENERATED CODE
	 ****************************************/
}
