/*
 Eteria IRC Client, an RFC 1459 compliant client program written in Java.
 Copyright (C) 2001  Christian Buck <cbuck at lantis.de>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
 This program 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
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 import java.awt.*;
 import java.awt.event.*;
 
 import ar.com.jkohen.awt.ImageButton;
 import ar.com.jkohen.util.Resources;
 
 public class TextAreaCopy extends NewDialog implements ActionListener
 {
 	private TextArea ta;
 	private Label label;
 
 	private Resources res;
 
 	public TextAreaCopy(EIRC eirc, String text)
 	{
 		super(eirc);
 
 		setFont(eirc.getFont());
 
 		GridBagLayout gb = new GridBagLayout();
 		GridBagConstraints gbc = new GridBagConstraints();
 		setLayout(gb);
 
 		gbc.insets = new Insets(2, 2, 2, 2);
 
 		ta = new TextArea(text);
 
 		gbc.fill = GridBagConstraints.BOTH;
 		gbc.weighty = 1.0;
 	  	gbc.weightx = 1.0;
 		gb.setConstraints(ta, gbc);
 		add(ta);
 	  	gbc.weightx = 0.0;
 		gbc.weighty = 0.0;
 		gbc.fill = GridBagConstraints.NONE;
 
 		gbc.gridy = 1;
 
 		Panel bottom_panel = new Panel();
 		GridBagLayout gb2 = new GridBagLayout();
 		GridBagConstraints gbc2 = new GridBagConstraints();
 		bottom_panel.setLayout(gb2);
 
 		gbc2.weightx = 1.0;
 		gbc2.insets = new Insets(0, 2, 0, 2);
 
 		label = new Label(res.getString("copy"));
 		bottom_panel.add(label);
 		ImageButton b = new ImageButton(res.getString("close"));
 		b.setActionCommand("ok");
 		gb2.setConstraints(b, gbc2);
 		bottom_panel.add(b);
 		b.addActionListener(this);
 		b.setEnabled(true);
 
 		gb.setConstraints(bottom_panel, gbc);
 		add(bottom_panel);
 
 		ta.selectAll();
 		pack();
 		setVisible(true);
 	}
 
 	public void setText(String s)
 	{
 		ta.setText(s);
 		ta.selectAll();
 	}
 	
 	public Dimension getPreferredSize()
 	{
 		Dimension d = eirc.getFrame().getSize();
 		return(new Dimension(d.width * 2/3, d.height * 2/3));
 	}
 
 /*
 	public void setBackground(Color c)
 	{
 		super.setBackground(c);
 		label.setBackground(c);
 	}
 
 	public void setForeground(Color c)
 	{
 		super.setForeground(c);
 		label.setForeground(c);
 	}
 */
 	public void setTextBackground(Color c)
 	{
 		ta.setBackground(c);
 	}
 
 	public void setTextForeground(Color c)
 	{
 		ta.setForeground(c);
 	}
 
 	public void actionPerformed(ActionEvent ev)
 	{
 		String ac = ev.getActionCommand();
 
 		if (ac.equals("ok"))
 			processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
 	}
 }