public abstract class AbstractContainer<O extends OutputManager<?>> extends AbstractWidget<O> implements Container<O>
Modifier and Type | Class and Description |
---|---|
private static class |
AbstractContainer.WorkArea
Stores global data relating to the state of the current context.
|
private static class |
AbstractContainer.ZKey
Auxiliary class for use on the normalizaOrder method
|
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private Widget<O> |
current
Current (in focus) widget.
|
private java.util.Set<Widget<?>> |
ignoreFocusSet
The set of widgets that are never selected for focus - they are ignored by
checkWidget(Widget, boolean).
|
private Insets |
insets
Container insets.
|
private LayoutManager<O> |
layoutManager
Layout manager.
|
private static java.util.logging.Logger |
LOG
logger
|
private Dimension |
size
Container size.
|
private java.util.ArrayList<Widget<O>> |
widgets
Widgets stored in the container.
|
private static ContextLocal<AbstractContainer.WorkArea> |
work
Stores context-local state variables.
|
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
AbstractContainer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Container<O> |
add(int pos,
Widget<O> widget)
Add the widget on the specified position.
|
Container<O> |
add(Widget<O> widget)
Add widget to container.
|
Container<O> |
add(Widget<O> before,
Widget<O> widget)
Add the widget before the specified widget.
|
protected void |
addDirectly(Widget<O> widget)
Add widget directly to the list without triggering repaint or other
operations.
|
protected boolean |
belongsTo(Widget<O> widget)
Check if specified widget belongs to this container.
|
protected boolean |
checkWidget(Widget<O> widget,
boolean direction)
Check potential focus candidate and set focus on it if it matches
criteria.
|
Point |
childrenLocation(Widget<O> child)
Get children location for one child.
|
boolean |
clipping()
This method should be overridden in a container that allows clipping.
|
protected NativeRectangle |
clipRectangle(NativePoint origin,
NativeDimension dimension,
boolean children)
Build clipped rectangle for given coordinates.
|
Widget<O> |
currentFocus()
Get widget which is in focus.
|
Widget<O> |
currentFocus(boolean recurse)
Get widget which is in focus.
|
protected void |
cycleFocus(boolean direction)
Search for the next or previous focusable widget in this container and
set focus on it.
|
Widget<O> |
defaultFocus()
Get default focusable widget.
|
void |
destroy()
Destroy this widget.
|
void |
detach(Widget<O> widget)
Detach this widget from this container.
|
Dimension |
dimension()
Get widget dimension.
|
void |
doLayout()
Lay out container.
|
void |
draw()
Draw widget.
|
void |
endSizeChange(boolean repaint)
Indicates the ending of the resize process.
|
Widget<O> |
findMouseSource(NativePoint p)
Find the widget positioned just bellow the specified mouse position (in physical units).
|
void |
firstFocus()
Set focus to first focusable widget.
|
Widget<O> |
focus()
Returns the focused direct child Component.
|
boolean |
focusTraversable()
Check if widget is focus traversable.
|
protected void |
focusWorker(boolean direction)
Search for the next or previous focusable widget in the container and
set focus on it.
|
Widget<O> |
get(int index)
Get widget for provided index or
null if no such component
exists. |
Rectangle |
getClipRect()
Get clipping rectangle.
|
private java.util.List<Widget<O>> |
getDrawableWidgets()
Get the widgets which can be drawn, from this container.
|
Dimension |
getEffectiveScrollableSize()
Calculates the effective size of the scrollable area of this container.
|
Widget<O> |
getFocusInt()
Get focused widget.
|
java.util.Set<Widget<?>> |
getIgnoreFocus()
Returns the set of widgets that are never selected for focus.
|
LayoutManager<O> |
getLayout()
Get active layout manager for the container.
|
Dimension |
getScrollableSize()
Returns the preferred size of the scrollable area of this container.
|
java.util.List<Widget<O>> |
getWidgetsList()
Get all widgets stored in the container.
|
boolean |
hasFocusable(Widget<O> exclude)
Reports if there is at least 1 focusable widget that is not the given
widget.
|
double |
height()
Get widget height.
|
Insets |
insets()
Get container insets.
|
void |
lastFocus()
Set focus to last focusable widget.
|
private Widget<O> |
locateFocusTraversable(java.lang.Iterable<Widget<O>> iter)
Helper method for traversing widgets in the container.
|
Dimension |
minimumSize()
Get widget minimum size.
|
void |
moveAfterTabItem(Widget<O> widget,
Widget<O> after)
Move specified widget after the widget "after".
|
void |
moveBeforeTabItem(Widget<O> widget,
Widget<O> before)
Move specified widget before the widget "before".
|
void |
moveToBottom(Widget<O> widget)
Mode specified widget to the bottom of the widget list.
|
boolean |
moveToBottomInClass(Widget<O> widget)
Mode specified widget to the bottom of the widget list considering Z-order class.
|
void |
moveToTop(Widget<O> widget)
Move specified widget to the top of widget list.
|
boolean |
moveToTopInClass(Widget<O> widget)
Move specified widget to the top of widget list considering Z-order class.
|
void |
moveToZpos(Widget<O> widget,
int pos)
Move widget to specified position in the widget list.
|
void |
nextFocus()
Select next focusable widget.
|
void |
normalizeZOrder()
Reorder widgets according to their ZOrderClass
retaining the order within the class
|
protected java.util.List<Widget<O>> |
prepareWidgets(java.util.List<Widget<O>> widgets)
Prepare widgets before drawing
|
void |
prevFocus()
Select previous focusable widget.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
void |
remove(Widget<O> widget)
Remove specified widget from the widget list.
|
void |
repaint()
Request widget repainting.
|
void |
replace(Widget<O> oldWidget,
Widget<O> newWidget)
Replace specified widget with another with preserving widget Z-order.
|
void |
requestFocus()
Request focus.
|
void |
setFocus(Widget<O> focus)
Set focus to specified widget.
|
void |
setFocusInt(Widget<O> focus)
Set focus to specified widget.
|
void |
setHeight(double height)
Set container height.
|
void |
setIgnoreFocus(java.util.Collection<Widget<?>> widgets)
Sets the set of widgets that are never selected for focus.
|
void |
setInsets(Insets insets)
Set container insets.
|
void |
setLayout(LayoutManager<O> manager)
Set layout manager for the container.
|
void |
setSize(Dimension size)
Set container size.
|
void |
setSize(double width,
double height)
Set container size.
|
void |
setWidth(double width)
Set container width.
|
void |
startSizeChange(boolean saveOldRect)
Indicates the beginning of the resize process.
|
void |
unrealize()
Unrealize this container and all its children.
|
protected <C extends WidgetConfig> |
updateSizeWorker(C beforeUpdate)
Instructs the widget that its size may have changed.
|
Widget<O>[] |
widgets()
Get all widgets stored in the container.
|
double |
width()
Get widget width.
|
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, config, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, config, defaultMousePtr, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, topLevelWindow, window
private static final java.util.logging.Logger LOG
private static final ContextLocal<AbstractContainer.WorkArea> work
private LayoutManager<O extends OutputManager<?>> layoutManager
private Widget<O extends OutputManager<?>> current
private Insets insets
private Dimension size
private java.util.ArrayList<Widget<O extends OutputManager<?>>> widgets
private java.util.Set<Widget<?>> ignoreFocusSet
public Container<O> add(Widget<O> widget)
add
in interface Container<O extends OutputManager<?>>
widget
- Widget to add.this
for fluent syntax support.java.lang.IllegalArgumentException
- when the argument is null or instance of TopLevelWindow
public Container<O> add(int pos, Widget<O> widget)
add
in interface Container<O extends OutputManager<?>>
pos
- The widget's position.widget
- The child widget to add.this
for fluent syntax support.java.lang.IllegalArgumentException
- when the argument is null or instance of TopLevelWindow
public Container<O> add(Widget<O> before, Widget<O> widget)
add
in interface Container<O extends OutputManager<?>>
before
- The widget before the new widget will be placed.widget
- The child widget to add.this
for fluent syntax support.java.lang.IllegalArgumentException
- when the argument is null or instance of TopLevelWindow
public boolean clipping()
clipping
in interface Container<O extends OutputManager<?>>
true
if container clips its children.public Widget<O> currentFocus()
currentFocus
in interface Container<O extends OutputManager<?>>
public Widget<O> currentFocus(boolean recurse)
The method allows to choose whether the focused widget is searched in the nested
containers (recurse == true
) or whether only this container is searched
(recurse == false
).
currentFocus
in interface Container<O extends OutputManager<?>>
recurse
- The parameter controls whether the method should recurse to the nested
containers when searching for the focused widget.public Widget<O> defaultFocus()
defaultFocus
in interface Container<O extends OutputManager<?>>
public Dimension dimension()
dimension
in interface Widget<O extends OutputManager<?>>
dimension
in class AbstractWidget<O extends OutputManager<?>>
public void doLayout()
doLayout
in interface Container<O extends OutputManager<?>>
public Widget<O> findMouseSource(NativePoint p)
findMouseSource
in interface Widget<O extends OutputManager<?>>
findMouseSource
in class AbstractWidget<O extends OutputManager<?>>
p
- The mouse physical location.null
if none found.public void draw()
draw
in interface Widget<O extends OutputManager<?>>
draw
in class AbstractWidget<O extends OutputManager<?>>
public Point childrenLocation(Widget<O> child)
childrenLocation
in interface Container<O extends OutputManager<?>>
child
- Child component.public void endSizeChange(boolean repaint)
startSizeChange
and endSizeChange
calls is
suppressed.endSizeChange
in interface Container<O extends OutputManager<?>>
repaint
- If true
then the current bounding rectangle and
the rectangle saved during startSizeChange
call
are repainted.public Widget<O> focus()
focus
in interface Container<O extends OutputManager<?>>
public boolean focusTraversable()
focusTraversable
in interface Widget<O extends OutputManager<?>>
focusTraversable
in class AbstractWidget<O extends OutputManager<?>>
true
if widget is focus traversable.public Widget<O> get(int index)
null
if no such component
exists.get
in interface Container<O extends OutputManager<?>>
index
- Widget index.null
if index is out
of range.public Rectangle getClipRect()
getClipRect
in interface Container<O extends OutputManager<?>>
public boolean hasFocusable(Widget<O> exclude)
hasFocusable
in interface Container<O extends OutputManager<?>>
exclude
- A widget to ignore or null
if any focusable
widget will do.true
if there is at least one other widget that
can be focused.public double height()
height
in interface Widget<O extends OutputManager<?>>
height
in class AbstractWidget<O extends OutputManager<?>>
public Insets insets()
insets
in interface Container<O extends OutputManager<?>>
insets
in interface Widget<O extends OutputManager<?>>
insets
in class AbstractWidget<O extends OutputManager<?>>
public Dimension minimumSize()
minimumSize
in interface Widget<O extends OutputManager<?>>
minimumSize
in class AbstractWidget<O extends OutputManager<?>>
public void moveBeforeTabItem(Widget<O> widget, Widget<O> before)
moveBeforeTabItem
in interface Container<O extends OutputManager<?>>
widget
- Widget to move.before
- The widget before which to insert mover.public void moveAfterTabItem(Widget<O> widget, Widget<O> after)
moveAfterTabItem
in interface Container<O extends OutputManager<?>>
widget
- Widget to move.after
- The widget after which to insert mover.public void moveToBottom(Widget<O> widget)
moveToBottom
in interface Container<O extends OutputManager<?>>
widget
- Widget to mover.public void moveToTop(Widget<O> widget)
moveToTop
in interface Container<O extends OutputManager<?>>
widget
- Widget to mover.public boolean moveToBottomInClass(Widget<O> widget)
moveToBottomInClass
in interface Container<O extends OutputManager<?>>
widget
- Widget to mover.true
if the widget was movedpublic boolean moveToTopInClass(Widget<O> widget)
moveToTopInClass
in interface Container<O extends OutputManager<?>>
widget
- Widget to mover.true
if the widget was movedpublic void moveToZpos(Widget<O> widget, int pos)
moveToZpos
in interface Container<O extends OutputManager<?>>
widget
- Widget to mover.pos
- Position in Z-order.public void nextFocus()
nextFocus
in interface Container<O extends OutputManager<?>>
public void prevFocus()
prevFocus
in interface Container<O extends OutputManager<?>>
public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<O extends OutputManager<?>>
processKeyEvent
in class AbstractWidget<O extends OutputManager<?>>
event
- Key event to process.public void remove(Widget<O> widget)
The widget will also be destroyed.
remove
in interface Container<O extends OutputManager<?>>
widget
- Widget to remove.public void detach(Widget<O> widget)
detach
in interface Container<O extends OutputManager<?>>
widget
- Widget to detach.java.lang.RuntimeException
- when the supplied widget is not attached to this containerpublic void destroy()
destroy
in interface Widget<O extends OutputManager<?>>
destroy
in class AbstractWidget<O extends OutputManager<?>>
public void repaint()
repaint
in interface Widget<O extends OutputManager<?>>
repaint
in class AbstractWidget<O extends OutputManager<?>>
public void replace(Widget<O> oldWidget, Widget<O> newWidget)
replace
in interface Container<O extends OutputManager<?>>
oldWidget
- Old widget.newWidget
- New widget.public void requestFocus()
requestFocus
in interface Widget<O extends OutputManager<?>>
requestFocus
in class AbstractWidget<O extends OutputManager<?>>
public void setFocus(Widget<O> focus)
focus.topLevelWindow()
. If the top-level window needs to be
activated, too, call WindowManager.activateWindow(TitledWindow)
.setFocus
in interface Container<O extends OutputManager<?>>
focus
- Widget to set focus on.public void setHeight(double height)
setHeight
in interface Container<O extends OutputManager<?>>
height
- New container height.public void setInsets(Insets insets)
setInsets
in interface Container<O extends OutputManager<?>>
insets
- Insets to set.public void setLayout(LayoutManager<O> manager)
setLayout
in interface Container<O extends OutputManager<?>>
manager
- New layout manager.public LayoutManager<O> getLayout()
getLayout
in interface Container<O extends OutputManager<?>>
public void setSize(Dimension size)
setSize
in interface Container<O extends OutputManager<?>>
size
- Size to set.public void setSize(double width, double height)
setSize
in interface Container<O extends OutputManager<?>>
width
- New width.height
- New height.public void setWidth(double width)
setWidth
in interface Container<O extends OutputManager<?>>
width
- Width to set.public void startSizeChange(boolean saveOldRect)
startSizeChange
and endSizeChange
calls is
suppressed.startSizeChange
in interface Container<O extends OutputManager<?>>
saveOldRect
- If true
then the current bounding rectangle is
saved for future repainting.public Widget<O>[] widgets()
widgets
in interface Container<O extends OutputManager<?>>
public java.util.List<Widget<O>> getWidgetsList()
public double width()
width
in interface Widget<O extends OutputManager<?>>
width
in class AbstractWidget<O extends OutputManager<?>>
public void firstFocus()
firstFocus
in interface Container<O extends OutputManager<?>>
public void lastFocus()
lastFocus
in interface Container<O extends OutputManager<?>>
public Dimension getScrollableSize()
This implementation simply delegates the call to dimension()
.
public Dimension getEffectiveScrollableSize()
This implementation accounts all the visible child widgets into the area and simply determines the furthest x and y from the origin.
public java.util.Set<Widget<?>> getIgnoreFocus()
getIgnoreFocus
in interface Container<O extends OutputManager<?>>
null
.public void setIgnoreFocus(java.util.Collection<Widget<?>> widgets)
null
may be used to clear the set.setIgnoreFocus
in interface Container<O extends OutputManager<?>>
widgets
- Set of widgets or null
.public void normalizeZOrder()
public void setFocusInt(Widget<O> focus)
focus
- Widget to set focus on.public void unrealize()
unrealize
in interface Widget<O extends OutputManager<?>>
unrealize
in class AbstractWidget<O extends OutputManager<?>>
protected java.util.List<Widget<O>> prepareWidgets(java.util.List<Widget<O>> widgets)
widgets
- Container children.protected void addDirectly(Widget<O> widget)
widget
- protected boolean belongsTo(Widget<O> widget)
widget
- Widget to check.true
if widget belongs to container.protected NativeRectangle clipRectangle(NativePoint origin, NativeDimension dimension, boolean children)
origin
- Physical location.dimension
- Physical dimension.children
- Flag to intersect the rectangle with the to-be-drawn chidren.protected <C extends WidgetConfig> void updateSizeWorker(C beforeUpdate)
This implementation ignores the supplied config instance. Instead it relies
on size
and AbstractWidget.config()
to detect whether size has changed.
updateSizeWorker
in class AbstractWidget<O extends OutputManager<?>>
beforeUpdate
- BaseConfig
reference or null
.protected void focusWorker(boolean direction)
direction
- Widget search direction.protected boolean checkWidget(Widget<O> widget, boolean direction)
widget
- Candidate widget.direction
- Search direction.true
if widget was focused and false
otherwise.protected void cycleFocus(boolean direction)
direction
- Widget search direction.private Widget<O> locateFocusTraversable(java.lang.Iterable<Widget<O>> iter)
iter
- Iterable for the contained widgets.null
if no matches found.