001: /*
002: * Copyright 2000,2005 wingS development team.
003: *
004: * This file is part of wingS (http://wingsframework.org).
005: *
006: * wingS is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * Please see COPYING for the complete licence.
012: */
013: package org.wings;
014:
015: import org.wings.plaf.DesktopPaneCG;
016: import org.wings.event.*;
017:
018: /**
019: * Container that holds SInternalFrames.
020: *
021: * @author <a href="mailto:engels@mercatis.de">Holger Engels</a>
022: */
023: public class SDesktopPane extends SContainer {
024: SInternalFrameListener listener = new SInternalFrameAdapter() {
025: public void internalFrameMaximized(SInternalFrameEvent e) {
026: reload();
027: }
028:
029: public void internalFrameUnmaximized(SInternalFrameEvent e) {
030: reload();
031: }
032: };
033:
034: public void setLayout(SLayoutManager l) {
035: }
036:
037: /**
038: * @param component The internal frame to be added.
039: * @param constraints nothing
040: */
041: public SComponent addComponent(SComponent component,
042: Object constraints, int index) {
043: if (constraints == null)
044: constraints = component.getName();
045:
046: ((SInternalFrame) component).addInternalFrameListener(listener);
047:
048: return super .addComponent(component, constraints, index);
049: }
050:
051: public void remove(SComponent c) {
052: super .remove(c);
053:
054: ((SInternalFrame) c).removeInternalFrameListener(listener);
055: }
056:
057: /**
058: * Sets the position for the specified component.
059: *
060: * @param c the Component to set the layer for
061: * @param position an int specifying the position, where
062: * 0 is the topmost position and
063: * -1 is the bottommost position
064: */
065: public void setPosition(SComponent c, int position) {
066: if (position != getComponentList().indexOf(c)) {
067: getComponentList().remove(c);
068: getComponentList().add(position, c);
069: reload();
070: }
071: }
072:
073: /**
074: * Returns the index of the specified Component.
075: * This is the absolute index, ignoring layers.
076: * Index numbers, like position numbers, have the topmost component
077: * at index zero. Larger numbers are closer to the bottom.
078: *
079: * @param c the Component to check
080: * @return an int specifying the component's index
081: */
082: public int getIndexOf(SComponent c) {
083: int i, count;
084:
085: count = getComponentCount();
086: for (i = 0; i < count; i++) {
087: if (c == getComponent(i))
088: return i;
089: }
090: return -1;
091: }
092:
093: /**
094: * Get the position of the component.
095: *
096: * @param c the Component to check
097: * @return an int giving the component's position, where 0 is the
098: * topmost position and the highest index value = the count
099: * count of components minus 1
100: * @see #getIndexOf
101: */
102: public int getPosition(SComponent c) {
103: return getIndexOf(c);
104: }
105:
106: public void setCG(DesktopPaneCG cg) {
107: super.setCG(cg);
108: }
109: }
|