Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.ui.wombat
Class Container

    java.lang.Object
      jcontrol.ui.wombat.Component
          jcontrol.ui.wombat.Container

All Implemented Interfaces:
  IContainer

    public class Container

extends Component
implements IContainer

A container object is a component that can contain other components.

Containers are used to group components that should e.g. become visible or invisible at the same time, have the same font, being replaced by other components all at once etc.
Normally, it is not nescessary to define any bounds for a container as component bounds are always treated as absolute display coordinates. Thus, components simply ignore their parent's bounds.

Components added to a container are tracked in an array. If the number of added components exceeds the initial array size, the array will be resized, i.e. enlarged.
Removing a component will not immediately dispose the component or delete the corresponding array index. First, the component is marked as to be deleted, then, on the next paint event, the graphic area covered by the component is cleared and the array index the component is stored in is set to `null`.
In other words, removing a component will not result in a smaller data array. The array is neither trimmed nor are the components beyond the removed one shifted forward. Adding a component to the container will use the first free index in the array to store it in. Consequentely in a container, components are not necessarily stored in the same order they have been added.

Note: As the drawing order of components in a container is not fixed, components should if possible not cover each other. Otherwise, it is not guaranteed that the last added component will always be painted above a previously added component. The only component that may (or should) be covered by other components is the `Border`.

(c) Copyright 2005-2007 DOMOLOGIC GmbH

See Also:
  `IFrame`

Field Summary

Fields inherited from class jcontrol.ui.wombat.Component
`backgroundColor, COLOR_COMPONENT_BACKGROUND, COLOR_COMPONENT_BACKGROUND_HIGHLIGHTED, COLOR_COMPONENT_DARK_SHADOW, COLOR_COMPONENT_FOREGROUND, COLOR_COMPONENT_FOREGROUND_INACTIVE, COLOR_COMPONENT_HIGHLIGHT_SHADOW, COLOR_COMPONENT_LIGHT_SHADOW, COLOR_COMPONENT_LIST_BACKGROUND, COLOR_COMPONENT_NORMAL_SHADOW, COLOR_COMPONENT_SELECTION_TEXT, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND_INACTIVE, COLOR_COMPONENT_SELECTION_TEXT_INACTIVE, eventQueue, font, foregroundColor, frame, height, parent, RESERVED1, RESERVED2, RESERVED3, RESERVED4, RESERVED5, RESERVED6, state, STATE_ABORT_UPDATE, STATE_ANIMATED, STATE_BG_COLOR_SET, STATE_COVERED, STATE_DIRTY_MASK, STATE_DIRTY_PAINTALL, STATE_DIRTY_REPAINT, STATE_DIRTY_UPDATE, STATE_DISABLED, STATE_DISPOSED, STATE_FG_COLOR_SET, STATE_FOCUS, STATE_HEIGHT_FIXED, STATE_NO_REDRAW, STATE_REVALIDATE, STATE_SELECTED, STATE_SIZE_FIXED, STATE_UPDATED, STATE_VISIBLE, STATE_WIDTH_FIXED, transparentColor, width, x, y`

Constructor Summary
`Container()` Create a new `Container` with a default initial capacity of 10.
`Container(int estimatedMaxCapacity)` Constructs a new Container.

Method Summary
`void` | `add(Component component)` Adds a child component to this container.
`protected void` | `dispose()`
`void` | `paint(XGraphics g)` Does nothing.
`void` | `remove(Component component)` Removes a child component from the container.
`void` | `removeAll()` Removes all child components from this container.
`void` | `repaint()` Causes a repaint for this container and all sub-components.
`void` | `repaintAll()` Causes the entire component to be marked as needing to be redrawn.
`void` | `setBackgroundColor(Color background)` Sets the background color for this container and all sub-components.
`protected void` | `setBackgroundColorInternal(Color background)`
`boolean` | `setDirty(Object source, int x, int y, int width, int height, int newstate, boolean onoff)` For internal use only.
`void` | `setFont(Resource font)` Set a font for this container and all sub-components that do not have their own font specified.
`void` | `setForegroundColor(Color foreground)` Sets the foreground color for this container and all sub-components.
`protected void` | `setForegroundColorInternal(Color foreground)`
`protected void` | `setParametersInternal(Resource font, Color foregroundColor, Color backgroundColor, Color transparentColor)`
`void` | `setTransparentColor(Color transparentColor)` Sets the transparent color for this container and all sub-components.
`void` | `setVisible(boolean visible)` Sets this container and all child components visible or invisible.
`void` | `update(XGraphics g)` Paints all child components.

Methods inherited from class jcontrol.ui.wombat.Component
`drawDisabledImage, getFrame, isEnabled, isVisible, isVisibleInternal, redrawInternalAndParent, safeExec, setBounds, setDirty, setEnabled, setRedraw, unsafeExec`

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Constructor Detail

### Container

    public Container(int estimatedMaxCapacity)

  Constructs a new Container. Containers can be extended, but are lightweight in this case and must be contained by a parent somewhere higher up in the component tree (such as Frame for example).

  The parameter `estimatedMaxCapacity` specifies the initial size of the internal data array the components will be stored in.
  If this number is exceeded the array will be resized, indeed. But this may consume a lot of memory. For a short period of time, two data arrays must be kept in memory simultaniously to copy the data from the small array to the larger one. In large applications this may exceed the available memory. To avoid this, it is recommended to initialize the container as big as it must never be enlarged any time. But it should of course neither be too large as then, memory will be allocated that is never used by the application. In most cases, it is quite easy for the programmer to know the number of components a container should hold. In simple applications, components are once added an never removed. Thus, it is easy to count them. When components should be removed and replaced by other ones at run-time, the maximum capacity should include the sum of both, removed and newly added components. This is because of the fact that removed components are not deleted from the data array immediately but on the next painting action.

  Parameters:
    `estimatedMaxCapacity` - the capacity the internal data array should be initialized with
  See Also:
    `Container()`

### Container

    public Container()

  Create a new `Container` with a default initial capacity of 10. Using this constructor corresponds to the call `new Container(10)`.

  See Also:
    `Container(int estimatedMaxCapacity)`

Method Detail

### add

    public void add(Component component)

  Adds a child component to this container.

  Specified by:
    `add` in interface `IContainer`
  Parameters:
    `component` - the component to add.

### remove

    public void remove(Component component)

  Removes a child component from the container.

  Specified by:
    `remove` in interface `IContainer`
  Parameters:
    `component` - the component to remove

### setParametersInternal

    protected void setParametersInternal(Resource font,
                                         Color foregroundColor,
                                         Color backgroundColor,
                                         Color transparentColor)

  Overrides:
    `setParametersInternal` in class `Component`

### setFont

    public void setFont(Resource font)

  Set a font for this container and all sub-components that do not have their own font specified.

  Overrides:
    `setFont` in class `Component`
  Parameters:
    `font` - the new font.
  See Also:
    `Component.setFont(Resource font)`

### setForegroundColorInternal

    protected void setForegroundColorInternal(Color foreground)

  Overrides:
    `setForegroundColorInternal` in class `Component`

### setBackgroundColorInternal

    protected void setBackgroundColorInternal(Color background)

  Overrides:
    `setBackgroundColorInternal` in class `Component`

### setForegroundColor

    public void setForegroundColor(Color foreground)

  Sets the foreground color for this container and all sub-components.

  Overrides:
    `setForegroundColor` in class `Component`
  Parameters:
    `foreground` - the foreground color to set

### setTransparentColor

    public void setTransparentColor(Color transparentColor)

  Sets the transparent color for this container and all sub-components. Transparent color is optional and will be used in components that have "transparent" areas. E.g. the round corners of buttons and borders or radio buttons where the main background shines through. If a transparent color for those components is set it will be used instead of the component's background color in the "transparent" areas.

  Overrides:
    `setTransparentColor` in class `Component`
  Parameters:
    `transparentColor` - the transparent color to set

### setBackgroundColor

    public void setBackgroundColor(Color background)

  Sets the background color for this container and all sub-components.

  Overrides:
    `setBackgroundColor` in class `Component`
  Parameters:
    `background` - the background color to set

### repaint

    public void repaint()

  Causes a repaint for this container and all sub-components.

  Overrides:
    `repaint` in class `Component`
  See Also:
    `Component.repaint()`

### repaintAll

    public void repaintAll()

  Causes the entire component to be marked as needing to be redrawn. The next time a paint request is processed, the background is cleared and the component will be completely painted.

  Overrides:
    `repaintAll` in class `Component`

### dispose

    protected void dispose()

### removeAll

    public void removeAll()

  Removes all child components from this container.

  Specified by:
    `removeAll` in interface `IContainer`

### setVisible

    public void setVisible(boolean visible)

  Sets this container and all child components visible or invisible.

  Overrides:
    `setVisible` in class `Component`
  Parameters:
    `visible` - `true` - visible, `false` - invisible
  See Also:
    `Component.setVisible(boolean visible)`

### paint

    public void paint(XGraphics g)

  Does nothing. This method can be overwritten by implementing classes in order to perform any painting routines (e.g. a border or background image) for this container.

  Overrides:
    `paint` in class `Component`
  Parameters:
    `g` - the application's graphics object.

### update

    public void update(XGraphics g)

  Paints all child components. This method must not be used by any application.

  Overrides:
    `update` in class `Component`
  Parameters:
    `g` - the application's graphics object.
  See Also:
    `Component.update(XGraphics g)`

### setDirty

    public boolean setDirty(Object source,
                            int x,
                            int y,
                            int width,
                            int height,
                            int newstate,
                            boolean onoff)

  For internal use only. Don't call this method directly!

  Specified by:
    `setDirty` in interface `IContainer`
    `newstate` - the state to set
  Returns:
    TODO

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD