01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.samples.explorer.client;
09:
10: import net.mygwt.samples.resources.client.TestData;
11: import net.mygwt.ui.client.MyDOM;
12: import net.mygwt.ui.client.Style;
13: import net.mygwt.ui.client.widget.ContentPanel;
14: import net.mygwt.ui.client.widget.ExpandBar;
15: import net.mygwt.ui.client.widget.ExpandItem;
16: import net.mygwt.ui.client.widget.WidgetContainer;
17: import net.mygwt.ui.client.widget.layout.BorderLayout;
18: import net.mygwt.ui.client.widget.layout.BorderLayoutData;
19: import net.mygwt.ui.client.widget.layout.FillLayout;
20:
21: import com.google.gwt.user.client.DOM;
22: import com.google.gwt.user.client.ui.SimplePanel;
23:
24: public class NestedBorderLayoutPage extends Page {
25:
26: protected void createWidget(WidgetContainer container) {
27: WidgetContainer c = new WidgetContainer();
28: c.setStyleName("my-border-layout");
29: c.setLayout(new BorderLayout());
30:
31: ContentPanel west = new ContentPanel(Style.HEADER);
32: west.setLayout(new FillLayout());
33: west.setText("West");
34: // hide border of content panel header
35: west.getHeader().setStyleAttribute("borderBottom", "none");
36:
37: ExpandBar expandBar = new ExpandBar(Style.SINGLE | Style.HEADER);
38: expandBar.setBorders(false);
39: fillBar(expandBar);
40: west.add(expandBar);
41:
42: WidgetContainer main = new WidgetContainer();
43: BorderLayout layout = new BorderLayout();
44: layout.setMargin(0);
45: main.setLayout(layout);
46:
47: ContentPanel top = new ContentPanel(Style.HEADER);
48: top.setText("Top Panel");
49:
50: SimplePanel bottom = new SimplePanel();
51: MyDOM.setStyleName(bottom.getElement(), "my-border");
52: DOM.setStyleAttribute(bottom.getElement(), "backgroundColor",
53: "white");
54:
55: WidgetContainer btm = new WidgetContainer();
56: btm.setBorders(true);
57: btm.setStyleAttribute("backgroundColor", "white");
58:
59: // use percentages for top panel height
60: main.add(top, new BorderLayoutData(Style.NORTH, .5f, 100, 400));
61: main.add(btm, new BorderLayoutData(Style.CENTER));
62:
63: c.add(west, new BorderLayoutData(Style.WEST, 150, 100, 300));
64: c.add(main, new BorderLayoutData(Style.CENTER));
65:
66: container.setLayout(new FillLayout(8));
67: container.add(c);
68:
69: }
70:
71: private void fillBar(ExpandBar expandBar) {
72: ExpandItem item1 = new ExpandItem();
73: item1.setText("Item 1");
74: item1.getContainer().addText(TestData.DUMMY_TEXT_SHORT);
75: expandBar.add(item1);
76:
77: ExpandItem item2 = new ExpandItem();
78: item2.setText("Item 2");
79: item2.getContainer().addText(TestData.DUMMY_TEXT_SHORT);
80: expandBar.add(item2);
81:
82: ExpandItem item3 = new ExpandItem();
83: item3.setText("Item 3");
84: item3.getContainer().addText(TestData.DUMMY_TEXT_SHORT);
85: expandBar.add(item3);
86:
87: item1.setExpanded(true);
88: }
89:
90: }
|