negge
26 Jun 2008, 5:36 AM
Leaving the height and width as Style.DEFAULT incorrectly renders the next widget on top of the first and does not use the components size, as indicated in the JavaDoc's.
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;
class SettingsTabItem extends TabItem {
public SettingsTabItem() {
setText("Settings");
}
protected void onRender(Element _parent,int _index) {
super.onRender(_parent,_index);
setLayout(new RowLayout(Orientation.HORIZONTAL));
ContentPanel left=new ContentPanel();
left.setHeading("Left");
left.setSize(150,250);
RowData data=new RowData();
//RowData data=new RowData(150,250);
data.setMargins(new Margins(10));
add(left,data);
ContentPanel right=new ContentPanel();
right.setHeading("Right");
right.setLayout(new RowLayout(Orientation.VERTICAL));
add(right,new RowData(1,1,new Margins(10,10,10,0)));
ContentPanel top=new ContentPanel();
top.setHeading("Top");
top.setHeight(200);
data=new RowData();
data.setMargins(new Margins(0));
right.add(top,data);
ContentPanel bottom=new ContentPanel();
bottom.setHeading("Bottom");
bottom.setLayout(new RowLayout(Orientation.HORIZONTAL));
right.add(bottom,new RowData(1,1,new Margins(10,0,0,0)));
ContentPanel left2=new ContentPanel();
left2.setHeading("Left 2");
left2.setSize(150,250);
data=new RowData();
//data=new RowData(150,250);
data.setMargins(new Margins(0));
bottom.add(left2,data);
ContentPanel right2=new ContentPanel();
right2.setHeading("Right 2");
bottom.add(right2,new RowData(1,1,new Margins(0,0,0,10)));
}
}
public class TestProject implements EntryPoint {
public void onModuleLoad() {
final Viewport viewport=new Viewport();
viewport.setLayout(new FillLayout());
RootPanel.get().add(viewport);
ContentPanel content=new ContentPanel();
content.setBorders(false);
content.setHeaderVisible(false);
content.setLayout(new FitLayout());
viewport.add(content);
TabPanel tabPanel=new TabPanel();
tabPanel.setTabScroll(true);
tabPanel.setBorderStyle(false);
tabPanel.setBodyBorder(false);
content.add(tabPanel);
tabPanel.add(new SettingsTabItem());
}
};Nathan
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;
class SettingsTabItem extends TabItem {
public SettingsTabItem() {
setText("Settings");
}
protected void onRender(Element _parent,int _index) {
super.onRender(_parent,_index);
setLayout(new RowLayout(Orientation.HORIZONTAL));
ContentPanel left=new ContentPanel();
left.setHeading("Left");
left.setSize(150,250);
RowData data=new RowData();
//RowData data=new RowData(150,250);
data.setMargins(new Margins(10));
add(left,data);
ContentPanel right=new ContentPanel();
right.setHeading("Right");
right.setLayout(new RowLayout(Orientation.VERTICAL));
add(right,new RowData(1,1,new Margins(10,10,10,0)));
ContentPanel top=new ContentPanel();
top.setHeading("Top");
top.setHeight(200);
data=new RowData();
data.setMargins(new Margins(0));
right.add(top,data);
ContentPanel bottom=new ContentPanel();
bottom.setHeading("Bottom");
bottom.setLayout(new RowLayout(Orientation.HORIZONTAL));
right.add(bottom,new RowData(1,1,new Margins(10,0,0,0)));
ContentPanel left2=new ContentPanel();
left2.setHeading("Left 2");
left2.setSize(150,250);
data=new RowData();
//data=new RowData(150,250);
data.setMargins(new Margins(0));
bottom.add(left2,data);
ContentPanel right2=new ContentPanel();
right2.setHeading("Right 2");
bottom.add(right2,new RowData(1,1,new Margins(0,0,0,10)));
}
}
public class TestProject implements EntryPoint {
public void onModuleLoad() {
final Viewport viewport=new Viewport();
viewport.setLayout(new FillLayout());
RootPanel.get().add(viewport);
ContentPanel content=new ContentPanel();
content.setBorders(false);
content.setHeaderVisible(false);
content.setLayout(new FitLayout());
viewport.add(content);
TabPanel tabPanel=new TabPanel();
tabPanel.setTabScroll(true);
tabPanel.setBorderStyle(false);
tabPanel.setBodyBorder(false);
content.add(tabPanel);
tabPanel.add(new SettingsTabItem());
}
};Nathan