*
* The MIT License (MIT)
*
- * Copyright (C) 2016 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"),
/**
* TRadioGroup is a collection of TRadioButtons with a box and label.
*/
-public final class TRadioGroup extends TWidget {
+public class TRadioGroup extends TWidget {
+
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Label for this radio button group.
*/
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.
this.label = label;
}
+ // ------------------------------------------------------------------------
+ // TWidget ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Draw a radio button with label.
*/
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;
}
/**