public class Container extends FocusableComponent
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
Container.LoopFunction
Interface used by the loop.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Component> |
components
List of child component.
|
description, renderer, title| Constructor and Description |
|---|
Container(java.lang.String title,
java.lang.String description,
Renderer renderer)
Constructor for a container.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComponent(Component component)
Add a component to the container.
|
protected void |
doComponentLoop(Context context,
Container.LoopFunction function)
Loop through all components in reverse order and check for focus requests.
|
void |
enter(Context context)
Handle the GUI being closed.
|
void |
exit(Context context)
Handle the GUI being closed.
|
void |
getHeight(Context context)
Returns the total height of the container, accounting for the height of its child components.
|
protected Context |
getSubContext(Context context,
int posy)
Create sub-context for child component.
|
void |
handleButton(Context context,
int button)
Handle a mouse button state change.
|
protected void |
handleFocus(Context context,
boolean focus)
Releases focus of children when called.
|
void |
handleKey(Context context,
int scancode)
Handle a key being typed.
|
void |
handleScroll(Context context,
int diff)
Handle mouse wheel being scrolled.
|
void |
releaseFocus()
Reset focus state of self and children.
|
void |
render(Context context)
Render the container.
|
getTitle, hasFocus, updateFocusprotected java.util.List<Component> components
public Container(java.lang.String title,
java.lang.String description,
Renderer renderer)
title - the caption of the containerdescription - the description for this componentrenderer - the renderer used by the containerpublic void addComponent(Component component)
component - the component to be addedpublic void render(Context context)
Context.setHeight(int).
The horizontal border is defined by Renderer.getBorder().
The vertical space between to components is defined by Renderer.getOffset().render in interface Componentrender in class FocusableComponentcontext - the Context for the componentpublic void handleButton(Context context, int button)
handleButton in interface ComponenthandleButton in class FocusableComponentcontext - the Context for the componentbutton - the button that changed its stateInterface.LBUTTON,
Interface.RBUTTONpublic void handleKey(Context context, int scancode)
handleKey in interface ComponenthandleKey in class FocusableComponentcontext - the Context for the componentscancode - the scancode for the key that was typedpublic void handleScroll(Context context, int diff)
handleScroll in interface ComponenthandleScroll in class FocusableComponentcontext - the Context for the componentdiff - the amount by which the wheel was movedpublic void getHeight(Context context)
getHeight in interface ComponentgetHeight in class FocusableComponentcontext - the Context for the componentpublic void enter(Context context)
enter in interface Componententer in class FocusableComponentcontext - the Context for the componentpublic void exit(Context context)
exit in interface Componentexit in class FocusableComponentcontext - the Context for the componentpublic void releaseFocus()
releaseFocus in interface ComponentreleaseFocus in class FocusableComponentprotected void handleFocus(Context context, boolean focus)
handleFocus in class FocusableComponentcontext - the Context for the componentfocus - the new focus stateprotected Context getSubContext(Context context, int posy)
context - the current contextposy - the vertical position of the child componentprotected void doComponentLoop(Context context, Container.LoopFunction function)
context - for the containerfunction - the function to execute in the loop