com.threerings.opengl.gui
Class ChatOverlay

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.Container
          extended by com.threerings.opengl.gui.ChatOverlay
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, ChatDisplay

public class ChatOverlay
extends Container
implements ChatDisplay

A chat display for use as a HUD element.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Container
Container.ChildOp
 
Field Summary
protected  TextArea _area
          The chat entry text area.
protected  Button _end
          The less, more, and end buttons.
protected  Button _less
          The less, more, and end buttons.
protected  Button _more
          The less, more, and end buttons.
protected  MessageBundle _msgs
          The bundle we use to translate messages.
protected  Color4f[] _systemColors
          The colors to use for each system message level.
 
Fields inherited from class com.threerings.opengl.gui.Container
_children, _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
ChatOverlay(GlContext ctx)
          Creates a new chat overlay.
 
Method Summary
protected  void appendMessage(ChatMessage msg, String text, Color4f color)
          Appends a message to the text area.
 void clear()
           
 boolean displayMessage(ChatMessage msg, boolean alreadyDisplayed)
           
protected  Color4f getColor(ChatMessage msg)
          Returns the color to use for the supplied message, or null for the default.
 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.
 void setBundle(String bundle)
          Sets the bundle to use to translate chat messsages.
 void setEnabled(boolean enabled)
          Sets this components enabled state.
 void setPreferredWidth(int width)
          Sets the preferred width for the text area.
 void setSystemColors(Color4f info, Color4f feedback, Color4f attention)
          Sets the colors to use for system chat messages.
protected  void updateButtons()
          Updates the enabled status of the buttons.
 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).
 
Methods inherited from class com.threerings.opengl.gui.Container
add, add, add, add, applyOperation, computePreferredSize, getComponent, getComponentCount, getComponentIndex, getDefaultStyleConfig, getFirstDescendantFocus, getLastDescendantFocus, getLayoutManager, getNextFocus, getPreviousFocus, layout, remove, remove, removeAll, renderComponent, replace, setAlpha, setHoverable, setLayoutManager, wasRemoved
 
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

_msgs

protected MessageBundle _msgs
The bundle we use to translate messages.


_systemColors

protected Color4f[] _systemColors
The colors to use for each system message level.


_less

protected Button _less
The less, more, and end buttons.


_more

protected Button _more
The less, more, and end buttons.


_end

protected Button _end
The less, more, and end buttons.


_area

protected TextArea _area
The chat entry text area.

Constructor Detail

ChatOverlay

public ChatOverlay(GlContext ctx)
Creates a new chat overlay.

Method Detail

setBundle

public void setBundle(String bundle)
Sets the bundle to use to translate chat messsages.


setPreferredWidth

public void setPreferredWidth(int width)
Sets the preferred width for the text area.


setSystemColors

public void setSystemColors(Color4f info,
                            Color4f feedback,
                            Color4f attention)
Sets the colors to use for system chat messages.


clear

public void clear()
Specified by:
clear in interface ChatDisplay

displayMessage

public boolean displayMessage(ChatMessage msg,
                              boolean alreadyDisplayed)
Specified by:
displayMessage in interface ChatDisplay

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 Container

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 Container

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 Container

getColor

protected Color4f getColor(ChatMessage msg)
Returns the color to use for the supplied message, or null for the default.


appendMessage

protected void appendMessage(ChatMessage msg,
                             String text,
                             Color4f color)
Appends a message to the text area.

Parameters:
text - the formatted, newline-terminated text of the message.
color - the color to use for the message, or null for the default.

updateButtons

protected void updateButtons()
Updates the enabled status of the buttons.


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 Container