public class ComboBoxGuiImpl extends ComboBox<GuiOutputManager> implements AutoResizable<ComboBoxConfig>
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private CoordinatesConversion |
cc
Coordinate converter
|
private static int |
ENTRY_TO_HEIGHT_Y_DIFF
The space difference between item row height and full combo-box height.
|
private EntryFieldGuiImpl |
entryField
Editable entry field for SIMPLE and DROP-DOWN modes.
|
private GuiColorResolver |
gc
Color resolver
|
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
private KeyInput |
keyToDefer
The key event that must be posted after drop-down exit.
|
private boolean |
pressed
Pressed button state flag.
|
private GuiOutputManager |
screen
Output manager
|
private ScrollableSelectionListGuiImpl |
simpleList
The list for SIMPLE combo-box mode.
|
private ScrollPaneGuiImpl |
simpleListPane
The list for SIMPLE combo-box mode.
|
static int |
TEXT_SHIFT
Shift in X to draw text inside entry.
|
config, dropDown, endConditionRaised, limit, selected, valueChanged
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
ComboBoxGuiImpl(WidgetId id,
WidgetConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addUISpecificEvents(EventList listToChange)
Adding mouse clicks as exit events.
|
void |
afterConfigUpdate(ComboBoxConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
void |
changed()
This method is invoked when selection is changed.
|
private void |
createEntryField()
Clean up the main registry pool from drop-down widgets when it is closing, if the widget is
a container, make recursive call.
|
MnemonicInfo |
createMnemonic()
Creates new
MnemonicInfo instance. |
private void |
createSimpleList()
Creates the list for SIMPLE mode of the combo-box.
|
void |
deferKeyEvent(KeyInput ki)
Saves the key event to be posted into event queue after drop-down is gone.
|
void |
destroy()
Destroy this widget.
|
void |
draw()
Draw the combo-box.
|
void |
drawCaret()
Sets position of terminal's cursor to the first char of the combo-box.
|
protected void |
dropDownRequestFocus()
Requesting focus to opened drop-down.
|
void |
entryFieldChanged(java.lang.String newValue)
Posts value changed event to the queue.
|
void |
exitDropDown()
Exit the drop-down (the "selection" mode of the combo-box).
|
java.util.Optional<MousePtrWrapper> |
getCustomMousePointer()
Get the current custom mouse pointer if it is set
|
int |
getDropDownScrollBarWidth()
Gets the width of the scrollbar used for drop-down.
|
(package private) int |
getEntryFieldHeight()
Returns entry field height.
|
int |
getFormatLength()
Returns the format length of the data type the combo-box represents.
|
java.lang.String |
getInitialScreenText(BaseDataType initVal)
Gets the initially setted screen value.
|
private int |
getInnerLines()
Returns the inner lines value for combo-box.
|
private int |
getItemMaximalWidth(int font)
Calculates the maximal item width in the pixel units for the given font number.
|
java.lang.Object |
getList()
Returns the list for SIMPLE combo-box mode.
|
int |
getRowHeight()
Gets the current row height depending on choosen font.
|
BaseDataType |
getScreenValue()
Get widget screen value.
|
int |
getSimpleListVisibleHeight()
Returns simple list height without (upper and lower) border.
|
boolean |
hasFocus()
Check if widget has focus.
|
double |
height()
Get widget height.
|
protected java.util.Set<java.lang.String> |
initEventsSet()
Initializes the event set to return.
|
void |
initialize(WidgetId id,
ComboBoxConfig wcfg)
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.
|
void |
invalidateSelection()
Invalidate the editor's selection.
|
boolean |
isAutoResize()
Get the AUTO-RESIZE status
|
boolean |
isSelectionValid()
Check if currently there is some selected text.
|
private void |
layoutSimpleList()
Layout simple list.
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Notification of a mouse released event occurred for this widget.
|
void |
onFocusGained(FocusEvent event)
This is called when the combo-box gains the input focus.
|
void |
onFocusLost(FocusEvent focusEvent)
This is called when the combo-box loses the input focus.
|
protected void |
postprocessDropDown()
Sometimes it is required to do several action the was deferred during drop-down life cycle.
|
void |
processFocusMoveKey(KeyInput keyEvent)
Process the action associated with the given focus movement key in an independent drawing
bracket.
|
void |
processKeyEvent(KeyInput keyEvent)
Process key events that have been generated by this component.
|
boolean |
processMnemonic(int key)
Process the given key, if this widget's mnemonic matches the key.
|
void |
processSystemKey(KeyInput keyEvent)
Process the action associated with the given key in an independent drawing bracket.
|
void |
refreshItems()
Refresh items in the combo-box after assignment.
|
protected void |
registerDropDownFrame()
Registers drop-down frame in current window system.
|
void |
removeSelectedText()
Removes selected text.
|
void |
setEnabled(boolean enabled)
Enable/disable widget.
|
private void |
setNewSelection(int indexNew)
Changes the selected value without opening drop-down.
|
boolean |
setSelection(int start,
int end)
Creates a new selection, eventually dropping the already existing one.
|
void |
setVisible(boolean visible_)
Shows or hides the combo-box and its label.
|
boolean |
supportsCustomMousePointer()
Check if the widget supports LOAD-MOUSE-POINTER() method
|
void |
updateSize(ComboBoxConfig beforeUpdate)
Update widget's size after config update
|
protected void |
valueChangedCommon()
Posts value changed event to the queue.
|
double |
width()
Get widget width.
|
activate, calcLimit, config, deactivateCode, dimension, getColon, getColumnLabelText, getColumnMnemonic, getDColor, getDropDownList, getItemText, getLabelInstance, getLabelText, getMaxLabelLen, getMnemonic, getScrollPaneId, getSelection, getText, getTo, getValue, isDropDownActive, isForceLabel, isFormatHonored, isModified, isNoLabels, isRightAligned, isSelected, isSimpleMode, lookup, manageSystemActions, minimumSize, model, onSelect, postprocessConfig, processEvent, requestFocus, setColumnMnemonic, setHidden, setLabelInstance, setMnemonic, setNoLabels, setValue, setWasVisible, valueChangedImpl, wasVisible
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, enable, enclosingFrame, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hidden, hide, highlighted, ignoreAction, insets, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, processMnemonicImpl, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, sync, topLevelWindow, toString, translate, unrealize, updateSizeWorker, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, displayPhysicalLocation, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, topLevelWindow, unrealize, window
mouseClicked, mouseEntered, mouseExited
getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, isMnemonicSupported, updateMnemonic
public static final int TEXT_SHIFT
private static final int ENTRY_TO_HEIGHT_Y_DIFF
private GuiDriver gd
private GuiOutputManager screen
private CoordinatesConversion cc
private GuiColorResolver gc
private GuiFontResolver gf
private boolean pressed
private EntryFieldGuiImpl entryField
private ScrollableSelectionListGuiImpl simpleList
private ScrollPaneGuiImpl simpleListPane
private KeyInput keyToDefer
public ComboBoxGuiImpl(WidgetId id, WidgetConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public void initialize(WidgetId id, ComboBoxConfig wcfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<ComboBoxConfig>
initialize
in class ComboBox<GuiOutputManager>
id
- The widget's ID.wcfg
- The config used to initialize this widget.public void afterConfigUpdate(ComboBoxConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<ComboBoxConfig>
afterConfigUpdate
in class ComboBox<GuiOutputManager>
beforeUpdate
- Config reference capturing the config state before
the owner's config was modified.public void draw()
draw
in interface Widget<GuiOutputManager>
draw
in class ComboBox<GuiOutputManager>
public void drawCaret()
drawCaret
in interface Widget<GuiOutputManager>
drawCaret
in class ComboBox<GuiOutputManager>
public void onFocusGained(FocusEvent event)
onFocusGained
in interface FocusListener
onFocusGained
in class ComboBox<GuiOutputManager>
event
- The focus event to be processed.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public boolean processMnemonic(int key)
processMnemonic
in interface Widget<GuiOutputManager>
processMnemonic
in class AbstractWidget<GuiOutputManager>
key
- The pressed mnemonic key code.true
if this widget accepted this mnemonic key. Not enabled or not
visible widget will not accept it.public MnemonicInfo createMnemonic()
MnemonicInfo
instance.createMnemonic
in interface MnemonicTrait<GuiOutputManager>
public void processKeyEvent(KeyInput keyEvent)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class ComboBox<GuiOutputManager>
keyEvent
- The key event to be handled.public void processSystemKey(KeyInput keyEvent)
This must be called only in the context of widget-level event processing.
processSystemKey
in class ComboBox<GuiOutputManager>
keyEvent
- The key to be processed.public void processFocusMoveKey(KeyInput keyEvent)
TAB
or BACK_TAB
.
This must be called only in SIMPLE or DROP-DOWN mode either from entry field or from attached selection list.
keyEvent
- The key to be processed, TAB
or BACK_TAB
.public BaseDataType getScreenValue()
getScreenValue
in class ComboBox<GuiOutputManager>
public void invalidateSelection()
invalidateSelection
in interface TextSelection
public boolean isSelectionValid()
isSelectionValid
in interface TextSelection
true
if text is selected.public void removeSelectedText()
removeSelectedText
in interface TextSelection
public boolean setSelection(int start, int end)
setSelection
in interface TextSelection
start
- The offset of the start of the new selection.end
- The offset of the end of the new selection.true
is operation is successful.public void setVisible(boolean visible_)
setVisible
in interface Widget<GuiOutputManager>
setVisible
in class ComboBox<GuiOutputManager>
visible_
- true
to make the widget visible,
false
to hide the widget.public double height()
AbstractWidget
height
in interface Widget<GuiOutputManager>
height
in class ComboBox<GuiOutputManager>
Widget.height()
public double width()
AbstractWidget
width
in interface Widget<GuiOutputManager>
width
in class ComboBox<GuiOutputManager>
Widget.width()
public void changed()
changed
in interface SelectionListener
changed
in class ComboBox<GuiOutputManager>
public void setEnabled(boolean enabled)
setEnabled
in interface Widget<GuiOutputManager>
setEnabled
in class AbstractWidget<GuiOutputManager>
enabled
- TRUE
to make the widget enabled,
FALSE
to disable the widget.public boolean hasFocus()
hasFocus
in interface Widget<GuiOutputManager>
hasFocus
in class AbstractWidget<GuiOutputManager>
true
if widget has focus.public int getRowHeight()
public int getDropDownScrollBarWidth()
public void destroy()
destroy
in interface Widget<GuiOutputManager>
destroy
in class ComboBox<GuiOutputManager>
public void entryFieldChanged(java.lang.String newValue)
newValue
- The new value for combo-box.public void deferKeyEvent(KeyInput ki)
ki
- The key event to be posted after drop-down become closed.protected void postprocessDropDown()
postprocessDropDown
in class ComboBox<GuiOutputManager>
public void exitDropDown()
exitDropDown
in class ComboBox<GuiOutputManager>
public void updateSize(ComboBoxConfig beforeUpdate)
updateSize
in interface AutoResizable<ComboBoxConfig>
beforeUpdate
- previous value of the widget's configpublic boolean isAutoResize()
isAutoResize
in interface AutoResizable<ComboBoxConfig>
true
is AUTO-RESIZE is enabledpublic void onFocusLost(FocusEvent focusEvent)
onFocusLost
in interface FocusListener
onFocusLost
in class ComboBox<GuiOutputManager>
focusEvent
- The focus event to be processed.public java.lang.Object getList()
public void refreshItems()
refreshItems
in interface ControlSetComponent
refreshItems
in class ComboBox<GuiOutputManager>
public int getSimpleListVisibleHeight()
protected void registerDropDownFrame()
registerDropDownFrame
in class ComboBox<GuiOutputManager>
protected void dropDownRequestFocus()
dropDownRequestFocus
in class ComboBox<GuiOutputManager>
public boolean supportsCustomMousePointer()
supportsCustomMousePointer
in interface Widget<GuiOutputManager>
supportsCustomMousePointer
in class AbstractWidget<GuiOutputManager>
true
if the widget supports
LOAD-MOUSE-POINTER() methodpublic java.util.Optional<MousePtrWrapper> getCustomMousePointer()
getCustomMousePointer
in interface Widget<GuiOutputManager>
getCustomMousePointer
in class AbstractWidget<GuiOutputManager>
protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
protected void valueChangedCommon()
valueChangedCommon
in class ComboBox<GuiOutputManager>
protected java.util.Set<java.lang.String> initEventsSet()
initEventsSet
in class ComboBox<GuiOutputManager>
protected void addUISpecificEvents(EventList listToChange)
addUISpecificEvents
in class ComboBox<GuiOutputManager>
listToChange
- The event list to modify.private void createEntryField()
private void createSimpleList()
int getEntryFieldHeight()
private void layoutSimpleList()
private void setNewSelection(int indexNew)
indexNew
- The index of the new item to select.public java.lang.String getInitialScreenText(BaseDataType initVal)
initVal
- The number of the list items pair or entry for the list item.public int getFormatLength()
private int getItemMaximalWidth(int font)
font
- The provided font.private int getInnerLines()