Fix UTF8 bug, create first executable JAR file
[jvcard.git] / src / com / googlecode / lanterna / gui2 / LayoutManager.java
... / ...
CommitLineData
1/*
2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
3 *
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.
8 *
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.
13 *
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/>.
16 *
17 * Copyright (C) 2010-2015 Martin
18 */
19package com.googlecode.lanterna.gui2;
20
21import com.googlecode.lanterna.TerminalSize;
22import java.util.List;
23
24/**
25 * A layout manager is a class that takes an area of usable space and a list of components to fit on that space. This
26 * is very similar to how AWT/Swing/SWT works. Lanterna contains a number of layout managers built-in that will arrange
27 * components in various ways, but you can also write your own. The typical way of providing customization and tuning,
28 * so the layout manager can distinguish between components and treat them in different ways, is to create a class
29 * and/or objects based on the {@code LayoutData} object, which can be assigned to each {@code Component}.
30 * @see AbsoluteLayout
31 * @see BorderLayout
32 * @see GridLayout
33 * @see LinearLayout
34 * @author Martin
35 */
36public interface LayoutManager {
37
38 /**
39 * This method returns the dimensions it would prefer to have to be able to layout all components while giving all
40 * of them as much space as they are asking for.
41 * @param components List of components
42 * @return Size the layout manager would like to have
43 */
44 TerminalSize getPreferredSize(List<Component> components);
45
46 /**
47 * Given a size constraint, update the location and size of each component in the component list by laying them out
48 * in the available area. This method will call {@code setPosition(..)} and {@code setSize(..)} on the Components.
49 * @param area Size available to this layout manager to lay out the components on
50 * @param components List of components to lay out
51 */
52 void doLayout(TerminalSize area, List<Component> components);
53
54 /**
55 * Returns true if the internal state of this LayoutManager has changed since the last call to doLayout. This will
56 * tell the container that it needs to call doLayout again.
57 * @return {@code true} if this layout manager's internal state has changed since the last call to {@code doLayout}
58 */
59 boolean hasChanged();
60}