TEditor 50% complete
[nikiroo-utils.git] / src / jexer / demos / DemoMainWindow.java
index c2f77e80882b95d509636d5a2173950a4a960cd9..598ac7f0ce92f889d56a78a6b42d7f41675dad02 100644 (file)
@@ -1,29 +1,27 @@
 /*
  * Jexer - Java Text User Interface
  *
- * License: LGPLv3 or later
+ * The MIT License (MIT)
  *
- * This module is licensed under the GNU Lesser General Public License
- * Version 3.  Please see the file "COPYING" in this directory for more
- * information about the GNU Lesser General Public License Version 3.
+ * Copyright (C) 2017 Kevin Lamonte
  *
- *     Copyright (C) 2015  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:
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see
- * http://www.gnu.org/licenses/, or write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
+ * 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
@@ -31,8 +29,8 @@
 package jexer.demos;
 
 import jexer.*;
-import jexer.event.*;
-import jexer.menu.*;
+import static jexer.TCommand.*;
+import static jexer.TKeypress.*;
 
 /**
  * This is the main "demo" application window.  It makes use of the TTimer,
@@ -84,16 +82,14 @@ public class DemoMainWindow extends TWindow {
         int row = 1;
 
         // Add some widgets
-        if (!isModal()) {
-            addLabel("Message Boxes", 1, row);
-            addButton("&MessageBoxes", 35, row,
-                new TAction() {
-                    public void DO() {
-                        new DemoMsgBoxWindow(getApplication());
-                    }
+        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);
@@ -104,77 +100,80 @@ public class DemoMainWindow extends TWindow {
                 }
             }
         );
-
         row += 2;
 
-        addLabel("Variable-width text field:", 1, row);
-        addField(35, row++, 15, false, "Field text");
-        addLabel("Fixed-width text field:", 1, row);
-        addField(35, row++, 15, true);
-        addLabel("Variable-width password:", 1, row);
-        addPasswordField(35, row++, 15, false);
-        addLabel("Fixed-width password:", 1, row);
-        addPasswordField(35, row++, 15, true, "hunter2");
+        addLabel("Text fields", 1, row);
+        addButton("Field&s", 35, row,
+            new TAction() {
+                public void DO() {
+                    new DemoTextFieldWindow(getApplication());
+                }
+            }
+        );
         row += 2;
 
-        if (!isModal()) {
-            addLabel("Radio buttons and checkboxes", 1, row);
-            addButton("&Checkboxes", 35, row,
-                new TAction() {
-                    public void DO() {
-                        new DemoCheckboxWindow(getApplication());
-                    }
+        addLabel("Radio buttons and checkboxes", 1, row);
+        addButton("&Checkboxes", 35, row,
+            new TAction() {
+                public void DO() {
+                    new DemoCheckboxWindow(getApplication());
                 }
-            );
-        }
+            }
+        );
         row += 2;
 
-        /*
-        if (!isModal()) {
-            addLabel("Editor window", 1, row);
-            addButton("Edito&r", 35, row,
-                {
-                    new TEditor(application, 0, 0, 60, 15);
+        addLabel("Editor window", 1, row);
+        addButton("Edito&r", 35, row,
+            new TAction() {
+                public void DO() {
+                    new DemoEditorWindow(getApplication());
                 }
-            );
-        }
+            }
+        );
         row += 2;
-         */
-
-        if (!isModal()) {
-            addLabel("Text areas", 1, row);
-            addButton("&Text", 35, row,
-                new TAction() {
-                    public void DO() {
-                        new DemoTextWindow(getApplication());
-                    }
+
+        addLabel("Text areas", 1, row);
+        addButton("&Text", 35, row,
+            new TAction() {
+                public void DO() {
+                    new DemoTextWindow(getApplication());
                 }
-            );
-        }
+            }
+        );
         row += 2;
 
-        if (!isModal()) {
-            addLabel("Tree views", 1, row);
-            addButton("Tree&View", 35, row,
-                new TAction() {
-                    public void DO() {
+        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;
 
-        if (!isModal()) {
-            addLabel("Terminal", 1, row);
-            addButton("Termi&nal", 35, row,
-                new TAction() {
-                    public void DO() {
-                        getApplication().openTerminal(0, 0);
-                    }
+        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);
@@ -193,5 +192,11 @@ public class DemoMainWindow extends TWindow {
                 }
             }
         );
+
+        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");
     }
 }