// Copyright 1996, Marimba Inc. All Rights Reserved.


// @(#)WidgetDialog.java, 1.2, 12/19/96





package marimba.gui;





import java.io.*;


import java.net.*;


import java.awt.*;


import java.util.*;





import marimba.persist.*;





/**


 * A dialog which sends its events to the widget it


 * belongs to.


 *


 * @author      Klaas Waslander


 * @version 	1.2, 12/19/96


 */


public class WidgetDialog extends PlayerDialog {


    Widget  w;





    /**


     * Construct a new player dialog and show a presentation in it,


     * by specifying the widget to which it belongs and the url


     * to the gui that has to be shown.


     */


    public WidgetDialog(Widget w, URL url) {


	super((Frame)w.getPlayerPanel().getParent(), null, url);


	this.w = w;


    }





    /**


     * Construct a new dialog by giving it a


     * presentation object directly.


     */


    public WidgetDialog(Widget w, Presentation p) {


	super((Frame)w.getPlayerPanel().getParent(), null, p);


	this.w = w;


    }





    /**


     * Handle events: handle the window things and post


     * the other events to the widget.


     */


    public boolean handleEvent(Event evt) {


	switch (evt.id) {


	    case Event.WINDOW_ICONIFY:


	    case Event.WINDOW_DEICONIFY:


		return super.handleEvent(evt);





	    case Event.WINDOW_DESTROY: {


		close();


	    }


	}


	w.postEvent(evt);


	return true;


    }


}


