All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wings.plaf.css.PaddingVoodoo Maven / Gradle / Ivy

The newest version!
// (c) copyright 2006 by eXXcellent solutions, Ulm. Author: bschmid

package org.wings.plaf.css;

import org.wings.SComponent;
import org.wings.border.SBorder;
import org.wings.io.Device;
import org.wings.plaf.css.Utils;

import java.io.IOException;
import java.awt.*;

/**
 * This class collect various rendering workaround methods needed to fix issues with the Microsoft Internet Explorer.
 * It is primarily kept as separate utility class for documentational and reference purpose!
 * 

* The methods call here should extensively document what they do and why to be maintainable. * * @author Benjamin Schmid */ public final class PaddingVoodoo { private PaddingVoodoo() { } // // MSIE TABLE Padding Voodooo section -------------------------------------------------------------------------------------- // /** * @param component The component to inspect * @return true if the componentn has any padding insets requiring workaround */ public static boolean hasPaddingInsets(final SComponent component) { if (component == null || component.getBorder() == null) return false; final Insets insets = component.getBorder().getInsets(); return insets != null && (insets.top > 0 || insets.left >0 || insets.right > 0 || insets.bottom > 0); } /** * Utility method to add selected border's insets to the targetInsets. * @param border border containing insets * @param targetInsets Target inset to modify * @param firstRow if true, add top to top * @param firstCol if true, add left to left * @param lastCol if true, add right to right * @param lastRow if true, add bottom to bottom */ public static void doBorderPaddingsWorkaround(final SBorder border, final Insets targetInsets, boolean firstRow, boolean firstCol, boolean lastCol, boolean lastRow) { if (border != null && border.getInsets() != null) { final Insets paddingInset = border.getInsets(); if (firstRow) targetInsets.top += paddingInset.top; if (firstCol) targetInsets.left += paddingInset.left; if (lastCol) targetInsets.right+= paddingInset.right; if (lastRow) targetInsets.bottom+= paddingInset.bottom; } } /** * MSIE does not support PADDING on table elements. * For borders we re-render their insets (which are paddings) on the inner TD elements. *

* Call this method after <TD and before > * @param d target device * @param component source component */ public static void doSimpleTablePaddingWorkaround(final Device d, final SComponent component) throws IOException { if (component == null) return; if (component.getBorder() != null && Utils.hasInsets(component.getBorder().getInsets())) { final StringBuilder stringBuilder = new StringBuilder(); Utils.createInlineStylesForInsets(stringBuilder, component.getBorder().getInsets()); Utils.optAttribute(d, "style", stringBuilder); } } // // MSIE ????????????????? section -------------------------------------------------------------------------------------- // }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy