X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDemoTextWindow.java;h=3538905d2a6cb1dca94998d3040e313965aa5acf;hb=be72cb5ccbd42fe304c0acafc380c5636f0d03a2;hp=a2ab68b0ae34bb6c6cb5d9da01da93405584d952;hpb=e16dda65585466c8987bd1efd718431450a96605;p=fanfix.git diff --git a/src/jexer/demos/DemoTextWindow.java b/src/jexer/demos/DemoTextWindow.java index a2ab68b..3538905 100644 --- a/src/jexer/demos/DemoTextWindow.java +++ b/src/jexer/demos/DemoTextWindow.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2016 Kevin Lamonte + * Copyright (C) 2017 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,6 +31,8 @@ package jexer.demos; import jexer.*; import jexer.event.*; import jexer.menu.*; +import static jexer.TCommand.*; +import static jexer.TKeypress.*; /** * This window demonstates the TText, THScroller, and TVScroller widgets. @@ -52,8 +54,38 @@ public class DemoTextWindow extends TWindow { public DemoTextWindow(final TApplication parent, final String title, final String text) { - super(parent, title, 0, 0, 44, 20, RESIZABLE); - textField = addText(text, 1, 1, 40, 16); + super(parent, title, 0, 0, 44, 22, RESIZABLE); + textField = addText(text, 1, 3, 40, 16); + + addButton("&Left", 1, 1, new TAction() { + public void DO() { + textField.leftJustify(); + } + }); + + addButton("&Center", 10, 1, new TAction() { + public void DO() { + textField.centerJustify(); + } + }); + + addButton("&Right", 21, 1, new TAction() { + public void DO() { + textField.rightJustify(); + } + }); + + addButton("&Full", 31, 1, new TAction() { + public void DO() { + textField.fullJustify(); + } + }); + + statusBar = newStatusBar("Reflowable text window"); + statusBar.addShortcutKeypress(kbF1, cmHelp, "Help"); + statusBar.addShortcutKeypress(kbF2, cmShell, "Shell"); + statusBar.addShortcutKeypress(kbF3, cmOpen, "Open"); + statusBar.addShortcutKeypress(kbF10, cmExit, "Exit"); } /** @@ -67,14 +99,14 @@ public class DemoTextWindow extends TWindow { "\n" + "Notice that some menu items should be disabled when this window has focus.\n" + "\n" + -"This library implements a text-based windowing system loosely\n" + -"reminiscient of Borland's [Turbo\n" + -"Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those\n" + -"wishing to use the actual C++ Turbo Vision library, see [Sergio\n" + -"Sigala's updated version](http://tvision.sourceforge.net/) that runs\n" + +"This library implements a text-based windowing system loosely " + +"reminiscient of Borland's [Turbo " + +"Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those " + +"wishing to use the actual C++ Turbo Vision library, see [Sergio " + +"Sigala's updated version](http://tvision.sourceforge.net/) that runs " + "on many more platforms.\n" + "\n" + -"This library is licensed MIT. See the file LICENSE for the full license\n" + +"This library is licensed MIT. See the file LICENSE for the full license " + "for the details.\n"); } @@ -88,9 +120,9 @@ public class DemoTextWindow extends TWindow { public void onResize(final TResizeEvent event) { if (event.getType() == TResizeEvent.Type.WIDGET) { // Resize the text field - textField.setWidth(event.getWidth() - 4); - textField.setHeight(event.getHeight() - 4); - textField.reflow(); + TResizeEvent textSize = new TResizeEvent(TResizeEvent.Type.WIDGET, + event.getWidth() - 4, event.getHeight() - 6); + textField.onResize(textSize); return; }