Add 'src/jexer/' from commit 'cf01c92f5809a0732409e280fb0f32f27393618d'
[nikiroo-utils.git] / src / jexer / TImage.java
index d1707074f8951d5d2775b94ada20e650fe9a886e..cd0ce96e0baf4523c64cb45527c01cbc4d1e1443 100644 (file)
@@ -202,24 +202,12 @@ public class TImage extends TWidget {
         this.clickAction = clickAction;
 
         sizeToImage(true);
-
-        getApplication().addImage(this);
     }
 
     // ------------------------------------------------------------------------
     // Event handlers ---------------------------------------------------------
     // ------------------------------------------------------------------------
 
-    /**
-     * Subclasses should override this method to cleanup resources.  This is
-     * called by TWindow.onClose().
-     */
-    @Override
-    protected void close() {
-        getApplication().removeImage(this);
-        super.close();
-    }
-
     /**
      * Handle mouse press events.
      *
@@ -228,7 +216,7 @@ public class TImage extends TWidget {
     @Override
     public void onMouseDown(final TMouseEvent mouse) {
         if (clickAction != null) {
-            clickAction.DO();
+            clickAction.DO(this);
             return;
         }
     }
@@ -378,25 +366,8 @@ public class TImage extends TWidget {
      * @param always if true, always resize the cells
      */
     private void sizeToImage(final boolean always) {
-        int textWidth = 16;
-        int textHeight = 20;
-
-        if (getScreen() instanceof SwingTerminal) {
-            SwingTerminal terminal = (SwingTerminal) getScreen();
-
-            textWidth = terminal.getTextWidth();
-            textHeight = terminal.getTextHeight();
-        } if (getScreen() instanceof MultiScreen) {
-            MultiScreen terminal = (MultiScreen) getScreen();
-
-            textWidth = terminal.getTextWidth();
-            textHeight = terminal.getTextHeight();
-        } else if (getScreen() instanceof ECMA48Terminal) {
-            ECMA48Terminal terminal = (ECMA48Terminal) getScreen();
-
-            textWidth = terminal.getTextWidth();
-            textHeight = terminal.getTextHeight();
-        }
+        int textWidth = getScreen().getTextWidth();
+        int textHeight = getScreen().getTextHeight();
 
         if (image == null) {
             image = rotateImage(originalImage, clockwise);