org.wings.plaf.css.CardLayoutCG Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2000,2005 wingS development team.
*
* This file is part of wingS (http://wingsframework.org).
*
* wingS is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* Please see COPYING for the complete licence.
*/
package org.wings.plaf.css;
import org.wings.*;
import org.wings.io.Device;
import org.wings.plaf.LayoutCG;
import java.io.IOException;
public class CardLayoutCG implements LayoutCG {
private static final long serialVersionUID = 1L;
/**
* @param d the device to write the code to
* @param l the layout manager
* @throws IOException
*/
@Override
public void write(Device d, SLayoutManager l)
throws IOException
{
SCardLayout cardLayout = (SCardLayout) l;
SContainer container = l.getContainer();
SComponent c = cardLayout.getVisibleComponent();
SDimension preferredSize = container.getPreferredSize();
String height = preferredSize != null ? preferredSize.getHeight() : null;
boolean clientLayout = Utils.isMSIE(container) && height != null && !"auto".equals(height);
if (clientLayout)
d.print("");
else
openLayouterRow(d, "100%");
openLayouterCell(d, c);
// Just present visible component
if (c != null) {
c.write(d);
}
closeLayouterCell(d);
closeLayouterRow(d);
}
public static void openLayouterRow(final Device d, String height) throws IOException {
d.print(" ");
}
public static void openLayouterCell(final Device d, SComponent component) throws IOException {
d.print("");
}
public static void closeLayouterCell(final Device d) throws IOException {
d.print(" ");
}
public static void closeLayouterRow(final Device d) throws IOException {
d.print(" ");
}
}