X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDesktopDemoApplication.java;h=73d0c5f88ae028e8c83fe9b4355ed5c506d4ca50;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=395817d073fe541eb18a9cef77cf2ce20b166981;hpb=0ee88b6d705993df0d9e32cdc08c619605c7d75c;p=fanfix.git diff --git a/src/jexer/demos/DesktopDemoApplication.java b/src/jexer/demos/DesktopDemoApplication.java index 395817d..73d0c5f 100644 --- a/src/jexer/demos/DesktopDemoApplication.java +++ b/src/jexer/demos/DesktopDemoApplication.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,12 +28,16 @@ */ package jexer.demos; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.IOException; +import java.util.ResourceBundle; +import java.util.Scanner; -import jexer.*; -import jexer.event.*; -import jexer.menu.*; +import jexer.TAction; +import jexer.TApplication; +import jexer.TWindow; +import jexer.event.TMenuEvent; +import jexer.menu.TMenu; /** * The demo application itself. @@ -41,35 +45,30 @@ import jexer.menu.*; public class DesktopDemoApplication extends TApplication { /** - * Add all the widgets of the demo. + * Translated strings. */ - private void addAllWidgets() { + private static final ResourceBundle i18n = ResourceBundle.getBundle(DesktopDemoApplication.class.getName()); - // Add the menus - addFileMenu(); - addEditMenu(); - addWindowMenu(); - addHelpMenu(); - - final DesktopDemo desktop = new DesktopDemo(this); - setDesktop(desktop); + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ - desktop.addButton("&Remove HATCH", 2, 5, - new TAction() { - public void DO() { - desktop.drawHatch = false; - } - } - ); - desktop.addButton("&Show HATCH", 2, 8, - new TAction() { - public void DO() { - desktop.drawHatch = true; - } - } - ); + /** + * Public constructor. + * + * @param backendType one of the TApplication.BackendType values + * @throws Exception if TApplication can't instantiate the Backend. + */ + public DesktopDemoApplication(final BackendType backendType) throws Exception { + super(backendType); + addAllWidgets(); + getBackend().setTitle(i18n.getString("applicationTitle")); } + // ------------------------------------------------------------------------ + // TApplication ----------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Handle menu events. * @@ -111,15 +110,159 @@ public class DesktopDemoApplication extends TApplication { return super.onMenu(menu); } + // ------------------------------------------------------------------------ + // DesktopDemoApplication ------------------------------------------------- + // ------------------------------------------------------------------------ + /** - * Public constructor. - * - * @param backendType one of the TApplication.BackendType values - * @throws Exception if TApplication can't instantiate the Backend. + * Add all the widgets of the demo. */ - public DesktopDemoApplication(final BackendType backendType) throws Exception { - super(backendType); - addAllWidgets(); - getBackend().setTitle("Jexer Demo Application"); + private void addAllWidgets() { + + // Add the menus + addFileMenu(); + addEditMenu(); + addWindowMenu(); + addHelpMenu(); + + final DesktopDemo desktop = new DesktopDemo(this); + setDesktop(desktop); + + desktop.addButton(i18n.getString("removeHatch"), 2, 5, + new TAction() { + public void DO() { + desktop.drawHatch = false; + } + } + ); + desktop.addButton(i18n.getString("showHatch"), 2, 8, + new TAction() { + public void DO() { + desktop.drawHatch = true; + } + } + ); + + final TWindow windowA = addWindow(i18n.getString("windowATitle"), + 25, 14); + final TWindow windowB = addWindow(i18n.getString("windowBTitle"), + 25, 14); + windowA.addButton(i18n.getString("showWindowB"), 2, 2, + new TAction() { + public void DO() { + windowB.show(); + } + } + ); + windowA.addButton(i18n.getString("hideWindowB"), 2, 4, + new TAction() { + public void DO() { + windowB.hide(); + } + } + ); + windowA.addButton(i18n.getString("maximizeWindowB"), 2, 6, + new TAction() { + public void DO() { + windowB.maximize(); + } + } + ); + windowA.addButton(i18n.getString("restoreWindowB"), 2, 8, + new TAction() { + public void DO() { + windowB.restore(); + } + } + ); + windowB.addButton(i18n.getString("showWindowA"), 2, 2, + new TAction() { + public void DO() { + windowA.show(); + } + } + ); + windowB.addButton(i18n.getString("hideWindowA"), 2, 4, + new TAction() { + public void DO() { + windowA.hide(); + } + } + ); + windowB.addButton(i18n.getString("maximizeWindowA"), 2, 6, + new TAction() { + public void DO() { + windowA.maximize(); + } + } + ); + windowB.addButton(i18n.getString("restoreWindowA"), 2, 8, + new TAction() { + public void DO() { + windowA.restore(); + } + } + ); + + desktop.addButton(i18n.getString("showWindowB"), 25, 2, + new TAction() { + public void DO() { + windowB.show(); + } + } + ); + desktop.addButton(i18n.getString("hideWindowB"), 25, 5, + new TAction() { + public void DO() { + windowB.hide(); + } + } + ); + desktop.addButton(i18n.getString("showWindowA"), 25, 8, + new TAction() { + public void DO() { + windowA.show(); + } + } + ); + desktop.addButton(i18n.getString("hideWindowA"), 25, 11, + new TAction() { + public void DO() { + windowA.hide(); + } + } + ); + desktop.addButton(i18n.getString("createWindowC"), 25, 15, + new TAction() { + public void DO() { + final TWindow windowC = desktop.getApplication().addWindow( + i18n.getString("windowCTitle"), 30, 20, + TWindow.NOCLOSEBOX); + windowC.addButton(i18n.getString("closeMe"), 5, 5, + new TAction() { + public void DO() { + windowC.close(); + } + } + ); + } + } + ); + + desktop.addButton(i18n.getString("enableFFM"), 25, 18, + new TAction() { + public void DO() { + DesktopDemoApplication.this.setFocusFollowsMouse(true); + } + } + ); + desktop.addButton(i18n.getString("disableFFM"), 25, 21, + new TAction() { + public void DO() { + DesktopDemoApplication.this.setFocusFollowsMouse(false); + } + } + ); } + }