1/*
2 * Copyright (c) 1995, 1998, Oracle and/or its affiliates. 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.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25package java.awt.peer;
26
27import java.awt.Dimension;
28import java.awt.List;
29
30/**
31 * The peer interface for {@link List}.
32 *
33 * The peer interfaces are intended only for use in porting
34 * the AWT. They are not intended for use by application
35 * developers, and developers should not implement peers
36 * nor invoke any of the peer methods directly on the peer
37 * instances.
38 */
39public interface ListPeer extends ComponentPeer {
40
41    /**
42     * Returns the indices of the list items that are currently selected.
43     * The returned array is not required to be a copy, the callers of this
44     * method already make sure it is not modified.
45     *
46     * @return the indices of the list items that are currently selected
47     *
48     * @see List#getSelectedIndexes()
49     */
50    int[] getSelectedIndexes();
51
52    /**
53     * Adds an item to the list at the specified index.
54     *
55     * @param item the item to add to the list
56     * @param index the index where to add the item into the list
57     *
58     * @see List#add(String, int)
59     */
60    void add(String item, int index);
61
62    /**
63     * Deletes items from the list. All items from start to end should are
64     * deleted, including the item at the start and end indices.
65     *
66     * @param start the first item to be deleted
67     * @param end the last item to be deleted
68     */
69    void delItems(int start, int end);
70
71    /**
72     * Removes all items from the list.
73     *
74     * @see List#removeAll()
75     */
76    void removeAll();
77
78    /**
79     * Selects the item at the specified {@code index}.
80     *
81     * @param index the index of the item to select
82     *
83     * @see List#select(int)
84     */
85    void select(int index);
86
87    /**
88     * De-selects the item at the specified {@code index}.
89     *
90     * @param index the index of the item to de-select
91     *
92     * @see List#deselect(int)
93     */
94    void deselect(int index);
95
96    /**
97     * Makes sure that the item at the specified {@code index} is visible,
98     * by scrolling the list or similar.
99     *
100     * @param index the index of the item to make visible
101     *
102     * @see List#makeVisible(int)
103     */
104    void makeVisible(int index);
105
106    /**
107     * Toggles multiple selection mode on or off.
108     *
109     * @param m {@code true} for multiple selection mode,
110     *        {@code false} for single selection mode
111     *
112     * @see List#setMultipleMode(boolean)
113     */
114    void setMultipleMode(boolean m);
115
116    /**
117     * Returns the preferred size for a list with the specified number of rows.
118     *
119     * @param rows the number of rows
120     *
121     * @return the preferred size of the list
122     *
123     * @see List#getPreferredSize(int)
124     */
125    Dimension getPreferredSize(int rows);
126
127    /**
128     * Returns the minimum size for a list with the specified number of rows.
129     *
130     * @param rows the number of rows
131     *
132     * @return the minimum size of the list
133     *
134     * @see List#getMinimumSize(int)
135     */
136    Dimension getMinimumSize(int rows);
137
138}
139