3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.container.Viewport
17 * @extends Ext.container.Container
19 A specialized container representing the viewable application area (the browser viewport).
21 The Viewport renders itself to the document body, and automatically sizes itself to the size of
22 the browser viewport and manages window resizing. There may only be one Viewport created
25 Like any {@link Ext.container.Container Container}, a Viewport will only perform sizing and positioning
26 on its child Components if you configure it with a {@link #layout}.
28 A Common layout used with Viewports is {@link Ext.layout.container.Border border layout}, but if the
29 required layout is simpler, a different layout should be chosen.
31 For example, to simply make a single child item occupy all available space, use {@link Ext.layout.container.Fit fit layout}.
33 To display one "active" item at full size from a choice of several child items, use {@link Ext.layout.container.Card card layout}.
35 Inner layouts are available by virtue of the fact that all {@link Ext.panel.Panel Panel}s
36 added to the Viewport, either through its {@link #items}, or through the items, or the {@link #add}
37 method of any of its child Panels may themselves have a layout.
39 The Viewport does not provide scrolling, so child Panels within the Viewport should provide
40 for scrolling if needed using the {@link #autoScroll} config.
41 {@img Ext.container.Viewport/Ext.container.Viewport.png Ext.container.Viewport component}
42 An example showing a classic application border layout:
44 Ext.create('Ext.container.Viewport', {
46 renderTo: Ext.getBody(),
49 html: '<h1 class="x-panel-header">Page Title</h1>',
58 // could use a TreePanel or AccordionLayout for navigational items
63 html: 'Information goes here',
75 xtype: 'tabpanel', // TabPanel itself has no title
76 activeTab: 0, // First tab active by default
79 html: 'The first tab\'s content. Others may be added dynamically'
86 Ext.define('Ext.container.Viewport', {
87 extend: 'Ext.container.Container',
88 alias: 'widget.viewport',
89 requires: ['Ext.EventManager'],
90 alternateClassName: 'Ext.Viewport',
93 * Privatize config options which, if used, would interfere with the
94 * correct operation of the Viewport as the sole manager of the
95 * layout of the document body.
98 * @cfg {Mixed} applyTo @hide
101 * @cfg {Boolean} allowDomMove @hide
104 * @cfg {Boolean} hideParent @hide
107 * @cfg {Mixed} renderTo @hide
110 * @cfg {Boolean} hideParent @hide
113 * @cfg {Number} height @hide
116 * @cfg {Number} width @hide
119 * @cfg {Boolean} autoHeight @hide
122 * @cfg {Boolean} autoWidth @hide
125 * @cfg {Boolean} deferHeight @hide
128 * @cfg {Boolean} monitorResize @hide
133 ariaRole: 'application',
134 initComponent : function() {
136 html = Ext.fly(document.body.parentNode),
138 me.callParent(arguments);
139 html.addCls(Ext.baseCSSPrefix + 'viewport');
141 html.setStyle('overflow', 'auto');
143 me.el = el = Ext.getBody();
144 el.setHeight = Ext.emptyFn;
145 el.setWidth = Ext.emptyFn;
146 el.setSize = Ext.emptyFn;
147 el.dom.scroll = 'no';
148 me.allowDomMove = false;
149 Ext.EventManager.onWindowResize(me.fireResize, me);
151 me.width = Ext.core.Element.getViewportWidth();
152 me.height = Ext.core.Element.getViewportHeight();
155 fireResize : function(w, h){
156 // setSize is the single entry point to layouts