public class RadioSet<O extends OutputManager<?>> extends LabeledPanel<O,RadioSetConfig> implements FocusListener, DataContainer, ControlSetComponent
RadioButton
objects.
This is the ChUI specific implementation of the widget.
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<RadioButton<O>> |
buttons
Button collection.
|
protected int |
current
current button
|
config
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
RadioSet(WidgetId id,
WidgetConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
afterConfigUpdate(RadioSetConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
Widget<O> |
currentFocus()
Return reference to this, since REDIO-SET is always retains focus on
itself.
|
Widget<O> |
defaultFocus()
Get default focusable widget.
|
protected void |
disable()
Disable widget.
|
void |
draw()
Draw RadioSet widget.
|
protected void |
enable()
Enable widget.
|
boolean |
focusTraversable()
Indicates whether this component can be traversed using TAB or BACK-TAB
events.
|
protected double |
getButtonsExpandWidth(ControlSetItem[] items)
Gets button width for expand mode.
|
protected double |
getButtonsExtraDistance()
Gets extra distance between radio-buttons.
|
double |
getCharWidth()
Getting the width of the button.
|
int |
getIndex(RadioButton<O> rb)
Request index of some button.
|
protected double |
getListHeightChars()
Gets the list height in character units for radio-set.
|
protected double |
getListWidthChars()
Gets the list width in character units for radio-set.
|
RadioButton<O> |
getSelected()
Get selected button.
|
int[] |
getSelection()
Request indexes of selected items.
|
java.lang.String |
getText()
Get text representation of the currently selected value.
|
BaseDataType |
getValue()
Must return the value of the radio-set as a BaseDataType.
|
Rectangle |
getVisiblePart()
Gets the sub-rectangle which should be visible.
|
void |
initialize(WidgetId id,
RadioSetConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
boolean |
isModified()
Getting the modification state of the widget.
|
boolean |
manageSystemActions()
Check if the current widget can manage non-global system actions on its own, and not via the
enclosing event loop.
|
void |
onFocusGained(FocusEvent focusEvent)
This is called when the radio-set takes the input focus.
|
void |
onFocusLost(FocusEvent focusEvent)
This is called when the radio-set looses the input focus.
|
void |
processKeyEvent(KeyInput keyEvent)
This overriding is used to move the focus from this widget to the
next/previous one, rather than moving between radio buttons inside the
current radio-set.
|
void |
reflectAncestorChange()
Called when any of the widget's ancestors gets re-assigned.
|
void |
refreshItems()
Refresh widget look using new set of buttons.
|
protected void |
refreshItemsImpl(int selectedId,
boolean selectedDisabled)
Refresh widget look using new set of buttons, after the concrete implementation has done any
other needed calculations.
|
void |
reset()
Resets the value of the radio-set (the selected button) to the first
button of the set.
|
protected void |
selectButton(RadioButton<O> button)
Select specified button and remove current selection.
|
void |
setEnabled(boolean enabled)
Enable/disable widget.
|
private void |
setInitial()
Track index of currently selected button.
|
void |
setValue(BaseDataType value)
Sets the value of the radio-set (the selected button) based on a
BaseDataType value.
|
void |
setWidthChars(double newWidth)
Set up the width of the button dynamically.
|
config, destroy, getColon, getColumnLabelText, getColumnMnemonic, getLabelInstance, getLabelText, getMnemonic, getTo, isForceLabel, isNoLabels, isRightAligned, postprocessConfig, setColumnMnemonic, setHidden, setLabelInstance, setMnemonic, setNoLabels, setVisible, setWasVisible, wasVisible
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, copyState, currentFocus, cycleFocus, detach, dimension, doLayout, dumpCurrentWidgets, dumpWidgets, endSizeChange, findMouseSource, firstFocus, focus, focusWorker, formatDump, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getTabItemList, hasFocusable, height, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, prepareWidgets, prevFocus, reflectLocationChange, remove, removeContainerStateListener, repaint, replace, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setTabItemList, setWidth, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList, width
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, displayPhysicalLocation, drawCaret, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isCurrent, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, dimension, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getZOrderClass, hasFocus, height, hidden, hide, highlighted, insets, isCurrent, isDirectManipulable, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, topLevelWindow, unrealize, width, window
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
createMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, isMnemonicSupported, updateMnemonic
protected int current
protected java.util.ArrayList<RadioButton<O extends OutputManager<?>>> buttons
public RadioSet(WidgetId id, WidgetConfig cfg)
Call initialize(com.goldencode.p2j.ui.WidgetId, com.goldencode.p2j.ui.RadioSetConfig)
to finish the widget initialization.
id
- The widget's ID.cfg
- Configuration data.public void initialize(WidgetId id, RadioSetConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<RadioSetConfig>
id
- The widget's ID.cfg
- The config used to initialize this widget.public void processKeyEvent(KeyInput keyEvent)
processKeyEvent
in interface Widget<O extends OutputManager<?>>
processKeyEvent
in class AbstractContainer<O extends OutputManager<?>>
keyEvent
- The key event to be processed.public BaseDataType getValue()
getValue
in interface DataContainer
public java.lang.String getText()
getText
in interface DataContainer
public void setValue(BaseDataType value)
setValue
in interface DataContainer
value
- The BaseDataType value of the button to be selected inside
the button group.public void reset()
public boolean focusTraversable()
focusTraversable
in interface Widget<O extends OutputManager<?>>
focusTraversable
in class AbstractContainer<O extends OutputManager<?>>
true
if widget can be traversed.public Widget<O> defaultFocus()
If at least one button is focusable, then return this radio-set (not individual button).
defaultFocus
in interface Container<O extends OutputManager<?>>
defaultFocus
in class AbstractContainer<O extends OutputManager<?>>
public Widget<O> currentFocus()
currentFocus
in interface Container<O extends OutputManager<?>>
currentFocus
in class AbstractContainer<O extends OutputManager<?>>
public boolean isModified()
isModified
in interface DataContainer
true
if the widget value was modified,
false
otherwise.public void setWidthChars(double newWidth)
newWidth
- The new width of the radio-button.public double getCharWidth()
public void draw()
draw
in interface Widget<O extends OutputManager<?>>
draw
in class AbstractContainer<O extends OutputManager<?>>
public void onFocusGained(FocusEvent focusEvent)
onFocusGained
in interface FocusListener
focusEvent
- The focus event to be processed.public void onFocusLost(FocusEvent focusEvent)
onFocusLost
in interface FocusListener
focusEvent
- The focus event to be processed.public void refreshItems()
refreshItems
in interface ControlSetComponent
public int[] getSelection()
getSelection
in interface ControlSetComponent
public int getIndex(RadioButton<O> rb)
rb
- Radio button.public void setEnabled(boolean enabled)
setEnabled
in interface Widget<O extends OutputManager<?>>
setEnabled
in class AbstractWidget<O extends OutputManager<?>>
enabled
- private void setInitial()
public RadioButton<O> getSelected()
public Rectangle getVisiblePart()
getVisiblePart
in interface Widget<O extends OutputManager<?>>
getVisiblePart
in class AbstractWidget<O extends OutputManager<?>>
public boolean manageSystemActions()
manageSystemActions
in class AbstractWidget<O extends OutputManager<?>>
true
as the widget has its own event management.public void afterConfigUpdate(RadioSetConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<RadioSetConfig>
afterConfigUpdate
in class LabeledPanel<O extends OutputManager<?>,RadioSetConfig>
beforeUpdate
- Original configuration state.public void reflectAncestorChange()
AbstractWidget.ancestorCache
and AbstractWidget.window
) for itself and the entire widget tree starting
from this container.reflectAncestorChange
in class AbstractContainer<O extends OutputManager<?>>
protected void disable()
disable
in class AbstractWidget<O extends OutputManager<?>>
protected void enable()
enable
in class AbstractWidget<O extends OutputManager<?>>
protected void refreshItemsImpl(int selectedId, boolean selectedDisabled)
selectedId
- The selected button ID; -1 if none selected.selectedDisabled
- Flag indicating if the selected button is disabled.protected void selectButton(RadioButton<O> button)
button
- Button to select.protected double getButtonsExpandWidth(ControlSetItem[] items)
items
- Radio-button set to check.protected double getButtonsExtraDistance()
protected double getListWidthChars()
protected double getListHeightChars()