Package org.gwtoolbox.sample.widget.client.panel

Source Code of org.gwtoolbox.sample.widget.client.panel.FixedHorizontalPanelSamplePane

package org.gwtoolbox.sample.widget.client.panel;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.SimplePanel;
import org.gwtoolbox.ioc.core.client.annotation.Component;
import org.gwtoolbox.ioc.core.client.annotation.Order;
import org.gwtoolbox.sample.widget.client.SamplePanel;
import org.gwtoolbox.widget.client.panel.*;
import org.gwtoolbox.widget.client.panel.layout.HorizontalLayoutData;

/**
* @author Uri Boness
*/
@Component
@Order(1)
@PanelSample
public class FixedHorizontalPanelSamplePane extends LayoutComposite implements SamplePanel {

    public FixedHorizontalPanelSamplePane() {

        FixedHorizontalPanel fhp = new FixedHorizontalPanel();
        DOM.setStyleAttribute(fhp.getElement(), "borderBottom", "1px solid blue");
        fhp.addWidget(createContent("width: 70px", "#CCFFCC", "BLUE"), new HorizontalLayoutData().setWidth("70px"));
        Widget content = createContent("width: 50%", "#FFFBA3", "GREEN");
        content.setVisible(true);
        fhp.addWidget(content, new HorizontalLayoutData().setWidth("50%"));
        fhp.addWidget(createContent("width: *", "#FFC0CB", "black"));
        fhp.addWidget(createContent("width: 50px", "#E6E6FA", "yellow"), new HorizontalLayoutData("50px"));
        fhp.addWidget(createContent("width: *", "orange", "cyan"));

        FitPanel panel = new FitPanel();
        panel.setSize("100%", "400px");

        panel.setWidget(fhp);

        SimplePanel sp = new SimplePanel();
        sp.setSize("400px", "100%");
        sp.setWidget(panel);

        initWidget(sp);
    }

    public String getName() {
        return "FixedHorizontalPanel";
    }

    public Widget getContentWidget() {
        return this;
    }

    public void reset() {
    }


    //================================================ Helper Methods ==================================================

    private static Widget createContent(String text, String color, String borderColor) {
        HTML html = new HTML(text);
        DOM.setStyleAttribute(html.getElement(), "backgroundColor", color);
        DOM.setStyleAttribute(html.getElement(), "border", "5px solid " + borderColor);
//        DOM.setStyleAttribute(html.getElement(), "-mozBoxSizing", "padding-box");
        html.setSize("100%", "100%");
        return html;
    }
}
TOP

Related Classes of org.gwtoolbox.sample.widget.client.panel.FixedHorizontalPanelSamplePane

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.