All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.extjs.gxt.ui.client.widget.Viewport Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Sencha GXT 2.3.0 - Sencha for GWT
 * Copyright(c) 2007-2013, Sencha, Inc.
 * [email protected]
 * 
 * http://www.sencha.com/products/gxt/license/
 */
 package com.extjs.gxt.ui.client.widget;

import com.extjs.gxt.ui.client.GXT;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;

/**
 * A LayoutContainer that fills the browser window and monitors window resizing.
 * Viewports are best used for applications that will fill the browser without
 * window scrolling. Children of the viewport can allow scrolling.

* * Code snippet: * *
 * Viewport viewport = new Viewport();
 * viewport.add(new ContentPanel(), new MarginData(10));
 * RootPanel.get().add(viewport);
 * 
* *

* The viewport is not added to the root panel automatically. Is is not * necessary to call {@link #layout()} after adding the viewport to the * RootPanel. Layout will be called after being added to the root panel. * *

*
Inherited Events:
*
LayoutContainer AfterLayout *
ScrollContainer Scroll
*
Container BeforeAdd
*
Container Add
*
Container BeforeRemove
*
Container Remove
*
BoxComponent Move
*
BoxComponent Resize
*
Component Enable
*
Component Disable
*
Component BeforeHide
*
Component Hide
*
Component BeforeShow
*
Component Show
*
Component Attach
*
Component Detach
*
Component BeforeRender
*
Component Render
*
Component BrowserEvent
*
Component BeforeStateRestore
*
Component StateRestore
*
Component BeforeStateSave
*
Component SaveState
*
*/ public class Viewport extends LayoutContainer { private String loadingPanelId = "loading"; private boolean enableScroll; public Viewport() { monitorWindowResize = true; baseStyle = "x-viewport"; getFocusSupport().setIgnore(false); } /** * Returns the window resizing state. * * @return true if window scrolling is enabled */ public boolean getEnableScroll() { return enableScroll; } /** * The loading panel id. * * @return the id */ public String getLoadingPanelId() { return loadingPanelId; } public void onAttach() { setEnableScroll(enableScroll); setSize(Window.getClientWidth(), Window.getClientHeight()); super.onAttach(); GXT.hideLoadingPanel(loadingPanelId); } /** * Sets whether window scrolling is enabled. * * @param enableScroll the window scroll state */ public void setEnableScroll(boolean enableScroll) { this.enableScroll = enableScroll; Window.enableScrolling(enableScroll); } /** * The element id of the loading panel which will be hidden when the viewport * is attached (defaults to 'loading'). * * @param loadingPanelId the loading panel element id */ public void setLoadingPanelId(String loadingPanelId) { this.loadingPanelId = loadingPanelId; } @Override protected void onRender(Element parent, int index) { super.onRender(parent, 0); } @Override protected void onWindowResize(int width, int height) { setSize(width, height); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy