/* dIntProg Browser. A webbrowser written in Java.
 * Copyright (C) 2001 Martin Geisler <gimpster@gimpster.com>
 *  
 * 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 javax.swing.*;

/** Specifies a box. A box has two characteristic properties: it's
 *  <code>width</code> and <code>height</code> which is accessed with
 *  {@link #getWidth()} and {@link #getHeight()}.
 * 
 *  <p>A box should also be able to draw itself, see {@link
 *  #drawAt(int, int, DocumentView)}, but after it has been given a
 *  chance to calculate it's layout with a call to {@link
 *  #doLayout(Graphics, JComponent, int)}. */
public interface Box {

    /** Returns the width of this box.
     *  @return the width of the box. */
    public int getWidth();

    /** Returns the minimum width of this box.
     *  @return the minimum width of this box. */
    public int getMinimumWidth();

    /** Returns the preferred width of this box. This can be used to
     *  get an indication of the amount of space this box would like
     *  to researve for itself.
     *  @return the preferred width for this box. */
    public int getPreferredWidth();

    /** Returns the height of this box.
     *  @return the height of the box. */
    public int getHeight();

    /** Makes the box update it's own width and height, and layout
     *  it's child-boxes.
     *  @param g the graphics context. Some boxes, like TextFragments,
     *  need a graphics context before they can determine their width
     *  and height.
     *  @param c the component into which the box will be drawn. An
     *  ImageBox needs to know the component to calculate the width
     *  and height.
     *  @param w the width available for to the Box. */
    public void doLayout(Graphics g, JComponent c, int w);

    /** Draws the box with it's upper-left corner at (<code>x</code>,
     *  <code>y</code>).
     *  @param v the {@link DocumentView} that does the actual
     *  drawing.
     *  @param x the x-coordinate of the upper-left corner.
     *  @param x the y-coordinate of the upper-left corner. */
    public void drawAt(int x, int y, DocumentView v);

    /** Gives you information about the box.
     *  @return information about the box - usefull for debugging. */
    public String toString();

}