com.google.gwt.user.client.ui.DecoratedStackPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.gwt-servlet
Show all versions of org.apache.servicemix.bundles.gwt-servlet
This OSGi bundle wraps ${pkgArtifactId} ${pkgVersion} jar file.
The newest version!
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.user.client.ui;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
/**
*
* A {@link StackPanel} that wraps each item in a 2x3 grid (six box), which
* allows users to add rounded corners.
*
*
*
* This widget will only work in quirks mode. If your application is in
* Standards Mode, use {@link StackLayoutPanel} instead.
*
*
*
*
CSS Style Rules
*
* - .gwt-DecoratedStackPanel { the panel itself }
* - .gwt-DecoratedStackPanel .gwt-StackPanelItem { unselected items }
* - .gwt-DecoratedStackPanel .gwt-StackPanelItem-selected { selected items }
* - .gwt-DecoratedStackPanel .gwt-StackPanelContent { the wrapper around the
* contents of the item }
* - .gwt-DecoratedStackPanel .stackItemTopLeft { top left corner of the
* item}
* - .gwt-DecoratedStackPanel .stackItemTopLeftInner { the inner element of
* the cell}
* - .gwt-DecoratedStackPanel .stackItemTopCenter { top center of the item}
* - .gwt-DecoratedStackPanel .stackItemTopCenterInner { the inner element of
* the cell}
* - .gwt-DecoratedStackPanel .stackItemTopRight { top right corner of the
* item}
* - .gwt-DecoratedStackPanel .stackItemTopRightInner { the inner element of
* the cell}
* - .gwt-DecoratedStackPanel .stackItemMiddleLeft { left side of the item }
* - .gwt-DecoratedStackPanel .stackItemMiddleLeftInner { the inner element
* of the cell}
* - .gwt-DecoratedStackPanel .stackItemMiddleCenter { center of the item,
* where the item text resides }
* - .gwt-DecoratedStackPanel .stackItemMiddleCenterInner { the inner element
* of the cell}
* - .gwt-DecoratedStackPanel .stackItemMiddleRight { right side of the item }
* - .gwt-DecoratedStackPanel .stackItemMiddleRightInner { the inner element
* of the cell}
*
*
*
* @see StackLayoutPanel
*/
public class DecoratedStackPanel extends StackPanel {
public static final String DEFAULT_STYLENAME = "gwt-DecoratedStackPanel";
private static final String[] DEFAULT_ROW_STYLENAMES = {
"stackItemTop", "stackItemMiddle"};
/**
* Creates an empty decorated stack panel.
*/
public DecoratedStackPanel() {
super();
setStylePrimaryName(DEFAULT_STYLENAME);
}
@Override
Element createHeaderElem() {
// Create the table
Element table = DOM.createTable();
Element tbody = DOM.createTBody();
DOM.appendChild(table, tbody);
table.getStyle().setProperty("width", "100%");
table.setPropertyInt("cellSpacing", 0);
table.setPropertyInt("cellPadding", 0);
// Add the decorated rows
for (int i = 0; i < DEFAULT_ROW_STYLENAMES.length; i++) {
DOM.appendChild(tbody, DecoratorPanel.createTR(DEFAULT_ROW_STYLENAMES[i]));
}
// Return the table
return table;
}
@Override
Element getHeaderTextElem(Element headerElem) {
Element tbody = DOM.getFirstChild(headerElem);
Element tr = DOM.getChild(tbody, 1);
Element td = DOM.getChild(tr, 1);
return DOM.getFirstChild(td);
}
}