public class ButtonGuiImpl extends GuiButton implements AutoResizable<ButtonConfig>
Modifier and Type | Class and Description |
---|---|
static class |
ButtonGuiImpl.Images
Helper class to provide uniform access to all button images.
|
Modifier and Type | Field and Description |
---|---|
protected CoordinatesConversion |
cc
Coordinate converter
|
static float |
DOT_LINE_WIDTH
Dotted line width.
|
private GuiColorResolver |
gc
Color resolver
|
protected GuiDriver |
gd
Screen driver
|
protected GuiFontResolver |
gf
Font resolver
|
private static int |
IMAGE_SHIFT
Shift in XY to draw images on the button.
|
private ImageWrapper<?> |
imgDisabled
Image to draw on button in disabled (insensitive) state.
|
private ImageWrapper<?> |
imgDown
Image to draw on button in pressed state.
|
protected ImageWrapper<?> |
imgUp
Image to draw on button in normal (non-pressed) state.
|
private boolean |
isResolverColorsUsed
Indicates that UI theme colors or resolver colors are used.
|
private boolean |
keyPressed
Pressed button state flag.
|
private boolean |
processedBySuperClass
Indicates that this event is processed by super class implementation logic
|
config, widgetFocused
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
ButtonGuiImpl(WidgetId id,
Container<GuiOutputManager> owner,
java.lang.String text)
This constructor creates a button with a given text label.
|
ButtonGuiImpl(WidgetId id,
WidgetConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
afterConfigUpdate(ButtonConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
MnemonicInfo |
createMnemonic()
Creates new
MnemonicInfo instance. |
void |
draw()
Draw the button.
|
private void |
fixupSizeByImageUp()
Adjust this widget size based on the image UP size after either the image UP def parameters were
changed or image bitmap set or replaced.
|
boolean |
focusTraversable()
Check if widget is focus traversable.
|
GuiFontResolver |
getFontResolver()
Gets the current font resolver.
|
ImageWrapper<?> |
getImgDisabled()
Obtain the image in disabled state, if available.
|
ImageWrapper<?> |
getImgDown()
Obtain the image in 'DOWN' state, if available.
|
ImageWrapper<?> |
getImgUp()
Obtain the image in 'UP' state, if available.
|
protected void |
handleBasicEvents(KeyInput event)
Process basic events - TAB, BACK-TAB and ENTER key event.
|
protected boolean |
handleCursorKeys(int key,
Frame<GuiOutputManager> frame)
Handle cursor movement keys.
|
double |
height()
Get widget height.
|
boolean |
highlighted()
Get current highlighted state.
|
void |
initialize(WidgetId id,
ButtonConfig 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.
|
boolean |
isAutoResize()
Get the AUTO-RESIZE status
|
boolean |
isDefaultButton()
Checks if this button works as default one.
|
boolean |
isDroppable()
Checks if the given widget is able to be the target of the drop operation.
|
boolean |
isFocusable()
NO-FOCUS buttons cannot receive focus.
|
boolean |
isKeyPressed()
Check whether this button is pressed by keyboard.
|
boolean |
isMnemonicSupported()
All GUI buttons support mnemonics.
|
boolean |
isPressed()
Check whether this button is pressed.
|
boolean |
isResolverColorsUsed()
Tests if this button uses the resolver colors or the current UI theme colors for
its background and foreground.
|
boolean |
loadImage(int type,
java.lang.String fullName)
Loads the new image for given button widget from the client side filesystem.
|
private void |
loadPendingImage(int type,
java.lang.String imgName,
int widgetId)
Refresh the image object to be used to draw button in different states with images that was
saved before in pending storage area.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Notification of a mouse clicked event occurred for this widget.
|
void |
onFocusLost(FocusEvent focusEvent)
This is called when the button looses the input focus.
|
NativeRectangle |
physicalBounds()
Determine the physical bounds, relative to screen, expressed in units native to UI type.
|
void |
processEvent(Event event)
It wraps around its super class implementation.
|
boolean |
processMnemonic(int key)
Process the given key, if this widget's mnemonic matches the key.
|
protected void |
refresh()
In GUI mode, the drawing needs to be delayed.
|
void |
requestFocus()
Request focus.
|
protected void |
setActionCode(KeyInput ki)
Prepare event for processing.
|
void |
setColorResolver(GuiColorResolver resolver)
Sets a color resolver.
|
void |
setFontResolver(GuiFontResolver fontResolver)
Sets the new font resolver.
|
boolean |
setImage(int type,
byte[] bytes)
Sets the new image for given button widget on the client side.
|
void |
setImage(int type,
ImageWrapper img)
Sets the new image for given button widget on the client side.
|
void |
setResolverColorsUsed(boolean isResolverColorsUsed)
Sets what colors theme will be used by this button.
|
void |
setVisible(boolean visible)
Shows or hides the button and its label.
|
boolean |
supportsCustomMousePointer()
Check if the widget supports LOAD-MOUSE-POINTER() method
|
java.lang.String |
toString()
Returns a string representation of the object.
|
private void |
updateDisabledImage()
Sets the disabled image according to UP image if the UP image defined but disabled - not.
|
void |
updateSize(ButtonConfig beforeUpdate)
Update widget's size after config update
|
private static boolean |
validOffsets(ButtonImageDefinition imageDef,
ImageWrapper<?> img)
Check that image offsets do not exceed the image dimensions.
|
double |
width()
Get widget width.
|
isMouseOver, mouseActions, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased
addListener, checkKey, config, destroy, getColon, getColumnLabelText, getCommand, getLabelInstance, getLabelText, getMnemonic, getTo, initButtonText, isForceLabel, isNoLabels, isRightAligned, postprocessConfig, processKeyEvent, setCommand, setHidden, setLabelInstance, setMnemonic, setNoLabels, setSupportsMnemonic, setText, setTextLabel, setWasVisible, textLabel, wasVisible
dimension, forceCursorOnFocus, getDefaultEvent, ignoreAction, manageSystemActions, minimumSize, onFocusGained, onKeyPressed, onKeyTyped, processKeyEventCommon
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, copyState, createMouseHoverAction, deactivateDirectManipulation, debug, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, findMouseSource, 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, initialHeight, initialWidth, insets, isCurrent, isDirectManipulationActive, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalDimension, physicalLocation, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, 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, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, showPopupMenu, sync, topLevelWindow, translate, unrealize, unregisterWidgetStateListener, updateSizeWorker, widgetStateChanged, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, defaultMousePtr, dimension, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hidden, hide, ignoreEnable, initialHeight, initialWidth, insets, isCurrent, isDirectManipulable, isDirectManipulationActive, isDisplayed, isEnabled, isHeader, isInitialValueLayout, isLegacyFocus, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, minimumSize, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalDimension, physicalLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, refreshWidget, registerWidgetStateListener, repaint, repaint, repaint, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, systemFocusGrabbed, topLevelWindow, unrealize, unregisterWidgetStateListener, validateDisplayValue, widgetStateChanged, window
getColumnMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, setColumnMnemonic, updateMnemonic
protected CoordinatesConversion cc
protected GuiDriver gd
protected GuiFontResolver gf
protected ImageWrapper<?> imgUp
private GuiColorResolver gc
private ImageWrapper<?> imgDisabled
private ImageWrapper<?> imgDown
private boolean isResolverColorsUsed
private boolean keyPressed
private boolean processedBySuperClass
public static final float DOT_LINE_WIDTH
private static final int IMAGE_SHIFT
public ButtonGuiImpl(WidgetId id, WidgetConfig cfg)
id
- The widget's ID.cfg
- Configuration data.ButtonGuiImpl(WidgetId id, Container<GuiOutputManager> owner, java.lang.String text)
id
- The widget's ID.owner
- The parent container, frame or dialog which will include this
button.text
- The string to be used as the button text.public void afterConfigUpdate(ButtonConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<ButtonConfig>
afterConfigUpdate
in class Button<GuiOutputManager>
beforeUpdate
- Config reference capturing the config state before
the owner's config was modified.public MnemonicInfo createMnemonic()
MnemonicInfo
instance.createMnemonic
in interface MnemonicTrait<GuiOutputManager>
public void draw()
draw
in interface Widget<GuiOutputManager>
draw
in class AbstractButton<GuiOutputManager,ButtonConfig>
public boolean focusTraversable()
focusTraversable
in interface Widget<GuiOutputManager>
focusTraversable
in class AbstractWidget<GuiOutputManager>
true
if widget is focus traversable.public GuiFontResolver getFontResolver()
public ImageWrapper<?> getImgDisabled()
public ImageWrapper<?> getImgDown()
public ImageWrapper<?> getImgUp()
public double height()
height
in interface Widget<GuiOutputManager>
height
in class Button<GuiOutputManager>
public boolean highlighted()
highlighted
in interface Widget<GuiOutputManager>
highlighted
in class AbstractWidget<GuiOutputManager>
public void initialize(WidgetId id, ButtonConfig wcfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<ButtonConfig>
initialize
in class Button<GuiOutputManager>
id
- The widget's ID.wcfg
- The config used to initialize this widget.public boolean isAutoResize()
isAutoResize
in interface AutoResizable<ButtonConfig>
true
is AUTO-RESIZE is enabledpublic boolean isDefaultButton()
TRUE
if button works as default one FALSE
otherwise.public boolean isDroppable()
isDroppable
in interface Widget<GuiOutputManager>
TRUE
if this widget can be droppable at this time,
FALSE
otherwise.public boolean isFocusable()
isFocusable
in interface Widget<GuiOutputManager>
isFocusable
in class AbstractWidget<GuiOutputManager>
false
for NO-FOCUS buttons.public boolean isKeyPressed()
true
if the button is pressed by keyboard.public boolean isMnemonicSupported()
isMnemonicSupported
in interface MnemonicTrait<GuiOutputManager>
isMnemonicSupported
in class Button<GuiOutputManager>
true
.public boolean isPressed()
public boolean isResolverColorsUsed()
public boolean loadImage(int type, java.lang.String fullName)
type
- Image type to load. Up, Down or Insensitive for buttons.fullName
- The fully qualified file name for the image to be loaded.TRUE
if operation successful FALSE
otherwise.public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void onFocusLost(FocusEvent focusEvent)
onFocusLost
in interface FocusListener
onFocusLost
in class AbstractButton<GuiOutputManager,ButtonConfig>
focusEvent
- The focus event to be processed.public NativeRectangle physicalBounds()
physicalBounds
in interface Widget<GuiOutputManager>
physicalBounds
in class AbstractWidget<GuiOutputManager>
public void processEvent(Event event)
processEvent
in interface Widget<GuiOutputManager>
processEvent
in class Button<GuiOutputManager>
event
- The processed eventpublic 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 void requestFocus()
requestFocus
in interface Widget<GuiOutputManager>
requestFocus
in class Button<GuiOutputManager>
public void setColorResolver(GuiColorResolver resolver)
GuiColorResolver.bgColor
which is used as the background color for this panel. If no resolver
is given, the color SysColor.COLOR_WINDOW
will be used by default.resolver
- color revolver, may be null
public void setFontResolver(GuiFontResolver fontResolver)
fontResolver
- The font resolverpublic boolean setImage(int type, byte[] bytes)
type
- Image type to load. Up, Down or Insensitive for buttons.bytes
- A new image array data.TRUE
if operation successful FALSE
otherwise.public final void setImage(int type, ImageWrapper img)
type
- Image type to load. Up, Down or Insensitive for buttons.img
- The image.public void setResolverColorsUsed(boolean isResolverColorsUsed)
isResolverColorsUsed
- The boolean valuepublic boolean supportsCustomMousePointer()
supportsCustomMousePointer
in interface Widget<GuiOutputManager>
supportsCustomMousePointer
in class AbstractWidget<GuiOutputManager>
true
if the widget supports
LOAD-MOUSE-POINTER() methodpublic java.lang.String toString()
toString
in class AbstractWidget<GuiOutputManager>
public void updateSize(ButtonConfig beforeUpdate)
updateSize
in interface AutoResizable<ButtonConfig>
beforeUpdate
- previous value of the widget's configpublic double width()
width
in interface Widget<GuiOutputManager>
width
in class Button<GuiOutputManager>
protected void handleBasicEvents(KeyInput event)
handleBasicEvents
in class Button<GuiOutputManager>
event
- Key event to process.protected boolean handleCursorKeys(int key, Frame<GuiOutputManager> frame)
handleCursorKeys
in class AbstractButton<GuiOutputManager,ButtonConfig>
key
- Key code.frame
- Parent frame.true
if any cursor key was found.protected void refresh()
refresh
in class AbstractButton<GuiOutputManager,ButtonConfig>
protected void setActionCode(KeyInput ki)
setActionCode
in class AbstractButton<GuiOutputManager,ButtonConfig>
ki
- Input event.private static final boolean validOffsets(ButtonImageDefinition imageDef, ImageWrapper<?> img)
imageDef
- the image definition, must not be null
img
- the image to check, may be null
true
if image offsets are validprivate void fixupSizeByImageUp()
private void loadPendingImage(int type, java.lang.String imgName, int widgetId)
type
- Image type to check. Up, Down or Insensitive.imgName
- the image file namewidgetId
- the button widget Idprivate final void updateDisabledImage()
public void setVisible(boolean visible)
setVisible
in interface Widget<GuiOutputManager>
setVisible
in class Button<GuiOutputManager>
visible
- true
to make the widget visible,
false
to hide the widget.