// ImageComments.py : Dialog box for adding comments to an image
//
// Distributed under the terms described in the LICENCE file.
//
// Developed by akuchlin@mems-exchange.org
//
// Presents the user with a text area for entering comments about an
// image.

import java.awt.*;
import java.awt.Event;

public class ImageEmailDialog extends Dialog {
    static String __revision__ = "$Id: ImageEmailDialog.java,v 1.5 2002/01/03 21:19:56 akuchlin Exp $";

    private TextArea textarea;
    private TextField email_field = null;
    private Button ok_button, cancel_button;
    private boolean show_email = false;
    public String comments = null;
    public String email = null;

    public ImageEmailDialog (Frame parent) {
        // Initialize as a modal dialog
        super(parent, "Image Comments", true);
        this.setLayout( new BorderLayout() );

        this.email_field = new TextField(20);
        this.textarea = new TextArea("", 6, 20);
        this.comments = null;
        this.email = null;

        Panel p = new Panel();
	p.setLayout( new BorderLayout() );
	p.add("South", new Label("Comments on this image") );
        p.add("North",  new Label("Your e-mail address:") );
        p.add("Center", this.email_field );
	this.add("North", p);

        p = new Panel();
	p.setLayout( new BorderLayout() );
        this.ok_button = new Button("OK");
        this.cancel_button = new Button("Cancel");
        p.add("West", this.ok_button);
        p.add("East", this.cancel_button);
	this.add("South", p);

        this.add("Center", this.textarea );
    }

    public boolean processEvent(Event e) {
        if (e.id == Event.WINDOW_DESTROY) {
            this.dispose();
            return true;
	}
	else if (e.id == Event.ACTION_EVENT &&
		 (e.target instanceof Button) ) {
            if (e.arg.equals("OK")) {
		this.comments = this.textarea.getText();
		this.email = this.email_field.getText();
	    }
	    
            this.dispose();
	    return true;
	}
	return false;
    }
}
