001 /*
002 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.swing;
027
028 import java.awt.Dimension;
029 import java.awt.Rectangle;
030
031 /**
032 * An interface that provides information to a scrolling container
033 * like JScrollPane. A complex component that's likely to be used
034 * as a viewing a JScrollPane viewport (or other scrolling container)
035 * should implement this interface.
036 *
037 * @see JViewport
038 * @see JScrollPane
039 * @see JScrollBar
040 * @version 1.19 05/05/07
041 * @author Hans Muller
042 */
043 public interface Scrollable {
044 /**
045 * Returns the preferred size of the viewport for a view component.
046 * For example, the preferred size of a <code>JList</code> component
047 * is the size required to accommodate all of the cells in its list.
048 * However, the value of <code>preferredScrollableViewportSize</code>
049 * is the size required for <code>JList.getVisibleRowCount</code> rows.
050 * A component without any properties that would affect the viewport
051 * size should just return <code>getPreferredSize</code> here.
052 *
053 * @return the preferredSize of a <code>JViewport</code> whose view
054 * is this <code>Scrollable</code>
055 * @see JViewport#getPreferredSize
056 */
057 Dimension getPreferredScrollableViewportSize();
058
059 /**
060 * Components that display logical rows or columns should compute
061 * the scroll increment that will completely expose one new row
062 * or column, depending on the value of orientation. Ideally,
063 * components should handle a partially exposed row or column by
064 * returning the distance required to completely expose the item.
065 * <p>
066 * Scrolling containers, like JScrollPane, will use this method
067 * each time the user requests a unit scroll.
068 *
069 * @param visibleRect The view area visible within the viewport
070 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
071 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
072 * @return The "unit" increment for scrolling in the specified direction.
073 * This value should always be positive.
074 * @see JScrollBar#setUnitIncrement
075 */
076 int getScrollableUnitIncrement(Rectangle visibleRect,
077 int orientation, int direction);
078
079 /**
080 * Components that display logical rows or columns should compute
081 * the scroll increment that will completely expose one block
082 * of rows or columns, depending on the value of orientation.
083 * <p>
084 * Scrolling containers, like JScrollPane, will use this method
085 * each time the user requests a block scroll.
086 *
087 * @param visibleRect The view area visible within the viewport
088 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
089 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
090 * @return The "block" increment for scrolling in the specified direction.
091 * This value should always be positive.
092 * @see JScrollBar#setBlockIncrement
093 */
094 int getScrollableBlockIncrement(Rectangle visibleRect,
095 int orientation, int direction);
096
097 /**
098 * Return true if a viewport should always force the width of this
099 * <code>Scrollable</code> to match the width of the viewport.
100 * For example a normal
101 * text view that supported line wrapping would return true here, since it
102 * would be undesirable for wrapped lines to disappear beyond the right
103 * edge of the viewport. Note that returning true for a Scrollable
104 * whose ancestor is a JScrollPane effectively disables horizontal
105 * scrolling.
106 * <p>
107 * Scrolling containers, like JViewport, will use this method each
108 * time they are validated.
109 *
110 * @return True if a viewport should force the Scrollables width to match its own.
111 */
112 boolean getScrollableTracksViewportWidth();
113
114 /**
115 * Return true if a viewport should always force the height of this
116 * Scrollable to match the height of the viewport. For example a
117 * columnar text view that flowed text in left to right columns
118 * could effectively disable vertical scrolling by returning
119 * true here.
120 * <p>
121 * Scrolling containers, like JViewport, will use this method each
122 * time they are validated.
123 *
124 * @return True if a viewport should force the Scrollables height to match its own.
125 */
126 boolean getScrollableTracksViewportHeight();
127 }
|