Commit | Line | Data |
---|---|---|
df8de03f KL |
1 | /** |
2 | * Jexer - Java Text User Interface | |
3 | * | |
df8de03f KL |
4 | * License: LGPLv3 or later |
5 | * | |
7b5261bc KL |
6 | * This module is licensed under the GNU Lesser General Public License |
7 | * Version 3. Please see the file "COPYING" in this directory for more | |
8 | * information about the GNU Lesser General Public License Version 3. | |
df8de03f KL |
9 | * |
10 | * Copyright (C) 2015 Kevin Lamonte | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or | |
13 | * modify it under the terms of the GNU Lesser General Public License | |
14 | * as published by the Free Software Foundation; either version 3 of | |
15 | * the License, or (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Lesser General Public | |
23 | * License along with this program; if not, see | |
24 | * http://www.gnu.org/licenses/, or write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
26 | * 02110-1301 USA | |
7b5261bc KL |
27 | * |
28 | * @author Kevin Lamonte [kevin.lamonte@gmail.com] | |
29 | * @version 1 | |
df8de03f KL |
30 | */ |
31 | package jexer.event; | |
32 | ||
33 | /** | |
34 | * This class encapsulates a screen or window resize event. | |
35 | */ | |
d4a29741 | 36 | public final class TResizeEvent extends TInputEvent { |
df8de03f KL |
37 | |
38 | /** | |
39 | * Resize events can be generated for either a total screen resize or a | |
40 | * widget/window resize. | |
41 | */ | |
42 | public enum Type { | |
7b5261bc KL |
43 | /** |
44 | * The entire screen size changed. | |
45 | */ | |
46 | SCREEN, | |
47 | ||
48 | /** | |
49 | * A widget was resized. | |
50 | */ | |
51 | WIDGET | |
52 | } | |
53 | ||
54 | /** | |
55 | * The type of resize. | |
56 | */ | |
57 | private Type type; | |
58 | ||
59 | /** | |
60 | * Get resize type. | |
61 | * | |
62 | * @return SCREEN or WIDGET | |
63 | */ | |
d4a29741 | 64 | public Type getType() { |
7b5261bc | 65 | return type; |
df8de03f KL |
66 | } |
67 | ||
68 | /** | |
7b5261bc KL |
69 | * New width. |
70 | */ | |
71 | private int width; | |
72 | ||
73 | /** | |
74 | * Get the new width. | |
75 | * | |
76 | * @return width | |
df8de03f | 77 | */ |
d4a29741 | 78 | public int getWidth() { |
7b5261bc KL |
79 | return width; |
80 | } | |
df8de03f KL |
81 | |
82 | /** | |
7b5261bc | 83 | * New height. |
df8de03f | 84 | */ |
7b5261bc | 85 | private int height; |
df8de03f KL |
86 | |
87 | /** | |
7b5261bc KL |
88 | * Get the new height. |
89 | * | |
90 | * @return height | |
df8de03f | 91 | */ |
d4a29741 KL |
92 | public int getHeight() { |
93 | return height; | |
7b5261bc | 94 | } |
df8de03f KL |
95 | |
96 | /** | |
7b5261bc | 97 | * Public contructor. |
df8de03f KL |
98 | * |
99 | * @param type the Type of resize, Screen or Widget | |
100 | * @param width the new width | |
05dbb28d | 101 | * @param height the new height |
df8de03f | 102 | */ |
7b5261bc KL |
103 | public TResizeEvent(final Type type, final int width, final int height) { |
104 | this.type = type; | |
105 | this.width = width; | |
106 | this.height = height; | |
df8de03f KL |
107 | } |
108 | ||
109 | /** | |
7b5261bc KL |
110 | * Make human-readable description of this TResizeEvent. |
111 | * | |
112 | * @return displayable String | |
df8de03f KL |
113 | */ |
114 | @Override | |
d4a29741 | 115 | public String toString() { |
7b5261bc KL |
116 | return String.format("Resize: %s width = %d height = %d", |
117 | type, width, height); | |
df8de03f KL |
118 | } |
119 | ||
120 | } |