/* 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.
 */

/** A RigidBox is a box that can only be split, not resized. As you
 *  can't resize such a box, the box must be able to find it's own
 *  width and height as soon as it has been given a {@link
 *  java.awt.Graphics} context via a call to {@link
 *  #doLayout(java.awt.Graphics, javax.swing.JComponent, int)}.
 *  
 *  <p>Rigid boxes are the leaves of the parse-tree, as they are the
 *  boxes with the actual contents (substrings, links, images, etc).
 *  */
public interface RigidBox extends Box {

    /** The left edge constant. Used when calling {@link #trim(int)}
     *  on boxes. */
    public final int LEFT = 1;

    /** The right edge constant. Used when calling {@link #trim(int)}
     *  on boxes. */
    public final int RIGHT = 2;

    /** The constant denoting both edges. Used when calling
     *  {@link #trim} on boxes. */
    public final int BOTH = 4;
    
    /** Reports wether or not the box can be split at <code>w</code>.
     *  @param w the place where the split should be.
     *  @return true if it's possible to split the box, false
     *  otherwise. */
    public boolean splitIsPossible(int w);

    /** Tries to split the box at <code>w</code>.
     *  @param w the place where the split should be.
     *  @return a new box that is the left part of the split. The box
     *  is guaranteed to be smaller than <code>w</code>, if possible.
     *  If the box can't be split, <code>null</code> is returned. */
    public Box splitHead(int w);

    /** Tries to split the box at <code>w</code>.
     *  @param w the place where the split should be.
     *  @return a new box that is the right part of a split, where the
     *  left part is guaranteed to be smaller than <code>w</code>, if
     *  possible. If the box can't be split, <code>null</code> is
     *  returned. */
    public Box splitTail(int w);

    /** Returns the left part of a split, where the left part is as
     *  small as possible. If the box can't be splitted at all,
     *  <code>null</code> is returned instead.
     *  @return a new box that can't be splitted into furhter pieces. */
    public Box getSmallestHead();

    /** Returns the right part of a split, where the right part is as
     *  large at possible. If the box can't be splitted at all,
     *  <code>null</code> is returned instead.
     *  @return a new box that can't be splitted into furhter pieces.
     *  */
    public Box getLargestTail();


    /** Trims the box. The box should remove any borders and white
     *  space it might have on left or right.
     *  @param edge to be trimmed. It must be one of {@link #LEFT},
     *  {@link #RIGHT}, or {@link #BOTH}. */
    public void trim(int edge);

}