com.threerings.opengl.gui
Class Container

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.Container
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>
Direct Known Subclasses:
ChatOverlay, List, ScrollBar, ScrollButton, ScrollingList, ScrollingList.Viewport, ScrollPane, ScrollPane.Viewport, Spinner, TabbedPane, TextArea, UserInterface, Window

public class Container
extends Component

A user interface element that is meant to contain other interface elements.


Nested Class Summary
protected static interface Container.ChildOp
          Used in wasAdded() and wasRemoved().
 
Field Summary
protected  ArrayList<Component> _children
           
protected  LayoutManager _layout
           
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
Container(GlContext ctx)
          Creates a container with no layout manager.
Container(GlContext ctx, LayoutManager layout)
          Creates a container with the supplied layout manager.
 
Method Summary
 void add(Component child)
          Adds a child to this container.
 void add(Component child, Object constraints)
          Adds a child to this container with the specified layout constraints.
 void add(int index, Component child)
          Adds a child to this container at the specified position.
 void add(int index, Component child, Object constraints)
          Adds a child to this container at the specified position, with the specified layout constraints.
protected  void applyOperation(Container.ChildOp op)
          Applies an operation to all of our children.
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
 Component getComponent(int index)
          Returns the indexth component from this container.
 int getComponentCount()
          Returns the number of components contained in this container.
 int getComponentIndex(Component component)
          Returns the index of the specified component in this container or -1 if the component count not be found.
protected  String getDefaultStyleConfig()
          Returns the name of the default config to be used for all instances of this component.
protected  Component getFirstDescendantFocus()
          Returns the first descendant of this component that accepts the keyboard focus (including the component itself), or null if no descendants accept it.
 Component getHitComponent(int mx, int my)
          Returns the component "hit" by the specified mouse coordinates which might be this component or any of its children.
protected  Component getLastDescendantFocus()
          Returns the last descendant of this component that accepts the keyboard focus (including the component itself), or null if no descendants accept it.
 LayoutManager getLayoutManager()
          Returns the layout manager configured for this container.
protected  Component getNextFocus(Component current)
          Returns the next component that should receive focus in this container given the current focus owner.
protected  Component getPreviousFocus(Component current)
          Returns the previous component that should receive focus in this container given the current focus owner.
protected  void layout()
          Instructs this component to lay itself out.
 void remove(Component child)
          Removes the specified child from this container.
 void remove(int index)
          Removes the child at a specific position from this container.
 void removeAll()
          Removes all children of this container.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
 boolean replace(Component oldc, Component newc)
          Replaces a given old component with a new component (if the old component exits).
 void setAlpha(float alpha)
          Sets the alpha level for this component.
 void setEnabled(boolean enabled)
          Sets this components enabled state.
 void setHoverable(boolean hoverable)
          Sets this component's hoverability state.
 void setLayoutManager(LayoutManager layout)
          Configures this container with an entity that will set the size and position of its children.
 void validate()
          Instructs this component to lay itself out and then mark itself as valid.
protected  void wasAdded()
          This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFallbackState, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, updateFromStyleConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_children

protected ArrayList<Component> _children

_layout

protected LayoutManager _layout
Constructor Detail

Container

public Container(GlContext ctx)
Creates a container with no layout manager. One should subsequently be set via a call to setLayoutManager(com.threerings.opengl.gui.layout.LayoutManager).


Container

public Container(GlContext ctx,
                 LayoutManager layout)
Creates a container with the supplied layout manager.

Method Detail

setLayoutManager

public void setLayoutManager(LayoutManager layout)
Configures this container with an entity that will set the size and position of its children.


getLayoutManager

public LayoutManager getLayoutManager()
Returns the layout manager configured for this container.


add

public void add(Component child)
Adds a child to this container.


add

public void add(int index,
                Component child)
Adds a child to this container at the specified position.


add

public void add(Component child,
                Object constraints)
Adds a child to this container with the specified layout constraints.


add

public void add(int index,
                Component child,
                Object constraints)
Adds a child to this container at the specified position, with the specified layout constraints.


remove

public void remove(int index)
Removes the child at a specific position from this container.


replace

public boolean replace(Component oldc,
                       Component newc)
Replaces a given old component with a new component (if the old component exits).

Returns:
true if the old component was replaced, false otherwise.

remove

public void remove(Component child)
Removes the specified child from this container.


getComponentCount

public int getComponentCount()
Returns the number of components contained in this container.


getComponent

public Component getComponent(int index)
Returns the indexth component from this container.


getComponentIndex

public int getComponentIndex(Component component)
Returns the index of the specified component in this container or -1 if the component count not be found.


removeAll

public void removeAll()
Removes all children of this container.


setAlpha

public void setAlpha(float alpha)
Description copied from class: Component
Sets the alpha level for this component.

Overrides:
setAlpha in class Component

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: Component
Sets this components enabled state. A component that is not enabled should not respond to user interaction and should render itself in such a way as not to afford user interaction.

Overrides:
setEnabled in class Component

setHoverable

public void setHoverable(boolean hoverable)
Description copied from class: Component
Sets this component's hoverability state.

Overrides:
setHoverable in class Component

getHitComponent

public Component getHitComponent(int mx,
                                 int my)
Description copied from class: Component
Returns the component "hit" by the specified mouse coordinates which might be this component or any of its children. This method should return null if the supplied mouse coordinates are outside the bounds of this component.

Overrides:
getHitComponent in class Component

validate

public void validate()
Description copied from class: Component
Instructs this component to lay itself out and then mark itself as valid.

Overrides:
validate in class Component

getDefaultStyleConfig

protected String getDefaultStyleConfig()
Description copied from class: Component
Returns the name of the default config to be used for all instances of this component. Derived classes will likely want to override this method and set up a default config for their type of component.

Overrides:
getDefaultStyleConfig in class Component

layout

protected void layout()
Description copied from class: Component
Instructs this component to lay itself out. This is called as a result of the component changing size.

Overrides:
layout in class Component

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: Component
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class Component

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: Component
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class Component
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.

wasAdded

protected void wasAdded()
Description copied from class: Component
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).

Overrides:
wasAdded in class Component

wasRemoved

protected void wasRemoved()
Description copied from class: Component
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in Component.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class Component

getNextFocus

protected Component getNextFocus(Component current)
Returns the next component that should receive focus in this container given the current focus owner. If the supplied current focus owner is null, the container should return its first focusable component. If the container has no focusable components following the current focus, it should call Component.getNextFocus() to search further up the hierarchy.


getPreviousFocus

protected Component getPreviousFocus(Component current)
Returns the previous component that should receive focus in this container given the current focus owner. If the supplied current focus owner is null, the container should return its last focusable component. If the container has no focusable components before the current focus, it should call Component.getPreviousFocus() to search further up the hierarchy.


getFirstDescendantFocus

protected Component getFirstDescendantFocus()
Description copied from class: Component
Returns the first descendant of this component that accepts the keyboard focus (including the component itself), or null if no descendants accept it.

Overrides:
getFirstDescendantFocus in class Component

getLastDescendantFocus

protected Component getLastDescendantFocus()
Description copied from class: Component
Returns the last descendant of this component that accepts the keyboard focus (including the component itself), or null if no descendants accept it.

Overrides:
getLastDescendantFocus in class Component

applyOperation

protected void applyOperation(Container.ChildOp op)
Applies an operation to all of our children.