001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008: package com.gwtext.sample.showcase2.client.layout;
009:
010: import com.gwtext.client.core.EventObject;
011: import com.gwtext.client.widgets.Button;
012: import com.gwtext.client.widgets.Component;
013: import com.gwtext.client.widgets.ComponentMgr;
014: import com.gwtext.client.widgets.Panel;
015: import com.gwtext.client.widgets.event.ButtonListenerAdapter;
016: import com.gwtext.client.widgets.layout.FitLayout;
017: import com.gwtext.client.widgets.layout.RowLayout;
018: import com.gwtext.client.widgets.layout.RowLayoutData;
019: import com.gwtext.sample.showcase2.client.ShowcasePanel;
020:
021: public class RowLayoutSample extends ShowcasePanel {
022:
023: public String getSourceUrl() {
024: return "source/layout/RowLayoutSample.java.html";
025: }
026:
027: public Panel getViewPanel() {
028: if (panel == null) {
029:
030: panel = new Panel();
031: panel.setLayout(new FitLayout());
032:
033: final Panel wrapperPanel = new Panel();
034: wrapperPanel.setLayout(new RowLayout());
035: wrapperPanel.setBorder(true);
036: wrapperPanel
037: .setBodyStyle("border-style:dotted;border-color:blue;");
038:
039: Panel firstPanel = new Panel();
040: firstPanel.setTitle("My Height is 75px");
041: firstPanel.setClosable(true);
042:
043: final Button removeGreedyButton = new Button(
044: "Remove Greedy Panel", new ButtonListenerAdapter() {
045: public void onClick(Button button, EventObject e) {
046: wrapperPanel.remove("greedy");
047: button.disable();
048: }
049: });
050:
051: final Button showHideButton = new Button(
052: "Show / Hide Bottom Panel",
053: new ButtonListenerAdapter() {
054: public void onClick(Button button, EventObject e) {
055: Component b = ComponentMgr
056: .getComponent("bottom");
057: b.setVisible(!b.isVisible());
058: }
059: });
060: firstPanel.add(showHideButton);
061: firstPanel.add(removeGreedyButton);
062:
063: wrapperPanel.add(firstPanel, new RowLayoutData(75));
064:
065: Panel secondPanel = new Panel();
066: secondPanel.setTitle("I will take half of the free space!");
067: secondPanel
068: .setHtml(" I am greedy <br><br><br><br><br><br><br><br><br><br><br><br><br><br>"
069: + "<br><br><br><br>...");
070: secondPanel.setId("greedy");
071: secondPanel.setCollapsible(true);
072: secondPanel.setAutoScroll(true);
073: secondPanel.setBodyStyle("margin-bottom:10px");
074:
075: wrapperPanel.add(secondPanel, new RowLayoutData("50%"));
076:
077: Panel third = new Panel();
078: third.setTitle("I'll take some too");
079: third
080: .setHtml("..if you don't mind. I don't have a <tt>height</tt> in the config.<br>Btw, "
081: + "you can resize me!<br><br><br><br><br><br><br><br><br><br><br><br><br>"
082: + "<br><br><br><br><br>...");
083: third.setId("panel3");
084: third.setAutoScroll(true);
085: wrapperPanel.add(third);
086:
087: Panel fourth = new Panel();
088: fourth.setId("slider");
089: wrapperPanel.add(fourth, new RowLayoutData(5));
090:
091: Panel fifth = new Panel();
092: fifth.setTitle("Let me settle too");
093: fifth
094: .setHtml("Since there are two of us without <tt>height</tt> given, each will take 1/2 "
095: + "of the unallocated space (which is 50%), that's why my height initially is 25%."
096: + "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>...");
097: fifth.setAutoScroll(true);
098: wrapperPanel.add(fifth);
099:
100: Panel sixth = new Panel();
101: sixth.setTitle("I'm the panel with height in pixels too");
102: sixth.setHtml("Nothing special, 60px panel");
103: sixth.setId("bottom");
104: wrapperPanel.add(sixth, new RowLayoutData(60));
105:
106: panel.add(wrapperPanel);
107: }
108: return panel;
109: }
110: }
|