double buffer swing
[nikiroo-utils.git] / src / jexer / demos / DemoTextWindow.java
1 /*
2 * Jexer - Java Text User Interface
3 *
4 * License: LGPLv3 or later
5 *
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.
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
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
30 */
31 package jexer.demos;
32
33 import jexer.*;
34 import jexer.event.*;
35 import jexer.menu.*;
36
37 /**
38 * This window demonstates the TText, THScroller, and TVScroller widgets.
39 */
40 class DemoTextWindow extends TWindow {
41
42 /**
43 * Hang onto my TText so I can resize it with the window.
44 */
45 private TText textField;
46
47 /**
48 * Public constructor.
49 *
50 * @param parent the main application
51 */
52 public DemoTextWindow(final TApplication parent) {
53 super(parent, "Text Areas", 0, 0, 44, 20, RESIZABLE);
54
55 textField = addText(
56 "This is an example of a reflowable text field. Some example text follows.\n" +
57 "\n" +
58 "This library implements a text-based windowing system loosely\n" +
59 "reminiscient of Borland's [Turbo\n" +
60 "Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those\n" +
61 "wishing to use the actual C++ Turbo Vision library, see [Sergio\n" +
62 "Sigala's updated version](http://tvision.sourceforge.net/) that runs\n" +
63 "on many more platforms.\n" +
64 "\n" +
65 "Currently the only console platform supported is Posix (tested on\n" +
66 "Linux). Input/output is handled through terminal escape sequences\n" +
67 "generated by the library itself: ncurses is not required or linked to. \n" +
68 "xterm mouse tracking using UTF8 coordinates is supported.\n" +
69 "\n" +
70 "This library is licensed LGPL (\"GNU Lesser General Public License\")\n" +
71 "version 3 or greater. See the file COPYING for the full license text,\n" +
72 "which includes both the GPL v3 and the LGPL supplemental terms.\n" +
73 "\n",
74 1, 1, 40, 16);
75 }
76
77 /**
78 * Handle window/screen resize events.
79 *
80 * @param event resize event
81 */
82 @Override
83 public void onResize(final TResizeEvent event) {
84 if (event.getType() == TResizeEvent.Type.WIDGET) {
85 // Resize the text field
86 textField.setWidth(event.getWidth() - 4);
87 textField.setHeight(event.getHeight() - 4);
88 textField.reflow();
89 return;
90 }
91
92 // Pass to children instead
93 for (TWidget widget: getChildren()) {
94 widget.onResize(event);
95 }
96 }
97 }
98