Layout.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-layout-Layout'>/**
  19. </span> * Base Layout class - extended by ComponentLayout and ContainerLayout
  20. */
  21. Ext.define('Ext.layout.Layout', {
  22. requires: [
  23. 'Ext.XTemplate'
  24. ],
  25. uses: [ 'Ext.layout.Context' ],
  26. <span id='Ext-layout-Layout-property-isLayout'> /**
  27. </span> * @property {Boolean} isLayout
  28. * `true` in this class to identify an object as an instantiated Layout, or subclass thereof.
  29. */
  30. isLayout: true,
  31. initialized: false,
  32. running: false,
  33. autoSizePolicy: {
  34. setsWidth: 0,
  35. setsHeight: 0
  36. },
  37. statics: {
  38. layoutsByType: {},
  39. create: function(layout, defaultType) {
  40. var ClassManager = Ext.ClassManager,
  41. layoutsByType = this.layoutsByType,
  42. alias, className, config, layoutClass, type, load;
  43. if (!layout || typeof layout === 'string') {
  44. type = layout || defaultType;
  45. config = {};
  46. } else if (layout.isLayout) {
  47. return layout;
  48. } else {
  49. config = layout;
  50. type = layout.type || defaultType;
  51. }
  52. if (!(layoutClass = layoutsByType[type])) {
  53. alias = 'layout.' + type;
  54. className = ClassManager.getNameByAlias(alias);
  55. // this is needed to support demand loading of the class
  56. if (!className) {
  57. load = true;
  58. }
  59. layoutClass = ClassManager.get(className);
  60. if (load || !layoutClass) {
  61. return ClassManager.instantiateByAlias(alias, config || {});
  62. }
  63. layoutsByType[type] = layoutClass;
  64. }
  65. return new layoutClass(config);
  66. }
  67. },
  68. constructor : function(config) {
  69. var me = this;
  70. me.id = Ext.id(null, me.type + '-');
  71. Ext.apply(me, config);
  72. me.layoutCount = 0;
  73. },
  74. <span id='Ext-layout-Layout-property-done'> /**
  75. </span> * @property {Boolean} done Used only during a layout run, this value indicates that a
  76. * layout has finished its calculations. This flag is set to true prior to the call to
  77. * {@link #calculate} and should be set to false if this layout has more work to do.
  78. */
  79. <span id='Ext-layout-Layout-method-beginLayout'> /**
  80. </span> * Called before any calculation cycles to prepare for layout.
  81. *
  82. * This is a write phase and DOM reads should be strictly avoided when overridding
  83. * this method.
  84. *
  85. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  86. * component.
  87. * @method beginLayout
  88. */
  89. beginLayout: Ext.emptyFn,
  90. <span id='Ext-layout-Layout-method-beginLayoutCycle'> /**
  91. </span> * Called before any calculation cycles to reset DOM values and prepare for calculation.
  92. *
  93. * This is a write phase and DOM reads should be strictly avoided when overridding
  94. * this method.
  95. *
  96. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  97. * component.
  98. * @method beginLayoutCycle
  99. */
  100. beginLayoutCycle: function (ownerContext) {
  101. var me = this,
  102. context = me.context,
  103. changed;
  104. if (me.lastWidthModel != ownerContext.widthModel) {
  105. if (me.lastWidthModel) {
  106. changed = true;
  107. }
  108. me.lastWidthModel = ownerContext.widthModel;
  109. }
  110. if (me.lastHeightModel != ownerContext.heightModel) {
  111. if (me.lastWidthModel) {
  112. changed = true;
  113. }
  114. me.lastHeightModel = ownerContext.heightModel;
  115. }
  116. if (changed) {
  117. (context = ownerContext.context).clearTriggers(me, false);
  118. context.clearTriggers(me, true);
  119. me.triggerCount = 0;
  120. }
  121. },
  122. <span id='Ext-layout-Layout-method-calculate'> /**
  123. </span> * Called to perform the calculations for this layout. This method will be called at
  124. * least once and may be called repeatedly if the {@link #done} property is cleared
  125. * before return to indicate that this layout is not yet done. The {@link #done} property
  126. * is always set to `true` before entering this method.
  127. *
  128. * This is a read phase and DOM writes should be strictly avoided in derived classes.
  129. * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to
  130. * be flushed at the next opportunity.
  131. *
  132. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  133. * component.
  134. * @method calculate
  135. * @abstract
  136. */
  137. <span id='Ext-layout-Layout-method-completeLayout'> /**
  138. </span> * This method (if implemented) is called at the end of the cycle in which this layout
  139. * completes (by not setting {@link #done} to `false` in {@link #calculate}). It is
  140. * possible for the layout to complete and yet become invalid before the end of the cycle,
  141. * in which case, this method will not be called. It is also possible for this method to
  142. * be called and then later the layout becomes invalidated. This will result in
  143. * {@link #calculate} being called again, followed by another call to this method.
  144. *
  145. * This is a read phase and DOM writes should be strictly avoided in derived classes.
  146. * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to
  147. * be flushed at the next opportunity.
  148. *
  149. * This method need not be implemented by derived classes and, in fact, should only be
  150. * implemented when needed.
  151. *
  152. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  153. * component.
  154. * @method completeLayout
  155. */
  156. <span id='Ext-layout-Layout-method-finalizeLayout'> /**
  157. </span> * This method (if implemented) is called after all layouts have completed. In most
  158. * ways this is similar to {@link #completeLayout}. This call can cause this (or any
  159. * layout) to be become invalid (see {@link Ext.layout.Context#invalidate}), but this
  160. * is best avoided. This method is intended to be where final reads are made and so it
  161. * is best to avoid invalidating layouts at this point whenever possible. Even so, this
  162. * method can be used to perform final checks that may require all other layouts to be
  163. * complete and then invalidate some results.
  164. *
  165. * This is a read phase and DOM writes should be strictly avoided in derived classes.
  166. * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to
  167. * be flushed at the next opportunity.
  168. *
  169. * This method need not be implemented by derived classes and, in fact, should only be
  170. * implemented when needed.
  171. *
  172. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  173. * component.
  174. * @method finalizeLayout
  175. */
  176. <span id='Ext-layout-Layout-method-finishedLayout'> /**
  177. </span> * This method is called after all layouts are complete and their calculations flushed
  178. * to the DOM. No further layouts will be run and this method is only called once per
  179. * layout run. The base component layout caches `lastComponentSize`.
  180. *
  181. * This is a write phase and DOM reads should be avoided if possible when overridding
  182. * this method.
  183. *
  184. * This method need not be implemented by derived classes and, in fact, should only be
  185. * implemented when needed.
  186. *
  187. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  188. * component.
  189. */
  190. finishedLayout: function () {
  191. this.ownerContext = null;
  192. },
  193. <span id='Ext-layout-Layout-method-notifyOwner'> /**
  194. </span> * This method (if implemented) is called after all layouts are finished, and all have
  195. * a `lastComponentSize` cached. No further layouts will be run and this method is only
  196. * called once per layout run. It is the bookend to {@link #beginLayout}.
  197. *
  198. * This is a write phase and DOM reads should be avoided if possible when overridding
  199. * this method. This is the catch-all tail method to a layout and so the rules are more
  200. * relaxed. Even so, for performance reasons, it is best to avoid reading the DOM. If
  201. * a read is necessary, consider implementing a {@link #finalizeLayout} method to do the
  202. * required reads.
  203. *
  204. * This method need not be implemented by derived classes and, in fact, should only be
  205. * implemented when needed.
  206. *
  207. * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner
  208. * component.
  209. * @method notifyOwner
  210. */
  211. redoLayout: Ext.emptyFn,
  212. undoLayout: Ext.emptyFn,
  213. getAnimatePolicy: function() {
  214. return this.animatePolicy;
  215. },
  216. <span id='Ext-layout-Layout-method-getItemSizePolicy'> /**
  217. </span> * Returns an object describing how this layout manages the size of the given component.
  218. * This method must be implemented by any layout that manages components.
  219. *
  220. * @param {Ext.Component} item
  221. *
  222. * @return {Object} An object describing the sizing done by the layout for this item or
  223. * null if the layout mimics the size policy of its ownerCt (e.g., 'fit' and 'card').
  224. * @return {Boolean} return.readsWidth True if the natural/auto width of this component
  225. * is used by the ownerLayout.
  226. * @return {Boolean} return.readsHeight True if the natural/auto height of this component
  227. * is used by the ownerLayout.
  228. * @return {Boolean} return.setsWidth True if the ownerLayout set this component's width.
  229. * @return {Boolean} return.setsHeight True if the ownerLayout set this component's height.
  230. *
  231. * @protected
  232. */
  233. getItemSizePolicy: function (item) {
  234. return this.autoSizePolicy;
  235. },
  236. isItemBoxParent: function (itemContext) {
  237. return false;
  238. },
  239. isItemLayoutRoot: function (item) {
  240. var sizeModel = item.getSizeModel(),
  241. width = sizeModel.width,
  242. height = sizeModel.height;
  243. // If this component has never had a layout and some of its dimensions are set by
  244. // its ownerLayout, we cannot be the layoutRoot...
  245. if (!item.componentLayout.lastComponentSize &amp;&amp; (width.calculated || height.calculated)) {
  246. return false;
  247. }
  248. // otherwise an ownerCt whose size is not effected by its content is a root
  249. return !width.shrinkWrap &amp;&amp; !height.shrinkWrap;
  250. },
  251. isItemShrinkWrap: function (item) {
  252. return item.shrinkWrap;
  253. },
  254. isRunning: function () {
  255. return !!this.ownerContext;
  256. },
  257. //-----------------------------------------------------
  258. /*
  259. * Clears any styles which must be cleared before layout can take place.
  260. * Only DOM WRITES must be performed at this stage.
  261. *
  262. * An entry for the owner's element ID must be created in the layoutContext containing
  263. * a reference to the target which must be sized/positioned/styled by the layout at
  264. * the flush stage:
  265. *
  266. * {
  267. * target: me.owner
  268. * }
  269. *
  270. * Component layouts should iterate through managed Elements,
  271. * pushing an entry for each element:
  272. *
  273. * {
  274. * target: childElement
  275. * }
  276. */
  277. //-----------------------------------------------------
  278. getItemsRenderTree: function (items, renderCfgs) {
  279. var length = items.length,
  280. i, item, itemConfig, result;
  281. if (length) {
  282. result = [];
  283. for (i = 0; i &lt; length; ++i) {
  284. item = items[i];
  285. // If we are being asked to move an already rendered Component, we must not recalculate its renderTree
  286. // and rerun its render process. The Layout's isValidParent check will ensure that the DOM is moved into place.
  287. if (!item.rendered) {
  288. // If we've already calculated the item's element config, don't calculate it again.
  289. // This may happen if the rendering process mutates the owning Container's items
  290. // collection, and Ext.layout.Container#getRenderTree runs through the collection again.
  291. // Note that the config may be null if a beforerender listener vetoed the operation, so
  292. // we must compare to undefined.
  293. if (renderCfgs &amp;&amp; (renderCfgs[item.id] !== undefined)) {
  294. itemConfig = renderCfgs[item.id];
  295. } else {
  296. // Perform layout preprocessing in the bulk render path
  297. this.configureItem(item);
  298. itemConfig = item.getRenderTree();
  299. if (renderCfgs) {
  300. renderCfgs[item.id] = itemConfig;
  301. }
  302. }
  303. // itemConfig mey be null if a beforerender listener vetoed the operation.
  304. if (itemConfig) {
  305. result.push(itemConfig);
  306. }
  307. }
  308. }
  309. }
  310. return result;
  311. },
  312. finishRender: Ext.emptyFn,
  313. finishRenderItems: function (target, items) {
  314. var length = items.length,
  315. i, item;
  316. for (i = 0; i &lt; length; i++) {
  317. item = items[i];
  318. // Only postprocess items which are being rendered. deferredRender may mean that only one has been rendered.
  319. if (item.rendering) {
  320. // Tell the item at which index in the Container it is
  321. item.finishRender(i);
  322. this.afterRenderItem(item);
  323. }
  324. }
  325. },
  326. renderChildren: function () {
  327. var me = this,
  328. items = me.getLayoutItems(),
  329. target = me.getRenderTarget();
  330. me.renderItems(items, target);
  331. },
  332. <span id='Ext-layout-Layout-method-renderItems'> /**
  333. </span> * Iterates over all passed items, ensuring they are rendered. If the items are already rendered,
  334. * also determines if the items are in the proper place in the dom.
  335. * @protected
  336. */
  337. renderItems : function(items, target) {
  338. var me = this,
  339. ln = items.length,
  340. i = 0,
  341. item;
  342. if (ln) {
  343. Ext.suspendLayouts();
  344. for (; i &lt; ln; i++) {
  345. item = items[i];
  346. if (item &amp;&amp; !item.rendered) {
  347. me.renderItem(item, target, i);
  348. } else if (!me.isValidParent(item, target, i)) {
  349. me.moveItem(item, target, i);
  350. } else {
  351. // still need to configure the item, it may have moved in the container.
  352. me.configureItem(item);
  353. }
  354. }
  355. Ext.resumeLayouts(true);
  356. }
  357. },
  358. <span id='Ext-layout-Layout-method-isValidParent'> /**
  359. </span> * Validates item is in the proper place in the dom.
  360. * @protected
  361. */
  362. isValidParent : function(item, target, position) {
  363. var itemDom = item.el ? item.el.dom : Ext.getDom(item),
  364. targetDom = (target &amp;&amp; target.dom) || target;
  365. // If it's resizable+wrapped, the position element is the wrapper.
  366. if (itemDom.parentNode &amp;&amp; itemDom.parentNode.className.indexOf(Ext.baseCSSPrefix + 'resizable-wrap') !== -1) {
  367. itemDom = itemDom.parentNode;
  368. }
  369. // Test DOM nodes for equality using &quot;===&quot; : http://jsperf.com/dom-equality-test
  370. if (itemDom &amp;&amp; targetDom) {
  371. if (typeof position == 'number') {
  372. return itemDom === targetDom.childNodes[position];
  373. }
  374. return itemDom.parentNode === targetDom;
  375. }
  376. return false;
  377. },
  378. <span id='Ext-layout-Layout-method-configureItem'> /**
  379. </span> * Called before an item is rendered to allow the layout to configure the item.
  380. * @param {Ext.Component} item The item to be configured
  381. * @protected
  382. */
  383. configureItem: function(item) {
  384. item.ownerLayout = this;
  385. },
  386. <span id='Ext-layout-Layout-method-renderItem'> /**
  387. </span> * Renders the given Component into the target Element.
  388. * @param {Ext.Component} item The Component to render
  389. * @param {Ext.dom.Element} target The target Element
  390. * @param {Number} position The position within the target to render the item to
  391. * @private
  392. */
  393. renderItem : function(item, target, position) {
  394. var me = this;
  395. if (!item.rendered) {
  396. me.configureItem(item);
  397. item.render(target, position);
  398. me.afterRenderItem(item);
  399. }
  400. },
  401. <span id='Ext-layout-Layout-method-moveItem'> /**
  402. </span> * Moves Component to the provided target instead.
  403. * @private
  404. */
  405. moveItem : function(item, target, position) {
  406. target = target.dom || target;
  407. if (typeof position == 'number') {
  408. position = target.childNodes[position];
  409. }
  410. target.insertBefore(item.el.dom, position || null);
  411. item.container = Ext.get(target);
  412. this.configureItem(item);
  413. },
  414. <span id='Ext-layout-Layout-method-onContentChange'> /**
  415. </span> * This method is called when a child item changes in some way. By default this calls
  416. * {@link Ext.AbstractComponent#updateLayout} on this layout's owner.
  417. *
  418. * @param {Ext.Component} child The child item that has changed.
  419. * @return {Boolean} True if this layout has handled the content change.
  420. */
  421. onContentChange: function () {
  422. this.owner.updateLayout();
  423. return true;
  424. },
  425. <span id='Ext-layout-Layout-method-initLayout'> /**
  426. </span> * A one-time initialization method called just before rendering.
  427. * @protected
  428. */
  429. initLayout : function() {
  430. this.initialized = true;
  431. },
  432. // @private Sets the layout owner
  433. setOwner : function(owner) {
  434. this.owner = owner;
  435. },
  436. <span id='Ext-layout-Layout-method-getLayoutItems'> /**
  437. </span> * Returns the set of items to layout (empty by default).
  438. * @protected
  439. */
  440. getLayoutItems : function() {
  441. return [];
  442. },
  443. // Placeholder empty functions for subclasses to extend
  444. afterRenderItem: Ext.emptyFn,
  445. onAdd : Ext.emptyFn,
  446. onRemove : Ext.emptyFn,
  447. onDestroy : Ext.emptyFn,
  448. <span id='Ext-layout-Layout-method-afterRemove'> /**
  449. </span> * Removes layout's itemCls and owning Container's itemCls.
  450. * Clears the managed dimensions flags
  451. * @protected
  452. */
  453. afterRemove : function(item) {
  454. var me = this,
  455. el = item.el,
  456. owner = me.owner,
  457. removeClasses;
  458. if (item.rendered) {
  459. removeClasses = [].concat(me.itemCls || []);
  460. if (owner.itemCls) {
  461. removeClasses = Ext.Array.push(removeClasses, owner.itemCls);
  462. }
  463. if (removeClasses.length) {
  464. el.removeCls(removeClasses);
  465. }
  466. }
  467. delete item.ownerLayout;
  468. },
  469. <span id='Ext-layout-Layout-method-destroy'> /**
  470. </span> * Destroys this layout. This method removes a `targetCls` from the `target`
  471. * element and calls `onDestroy`.
  472. *
  473. * A derived class can override either this method or `onDestroy` but in all
  474. * cases must call the base class versions of these methods to allow the base class to
  475. * perform its cleanup.
  476. *
  477. * This method (or `onDestroy`) are overridden by subclasses most often to purge
  478. * event handlers or remove unmanged DOM nodes.
  479. *
  480. * @protected
  481. */
  482. destroy : function() {
  483. var me = this,
  484. target;
  485. if (me.targetCls) {
  486. target = me.getTarget();
  487. if (target) {
  488. target.removeCls(me.targetCls);
  489. }
  490. }
  491. me.onDestroy();
  492. },
  493. sortWeightedItems: function (items, reverseProp) {
  494. for (var i = 0, length = items.length; i &lt; length; ++i) {
  495. items[i].$i = i;
  496. }
  497. Ext.Array.sort(items, function (item1, item2) {
  498. var ret = item2.weight - item1.weight;
  499. if (!ret) {
  500. ret = item1.$i - item2.$i;
  501. if (item1[reverseProp]) {
  502. ret = -ret;
  503. }
  504. }
  505. return ret;
  506. });
  507. for (i = 0; i &lt; length; ++i) {
  508. delete items[i].$i;
  509. }
  510. }
  511. }, function () {
  512. var Layout = this,
  513. sizeModels = {},
  514. sizeModelsArray = [],
  515. i, j, n, pairs, sizeModel;
  516. Layout.prototype.sizeModels = Layout.sizeModels = sizeModels;
  517. <span id='Ext-layout-SizeModel'> /**
  518. </span> * This class describes a size determination strategy or algorithm used by the layout
  519. * system. There are special instances of this class stored as static properties to
  520. * avoid needless object instantiation. These instances should be treated as readonly.
  521. *
  522. * * `calculated`
  523. * * `configured`
  524. * * `constrainedMax`
  525. * * `constrainedMin`
  526. * * `natural`
  527. * * `shrinkWrap`
  528. * * `calculatedFromConfigured`
  529. * * `calculatedFromNatural`
  530. * * `calculatedFromShrinkWrap`
  531. *
  532. * Using one of these instances is simply:
  533. *
  534. * var calculated = Ext.layout.SizeModel.calculated;
  535. *
  536. * @class Ext.layout.SizeModel
  537. * @protected
  538. */
  539. var SizeModel = function (config) {
  540. var me = this,
  541. name = config.name;
  542. Ext.apply(Ext.apply(me, defaults), config);
  543. me[name] = true; // set the one special flag that matches our name
  544. SizeModel[name] = sizeModels[name] = me;
  545. me.fixed = !(me.auto = me.natural || me.shrinkWrap);
  546. <span id='Ext-layout-SizeModel-property-ordinal'> /**
  547. </span> * @prop {Number} ordinal
  548. * The 0-based ordinal for this `SizeModel` instance.
  549. * @readonly
  550. */
  551. me.ordinal = sizeModelsArray.length;
  552. sizeModelsArray.push(me);
  553. };
  554. Ext.layout.SizeModel = SizeModel;
  555. var defaults = {
  556. <span id='Ext-layout-SizeModel-property-name'> /**
  557. </span> * @property {String} name
  558. * The name of this size model (e.g., &quot;calculated&quot;).
  559. * @readonly
  560. */
  561. <span id='Ext-layout-SizeModel-property-auto'> /**
  562. </span> * @property {Boolean} auto
  563. * True if the size is either `natural` or `shrinkWrap`, otherwise false.
  564. * @readonly
  565. */
  566. <span id='Ext-layout-SizeModel-property-calculated'> /**
  567. </span> * @property {Boolean} calculated
  568. * True if the size is calculated by the `ownerLayout`.
  569. * @readonly
  570. */
  571. calculated: false,
  572. <span id='Ext-layout-SizeModel-property-configured'> /**
  573. </span> * @property {Boolean} configured
  574. * True if the size is configured (e.g., by a `width` or `minWidth`). The names of
  575. * configuration properties can be found in the {@link #names} property.
  576. * @readonly
  577. */
  578. configured: false,
  579. <span id='Ext-layout-SizeModel-property-constrainedMax'> /**
  580. </span> * @property {Boolean} constrainedMax
  581. * True if the size is constrained by a `maxWidth` or `maxHeight` configuration. This
  582. * is a flavor of `configured` (since `maxWidth` and `maxHeight` are config options).
  583. * If true, the {@link #names} property will be defined as well.
  584. * @readonly
  585. */
  586. constrainedMax: false,
  587. <span id='Ext-layout-SizeModel-property-constrainedMin'> /**
  588. </span> * @property {Boolean} constrainedMin
  589. * True if the size is constrained by a `minWidth` or `minHeight` configuration. This
  590. * is a flavor of `configured` (since `minWidth` and `minHeight` are config options).
  591. * If true, the {@link #names} property will be defined as well.
  592. * @readonly
  593. */
  594. constrainedMin: false,
  595. <span id='Ext-layout-SizeModel-property-fixed'> /**
  596. </span> * @property {Boolean} fixed
  597. * True if the size is either `calculated` or `configured`, otherwise false.
  598. * @readonly
  599. */
  600. <span id='Ext-layout-SizeModel-property-natural'> /**
  601. </span> * @property {Boolean} natural
  602. * True if the size is determined by CSS and not by content. Such sizes are assumed to
  603. * be dependent on the container box and measurement occurs on the outer-most element.
  604. * @readonly
  605. */
  606. natural: false,
  607. <span id='Ext-layout-SizeModel-property-shrinkWrap'> /**
  608. </span> * @property {Boolean} shrinkWrap
  609. * True if the size is determined by content irrespective of the container box.
  610. * @readonly
  611. */
  612. shrinkWrap: false,
  613. <span id='Ext-layout-SizeModel-property-calculatedFromConfigured'> /**
  614. </span> * @property {Boolean} calculatedFromConfigured
  615. * True if the size is calculated by the `ownerLayout` based on a configured size.
  616. * @readonly
  617. */
  618. calculatedFromConfigured: false,
  619. <span id='Ext-layout-SizeModel-property-calculatedFromNatural'> /**
  620. </span> * @property {Boolean} calculatedFromNatural
  621. * True if the size is calculated by the `ownerLayout` based on `natural` size model
  622. * results.
  623. * @readonly
  624. */
  625. calculatedFromNatural: false,
  626. <span id='Ext-layout-SizeModel-property-calculatedFromShrinkWrap'> /**
  627. </span> * @property {Boolean} calculatedFromShrinkWrap
  628. * True if the size is calculated by the `ownerLayout` based on `shrinkWrap` size model
  629. * results.
  630. * @readonly
  631. */
  632. calculatedFromShrinkWrap: false,
  633. <span id='Ext-layout-SizeModel-property-names'> /**
  634. </span> * @property {Object} names An object with the config property names that determine the
  635. * size.
  636. * @property {String} names.width The width property name (e.g., 'width').
  637. * @property {String} names.height The height property name (e.g., 'minHeight').
  638. * @readonly
  639. */
  640. names: null
  641. };
  642. //-------------------------------------------------------------------------------
  643. // These are the 4 fundamental size models.
  644. new SizeModel({
  645. name: 'calculated'
  646. });
  647. new SizeModel({
  648. name: 'configured',
  649. names: { width: 'width', height: 'height' }
  650. });
  651. new SizeModel({
  652. name: 'natural'
  653. });
  654. new SizeModel({
  655. name: 'shrinkWrap'
  656. });
  657. //-------------------------------------------------------------------------------
  658. // These are the size models are flavors of the above but with some extra detail
  659. // about their dynamic use.
  660. new SizeModel({
  661. name: 'calculatedFromConfigured',
  662. configured: true,
  663. names: { width: 'width', height: 'height' }
  664. });
  665. new SizeModel({
  666. name: 'calculatedFromNatural',
  667. natural: true
  668. });
  669. new SizeModel({
  670. name: 'calculatedFromShrinkWrap',
  671. shrinkWrap: true
  672. });
  673. new SizeModel({
  674. name: 'constrainedMax',
  675. configured: true,
  676. constrained: true,
  677. names: { width: 'maxWidth', height: 'maxHeight' }
  678. });
  679. new SizeModel({
  680. name: 'constrainedMin',
  681. configured: true,
  682. constrained: true,
  683. names: { width: 'minWidth', height: 'minHeight' }
  684. });
  685. for (i = 0, n = sizeModelsArray.length; i &lt; n; ++i) {
  686. sizeModel = sizeModelsArray[i];
  687. <span id='Ext-layout-SizeModel-property-pairsByHeightOrdinal'> /**
  688. </span> * An array of objects indexed by the {@link #ordinal} of a height `SizeModel` on
  689. * a width `SizeModel` to yield an object describing both height and width size
  690. * models.
  691. *
  692. * Used like this:
  693. *
  694. * widthModel.pairsByHeightOrdinal[heightModel.ordinal]
  695. *
  696. * This provides a reusable object equivalent to the following:
  697. *
  698. * {
  699. * width: widthModel,
  700. * height: heightModel
  701. * }
  702. *
  703. * @property {Object[]} pairsByHeightOrdinal
  704. * @property {Ext.layout.SizeModel} pairsByHeightOrdinal.width The `SizeModel` for
  705. * the width.
  706. * @property {Ext.layout.SizeModel} pairsByHeightOrdinal.height The `SizeModel` for
  707. * the height.
  708. */
  709. sizeModel.pairsByHeightOrdinal = pairs = [];
  710. for (j = 0; j &lt; n; ++j) {
  711. pairs.push({
  712. width: sizeModel,
  713. height: sizeModelsArray[j]
  714. });
  715. }
  716. }
  717. });
  718. </pre>
  719. </body>
  720. </html>