|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.opengl.gui.Component
public class Component
The basic entity in the UI user interface system. A hierarchy of components and component derivations make up a user interface.
| Field Summary | |
|---|---|
protected float |
_alpha
|
protected Background[] |
_backgrounds
|
protected Border[] |
_borders
|
protected Color4f[] |
_colors
|
protected GlContext |
_ctx
The application context. |
protected Cursor |
_cursor
|
protected boolean |
_enabled
|
protected int |
_height
|
protected boolean |
_hover
|
protected boolean |
_hoverable
|
protected Insets[] |
_insets
|
protected CopyOnWriteArrayList<ComponentListener> |
_listeners
|
protected Container |
_parent
|
protected Dimension |
_preferredSize
|
protected HashMap<String,Object> |
_properties
|
protected static Rectangle |
_rect
Temporary storage for scissor box. |
protected StyleConfig[] |
_styleConfigs
The component's style configurations for each state. |
protected boolean |
_tipmouse
|
protected String |
_tiptext
|
protected ConfigReference<StyleConfig> |
_tooltipStyle
The style to use for tooltips. |
protected TransferHandler |
_transferHandler
Handler for data transfer operations. |
protected boolean |
_valid
|
protected boolean |
_visible
|
protected int |
_width
|
protected int |
_x
|
protected int |
_y
|
static int |
DEFAULT
The default component state. |
static int |
DISABLED
A component state indicating that the component is disabled. |
static int |
HOVER
A component state indicating that the mouse is hovering over the component. |
protected static int |
STATE_COUNT
|
protected static String[] |
STATE_PCLASSES
|
| Constructor Summary | |
|---|---|
Component(GlContext ctx)
Creates a new component. |
|
| Method Summary | |
|---|---|
boolean |
acceptsFocus()
Returns whether or not this component accepts the keyboard focus. |
void |
addListener(ComponentListener listener)
Adds a listener to this component. |
String |
boundsToString()
Returns our bounds as a nicely formatted string. |
protected boolean |
changeCursor()
Returns true if the component should update the mouse cursor. |
protected Dimension |
computePreferredSize(int whint,
int hhint)
Computes and returns a preferred size for this component. |
void |
configUpdated(ConfigEvent<ManagedConfig> event)
Called when a configuration has been updated. |
boolean |
contains(int mx,
int my)
Determines whether this component contains the specified coordinates. |
static Component |
createDefaultTooltipComponent(GlContext ctx,
String tiptext)
Creates a tooltip component of the default form with the default style. |
static Component |
createDefaultTooltipComponent(GlContext ctx,
String tiptext,
ConfigReference<StyleConfig> tipstyle)
Creates a tooltip component of the default form. |
protected Component |
createTooltipComponent(String tiptext)
Creates the component that will be used to display our tooltip. |
boolean |
dispatchEvent(Event event)
Instructs this component to process the supplied event. |
protected boolean |
emitEvent(Event event)
Dispatches an event emitted by this component. |
int |
getAbsoluteX()
Returns the x position of this component in absolute screen coordinates. |
int |
getAbsoluteY()
Returns the y position of this component in absolute screen coordinates. |
float |
getAlpha()
Returns the alpha transparency of this component. |
Background |
getBackground()
Returns a reference to the background used by this component. |
Border |
getBorder()
Returns the currently active border for this component. |
Rectangle |
getBounds()
Returns the bounds of this component in a new rectangle. |
Color4f |
getColor()
Returns the (foreground) color configured for this component. |
GlContext |
getContext()
Returns a reference to the component context. |
Cursor |
getCursor()
Returns a reference to the cursor used by this component. |
protected String |
getDefaultStyleConfig()
Returns the name of the default config to be used for all instances of this component. |
protected int |
getFallbackState(int state)
Returns the fallback to use for the specified state if no explicit style was given. |
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 |
getFocusTarget()
Returns the component that should receive focus if this component is clicked. |
int |
getHeight()
Returns the height of this component. |
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. |
Insets |
getInsets()
Returns the insets configured on this component. |
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. |
protected Component |
getNextFocus()
Searches for the next component that should receive the keyboard focus. |
Container |
getParent()
Returns the parent of this component in the interface hierarchy. |
Dimension |
getPreferredSize(int whint,
int hhint)
Returns the preferred size of this component, supplying a width and or height hint to the component to inform it of restrictions in one of the two dimensions. |
protected Component |
getPreviousFocus()
Searches for the previous component that should receive the keyboard focus. |
Object |
getProperty(String key)
Returns the user defined property mapped to the specified key, or null. |
int |
getState()
Returns the state of this component, either DEFAULT or DISABLED. |
protected int |
getStateCount()
Returns the number of different states that this component can take. |
protected String |
getStatePseudoClass(int state)
Returns the pseudoclass identifier for the specified component state. |
StyleConfig[] |
getStyleConfigs()
Returns a reference to the component's array of style configs. |
String |
getTooltipText()
Returns the tooltip text configured for this component. |
float |
getTooltipTimeout()
Returns the component's tooltip timeout, or -1 to use the default. |
String |
getTooltipWindowStyle()
Returns a reference to the component's tooltip window style config. |
TransferHandler |
getTransferHandler()
Returns the transfer handler for this component. |
int |
getWidth()
Returns the width of this component. |
protected Window |
getWindow()
Returns the window that defines the root of our component hierarchy. |
int |
getX()
Returns the x coordinate of this component. |
int |
getY()
Returns the y coordinate of this component. |
boolean |
hasFocus()
Returns true if this component has the focus. |
protected static Rectangle |
intersectScissor(Renderer renderer,
Rectangle store,
int x,
int y,
int width,
int height)
Activates scissoring and sets the scissor region to the intersection of the current region (if any) and the specified rectangle. |
void |
invalidate()
Marks this component as invalid and needing a relayout. |
boolean |
isAdded()
Returns true if this component is added to a hierarchy of components that culminates in a top-level window. |
boolean |
isEnabled()
Returns true if this component is enabled and responding to user interaction, false if not. |
boolean |
isHoverable()
Returns this component's hoverability state. |
boolean |
isShowing()
Returns true if this component is both added to the interface hierarchy and visible, false if not. |
boolean |
isTooltipRelativeToMouse()
Returns true if the tooltip window should be position relative to the mouse. |
boolean |
isValid()
Returns true if this component has been validated and laid out. |
boolean |
isVisible()
Returns true if this component is visible, false if it is not. |
protected void |
layout()
Instructs this component to lay itself out. |
void |
removeAllListeners()
Removes all listeners registered on this component. |
void |
removeAllListeners(Class<? extends ComponentListener> clazz)
Removes all listeners of the specified class. |
boolean |
removeListener(ComponentListener listener)
Removes a listener from this component. |
void |
render(Renderer renderer)
Translates into the component's coordinate space, renders the background and border and then calls renderComponent(com.threerings.opengl.renderer.Renderer) to allow the component to render itself. |
protected void |
renderBackground(Renderer renderer)
Renders the background for this component. |
protected void |
renderBorder(Renderer renderer)
Renders the border for this component. |
protected void |
renderComponent(Renderer renderer)
Renders any custom bits for this component. |
void |
requestFocus()
Requests that this component be given the input focus. |
void |
scrollRectToVisible(int x,
int y,
int w,
int h)
Request to have the specified rectangle, in this component's coordinate space, scrolled into view. |
void |
scrollRectToVisible(Rectangle rect)
Request to have the specified rectangle, in this component's coordinate space, scrolled into view. |
void |
setAlpha(float alpha)
Sets the alpha level for this component. |
void |
setBackground(int state,
Background background)
Configures the background for this component for the specified state. |
void |
setBounds(int x,
int y,
int width,
int height)
Sets the bounds of this component in screen coordinates. |
void |
setCursor(Cursor cursor)
Configures the cursor for this component. |
void |
setEnabled(boolean enabled)
Sets this components enabled state. |
void |
setHoverable(boolean hoverable)
Sets this component's hoverability state. |
void |
setLocation(int x,
int y)
Sets the upper left position of this component in absolute screen coordinates. |
void |
setParent(Container parent)
Informs this component of its parent in the interface heirarchy. |
void |
setPreferredSize(Dimension preferredSize)
Configures the preferred size of this component. |
void |
setPreferredSize(int width,
int height)
Configures the preferred size of this component. |
void |
setProperty(String key,
Object value)
Sets a user defined property on this component. |
void |
setSize(int width,
int height)
Sets the width and height of this component in screen coordinates. |
void |
setStyleConfig(ConfigReference<StyleConfig> ref)
Sets the style configuration. |
void |
setStyleConfig(String name)
Sets the style configuration. |
void |
setStyleConfig(String name,
String firstKey,
Object firstValue,
Object... otherArgs)
Sets the style configuration. |
void |
setStyleConfigs(StyleConfig... styleConfigs)
Sets the style configurations. |
void |
setTooltipRelativeToMouse(boolean mouse)
Sets where to position the tooltip window. |
void |
setTooltipText(String text)
Configures the tooltip text for this component. |
void |
setTransferHandler(TransferHandler handler)
Sets the transfer handler for this component. |
void |
setVisible(boolean visible)
Sets this component's visibility state. |
protected void |
stateDidChange()
Called when the component's state has changed. |
protected void |
updateCursor(Cursor cursor)
Updates the mouse cursor with the supplied cursor. |
protected void |
updateFromStyleConfig(int state)
Updates the component's style from the style configs. |
protected void |
updateFromStyleConfig(int state,
StyleConfig.Original config)
Updates from the resolved style config. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT
public static final int HOVER
public static final int DISABLED
protected GlContext _ctx
protected StyleConfig[] _styleConfigs
protected ConfigReference<StyleConfig> _tooltipStyle
protected Container _parent
protected Dimension _preferredSize
protected int _x
protected int _y
protected int _width
protected int _height
protected CopyOnWriteArrayList<ComponentListener> _listeners
protected HashMap<String,Object> _properties
protected String _tiptext
protected boolean _tipmouse
protected boolean _valid
protected boolean _enabled
protected boolean _visible
protected boolean _hoverable
protected boolean _hover
protected float _alpha
protected Color4f[] _colors
protected Insets[] _insets
protected Border[] _borders
protected Background[] _backgrounds
protected Cursor _cursor
protected TransferHandler _transferHandler
protected static Rectangle _rect
protected static final int STATE_COUNT
protected static final String[] STATE_PCLASSES
| Constructor Detail |
|---|
public Component(GlContext ctx)
| Method Detail |
|---|
public static Component createDefaultTooltipComponent(GlContext ctx,
String tiptext)
public static Component createDefaultTooltipComponent(GlContext ctx,
String tiptext,
ConfigReference<StyleConfig> tipstyle)
public GlContext getContext()
public void setStyleConfig(String name)
public void setStyleConfig(String name,
String firstKey,
Object firstValue,
Object... otherArgs)
public void setStyleConfig(ConfigReference<StyleConfig> ref)
public void setStyleConfigs(StyleConfig... styleConfigs)
public StyleConfig[] getStyleConfigs()
public String getTooltipWindowStyle()
public void setParent(Container parent)
public Container getParent()
public Dimension getPreferredSize(int whint,
int hhint)
public void setPreferredSize(Dimension preferredSize)
public void setPreferredSize(int width,
int height)
setPreferredSize(Dimension).
public int getX()
public int getY()
public int getWidth()
public int getHeight()
public int getAbsoluteX()
public int getAbsoluteY()
public Rectangle getBounds()
public Insets getInsets()
null will never be returned,
an Insets instance with all fields set to zero will be returned instead.
public Color4f getColor()
public String boundsToString()
public Border getBorder()
public Background getBackground()
public void setBackground(int state,
Background background)
public Cursor getCursor()
public void setCursor(Cursor cursor)
public void setAlpha(float alpha)
public float getAlpha()
public void setEnabled(boolean enabled)
public boolean isEnabled()
public void setVisible(boolean visible)
public boolean isVisible()
public void setHoverable(boolean hoverable)
public boolean isHoverable()
public boolean isShowing()
public int getState()
DEFAULT or DISABLED.
public void setProperty(String key,
Object value)
public Object getProperty(String key)
public boolean acceptsFocus()
public boolean hasFocus()
public Component getFocusTarget()
public void requestFocus()
public void setLocation(int x,
int y)
public void setSize(int width,
int height)
public void setBounds(int x,
int y,
int width,
int height)
setLocation(int, int),
setSize(int, int)public void addListener(ComponentListener listener)
public boolean removeListener(ComponentListener listener)
public void removeAllListeners()
public void removeAllListeners(Class<? extends ComponentListener> clazz)
public void setTooltipText(String text)
Label.
public String getTooltipText()
public void setTooltipRelativeToMouse(boolean mouse)
mouse - if true, the window will appear relative to the mouse position, if false, the
window will appear relative to the component bounds.public boolean isTooltipRelativeToMouse()
public float getTooltipTimeout()
public void setTransferHandler(TransferHandler handler)
public TransferHandler getTransferHandler()
public boolean isAdded()
public boolean isValid()
public void validate()
public void invalidate()
public void render(Renderer renderer)
renderComponent(com.threerings.opengl.renderer.Renderer) to allow the component to render itself.
public Component getHitComponent(int mx,
int my)
public boolean contains(int mx,
int my)
public final void scrollRectToVisible(Rectangle rect)
public void scrollRectToVisible(int x,
int y,
int w,
int h)
public boolean dispatchEvent(Event event)
super.dispatchEvent for events that they did not "consume".
public void configUpdated(ConfigEvent<ManagedConfig> event)
ConfigUpdateListener
configUpdated in interface ConfigUpdateListener<ManagedConfig>protected void updateFromStyleConfig(int state)
protected void updateFromStyleConfig(int state,
StyleConfig.Original config)
protected void layout()
protected Dimension computePreferredSize(int whint,
int hhint)
protected void wasAdded()
protected void wasRemoved()
wasAdded(), this is a fine place
to do so.
protected Component createTooltipComponent(String tiptext)
getTooltipText() returns non-null text.
protected void renderBackground(Renderer renderer)
protected void renderBorder(Renderer renderer)
protected void renderComponent(Renderer renderer)
protected String getDefaultStyleConfig()
protected int getStateCount()
protected String getStatePseudoClass(int state)
DISABLED state maps to disabled and is configured like so:
component:disabled {
color: #CCCCCC; // etc.
}
protected int getFallbackState(int state)
protected void stateDidChange()
protected boolean changeCursor()
protected void updateCursor(Cursor cursor)
protected Window getWindow()
protected Component getNextFocus()
protected Component getPreviousFocus()
protected Component getFirstDescendantFocus()
null if no descendants accept it.
protected Component getLastDescendantFocus()
null if no descendants accept it.
protected boolean emitEvent(Event event)
dispatchEvent(com.threerings.opengl.gui.event.Event)
with the event.
protected static Rectangle intersectScissor(Renderer renderer,
Rectangle store,
int x,
int y,
int width,
int height)
store - a rectangle to hold the previous scissor region for later restoration
null if scissoring was disabled, otherwise a reference to the
store parameter.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||