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


// @(#)Tip.java, 1.14, 09/27/96





package marimba.gui;





import java.awt.*;





/**


 * This class represents a simple popup widget displaying


 * a single line of text.


 *


 * @author	Arthur van Hoff


 * @version 	1.14, 09/27/96


 */


public class Tip extends PopupWidget {


    public static Font tipFont = new Font("Dialog", Font.PLAIN, 12);


    public static Color tipBackground = new Color(255, 255, 235);


    public static Color tipForeground = Color.black;





    /**


     * Constructor.


     */


    public Tip(Widget parent, String tip, int x, int y) {


	this.tip = tip;


	setFont(tipFont);


	setForeground(tipForeground);


	setBackground(tipBackground);


	FontMetrics fm = getFontMetrics(tipFont);


	popup(parent, x-10, y+14, fm.stringWidth(tip) + 8, fm.getHeight() + 4);


	fit();


    }





    /**


     * Paint the tip widget.


     */


    public void paint(Graphics g) {


	g.setColor(foreground);


	g.drawString(tip, 4, g.getFontMetrics().getAscent() + 2);


    }





    /**


     * Paint the background


     */


    public void paint(Graphics g, int cx, int cy, int cw, int ch) {


	/*


	g.setColor(background);


	g.fillRect(cx, cy, cw, ch);





	g.setColor(new Color(221, 221, 221));


	g.drawLine(cx, cy, cx+cw-1, cy);


	g.drawLine(cx, cy+1, cx, cy+ch-1);


	


	g.setColor(foreground);


	g.drawLine(cx+cw-1, cy, cx+cw-1, cy+ch-1);


	g.drawLine(cx+cw-1, cy+ch-1, cx, cy+ch-1);


	*/





	g.setColor(Color.black);


	g.drawRect(0, 0, width-1, height-1);


	g.setColor(Color.white);


	g.fillRect(1, 1, width-2, height-2);





	paint(g);


    }


}


