public class FillInGuiImpl extends FillIn<GuiOutputManager,FillInConfig> implements AutoResizable<FillInConfig>
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.
|
Widget.ZOrderClass
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
|
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.
|
protected EditScroller |
createLeftAnchor()
Create the left-edge scroller.
|
MnemonicInfo |
createMnemonic()
Creates new
MnemonicInfoGuiImpl instance. |
protected EditScroller |
createRightAnchor()
Create the right-edge scroller.
|
private int |
cursorPhysicalColumn()
Compute the cursor's physical column, relative to the fill-in's leftside border.
|
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.
|
protected void |
drawSelection(java.lang.String txt,
int font,
int clipWidth,
int clipHeight,
ColorRgb fgColor,
ColorRgb bgColor)
Draws the selected part of the entry field.
|
protected void |
drawSelectionInt(java.lang.String txt,
int font,
int clipWidth,
int clipHeight,
ColorRgb fgColor,
ColorRgb bgColor)
Draws the selected part of the entry field.
|
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 |
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 |
getSelectedText()
Obtain any selected text in the widget for copying to the clipboard.
|
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 |
isRMBEntrySupported()
Check if this widget gains ENTRY event when right/middle mouse button is clicked.
|
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 |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
private void |
moveCursorToFirst()
Move the cursor to the leftmost index.
|
private 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()
Refresh widget by performing an immediate drawing.
|
void |
removeSelectedText()
Removes selected text.
|
protected void |
resetEditScroller()
Reset the edit scroller to the initial state.
|
boolean |
setSelection(int start,
int end)
Creates a new selection, eventually dropping the already existing one.
|
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, 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, 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, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, cycleFocus, detach, dimension, doLayout, endSizeChange, findMouseSource, firstFocus, focus, focusWorker, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getWidgetsList, hasFocusable, insets, lastFocus, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, prepareWidgets, prevFocus, remove, repaint, replace, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setWidth, startSizeChange, unrealize, updateSizeWorker, widgets
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, sync, topLevelWindow, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, 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.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 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.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.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.protected void drawSelection(java.lang.String txt, int font, int clipWidth, int clipHeight, ColorRgb fgColor, ColorRgb bgColor)
txt
- The text to draw.font
- The font details to use while text drawing.clipWidth
- Clipping width.clipHeight
- Clipping height.fgColor
- The text color.bgColor
- protected void drawSelectionInt(java.lang.String txt, int font, int clipWidth, int clipHeight, ColorRgb fgColor, ColorRgb bgColor)
txt
- The text to draw.font
- The font details to use while text drawing.clipWidth
- Cliping width.clipHeight
- Clipping height.fgColor
- The text color.bgColor
- 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()
refresh
in class FillIn<GuiOutputManager,FillInConfig>
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.
private int cursorPhysicalColumn()
private void moveCursorToLast()
private void moveCursorToFirst()
private boolean isUninitialized()
true
if the fill-in is in the ScreenBuffer.UNINITIALIZED
state.