/** Sets if design time is turned on for a Container in {@link ContainerWrapper}. * @param cw The container to set design time for. <code>null</code> is legal and can be used as * a key to turn on/off design time "in general". Note though that design time "in general" is * always on as long as there is at least one ContainerWrapper with design time. * <p> * <strong>If this method has not ever been called it will default to what * <code>Beans.isDesignTime()</code> returns.</strong> This means that if you call * this method you indicate that you will take responsibility for the design time value. * @param b <code>true</code> means design time on. */ public static void setDesignTime(ContainerWrapper cw, boolean b) { if (DT_MAP == null) DT_MAP = new WeakHashMap<Object, Boolean>(); DT_MAP.put((cw != null ? cw.getComponent() : null), b); }
private void clearGroupLinkBounds() { if (linkTargetIDs == null) return; for (Map.Entry<String, Boolean> o : linkTargetIDs.entrySet()) { if (o.getValue() == Boolean.TRUE) LinkHandler.clearBounds(container.getLayout(), o.getKey()); } }
return parent.getPixelUnitFactor(unit == LPX) * value; f *= s; return (isHor ? parent.getHorizontalScreenDPI() : parent.getVerticalScreenDPI()) * value / f; return (unit == SPX ? parent.getScreenWidth() : parent.getScreenHeight()) * value * 0.01f; Integer st = LinkHandler.getValue(parent.getLayout(), "visual", isHor ? LinkHandler.X : LinkHandler.Y); Integer sz = LinkHandler.getValue(parent.getLayout(), "visual", isHor ? LinkHandler.WIDTH : LinkHandler.HEIGHT); if (st == null || sz == null) return 0; case LINK_XPOS: case LINK_YPOS: Integer v = LinkHandler.getValue(parent.getLayout(), getLinkTargetId(), unit - (unit >= LINK_XPOS ? LINK_XPOS : LINK_X)); if (v == null) return 0; return parent.getScreenLocationX() + v; if (unit == LINK_YPOS) return parent.getScreenLocationY() + v;
private void resetLinkValues(boolean parentSize, boolean compLinks) { Object lay = container.getLayout(); if (compLinks) LinkHandler.clearTemporaryBounds(lay); boolean defIns = !hasDocks(); int parW = parentSize ? lc.getWidth().constrain(container.getWidth(), getParentSize(container, true), container) : 0; int parH = parentSize ? lc.getHeight().constrain(container.getHeight(), getParentSize(container, false), container) : 0; int insX = LayoutUtil.getInsets(lc, 0, defIns).getPixels(0, container, null); int insY = LayoutUtil.getInsets(lc, 1, defIns).getPixels(0, container, null); int visW = parW - insX - LayoutUtil.getInsets(lc, 2, defIns).getPixels(0, container, null); int visH = parH - insY - LayoutUtil.getInsets(lc, 3, defIns).getPixels(0, container, null); LinkHandler.setBounds(lay, "visual", insX, insY, visW, visH, true, false); LinkHandler.setBounds(lay, "container", 0, 0, parW, parH, true, false); }
boolean useVisualPadding = lc.isVisualPadding(); final ComponentWrapper[] comps = container.getComponents(); int[] dockInsets = null; // top, left, bottom, right insets for docks. LinkHandler.clearTemporaryBounds(container.getLayout());
int compCount = container.getComponentCount();
private ContainerWrapper checkParent(Composite parent) { if (parent == null) return null; if (cacheParentW == null || cacheParentW.getComponent() != parent) cacheParentW = new SwtContainerWrapper(parent); return cacheParentW; }
/** * @param cw Never <code>null</code>. * @param cc Never <code>null</code>. * @param external The bounds should be stored even if they are not in {@link #linkTargetIDs}. * @return If a change has been made. */ private boolean setLinkedBounds(ComponentWrapper cw, CC cc, int x, int y, int w, int h, boolean external) { String id = cc.getId() != null ? cc.getId() : cw.getLinkId(); if (id == null) return false; String gid = null; int grIx = id.indexOf('.'); if (grIx != -1 ) { gid = id.substring(0, grIx); id = id.substring(grIx + 1); } Object lay = container.getLayout(); boolean changed = false; if (external || (linkTargetIDs != null && linkTargetIDs.containsKey(id))) changed = LinkHandler.setBounds(lay, id, x, y, w, h, !external, false); if (gid != null && (external || (linkTargetIDs != null && linkTargetIDs.containsKey(gid)))) { if (linkTargetIDs == null) linkTargetIDs = new HashMap<String, Boolean>(4); linkTargetIDs.put(gid, Boolean.TRUE); changed |= LinkHandler.setBounds(lay, gid, x, y, w, h, !external, true); } return changed; }
private ContainerWrapper checkParent(Container parent) { if (parent == null) return null; if (cacheParentW == null || cacheParentW.getComponent() != parent) cacheParentW = new SwingContainerWrapper(parent); return cacheParentW; }
/** Returns if design time is turned on for a Container in {@link ContainerWrapper}. * @param cw The container to set design time for. <code>null</code> is legal will return <code>true</code> * if there is at least one <code>ContainerWrapper</code> (or <code>null</code>) that have design time * turned on. * @return If design time is set for <code>cw</code>. */ public static boolean isDesignTime(ContainerWrapper cw) { if (DT_MAP == null) return HAS_BEANS && Beans.isDesignTime(); // assume design time "in general" (cw is null) if there is at least one container with design time // (for storing constraints creation strings in method putCCString()) if (cw == null && DT_MAP != null && !DT_MAP.isEmpty() ) return true; if (cw != null && DT_MAP.containsKey(cw.getComponent()) == false) cw = null; Boolean b = DT_MAP.get(cw != null ? cw.getComponent() : null); return b != null && b; }
/** Sets the debugging state for this layout manager instance. If debug is turned on a timer will repaint the last laid out parent * with debug information on top. * <p> * Red fill and dashed dark red outline is used to indicate occupied cells in the grid. Blue dashed outline indicate * component bounds set. * <p> * Note that debug can also be set on the layout constraints. There it will be persisted. The value set here will not. See the class * JavaDocs for information. * @param parentW The parent. Never <code>null</code>. * @param b <code>true</code> means debug is turned on. */ private synchronized void setDebug(final ComponentWrapper parentW, boolean b) { if (b && (debugTimer == null || curDelay != getDebugMillis())) { if (debugTimer != null) debugTimer.cancel(); debugTimer = new Timer(true); curDelay = getDebugMillis(); debugTimer.schedule(new MyDebugRepaintTask(this), curDelay, curDelay); ContainerWrapper pCW = parentW.getParent(); Composite parent = pCW != null ? (Composite) pCW.getComponent() : null; if (parent != null) parent.layout(); } else if (!b && debugTimer != null) { debugTimer.cancel(); debugTimer = null; } }
final Component parent = pCW != null ? (Component) pCW.getComponent() : null;
return; Container packable = getPackable((Component) parent.getComponent()); Component pc = (Component) parent.getComponent();
ixArr[ix++] = i; putSizesAndIndexes(container.getComponent(), rowColSizes, ixArr, isRows);
lastSize = newSize; final ContainerWrapper containerWrapper = checkParent(parent); Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, (Component)containerWrapper.getComponent())); if (win != null) { if (win.isVisible()) {