2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.gui2
;
21 import com
.googlecode
.lanterna
.input
.KeyStroke
;
22 import java
.util
.Collection
;
25 * Container is a component that contains a collection of child components. The basic example of an implementation of
26 * this is the {@code Panel} class which uses a layout manager to size and position the children over its area. Note
27 * that there is no method for adding components to the container, since this depends on the implementation. In general,
28 * composites that contains one one (or zero) children, the method for specifying the child is in {@code Composite}.
29 * Multi-child containers are generally using the {@code Panel} implementation which has an {@code addComponent(..)}
33 public interface Container
extends Component
{
36 * Returns the number of children this container currently has
37 * @return Number of children currently in this container
42 * Returns collection that is to be considered a copy of the list of children contained inside of this object.
43 * Modifying this list will not affect any internal state.
44 * @return Child-components inside of this Container
46 Collection
<Component
> getChildren();
49 * Returns {@code true} if this container contains the supplied component either directly or indirectly through
50 * intermediate containers.
51 * @param component Component to check if it's part of this container
52 * @return {@code true} if the component is inside this Container, otherwise {@code false}
54 boolean containsComponent(Component component
);
57 * Removes the component from the container. This should remove the component from the Container's internal data
58 * structure as well as call the onRemoved(..) method on the component itself if it was found inside the container.
59 * @param component Component to remove from the Container
60 * @return {@code true} if the component existed inside the container and was removed, {@code false} otherwise
62 boolean removeComponent(Component component
);
65 * Given an interactable, find the next one in line to receive focus. If the interactable isn't inside this
66 * container, this method should return {@code null}.
68 * @param fromThis Component from which to get the next interactable, or if
69 * null, pick the first available interactable
70 * @return The next interactable component, or null if there are no more
71 * interactables in the list
73 Interactable
nextFocus(Interactable fromThis
);
76 * Given an interactable, find the previous one in line to receive focus. If the interactable isn't inside this
77 * container, this method should return {@code null}.
79 * @param fromThis Component from which to get the previous interactable,
80 * or if null, pick the last interactable in the list
81 * @return The previous interactable component, or null if there are no more
82 * interactables in the list
84 Interactable
previousFocus(Interactable fromThis
);
87 * If an interactable component inside this container received a keyboard event that wasn't handled, the GUI system
88 * will recursively send the event to each parent container to give each of them a chance to consume the event.
89 * Return {@code false} if the implementer doesn't care about this particular keystroke and it will be automatically
90 * sent up the hierarchy the to next container. If you return {@code true}, the event will stop here and won't be
91 * reported as unhandled.
92 * @param key Keystroke that was ignored by the interactable inside this container
93 * @return {@code true} if this event was handled by this container and shouldn't be processed anymore,
94 * {@code false} if the container didn't take any action on the event and want to pass it on
96 boolean handleInput(KeyStroke key
);
99 * Takes a lookup map and updates it with information about where all the interactables inside of this container
101 * @param interactableLookupMap Interactable map to update
103 void updateLookupMap(InteractableLookupMap interactableLookupMap
);