Draw2.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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-component-Draw'>/**
  19. </span> * @class Ext.layout.component.Draw
  20. * @private
  21. *
  22. */
  23. Ext.define('Ext.layout.component.Draw', {
  24. /* Begin Definitions */
  25. alias: 'layout.draw',
  26. extend: 'Ext.layout.component.Auto',
  27. /* End Definitions */
  28. type: 'draw',
  29. measureContentWidth : function (ownerContext) {
  30. var target = ownerContext.target,
  31. paddingInfo = ownerContext.getPaddingInfo(),
  32. bbox = this.getBBox(ownerContext);
  33. if (!target.viewBox) {
  34. if (target.autoSize) {
  35. return bbox.width + paddingInfo.width;
  36. } else {
  37. return bbox.x + bbox.width + paddingInfo.width;
  38. }
  39. } else {
  40. if (ownerContext.heightModel.shrinkWrap) {
  41. return paddingInfo.width;
  42. } else {
  43. return bbox.width / bbox.height * (ownerContext.getProp('contentHeight') - paddingInfo.height) + paddingInfo.width;
  44. }
  45. }
  46. },
  47. measureContentHeight : function (ownerContext) {
  48. var target = ownerContext.target,
  49. paddingInfo = ownerContext.getPaddingInfo(),
  50. bbox = this.getBBox(ownerContext);
  51. if (!ownerContext.target.viewBox) {
  52. if (target.autoSize) {
  53. return bbox.height + paddingInfo.height;
  54. } else {
  55. return bbox.y + bbox.height + paddingInfo.height;
  56. }
  57. } else {
  58. if (ownerContext.widthModel.shrinkWrap) {
  59. return paddingInfo.height;
  60. } else {
  61. return bbox.height / bbox.width * (ownerContext.getProp('contentWidth') - paddingInfo.width) + paddingInfo.height;
  62. }
  63. }
  64. },
  65. getBBox: function(ownerContext) {
  66. var bbox = ownerContext.surfaceBBox;
  67. if (!bbox) {
  68. bbox = ownerContext.target.surface.items.getBBox();
  69. // If the surface is empty, we'll get these values, normalize them
  70. if (bbox.width === -Infinity &amp;&amp; bbox.height === -Infinity) {
  71. bbox.width = bbox.height = bbox.x = bbox.y = 0;
  72. }
  73. ownerContext.surfaceBBox = bbox;
  74. }
  75. return bbox;
  76. },
  77. publishInnerWidth: function (ownerContext, width) {
  78. ownerContext.setContentWidth(width - ownerContext.getFrameInfo().width, true);
  79. },
  80. publishInnerHeight: function (ownerContext, height) {
  81. ownerContext.setContentHeight(height - ownerContext.getFrameInfo().height, true);
  82. },
  83. finishedLayout: function (ownerContext) {
  84. // TODO: Is there a better way doing this?
  85. var props = ownerContext.props,
  86. paddingInfo = ownerContext.getPaddingInfo();
  87. // We don't want the cost of getProps, so we just use the props data... this is ok
  88. // because all the props have been calculated by this time
  89. this.owner.setSurfaceSize(props.contentWidth - paddingInfo.width, props.contentHeight - paddingInfo.height);
  90. // calls afterComponentLayout, so we want the surface to be sized before that:
  91. this.callParent(arguments);
  92. }
  93. });
  94. </pre>
  95. </body>
  96. </html>