| 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 | /** |
| 24 | * This interface defines a renderer for a component, an external class that does the sizing and rendering. All |
| 25 | * components will have a default renderer defined, which can usually be overridden manually and swapped out for a |
| 26 | * different renderer, but also themes can contain renderer definitions which are automatically assigned to their |
| 27 | * associated components. |
| 28 | * @param <T> Type of the component which this renderer is designed for |
| 29 | * @author Martin |
| 30 | */ |
| 31 | public interface ComponentRenderer<T extends Component> { |
| 32 | /** |
| 33 | * Given the supplied component, how large does this renderer want the component to be? Notice that this is the |
| 34 | * responsibility of the renderer and not the component itself, since the component has no idea what its visual |
| 35 | * representation looks like. |
| 36 | * @param component Component to calculate the preferred size of |
| 37 | * @return The size this renderer would like the component to take up |
| 38 | */ |
| 39 | TerminalSize getPreferredSize(T component); |
| 40 | |
| 41 | /** |
| 42 | * Using the supplied graphics object, draws the component passed in. |
| 43 | * @param graphics Graphics object to use for drawing |
| 44 | * @param component Component to draw |
| 45 | */ |
| 46 | void drawComponent(TextGUIGraphics graphics, T component); |
| 47 | } |