X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDemoMainWindow.java;h=8f77448b29f45c65cd67e52c38268e0564ad1e0d;hb=e6bb1700749980e69b5e913acbfd276f129c24dc;hp=53f30d7d5a630efa202f202fa8c1809ce7176e89;hpb=12b55d76e3473407bf37fca3667860240cb8f3be;p=fanfix.git diff --git a/src/jexer/demos/DemoMainWindow.java b/src/jexer/demos/DemoMainWindow.java deleted file mode 100644 index 53f30d7..0000000 --- a/src/jexer/demos/DemoMainWindow.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Jexer - Java Text User Interface - * - * The MIT License (MIT) - * - * 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * @author Kevin Lamonte [kevin.lamonte@gmail.com] - * @version 1 - */ -package jexer.demos; - -import jexer.*; -import static jexer.TCommand.*; -import static jexer.TKeypress.*; - -/** - * This is the main "demo" application window. It makes use of the TTimer, - * TProgressBox, TLabel, TButton, and TField widgets. - */ -public class DemoMainWindow extends TWindow { - - // Timer that increments a number. - private TTimer timer; - - // Timer label is updated with timer ticks. - TLabel timerLabel; - - /** - * We need to override onClose so that the timer will no longer be called - * after we close the window. TTimers currently are completely unaware - * of the rest of the UI classes. - */ - @Override - public void onClose() { - getApplication().removeTimer(timer); - } - - /** - * Construct demo window. It will be centered on screen. - * - * @param parent the main application - */ - public DemoMainWindow(final TApplication parent) { - this(parent, CENTERED | RESIZABLE); - } - - // These are used by the timer loop. They have to be at class scope so - // that they can be accessed by the anonymous TAction class. - int timerI = 0; - TProgressBar progressBar; - - /** - * Constructor. - * - * @param parent the main application - * @param flags bitmask of MODAL, CENTERED, or RESIZABLE - */ - private DemoMainWindow(final TApplication parent, final int flags) { - // Construct a demo window. X and Y don't matter because it will be - // centered on screen. - super(parent, "Demo Window", 0, 0, 60, 22, flags); - - int row = 1; - - // Add some widgets - addLabel("Message Boxes", 1, row); - addButton("&MessageBoxes", 35, row, - new TAction() { - public void DO() { - new DemoMsgBoxWindow(getApplication()); - } - } - ); - row += 2; - - addLabel("Open me as modal", 1, row); - addButton("W&indow", 35, row, - new TAction() { - public void DO() { - new DemoMainWindow(getApplication(), MODAL); - } - } - ); - row += 2; - - addLabel("Text fields", 1, row); - addButton("Field&s", 35, row, - new TAction() { - public void DO() { - new DemoTextFieldWindow(getApplication()); - } - } - ); - row += 2; - - addLabel("Radio buttons and checkboxes", 1, row); - addButton("&Checkboxes", 35, row, - new TAction() { - public void DO() { - new DemoCheckboxWindow(getApplication()); - } - } - ); - row += 2; - - addLabel("Editor window", 1, row); - addButton("Edito&r", 35, row, - new TAction() { - public void DO() { - new DemoEditorWindow(getApplication()); - } - } - ); - row += 2; - - addLabel("Text areas", 1, row); - addButton("&Text", 35, row, - new TAction() { - public void DO() { - new DemoTextWindow(getApplication()); - } - } - ); - row += 2; - - addLabel("Tree views", 1, row); - addButton("Tree&View", 35, row, - new TAction() { - public void DO() { - try { - new DemoTreeViewWindow(getApplication()); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - ); - row += 2; - - addLabel("Terminal", 1, row); - addButton("Termi&nal", 35, row, - new TAction() { - public void DO() { - getApplication().openTerminal(0, 0); - } - } - ); - row += 2; - - addLabel("Color editor", 1, row); - addButton("Co&lors", 35, row, - new TAction() { - public void DO() { - new TEditColorThemeWindow(getApplication()); - } - } - ); - row += 2; - - progressBar = addProgressBar(1, row, 22, 0); - row++; - timerLabel = addLabel("Timer", 1, row); - timer = getApplication().addTimer(250, true, - new TAction() { - - public void DO() { - timerLabel.setLabel(String.format("Timer: %d", timerI)); - timerLabel.setWidth(timerLabel.getLabel().length()); - if (timerI < 100) { - timerI++; - } - progressBar.setValue(timerI); - } - } - ); - - statusBar = newStatusBar("Demo Main Window"); - statusBar.addShortcutKeypress(kbF1, cmHelp, "Help"); - statusBar.addShortcutKeypress(kbF2, cmShell, "Shell"); - statusBar.addShortcutKeypress(kbF3, cmOpen, "Open"); - statusBar.addShortcutKeypress(kbF10, cmExit, "Exit"); - } -}