X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTRadioGroup.java;h=d57d86478a8ed502d1437bc5a74fca9125747c67;hb=4c46ea176c25101865057accbfe01da1d9b6b8ab;hp=d811f273a56c6a6fc6d62b9a516701d2c894f55a;hpb=051e29138b18fb4b731a72f8727475b10e4c74e4;p=fanfix.git diff --git a/src/jexer/TRadioGroup.java b/src/jexer/TRadioGroup.java index d811f27..d57d864 100644 --- a/src/jexer/TRadioGroup.java +++ b/src/jexer/TRadioGroup.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"), @@ -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; } /**