Here's the code.
package com.test.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Tp implements EntryPoint
{
interface Binder extends UiBinder<Widget, Tp>
{
}
private static final Binder binder = GWT.create( Binder.class );
@UiField(provided=true) ScrollPanel scrollPanel = new MyScrollPanel();
@UiField AbsolutePanel absolutePanel;
@UiField HorizontalPanel horizontalPanel;
/**
* This is the entry point method.
*/
public void onModuleLoad()
{
binder.createAndBindUi( this );
RootLayoutPanel.get().getElement().getStyle().setBackgroundColor( "gray" );
scrollPanel.getElement().getStyle().setBackgroundColor( "yellow" );
absolutePanel.getElement().getStyle().setBackgroundColor( "green" );
absolutePanel.getElement().getStyle().setMargin( 0.0, Style.Unit.PX );
absolutePanel.getElement().getStyle().setBorderWidth( 0.0, Style.Unit.PX );
absolutePanel.getElement().getStyle().setBorderStyle( BorderStyle.NONE );
absolutePanel.getElement().getStyle().setBorderWidth( 0.0, Style.Unit.PX );
absolutePanel.getElement().getStyle().setPadding( 0.0, Style.Unit.PX );
horizontalPanel.getElement().getStyle().setBackgroundColor( "cyan" );
horizontalPanel.getElement().getStyle().setMargin( 0.0, Style.Unit.PX );
horizontalPanel.getElement().getStyle().setBorderWidth( 0.0, Style.Unit.PX );
horizontalPanel.getElement().getStyle().setBorderStyle( BorderStyle.NONE );
horizontalPanel.getElement().getStyle().setBorderWidth( 0.0, Style.Unit.PX );
horizontalPanel.getElement().getStyle().setPadding( 0.0, Style.Unit.PX );
RootLayoutPanel.get().add( scrollPanel );
scrollPanel.onResize();
}
private int SLOP = 1;
/*
*
*/
private class MyScrollPanel extends ScrollPanel
{
public void onResize()
{
System.out.println( "-- MyScrollPanel->onResize()" );
int w = RootLayoutPanel.get().getOffsetWidth();
int h = RootLayoutPanel.get().getOffsetHeight();
setWidth( w + "px" );
setHeight( h + "px" );
if( w < absolutePanel.getWidgetLeft( horizontalPanel ) + horizontalPanel.getOffsetWidth() )
w = absolutePanel.getWidgetLeft( horizontalPanel ) + horizontalPanel.getOffsetWidth();
if( h < absolutePanel.getWidgetTop( horizontalPanel ) + horizontalPanel.getOffsetHeight() )
h = absolutePanel.getWidgetTop( horizontalPanel ) + horizontalPanel.getOffsetHeight();
absolutePanel.setWidth( ((int)w - SLOP) + "px" );
absolutePanel.setHeight( ((int)h - SLOP) + "px" );
super.onResize();
System.out.println( " scrollpanel w=" + getOffsetWidth() + " h=" + getOffsetHeight() );
System.out.println( " absolutePanel w=" + absolutePanel.getOffsetWidth() + " h=" + absolutePanel.getOffsetHeight() );
System.out.println( "== MyScrollPanel->onResize()" );
}
}
}
uibinder:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:ScrollPanel ui:field="scrollPanel" width="100%" height="100%">
<g:AbsolutePanel width="" height="" ui:field="absolutePanel">
<g:at left="50" top="100">
<g:HorizontalPanel ui:field="horizontalPanel" width="360px" height="25px">
<g:Button width="180px" height="25px">Hello World</g:Button>
<g:Button width="180px" height="25px">Hello World</g:Button>
</g:HorizontalPanel>
</g:at>
</g:AbsolutePanel>
</g:ScrollPanel>
</ui:UiBinder>
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment