public class ButtonGuiImpl extends GuiButton implements AutoResizable<ButtonConfig>
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private CoordinatesConversion |
cc
Coordinate converter
|
static float |
DOT_LINE_WIDTH
Dotted line width.
|
private static float |
DOT_STEP
Dotted line specific parameter.
|
private GuiColorResolver |
gc
Color resolver
|
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
private static int |
IMAGE_SHIFT
Shift in XY to draw images on the button.
|
private ImageGuiImpl |
imgDisabled
Image to draw on button in disabled state.
|
private ImageGuiImpl |
imgDown
Image to draw on button in pressed state.
|
private ImageGuiImpl |
imgUp
Image to draw on button in up state.
|
private boolean |
keyPressed
Pressed button state flag.
|
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 |
---|---|
MnemonicInfo |
createMnemonic()
Creates new
MnemonicInfo instance. |
void |
draw()
Draw the button.
|
private void |
fixupImageCoord(ImageGuiImpl imgToFix,
ButtonImageDefinition def)
Sets up initial image location inside the button widget.
|
boolean |
focusTraversable()
Check if widget is focus traversable.
|
ImageGuiImpl |
getImgDisabled()
Obtain the image in disabled state, if available.
|
ImageGuiImpl |
getImgDown()
Obtain the image in 'DOWN' state, if available.
|
ImageGuiImpl |
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.
|
boolean |
hasImages()
Check if the button has any images to be used to draw button.
|
boolean |
hasPrepackagedImages(ButtonConfig bcfg)
Check if the button has prepackaged images to be used to draw button.
|
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 |
isFocusable()
NO-FOCUS buttons cannot receive focus.
|
boolean |
isMnemonicSupported()
Check whether this button supports mnemonics.
|
boolean |
isPressed()
Check whether this button is pressed.
|
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)
Refresh the image object to be used to draw button in different states with images that was
saved before in pending storage area.
|
private void |
loadPendingImages()
Refresh the image objects 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.
|
boolean |
processMnemonic(int key)
Process the given key, if this widget's mnemonic matches the key.
|
private void |
recalcImageCoord(ImageGuiImpl imgToFix,
int bw,
int bh)
Reposition image and change the width according button width and height.
|
private void |
recalcImagesCoords()
Need to recalculate image coordinates after all images have been loaded.
|
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.
|
boolean |
setImage(int type,
byte[] image)
Sets the new image for given button widget on the client side.
|
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
|
protected <C extends WidgetConfig> |
updateSizeWorker(C beforeUpdate)
Instructs the widget that its size may have changed and need to recompute the location of
the image, if any.
|
double |
width()
Get widget width.
|
isMouseOver, mouseActions, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased
addListener, afterConfigUpdate, checkKey, config, destroy, getColon, getColumnLabelText, getCommand, getLabelInstance, getLabelText, getMnemonic, getTo, initButtonText, isForceLabel, isNoLabels, isRightAligned, postprocessConfig, processEvent, processKeyEvent, setCommand, setHidden, setLabelInstance, setMnemonic, setNoLabels, setSupportsMnemonic, setText, setTextLabel, setVisible, 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, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, findMouseSource, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, insets, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, sync, topLevelWindow, translate, unrealize, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, dimension, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, insets, isDirectManipulable, isDisplayed, isEnabled, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalDimension, physicalLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, topLevelWindow, unrealize, window
getColumnMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, setColumnMnemonic, updateMnemonic
public static final float DOT_LINE_WIDTH
private static final int IMAGE_SHIFT
private static final float DOT_STEP
private GuiDriver gd
private CoordinatesConversion cc
private GuiColorResolver gc
private GuiFontResolver gf
private boolean keyPressed
private ImageGuiImpl imgUp
private ImageGuiImpl imgDown
private ImageGuiImpl imgDisabled
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 ButtonGuiImpl(WidgetId id, WidgetConfig cfg)
id
- The widget's ID.cfg
- Configuration data.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 setImage(int type, byte[] image)
type
- Image type to load. Up, Down or Insensitive for buttons.image
- A new image array data.TRUE
if operation successful FALSE
otherwise.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 boolean supportsCustomMousePointer()
supportsCustomMousePointer
in interface Widget<GuiOutputManager>
supportsCustomMousePointer
in class AbstractWidget<GuiOutputManager>
true
if the widget supports
LOAD-MOUSE-POINTER() methodprotected void refresh()
refresh
in class AbstractButton<GuiOutputManager,ButtonConfig>
public void draw()
draw
in interface Widget<GuiOutputManager>
draw
in class AbstractButton<GuiOutputManager,ButtonConfig>
public MnemonicInfo createMnemonic()
MnemonicInfo
instance.createMnemonic
in interface MnemonicTrait<GuiOutputManager>
private void updateDisabledImage()
public boolean isDefaultButton()
TRUE
if button works as default one FALSE
otherwise.private void fixupImageCoord(ImageGuiImpl imgToFix, ButtonImageDefinition def)
imgToFix
- Image object to fix the coordinates.def
- Image definition object to override the image under fixup.public boolean hasImages()
true
there is at least one image to use.public boolean hasPrepackagedImages(ButtonConfig bcfg)
true
there is at least one image to use.private void recalcImagesCoords()
private void recalcImageCoord(ImageGuiImpl imgToFix, int bw, int bh)
imgToFix
- Image object to fix the coordinates.bw
- Button width.bh
- Button height.private void loadPendingImages()
private void loadPendingImage(int type)
type
- Image type to check. Up, Down or Insensitive.public NativeRectangle physicalBounds()
physicalBounds
in interface Widget<GuiOutputManager>
physicalBounds
in class AbstractWidget<GuiOutputManager>
public double height()
height
in interface Widget<GuiOutputManager>
height
in class Button<GuiOutputManager>
public double width()
width
in interface Widget<GuiOutputManager>
width
in class Button<GuiOutputManager>
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 requestFocus()
requestFocus
in interface Widget<GuiOutputManager>
requestFocus
in class Button<GuiOutputManager>
public boolean focusTraversable()
focusTraversable
in interface Widget<GuiOutputManager>
focusTraversable
in class AbstractWidget<GuiOutputManager>
true
if widget is focus traversable.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.public boolean isAutoResize()
isAutoResize
in interface AutoResizable<ButtonConfig>
true
is AUTO-RESIZE is enabledpublic void updateSize(ButtonConfig beforeUpdate)
updateSize
in interface AutoResizable<ButtonConfig>
beforeUpdate
- previous value of the widget's configprotected <C extends WidgetConfig> void updateSizeWorker(C beforeUpdate)
updateSizeWorker
in class AbstractWidget<GuiOutputManager>
beforeUpdate
- BaseConfig
reference or null
.public void onFocusLost(FocusEvent focusEvent)
onFocusLost
in interface FocusListener
onFocusLost
in class AbstractButton<GuiOutputManager,ButtonConfig>
focusEvent
- The focus event to be processed.protected void setActionCode(KeyInput ki)
setActionCode
in class AbstractButton<GuiOutputManager,ButtonConfig>
ki
- Input event.public boolean isMnemonicSupported()
isMnemonicSupported
in interface MnemonicTrait<GuiOutputManager>
isMnemonicSupported
in class Button<GuiOutputManager>
true
.public boolean highlighted()
highlighted
in interface Widget<GuiOutputManager>
highlighted
in class AbstractWidget<GuiOutputManager>
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 ImageGuiImpl getImgUp()
public ImageGuiImpl getImgDown()
public ImageGuiImpl getImgDisabled()
public boolean isPressed()
public boolean isFocusable()
isFocusable
in interface Widget<GuiOutputManager>
isFocusable
in class AbstractWidget<GuiOutputManager>
false
for NO-FOCUS buttons.public java.lang.String toString()
AbstractWidget
toString
in class AbstractWidget<GuiOutputManager>