Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.layout.container.Anchor.html
1 <!DOCTYPE html><html><head><title>Ext.layout.container.Anchor | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.layout.container.Anchor',
13         docClass: 'Ext.layout.container.Anchor',
14         docReq: 'Ext.layout.container.Anchor',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'Anchor.html#Ext-layout.container.Anchor';
33     clsInfo = {"methods":["getLayoutItems","getRenderTarget","getTarget"],"cfgs":["anchor","bindToOwnerCtComponent","bindToOwnerCtContainer","defaultAnchor","itemCls"],"properties":[],"events":[],"subclasses":["Ext.layout.container.Absolute"]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Anchor.html#Ext-layout.container.Anchor" target="_blank">Ext.layout.container.Anchor</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><pre class="subclasses"><h4>Hierarchy</h4><div class="subclass f"><a href="Ext.layout.Layout.html" rel="Ext.layout.Layout" class="cls docClass">Ext.layout.Layout</a><div class="subclass"><a href="Ext.layout.container.AbstractContainer.html" rel="Ext.layout.container.AbstractContainer" class="cls docClass">Ext.layout.container.AbstractContainer</a><div class="subclass"><a href="Ext.layout.container.Container.html" rel="Ext.layout.container.Container" class="cls docClass">Ext.layout.container.Container</a><div class="subclass"><strong>Ext.layout.container.Anchor</strong></div></div></div></div></pre><p>This is a layout that enables anchoring of contained elements relative to the container's dimensions.
38 If the container is resized, all anchored items are automatically rerendered according to their
39 <b><tt><a href="Ext.layout.container.Anchor.html#anchor" rel="Ext.layout.container.Anchor#anchor" class="docClass">anchor</a></tt></b> rules.</p>
40
41 <p>This class is intended to be extended or created via the layout: 'anchor' <a href="Ext.layout.container.AbstractContainer.html#layout" rel="Ext.layout.container.AbstractContainer#layout" class="docClass">Ext.layout.container.AbstractContainer.layout</a>
42 config, and should generally not need to be created directly via the new keyword.</p></p>
43
44 <p>AnchorLayout does not have any direct config options (other than inherited ones). By default,
45 AnchorLayout will calculate anchor measurements based on the size of the container itself. However, the
46 container using the AnchorLayout can supply an anchoring-specific config property of <b>anchorSize</b>.
47 If anchorSize is specifed, the layout will use it as a virtual container for the purposes of calculating
48 anchor measurements based on it instead, allowing the container to be sized independently of the anchoring
49 logic if necessary.</p>
50
51 <p><img class="screenshot" src="../Ext.layout.container.Anchor.png" alt="Ext.layout.container.Anchor container layout" /></p>
52
53 <p>For example:</p>
54
55 <pre class="prettyprint"><code>Ext.create('Ext.Panel', {
56     width: 500,
57     height: 400,
58     title: "AnchorLayout Panel",
59     layout: 'anchor',
60     renderTo: Ext.getBody(),
61     items: [{
62         xtype: 'panel',
63         title: '75% Width and 20% Height',
64         anchor: '75% 20%'
65     },{
66         xtype: 'panel',
67         title: 'Offset -300 Width &amp; -200 Height',
68         anchor: '-300 -200'     
69     },{
70         xtype: 'panel',
71         title: 'Mixed Offset and Percent',
72         anchor: '-250 20%'
73     }]
74 });
75 </code></pre>
76 <div class="members"><div class="m-cfgs"><div class="definedBy">Defined By</div><a name="configs"></a><h3 class="cfg p">Config Options</h3><h4 class="cfgGroup">CSS Class configs</h4><div id="config-itemCls" class="member f inherited"><a href="Ext.layout.container.Anchor.html#config-itemCls" rel="config-itemCls" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-cfg-itemCls" class="viewSource">view source</a></div><a name="itemCls"></a><a name="config-itemCls"></a><a href="Ext.layout.container.Anchor.html#" rel="config-itemCls" class="cls expand">itemCls</a><span> : String</span></div><div class="description"><div class="short">An optional extra CSS class that will be added to the container. This can be useful for adding
77 customized styles to t...</div><div class="long"><p>An optional extra CSS class that will be added to the container. This can be useful for adding
78 customized styles to the container or any of its children using standard CSS rules. See
79 <a href="Ext.Component.html" rel="Ext.Component" class="docClass">Ext.Component</a>.<a href="Ext.Component.html#ctCls" rel="Ext.Component#ctCls" class="docClass">ctCls</a> also.</p>
80
81
82 <p></p></p>
83 </div></div></div><h4 class="cfgGroup">Other Configs</h4><div id="config-anchor" class="member f ni"><a href="Ext.layout.container.Anchor.html#config-anchor" rel="config-anchor" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.Anchor.html" class="definedIn docClass">Ext.layout.container.Anchor</a><br/><a href="../source/Anchor.html#Ext-layout.container.Anchor-cfg-anchor" class="viewSource">view source</a></div><a name="anchor"></a><a name="config-anchor"></a><a href="Ext.layout.container.Anchor.html#" rel="config-anchor" class="cls expand">anchor</a><span> : String</span></div><div class="description"><div class="short">This configuation option is to be applied to child items of a container managed by
84 this layout (ie. configured with l...</div><div class="long"><p>This configuation option is to be applied to <b>child <tt>items</tt></b> of a container managed by
85 this layout (ie. configured with <tt>layout:'anchor'</tt>).</p>
86
87
88 <br/>
89
90
91
92
93 <p>This value is what tells the layout how an item should be anchored to the container. <tt>items</tt>
94 added to an AnchorLayout accept an anchoring-specific config property of <b>anchor</b> which is a string
95 containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%').
96 The following types of anchor values are supported:<div class="mdetail-params"><ul>
97
98 <li><b>Percentage</b> : Any value between 1 and 100, expressed as a percentage.<div class="sub-desc">
99 The first anchor is the percentage width that the item should take up within the container, and the
100 second is the percentage height.  For example:
101 <pre><code>// two values specified
102 anchor: '100% 50%' // render item complete width of the container and
103                    // 1/2 height of the container
104 // one value specified
105 anchor: '100%'     // the width value; the height will default to auto
106 </code></pre></div></li>
107
108 <li><b>Offsets</b> : Any positive or negative integer value.<div class="sub-desc">
109 This is a raw adjustment where the first anchor is the offset from the right edge of the container,
110 and the second is the offset from the bottom edge. For example:
111 <pre><code>// two values specified
112 anchor: '-50 -100' // render item the complete width of the container
113                    // minus 50 pixels and
114                    // the complete height minus 100 pixels.
115 // one value specified
116 anchor: '-50'      // anchor value is assumed to be the right offset value
117                    // bottom offset will default to 0
118 </code></pre></div></li>
119
120 <li><b>Sides</b> : Valid values are <tt>'right'</tt> (or <tt>'r'</tt>) and <tt>'bottom'</tt>
121 (or <tt>'b'</tt>).<div class="sub-desc">
122 Either the container must have a fixed size or an anchorSize config value defined at render time in
123 order for these to have any effect.</div></li>
124
125 <li><b>Mixed</b> : <div class="sub-desc">
126 Anchor values can also be mixed as needed.  For example, to render the width offset from the container
127 right edge by 50 pixels and 75% of the container's height use:
128 <pre><code>anchor: '-50 75%'
129 </code></pre></div></li>
130
131
132 </ul></div>
133
134 </div></div></div><div id="config-bindToOwnerCtComponent" class="member inherited"><a href="Ext.layout.container.Anchor.html#config-bindToOwnerCtComponent" rel="config-bindToOwnerCtComponent" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-cfg-bindToOwnerCtComponent" class="viewSource">view source</a></div><a name="bindToOwnerCtComponent"></a><a name="config-bindToOwnerCtComponent"></a><a href="Ext.layout.container.Anchor.html#" rel="config-bindToOwnerCtComponent" class="cls expand">bindToOwnerCtComponent</a><span> : Boolean</span></div><div class="description"><div class="short"><p>Flag to notify the ownerCt Component on afterLayout of a change</p>
135 </div><div class="long"><p>Flag to notify the ownerCt Component on afterLayout of a change</p>
136 </div></div></div><div id="config-bindToOwnerCtContainer" class="member inherited"><a href="Ext.layout.container.Anchor.html#config-bindToOwnerCtContainer" rel="config-bindToOwnerCtContainer" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-cfg-bindToOwnerCtContainer" class="viewSource">view source</a></div><a name="bindToOwnerCtContainer"></a><a name="config-bindToOwnerCtContainer"></a><a href="Ext.layout.container.Anchor.html#" rel="config-bindToOwnerCtContainer" class="cls expand">bindToOwnerCtContainer</a><span> : Boolean</span></div><div class="description"><div class="short"><p>Flag to notify the ownerCt Container on afterLayout of a change</p>
137 </div><div class="long"><p>Flag to notify the ownerCt Container on afterLayout of a change</p>
138 </div></div></div><div id="config-defaultAnchor" class="member ni"><a href="Ext.layout.container.Anchor.html#config-defaultAnchor" rel="config-defaultAnchor" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.Anchor.html" class="definedIn docClass">Ext.layout.container.Anchor</a><br/><a href="../source/Anchor.html#Ext-layout.container.Anchor-cfg-defaultAnchor" class="viewSource">view source</a></div><a name="defaultAnchor"></a><a name="config-defaultAnchor"></a><a href="Ext.layout.container.Anchor.html#" rel="config-defaultAnchor" class="cls expand">defaultAnchor</a><span> : String</span></div><div class="description"><div class="short">default anchor for all child container items applied if no anchor or specific width is set on the child item.  Defaul...</div><div class="long"><p>default anchor for all child container items applied if no anchor or specific width is set on the child item.  Defaults to '100%'.</p>
139 </div></div></div><div id="config-itemCls" class="member inherited"><a href="Ext.layout.container.Anchor.html#config-itemCls" rel="config-itemCls" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-cfg-itemCls" class="viewSource">view source</a></div><a name="itemCls"></a><a name="config-itemCls"></a><a href="Ext.layout.container.Anchor.html#" rel="config-itemCls" class="cls expand">itemCls</a><span> : String</span></div><div class="description"><div class="short">An optional extra CSS class that will be added to the container. This can be useful for adding
140 customized styles to t...</div><div class="long"><p>An optional extra CSS class that will be added to the container. This can be useful for adding
141 customized styles to the container or any of its children using standard CSS rules. See
142 <a href="Ext.Component.html" rel="Ext.Component" class="docClass">Ext.Component</a>.<a href="Ext.Component.html#ctCls" rel="Ext.Component#ctCls" class="docClass">ctCls</a> also.</p>
143
144
145 <p></p></p>
146 </div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-getLayoutItems" class="member f inherited"><a href="Ext.layout.container.Anchor.html#method-getLayoutItems" rel="method-getLayoutItems" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-method-getLayoutItems" class="viewSource">view source</a></div><a name="getLayoutItems"></a><a name="method-getLayoutItems"></a><a href="Ext.layout.container.Anchor.html#" rel="method-getLayoutItems" class="cls expand">getLayoutItems</a> : Array</div><div class="description"><div class="short">Returns an array of child components either for a render phase (Performed in the beforeLayout method of the layout's
147 ...</div><div class="long"><p>Returns an array of child components either for a render phase (Performed in the beforeLayout method of the layout's
148 base class), or the layout phase (onLayout).</p>
149
150 <h3 class="pa">Returns</h3><ul><li><span class="pre">Array</span>&nbsp; &nbsp;<p>of child components</p>
151 </li></ul></div></div></div><div id="method-getRenderTarget" class="member inherited"><a href="Ext.layout.container.Anchor.html#method-getRenderTarget" rel="method-getRenderTarget" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-method-getRenderTarget" class="viewSource">view source</a></div><a name="getRenderTarget"></a><a name="method-getRenderTarget"></a><a href="Ext.layout.container.Anchor.html#" rel="method-getRenderTarget" class="cls expand">getRenderTarget</a> : Ext.core.Element</div><div class="description"><div class="short">Returns the element into which rendering must take place. Defaults to the owner Container's Ext.AbstractComponent.tar...</div><div class="long"><p>Returns the element into which rendering must take place. Defaults to the owner Container's <a href="Ext.AbstractComponent.html#targetEl" rel="Ext.AbstractComponent#targetEl" class="docClass">Ext.AbstractComponent.targetEl</a>.</p>
152
153
154 <p>May be overridden in layout managers which implement an inner element.</p>
155 <h3 class="pa">Returns</h3><ul><li><span class="pre">Ext.core.Element</span>&nbsp; &nbsp;
156 </li></ul></div></div></div><div id="method-getTarget" class="member inherited"><a href="Ext.layout.container.Anchor.html#method-getTarget" rel="method-getTarget" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.layout.container.AbstractContainer.html" class="definedIn docClass">Ext.layout.container.AbstractContainer</a><br/><a href="../source/AbstractContainer2.html#Ext-layout.container.AbstractContainer-method-getTarget" class="viewSource">view source</a></div><a name="getTarget"></a><a name="method-getTarget"></a><a href="Ext.layout.container.Anchor.html#" rel="method-getTarget" class="cls expand">getTarget</a> : Ext.core.Element</div><div class="description"><div class="short"><p>Returns the owner component's resize element.</p>
157 </div><div class="long"><p>Returns the owner component's resize element.</p>
158 <h3 class="pa">Returns</h3><ul><li><span class="pre">Ext.core.Element</span>&nbsp; &nbsp;
159 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>