Commit | Line | Data |
---|---|---|
a3b510ab NR |
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 | */ | |
19 | package com.googlecode.lanterna.gui2; | |
20 | ||
21 | import com.googlecode.lanterna.TerminalSize; | |
22 | ||
23 | import java.util.List; | |
24 | ||
25 | /** | |
26 | * Window manager is a class that is plugged in to a {@code WindowBasedTextGUI} to manage the position and placement | |
27 | * of windows. The window manager doesn't contain the list of windows so it normally does not need to maintain much | |
28 | * state but it is passed all required objects as the window model changes. | |
29 | * @see DefaultWindowManager | |
30 | * @author Martin | |
31 | */ | |
32 | public interface WindowManager { | |
33 | ||
34 | /** | |
35 | * Will be polled by the the {@link WindowBasedTextGUI} to see if the window manager believes an update is required. | |
36 | * For example, it could be that there is no input, no events and none of the components are invalid, but the window | |
37 | * manager decides for some other reason that the GUI needs to be updated, in that case you should return | |
38 | * {@code true} here. Please note that returning {@code false} will not prevent updates from happening, it's just | |
39 | * stating that the window manager isn't aware of some internal state change that would require an update. | |
40 | * @return {@code true} if the window manager believes the GUI needs to be update, {@code false} otherwise | |
41 | */ | |
42 | boolean isInvalid(); | |
43 | ||
44 | /** | |
45 | * Returns the {@code WindowDecorationRenderer} for a particular window | |
46 | * @param window Window to get the decoration renderer for | |
47 | * @return {@code WindowDecorationRenderer} for the window | |
48 | */ | |
49 | WindowDecorationRenderer getWindowDecorationRenderer(Window window); | |
50 | ||
51 | /** | |
52 | * Called whenever a window is added to the {@code WindowBasedTextGUI}. This gives the window manager an opportunity | |
53 | * to setup internal state, if required, or decide on an initial position of the window | |
54 | * @param textGUI GUI that the window was added too | |
55 | * @param window Window that was added | |
56 | * @param allWindows All windows, including the new window, in the GUI | |
57 | */ | |
58 | void onAdded(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows); | |
59 | ||
60 | /** | |
61 | * Called whenever a window is removed from a {@code WindowBasedTextGUI}. This gives the window manager an | |
62 | * opportunity to clear internal state if needed. | |
63 | * @param textGUI GUI that the window was removed from | |
64 | * @param window Window that was removed | |
65 | * @param allWindows All windows, excluding the removed window, in the GUI | |
66 | */ | |
67 | @SuppressWarnings("EmptyMethod") | |
68 | void onRemoved(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows); | |
69 | ||
70 | /** | |
71 | * Called by the GUI system before iterating through all windows during the drawing process. The window manager | |
72 | * should ensure the position and decorated size of all windows at this point by using | |
73 | * {@code Window.setPosition(..)} and {@code Window.setDecoratedSize(..)}. Be sure to inspect the window hints | |
74 | * assigned to the window, in case you want to try to honour them. Use the | |
75 | * {@link #getWindowDecorationRenderer(Window)} method to get the currently assigned window decoration rendering | |
76 | * class which can tell you the decorated size of a window given it's content size. | |
77 | * | |
78 | * @param textGUI Text GUI that is about to draw the windows | |
79 | * @param allWindows All windows that are going to be drawn, in the order they will be drawn | |
80 | * @param screenSize Size of the terminal that is available to draw on | |
81 | */ | |
82 | void prepareWindows(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize); | |
83 | } |