public class SelectionListBodyGuiImpl extends SelectionListBody<GuiOutputManager>
Modifier and Type | Field and Description |
---|---|
private int |
colLeft
The current left column in the item list to display.
|
private ColorRgb |
disabledFore
Disabled state text color.
|
private ColorRgb |
focusDots
Focus dotted line color, when no row is selected.
|
private boolean |
focusedDraw
Flag indicating if in no-selection mode, the dotted line must be drawn to show focus.
|
protected GuiColorResolver |
gc
Color resolver
|
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
private int |
maxWidth
Maximum width of the item list in character units.
|
private int |
mousePressedRow
The selected row index at the moment the left mouse button was pressed.
|
private int |
nativeWidth
The width in pixels of the list visible area.
|
private ColorRgb |
selectionBack
Selected item box color.
|
private ColorRgb |
selectionDots
Selected dotted line color.
|
private ColorRgb |
selectionFore
Selected item text color.
|
config, cursorVisible, items, rowTop, widgetFocused
currentRow, listModel, selectionModel, selectionStart
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
SelectionListBodyGuiImpl(WidgetId id,
SelectionListConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
draw()
Draws this component.
|
private void |
drawItem(int number,
int x,
int y,
int rw,
int rh,
int fontSize,
boolean enabled,
boolean focused)
Draws the next text item in the list inside visible part of the drop-down.
|
int |
getCharWidth()
Gets the current char width depending on choosen font.
|
private int |
getMaxWidth()
Gets the maximum possible width of the current selection-list in character units.
|
int |
getRowHeight()
Gets the current row height depending on chosen font.
|
NativeDimension |
getScrollDimension()
Returns the scroll dimension of this widget.
|
NativeDimension |
getScrollStep()
Returns the dimension of the base scroll step desired by the widget
in the X and Y directions.
|
NativeDimension |
getVisibleDimension()
Returns the visible dimension of this widget.
|
void |
initialize(WidgetId id,
SelectionListConfig 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.
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Notification of a mouse dragged event occurred for 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 |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Notification of a mouse wheel moved event occurred for this widget.
|
private boolean |
needProcessKey(int key)
Check if the key event needs to be processed or not based on current position.
|
protected boolean |
needValueChanged()
Checks if we need to post VALUE-CHANGED event.
|
void |
onFocusLost(FocusEvent focusEvent)
This is called when the selection-list looses the input focus.
|
protected void |
postScrollEvent(java.lang.Integer column,
java.lang.Integer row)
Post scroll event with the specified row.
|
boolean |
processKey(int key)
Process key event.
|
private int |
resolveCurrentFontNum()
Gets the font number currently using with this selection-list.
|
boolean |
scrollToItem(int index)
Implements SCROLL-TO-ITEM() method for selection-list widget in GUI interface.
|
protected boolean |
scrollWorker(java.lang.Integer newXPosition,
java.lang.Integer newYPosition)
Directs the widget to scroll to the specified X and Y positions.
|
private void |
selectItemAtMousePosition(java.awt.event.MouseEvent e)
Select the item under mouse pointer.
|
private boolean |
selectRange(int row)
Set selection from selectionStart the to argument.
|
protected void |
setFocusedDraw(boolean focusedDraw)
Set the
focusedDraw flag. |
void |
setInternalWidth(int widthInPixels)
Sets the visible width in pixels for list are.
|
double |
width()
Get widget width.
|
afterConfigUpdate, calculateScrollYPosition, changed, config, entry, getDefaultEvent, getItemText, getScreenValue, getText, getValue, isHorizontalScrollBar, isModified, isSelected, isVerticalScrollBar, location, manageSystemActions, onFocusGained, pageSize, physicalLocation, processKeyEvent, requestFocus, resetView, scroll, scrollToItem, setLocation, setPhysicalLocation, setValue, shiftByCursorKeys, shiftSelectCurrentRow, toggleCurrentRowSelection
addScrollListener, addSelectionListener, currentRow, deselect, dimension, ensureRowVisible, ensureRowVisible, first, getColumns, height, isScrollPopupSupported, isSingleSelectionMode, minimumSize, model, select, selectCurrentRow, selected, selection, selectionClear, selectionMode, selectionSize, set, setColumns, setCurrentRow, setSelectionMode, setVisibleRows, shiftCurrentRow, value, visibleRows
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, copyState, createMouseHoverAction, deactivateDirectManipulation, debug, destroy, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, initialHeight, initialWidth, insets, isCurrent, isDirectManipulationActive, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, mouseClicked, mouseEntered, mouseExited, mouseMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, postprocessConfig, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, reflectAncestorChange, reflectLocationChange, refresh, registerWidgetStateListener, repaint, repaint, repaint, requestFocus, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setMousePointer, setParent, setState, setVisible, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unrealize, unregisterWidgetStateListener, updateSizeWorker, widgetStateChanged, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, defaultMousePtr, destroy, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, insets, isCurrent, isDirectManipulable, isDirectManipulationActive, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, maySwitchFocus, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, postprocessConfig, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetStateListener, repaint, repaint, repaint, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setMousePointer, setParent, setState, setVisible, show, supportsCustomMousePointer, systemFocusGrabbed, topLevelWindow, unrealize, unregisterWidgetStateListener, validateDisplayValue, widgetStateChanged, window
protected GuiColorResolver gc
private int colLeft
private ColorRgb disabledFore
private GuiDriver gd
private GuiFontResolver gf
private int maxWidth
private int nativeWidth
private ColorRgb selectionBack
private ColorRgb selectionDots
private ColorRgb focusDots
private ColorRgb selectionFore
private int mousePressedRow
private boolean focusedDraw
public SelectionListBodyGuiImpl(WidgetId id, SelectionListConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public void draw()
draw
in interface Widget<GuiOutputManager>
draw
in class SelectionListBody<GuiOutputManager>
public int getCharWidth()
public int getRowHeight()
public NativeDimension getScrollDimension()
The returned dimension doesn't need to be in the same units as the
widget's physical size but it must be compatible with the result
of getVisibleDimension()
and getScrollStep()
.
getScrollDimension
in interface ScrollableWidget<GuiOutputManager>
getScrollDimension
in class DefaultList<java.lang.String,GuiOutputManager>
public NativeDimension getScrollStep()
The scroll step must be in the same units as the dimensions returned
by getScrollDimension()
and getVisibleDimension()
.
getScrollStep
in interface ScrollableWidget<GuiOutputManager>
getScrollStep
in class DefaultList<java.lang.String,GuiOutputManager>
public NativeDimension getVisibleDimension()
The returned dimension doesn't need to be in the same units as the
widget's physical size but it must be compatible with the result
of getScrollDimension()
and getScrollStep()
.
getVisibleDimension
in interface ScrollableWidget<GuiOutputManager>
getVisibleDimension
in class DefaultList<java.lang.String,GuiOutputManager>
public void initialize(WidgetId id, SelectionListConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<SelectionListConfig>
initialize
in class SelectionListBody<GuiOutputManager>
id
- The widget's ID.cfg
- The config used to initialize this widget.public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.private final void selectItemAtMousePosition(java.awt.event.MouseEvent e)
e
- the mouse eventpublic 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 mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
mouseWheelMoved
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public boolean processKey(int key)
processKey
in class DefaultList<java.lang.String,GuiOutputManager>
key
- key to processtrue
if the widget needs repaintingpublic boolean scrollToItem(int index)
scrollToItem
in class SelectionListBody<GuiOutputManager>
index
- The 0-based index of an item to scroll.TRUE
in success, FALSE
otherwise.public void setInternalWidth(int widthInPixels)
widthInPixels
- New pixel width.public double width()
width
in interface Widget<GuiOutputManager>
width
in class DefaultList<java.lang.String,GuiOutputManager>
public void onFocusLost(FocusEvent focusEvent)
Restore the focusedDraw
flag back to true
.
onFocusLost
in interface FocusListener
onFocusLost
in class SelectionListBody<GuiOutputManager>
focusEvent
- The focus event to be processed.protected void setFocusedDraw(boolean focusedDraw)
focusedDraw
flag. When this is off, the dotted line will not be shown, if there is
no selection.focusedDraw
- true
to highlight via the dotted line.protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
protected boolean needValueChanged()
needValueChanged
in class SelectionListBody<GuiOutputManager>
TRUE
for GUI mode.protected void postScrollEvent(java.lang.Integer column, java.lang.Integer row)
postScrollEvent
in class DefaultList<java.lang.String,GuiOutputManager>
column
- Scroll column.row
- Scroll row.protected boolean scrollWorker(java.lang.Integer newXPosition, java.lang.Integer newYPosition)
getScrollDimension()
, getVisibleDimension()
and getScrollStep()
.scrollWorker
in class SelectionListBody<GuiOutputManager>
newXPosition
- New X scroll position.newYPosition
- New Y scroll position.true
to indicate that the scroll operation actually
invalidated this list.private void drawItem(int number, int x, int y, int rw, int rh, int fontSize, boolean enabled, boolean focused)
number
- The number of the item to draw.x
- The X coordinate of the enclosing rectangle to draw item.y
- The Y coordinate of the enclosing rectangle to draw item.rw
- The pixel width of the enclosing rectangle to draw item.rh
- The pixel height of the enclosing rectangle to draw item.fontSize
- The vertical size of font to draw item text.enabled
- Flag indicating the enabled state of the list.focused
- Flag indicating the focused state of the list.private int getMaxWidth()
private final boolean needProcessKey(int key)
key
- key to processprivate int resolveCurrentFontNum()
private final boolean selectRange(int row)
row
- the row to select totrue
if selection was changed by this call