2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
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.
10 * Copyright (C) 2015 Kevin Lamonte
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.
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.
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
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
37 * This window demonstates the TText, THScroller, and TVScroller widgets.
39 public class DemoTextWindow
extends TWindow
{
42 * Hang onto my TText so I can resize it with the window.
44 private TText textField
;
47 * Public constructor makes a text window out of any string.
49 * @param parent the main application
50 * @param title the text string
51 * @param text the text string
53 public DemoTextWindow(final TApplication parent
, final String title
,
56 super(parent
, title
, 0, 0, 44, 20, RESIZABLE
);
57 textField
= addText(text
, 1, 1, 40, 16);
63 * @param parent the main application
65 public DemoTextWindow(final TApplication parent
) {
66 this(parent
, "Text Area",
67 "This is an example of a reflowable text field. Some example text follows.\n" +
69 "This library implements a text-based windowing system loosely\n" +
70 "reminiscient of Borland's [Turbo\n" +
71 "Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those\n" +
72 "wishing to use the actual C++ Turbo Vision library, see [Sergio\n" +
73 "Sigala's updated version](http://tvision.sourceforge.net/) that runs\n" +
74 "on many more platforms.\n" +
76 "Currently the only console platform supported is Posix (tested on\n" +
77 "Linux). Input/output is handled through terminal escape sequences\n" +
78 "generated by the library itself: ncurses is not required or linked to. \n" +
79 "xterm mouse tracking using UTF8 coordinates is supported.\n" +
81 "This library is licensed LGPL (\"GNU Lesser General Public License\")\n" +
82 "version 3 or greater. See the file COPYING for the full license text,\n" +
83 "which includes both the GPL v3 and the LGPL supplemental terms.\n" +
89 * Handle window/screen resize events.
91 * @param event resize event
94 public void onResize(final TResizeEvent event
) {
95 if (event
.getType() == TResizeEvent
.Type
.WIDGET
) {
96 // Resize the text field
97 textField
.setWidth(event
.getWidth() - 4);
98 textField
.setHeight(event
.getHeight() - 4);
103 // Pass to children instead
104 for (TWidget widget
: getChildren()) {
105 widget
.onResize(event
);