Prep for 2019 release
[nikiroo-utils.git] / src / jexer / TRadioGroup.java
index d811f273a56c6a6fc6d62b9a516701d2c894f55a..d57d86478a8ed502d1437bc5a74fca9125747c67 100644 (file)
@@ -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"),
@@ -35,6 +35,10 @@ import jexer.bits.CellAttributes;
  */
 public class TRadioGroup extends TWidget {
 
+    // ------------------------------------------------------------------------
+    // Variables --------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Label for this radio button group.
      */
@@ -45,30 +49,9 @@ public class TRadioGroup extends TWidget {
      */
     private TRadioButton selectedButton = null;
 
-    /**
-     * Get the radio button ID that was selected.
-     *
-     * @return ID of the selected button, or 0 if no button is selected
-     */
-    public int getSelected() {
-        if (selectedButton == null) {
-            return 0;
-        }
-        return selectedButton.getId();
-    }
-
-    /**
-     * Set the new selected radio button.  Note package private access.
-     *
-     * @param button new button that became selected
-     */
-    void setSelected(final TRadioButton button) {
-        assert (button.isSelected());
-        if (selectedButton != null) {
-            selectedButton.setSelected(false);
-        }
-        selectedButton = button;
-    }
+    // ------------------------------------------------------------------------
+    // Constructors -----------------------------------------------------------
+    // ------------------------------------------------------------------------
 
     /**
      * Public constructor.
@@ -87,6 +70,10 @@ public class TRadioGroup extends TWidget {
         this.label = label;
     }
 
+    // ------------------------------------------------------------------------
+    // TWidget ----------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Draw a radio button with label.
      */
@@ -100,11 +87,40 @@ public class TRadioGroup extends TWidget {
             radioGroupColor = getTheme().getColor("tradiogroup.inactive");
         }
 
-        getScreen().drawBox(0, 0, getWidth(), getHeight(),
-            radioGroupColor, radioGroupColor, 3, false);
+        drawBox(0, 0, getWidth(), getHeight(), radioGroupColor, radioGroupColor,
+            3, false);
 
-        getScreen().hLineXY(1, 0, label.length() + 2, ' ', radioGroupColor);
-        getScreen().putStringXY(2, 0, label, radioGroupColor);
+        hLineXY(1, 0, label.length() + 2, ' ', radioGroupColor);
+        putStringXY(2, 0, label, radioGroupColor);
+    }
+
+    // ------------------------------------------------------------------------
+    // TRadioGroup ------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
+    /**
+     * Get the radio button ID that was selected.
+     *
+     * @return ID of the selected button, or 0 if no button is selected
+     */
+    public int getSelected() {
+        if (selectedButton == null) {
+            return 0;
+        }
+        return selectedButton.getId();
+    }
+
+    /**
+     * Set the new selected radio button.  Note package private access.
+     *
+     * @param button new button that became selected
+     */
+    void setSelected(final TRadioButton button) {
+        assert (button.isSelected());
+        if (selectedButton != null) {
+            selectedButton.setSelected(false);
+        }
+        selectedButton = button;
     }
 
     /**