blob: a728f9addaa73a3b523e97f9f09bb032c49af19f [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.swing;
27
28import java.awt.Dimension;
29import java.awt.Rectangle;
30
31
32/**
33 * An interface that provides information to a scrolling container
34 * like JScrollPane. A complex component that's likely to be used
35 * as a viewing a JScrollPane viewport (or other scrolling container)
36 * should implement this interface.
37 *
38 * @see JViewport
39 * @see JScrollPane
40 * @see JScrollBar
41 * @author Hans Muller
42 */
43public interface Scrollable
44{
45 /**
46 * Returns the preferred size of the viewport for a view component.
47 * For example, the preferred size of a <code>JList</code> component
48 * is the size required to accommodate all of the cells in its list.
49 * However, the value of <code>preferredScrollableViewportSize</code>
50 * is the size required for <code>JList.getVisibleRowCount</code> rows.
51 * A component without any properties that would affect the viewport
52 * size should just return <code>getPreferredSize</code> here.
53 *
54 * @return the preferredSize of a <code>JViewport</code> whose view
55 * is this <code>Scrollable</code>
56 * @see JViewport#getPreferredSize
57 */
58 Dimension getPreferredScrollableViewportSize();
59
60
61 /**
62 * Components that display logical rows or columns should compute
63 * the scroll increment that will completely expose one new row
64 * or column, depending on the value of orientation. Ideally,
65 * components should handle a partially exposed row or column by
66 * returning the distance required to completely expose the item.
67 * <p>
68 * Scrolling containers, like JScrollPane, will use this method
69 * each time the user requests a unit scroll.
70 *
71 * @param visibleRect The view area visible within the viewport
72 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
73 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
74 * @return The "unit" increment for scrolling in the specified direction.
75 * This value should always be positive.
76 * @see JScrollBar#setUnitIncrement
77 */
78 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
79
80
81 /**
82 * Components that display logical rows or columns should compute
83 * the scroll increment that will completely expose one block
84 * of rows or columns, depending on the value of orientation.
85 * <p>
86 * Scrolling containers, like JScrollPane, will use this method
87 * each time the user requests a block scroll.
88 *
89 * @param visibleRect The view area visible within the viewport
90 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
91 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
92 * @return The "block" increment for scrolling in the specified direction.
93 * This value should always be positive.
94 * @see JScrollBar#setBlockIncrement
95 */
96 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
97
98
99 /**
100 * Return true if a viewport should always force the width of this
101 * <code>Scrollable</code> to match the width of the viewport.
102 * For example a normal
103 * text view that supported line wrapping would return true here, since it
104 * would be undesirable for wrapped lines to disappear beyond the right
105 * edge of the viewport. Note that returning true for a Scrollable
106 * whose ancestor is a JScrollPane effectively disables horizontal
107 * scrolling.
108 * <p>
109 * Scrolling containers, like JViewport, will use this method each
110 * time they are validated.
111 *
112 * @return True if a viewport should force the Scrollables width to match its own.
113 */
114 boolean getScrollableTracksViewportWidth();
115
116 /**
117 * Return true if a viewport should always force the height of this
118 * Scrollable to match the height of the viewport. For example a
119 * columnar text view that flowed text in left to right columns
120 * could effectively disable vertical scrolling by returning
121 * true here.
122 * <p>
123 * Scrolling containers, like JViewport, will use this method each
124 * time they are validated.
125 *
126 * @return True if a viewport should force the Scrollables height to match its own.
127 */
128 boolean getScrollableTracksViewportHeight();
129}