public class FillInGuiImpl extends FillIn<GuiOutputManager,FillInConfig> implements AutoResizable<FillInConfig>, StreamableWidget, LightweightTextWidget
Modifier and Type | Class and Description |
---|---|
private class |
FillInGuiImpl.LeftAnchorEditScroller
Content scroller implementation when the anchor is positioned on the left-side editable edge.
|
private class |
FillInGuiImpl.RightAnchorEditScroller
Content scroller implementation when the anchor is positioned on the right-side editable edge.
|
LightweightTextWidget.TextLineSelection
Modifier and Type | Field and Description |
---|---|
private boolean |
bypassFocusInit
Flag indicating initialization is not needed on a focus-gained event, as it was treated
explicitly by some other logic (like mouse clicked).
|
protected ColorRgb |
disabledFore
Disabled state text color.
|
protected boolean |
disabledForeFixedColor
true if the foreground color of a disabled field is fixed (grey). |
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
private int |
lastPressedX
The absolute x-coordinate of the last mouse pressed event
|
browse, drawLine, editScroller, justActivated, leftAnchor, rightAnchor, selected, useUnderline
config
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
FillInGuiImpl(WidgetId id,
FillInConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adjustEditScroller(int key)
Adjust the edit scroller depending on the key being processed and the cursor location.
|
protected java.lang.String |
blankScreenValue(DisplayFormat.Presentation curPres,
int fmtWidth)
Implements screen value blanking when BLANK modifier is used.
|
Widget<?> |
convertToStreamable()
Convert this widget instance to its streamable equivalent.
|
protected EditScroller |
createLeftAnchor()
Create the left-edge scroller.
|
MnemonicInfo |
createMnemonic()
Creates new
MnemonicInfoGuiImpl instance. |
protected EditScroller |
createRightAnchor()
Create the right-edge scroller.
|
void |
draw(Color aColor)
Actual drawing routine.
|
protected void |
drawBorder(GuiColorResolver gcd,
int x,
int y,
NativeDimension dim,
boolean threeDBorder)
Draws the border box around the fill-in.
|
void |
drawCaret()
Draws the caret.
|
protected void |
drawCaretInt()
Draws the caret.
|
void |
drawCursor()
Draws a special cursor relative to the current origin.
|
protected NativeDimension |
editableNativeDimension()
Determine the interior portion of the widget.
|
private NativePoint |
editableNativeLocation()
Compute the location of the fill-in's editable content, relative to the fill-in's top-left
corner.
|
int |
getCursorColumnOffset()
Gets the current cursor column within its text content.
|
int |
getCursorRowOffset()
Gets the current cursor row within its text content.
|
GuiFontResolver.FontCache |
getFontCache()
Returns the current font cache.
|
int |
getInitialCursorPos()
Compute the initial cursor position, depending on the widget's implementation.
|
protected boolean |
getInsertMode()
Returns the insert mode state.
|
int |
getLastOffset()
Returns the last valid cursor position from the left bound of the FillIn.
|
protected int |
getNativeCursorPos()
Get the cursor position, in native units, as it would be positioned in the fully-visible
text.
|
java.lang.String |
getScreenText()
Gets the screen text content.
|
java.lang.String |
getScreenText(int line)
Gets the screen text content.
|
int |
getScrollColumnOffset()
Gets the current scroll offset within its text content.
|
int |
getScrollRowOffset()
Gets the current scroll offset within its text content.
|
java.lang.String |
getSelectedText()
Obtain any selected text in the widget for copying to the clipboard.
|
protected Theme.TextLookAndFeel |
getTextLookAndFeel(GuiColorResolver gcd,
GuiColorResolver gce)
Returns text look and feel.
|
LightweightTextWidget.TextLineSelection |
getTextSelection(int line)
Gets the current text selection object for the given line.
|
protected int |
getValidCursorPos()
Get valid cursor position.
|
void |
initialize(WidgetId id,
FillInConfig 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.
|
void |
invalidateSelection()
Invalidate the text selection state.
|
boolean |
isAutoResize()
Get the AUTO-RESIZE status
|
boolean |
isDroppable()
Checks if the given widget is able to be the target of the drop operation.
|
boolean |
isRMBEntrySupported()
Check if this widget gains ENTRY event when right/middle mouse button is clicked.
|
protected boolean |
isTextSelectionDisplayed()
Tests if the text selection is displayed.
|
private boolean |
isUninitialized()
Check if this fill-in acts as "uninitialized".
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Notification of a mouse clicked event occurred for this widget.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Handle the mouse dragged events in order to support fillin functionality.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Notification of a mouse wheel moved event occurred for this widget.
|
private void |
moveCursorToFirst()
Move the cursor to the leftmost index.
|
protected void |
moveCursorToLast()
Move the cursor to the rightmost index.
|
protected int |
nativeHeight()
Retrieve the widget's height in native units.
|
protected int |
nativeWidth()
Retrieve the widget's width in native units.
|
protected static int |
nativeWidth(FillIn<GuiOutputManager,?> widget,
GuiDriver gd,
GuiFontResolver gf,
boolean isText)
Compute the widget's width in native units.
|
void |
processKeyEvent(KeyInput ke)
Process GUI specific keys:
VK_SHIFT_CURSOR_RIGHT - expands text selection to the right.
VK_SHIFT_CURSOR_LEFT - expands text selection to the left.
VK_SHIFT_HOME - expands text selection to the first char.
VK_SHIFT_END - expands text selection to the last char.
VK_CTRL_A - selects the entire content.
KA_COPY - copies the selected text to the OS clipboard.
KA_CUT - copies and deletes the selected text.
KA_PASTE - inserts the OS cliboard content into the widget.
|
boolean |
processMnemonic(int key)
Process the given key, if this widget's mnemonic matches the key.
|
protected void |
refresh(boolean delayed)
Refresh widget by performing an immediate drawing.
|
void |
removeSelectedText()
Removes selected text.
|
protected void |
resetEditScroller()
Reset the edit scroller to the initial state.
|
private void |
setCursorOffset(java.lang.String stxt,
java.awt.event.MouseEvent e)
Sets the current cursor position by the mouse position within the given text.
|
boolean |
setSelection(int start,
int end)
Creates a new selection, eventually dropping the already existing one.
|
protected Menu<GuiOutputManager> |
showPopupMenu(java.awt.event.MouseEvent e,
java.lang.Runnable dismissHandler)
The method shows the popup menu for this widget.
|
boolean |
supportsCustomMousePointer()
Check if the widget supports LOAD-MOUSE-POINTER() method
|
private NativePoint |
textNativeLocation()
Compute the fill-in's content location, adjusted so that only the required portion will be
visible.
|
void |
updateSize(FillInConfig beforeUpdate)
Update widget's size after config update
|
activate, activate, adjustCursor, afterConfigUpdate, clear, clear, copyState, currentFocus, defaultFocus, display, draw, focusTraversable, getCurrentFormat, getCursorOffset, getDataEntryReturn, getDrawText, getEditScroller, getFirstInGroup, getFormat, getScreenValue, getText, getText, getValue, getVariable, height, isAtField, isDrawLine, isFormatCheck, isInAutoReturn, isLeftEdgeWidget, isLinkedToBrowse, isRightAligned, isRightAlignedInt, isRightEdgeWidget, isSelected, isSelectionValid, isZapActive, isZapToBeApplied, refresh, requestFocus, reset, resetCaret, setAttrFormat, setBrowse, setCursorOffset, setDataType, setEnabled, setForceLeft, setFormatCheck, setHeaderParm, setInAutoReturn, setInsertMode, setPendingNoZap, setSize, setTextGroup, setUnderline, setValue, setValue, setZapMode, setZapMode, silentActivation, toString, update, updateCursorOffsetValue, updateSize, updateZapState, width
config, defaultMousePtr, destroy, getColon, getColumnLabelText, getColumnMnemonic, getLabelInstance, getLabelText, getMnemonic, getTo, isForceLabel, isModified, isNoLabels, postprocessConfig, setColumnMnemonic, setHidden, setLabelInstance, setMnemonic, setNoLabels, setVisible, setWasVisible, wasVisible
minimumSize
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, cycleFocus, detach, dimension, doLayout, dumpCurrentWidgets, dumpWidgets, endSizeChange, findMouseSource, firstFocus, focus, focusWorker, formatDump, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getTabItemList, hasFocusable, insets, lastFocus, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChange, remove, removeContainerStateListener, repaint, replace, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setTabItemList, setWidth, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isCurrent, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseEntered, mouseExited, mouseMoved, mouseReleased, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, 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, sync, topLevelWindow, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
convertToStreamable
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, dimension, displayPhysicalLocation, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isCurrent, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, repaint, repaint, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, topLevelWindow, unrealize, window
mouseEntered, mouseExited, mouseReleased
getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, isMnemonicSupported, updateMnemonic
private GuiDriver gd
private GuiFontResolver gf
private boolean bypassFocusInit
protected ColorRgb disabledFore
protected boolean disabledForeFixedColor
true
if the foreground color of a disabled field is fixed (grey).
false
if the foreground color of a disabled field is defined by the FGCOLOR
attribute.private int lastPressedX
public FillInGuiImpl(WidgetId id, FillInConfig cfg)
Call initialize(com.goldencode.p2j.ui.WidgetId, com.goldencode.p2j.ui.FillInConfig)
to finish the widget initialization.
id
- The widget's ID.cfg
- Configuration data.public Widget<?> convertToStreamable()
convertToStreamable
in interface StreamableWidget
public boolean supportsCustomMousePointer()
supportsCustomMousePointer
in interface Widget<GuiOutputManager>
supportsCustomMousePointer
in class AbstractWidget<GuiOutputManager>
true
if the widget supports
LOAD-MOUSE-POINTER() methodprotected static int nativeWidth(FillIn<GuiOutputManager,?> widget, GuiDriver gd, GuiFontResolver gf, boolean isText)
widget
- The FILL-IN or TEXT widget.gd
- The GUI driver in use.gf
- The font resolver.isText
- true
if this is for a TEXT widget.public void initialize(WidgetId id, FillInConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<FillInConfig>
initialize
in class FillIn<GuiOutputManager,FillInConfig>
id
- The widget's ID.cfg
- The config used to initialize this widget.protected int nativeWidth()
nativeWidth
in class FillIn<GuiOutputManager,FillInConfig>
protected int nativeHeight()
nativeHeight
in class FillIn<GuiOutputManager,FillInConfig>
public int getLastOffset()
getLastOffset
in class FillIn<GuiOutputManager,FillInConfig>
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()
MnemonicInfoGuiImpl
instance.createMnemonic
in interface MnemonicTrait<GuiOutputManager>
MnemonicInfoGuiImpl
instance.public void mousePressed(java.awt.event.MouseEvent e)
If the widget is not already focused, it forces the focus to it. After the focus was received, it computes the caret location, based on the mouse position over the widget's content.
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseClicked(java.awt.event.MouseEvent e)
If the widget is not already focused, it forces the focus to it. After the focus was received, it computes the caret location, based on the mouse position over the widget's content.
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.protected Menu<GuiOutputManager> showPopupMenu(java.awt.event.MouseEvent e, java.lang.Runnable dismissHandler)
AbstractWidget.resolvePopupMenuId()
.showPopupMenu
in class AbstractWidget<GuiOutputManager>
e
- The related mouse event that caused a popup to be shown.dismissHandler
- When not null, the runnable instance is executed when the popup menu is dismissed, regardless
whether an item is chosen or not.null
if no popup is resolved for this widget.public void mouseDragged(java.awt.event.MouseEvent e)
If the fillin is enabled and has focus, it will re-adjust the selected text depending on where the mouse is moving.
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 void processKeyEvent(KeyInput ke)
VK_SHIFT_CURSOR_RIGHT
- expands text selection to the right.VK_SHIFT_CURSOR_LEFT
- expands text selection to the left.VK_SHIFT_HOME
- expands text selection to the first char.VK_SHIFT_END
- expands text selection to the last char.VK_CTRL_A
- selects the entire content.KA_COPY
- copies the selected text to the OS clipboard.KA_CUT
- copies and deletes the selected text.KA_PASTE
- inserts the OS cliboard content into the widget.processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class FillIn<GuiOutputManager,FillInConfig>
ke
- Key event structure.public void drawCaret()
drawCaret
in interface Widget<GuiOutputManager>
drawCaret
in class FillIn<GuiOutputManager,FillInConfig>
public void draw(Color aColor)
draw
in class FillIn<GuiOutputManager,FillInConfig>
aColor
- Color for drawing.protected void drawBorder(GuiColorResolver gcd, int x, int y, NativeDimension dim, boolean threeDBorder)
threeDBorder
- Indicates whether 3d or flat border should be drawn.protected Theme.TextLookAndFeel getTextLookAndFeel(GuiColorResolver gcd, GuiColorResolver gce)
gcd
- The gui color resolver used for normal text.gce
- The gui color resolver used for selected text.public int getInitialCursorPos()
In GUI, the initial cursor position is always on the right-side text edge.
getInitialCursorPos
in interface EditableField
public java.lang.String getSelectedText()
getSelectedText
in interface Widget<GuiOutputManager>
getSelectedText
in class AbstractWidget<GuiOutputManager>
null
if there is no selected text or if the
widget type does not support clipboard operations.protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
public boolean isAutoResize()
isAutoResize
in interface AutoResizable<FillInConfig>
true
is AUTO-RESIZE is enabledpublic void updateSize(FillInConfig beforeUpdate)
updateSize
in interface AutoResizable<FillInConfig>
beforeUpdate
- previous value of the widget's configpublic boolean isRMBEntrySupported()
isRMBEntrySupported
in interface Widget<GuiOutputManager>
isRMBEntrySupported
in class AbstractWidget<GuiOutputManager>
true
if this widget gains ENTRY event
when right/middle mouse button is clicked.public void invalidateSelection()
invalidateSelection
in interface TextSelection
invalidateSelection
in class FillIn<GuiOutputManager,FillInConfig>
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 boolean isDroppable()
isDroppable
in interface Widget<GuiOutputManager>
TRUE
if this widget can be droppable at this time,
FALSE
otherwise.protected boolean isTextSelectionDisplayed()
protected void drawCaretInt()
protected void adjustEditScroller(int key)
adjustEditScroller
in class FillIn<GuiOutputManager,FillInConfig>
key
- The currently processed key.protected int getValidCursorPos()
getValidCursorPos
in class FillIn<GuiOutputManager,FillInConfig>
protected int getNativeCursorPos()
getNativeCursorPos
in class FillIn<GuiOutputManager,FillInConfig>
protected boolean getInsertMode()
getInsertMode
in class FillIn<GuiOutputManager,FillInConfig>
false
.protected void resetEditScroller()
resetEditScroller
in class FillIn<GuiOutputManager,FillInConfig>
protected void refresh(boolean delayed)
refresh
in class FillIn<GuiOutputManager,FillInConfig>
delayed
- Flag indicating if the drawing should be immediately or delayed.protected EditScroller createLeftAnchor()
createLeftAnchor
in class FillIn<GuiOutputManager,FillInConfig>
protected EditScroller createRightAnchor()
createRightAnchor
in class FillIn<GuiOutputManager,FillInConfig>
protected NativeDimension editableNativeDimension()
For GUI widgets, this is the physical dimension without the insets.
editableNativeDimension
in class FillIn<GuiOutputManager,FillInConfig>
protected java.lang.String blankScreenValue(DisplayFormat.Presentation curPres, int fmtWidth)
blankScreenValue
in class FillIn<GuiOutputManager,FillInConfig>
curPres
- Effective screen value.fmtWidth
- Effective format width.private NativePoint editableNativeLocation()
private NativePoint textNativeLocation()
The returned location is relative to the fill-in's top-left corner, and the X coordinate may be negative. When used during drawing, the clipping rectangle ensures that nothing is drawn outside of the required area.
protected void moveCursorToLast()
private void moveCursorToFirst()
private boolean isUninitialized()
true
if the fill-in is in the ScreenBuffer.UNINITIALIZED
state.private void setCursorOffset(java.lang.String stxt, java.awt.event.MouseEvent e)
stxt
- The given texte
- The mouse event holding the current mouse coordinatespublic void drawCursor()
drawCursor
in interface LightweightTextWidget
public java.lang.String getScreenText(int line)
getScreenText
in interface LightweightTextWidget
line
- The given line numberpublic java.lang.String getScreenText()
getScreenText
in interface LightweightTextWidget
public int getCursorColumnOffset()
getCursorColumnOffset
in interface LightweightTextWidget
public int getCursorRowOffset()
getCursorRowOffset
in interface LightweightTextWidget
public int getScrollColumnOffset()
getScrollColumnOffset
in interface LightweightTextWidget
public int getScrollRowOffset()
getScrollRowOffset
in interface LightweightTextWidget
public GuiFontResolver.FontCache getFontCache()
getFontCache
in interface LightweightTextWidget
public LightweightTextWidget.TextLineSelection getTextSelection(int line)
getTextSelection
in interface LightweightTextWidget
line
- The given line number