13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='Ext-grid-ColumnComponentLayout'>/**
</span> * Component layout for grid column headers which have a title element at the top followed by content.
 * @private
 */
Ext.define('Ext.grid.ColumnComponentLayout', {
    extend: 'Ext.layout.component.Auto',
    alias: 'layout.columncomponent',
 
<span id='Ext-grid-ColumnComponentLayout-property-type'>    type: 'columncomponent',
</span>
<span id='Ext-grid-ColumnComponentLayout-cfg-setWidthInDom'>    setWidthInDom: true,
</span>
<span id='Ext-grid-ColumnComponentLayout-method-beginLayout'>    beginLayout: function(ownerContext) {
</span>        var me = this;
 
        me.callParent(arguments);
        ownerContext.titleContext = ownerContext.getEl('titleEl');
        ownerContext.triggerContext = ownerContext.getEl('triggerEl');
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-beginLayoutCycle'>    beginLayoutCycle: function(ownerContext) {
</span>        var me = this,
            owner = me.owner;
 
        me.callParent(arguments);
 
        // If shrinkwrapping, allow content width to stretch the element
        if (ownerContext.widthModel.shrinkWrap) {
            owner.el.setWidth('');
        }
 
        // When we are the last subheader, bordering is provided by our owning header, so we need
        // to set border width to zero
        var borderRightWidth = owner.isLast &amp;&amp; owner.isSubHeader ? '0' : '';
        if (borderRightWidth !== me.lastBorderRightWidth) {
            owner.el.dom.style.borderRightWidth = me.lasBorderRightWidth = borderRightWidth;
        }
 
        owner.titleEl.setStyle({
            paddingTop: '',  // reset back to default padding of the style
            paddingBottom: ''
        });
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-publishInnerHeight'>    // If not shrink wrapping, push height info down into child items
</span>    publishInnerHeight: function(ownerContext, outerHeight) {
        // TreePanels (and grids with hideHeaders: true) set their column container height to zero ti hide them.
        // This is because they need to lay out in order to calculate widths for the columns (eg flexes).
        // If there is no height to lay out, bail out early.
        if (!outerHeight) {
            return;
        }
 
        var me = this,
            owner = me.owner,
            innerHeight = outerHeight - ownerContext.getBorderInfo().height,
            availableHeight = innerHeight,
            textHeight,
            titleHeight,
            pt, pb;
 
        // We do not have enough information to get the height of the titleEl
        if (!owner.noWrap &amp;&amp; !ownerContext.hasDomProp('width')) {
            me.done = false;
            return;
        }
 
        // If we are not a container, but just have HTML content...
        if (ownerContext.hasRawContent) {
            titleHeight = availableHeight;
 
            // Vertically center the header text and ensure titleContext occupies availableHeight
            textHeight = owner.textEl.getHeight();
            if (textHeight) {
                availableHeight -= textHeight;
                if (availableHeight &gt; 0) {
                    pt = Math.floor(availableHeight / 2);
                    pb = availableHeight - pt;
                    ownerContext.titleContext.setProp('padding-top', pt);
                    ownerContext.titleContext.setProp('padding-bottom', pb);
                }
            }
        }
 
        // There are child items
        else {
            titleHeight = owner.titleEl.getHeight();
            ownerContext.setProp('innerHeight', innerHeight - titleHeight, false);
        }
        // Only IE6 and IEQuirks needs this.
        // This is why we maintain titleHeight when setting it.
        if ((Ext.isIE6 || Ext.isIEQuirks) &amp;&amp; ownerContext.triggerContext) {
            ownerContext.triggerContext.setHeight(titleHeight);
        }
 
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-measureContentHeight'>    // We do not need the Direct2D sub pixel measurement here. Just the offsetHeight will do.
</span>    // TODO: When https://sencha.jira.com/browse/EXTJSIV-7734 is fixed to not do subpixel adjustment on height,
    // remove this override.
    measureContentHeight: function(ownerContext) {
        return ownerContext.el.dom.offsetHeight;
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-publishOwnerHeight'>    publishOwnerHeight: function(ownerContext, contentHeight) {
</span>        this.callParent(arguments);
        // Only IE6 and IEQuirks needs this.
        // This is why we maintain titleHeight when setting it.
        if ((Ext.isIE6 || Ext.isIEQuirks) &amp;&amp; ownerContext.triggerContext) {
            ownerContext.triggerContext.setHeight(contentHeight);
        }
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-publishInnerWidth'>    // If not shrink wrapping, push width info down into child items
</span>    publishInnerWidth: function(ownerContext, outerWidth) {
        // If we are acting as a container, publish the innerWidth for the ColumnLayout to use
        if (!ownerContext.hasRawContent) {
            ownerContext.setProp('innerWidth', outerWidth - ownerContext.getBorderInfo().width, false);
        }
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-calculateOwnerHeightFromContentHeight'>    // Push content height outwards when we are shrinkwrapping
</span>    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {
        var result = this.callParent(arguments);
 
        // If we are NOT a group header, we just use the auto component's measurement
        if (!ownerContext.hasRawContent) {
            if (this.owner.noWrap || ownerContext.hasDomProp('width')) {
                return contentHeight + this.owner.titleEl.getHeight() + ownerContext.getBorderInfo().height;
            }
 
            // We do not have the information to return the height yet because we cannot know
            // the final height of the text el
            return null;
        }
        return result;
    },
 
<span id='Ext-grid-ColumnComponentLayout-method-calculateOwnerWidthFromContentWidth'>    // Push content width outwards when we are shrinkwrapping
</span>    calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {
        var owner = this.owner,
            inner = Math.max(contentWidth, owner.textEl.getWidth() + ownerContext.titleContext.getPaddingInfo().width),
            padWidth = ownerContext.getPaddingInfo().width,
            triggerOffset = this.getTriggerOffset(owner, ownerContext);
            
        return inner + padWidth + triggerOffset;
    },
    
<span id='Ext-grid-ColumnComponentLayout-method-getTriggerOffset'>    getTriggerOffset: function(owner, ownerContext) {
</span>        var width = 0;
        if (ownerContext.widthModel.shrinkWrap &amp;&amp; !owner.menuDisabled) {
            // If we have any children underneath, then we already have space reserved
            if (owner.query('&gt;:not([hidden])').length === 0) {
                width = owner.self.triggerElWidth;
            }
        }
        return width;
    }
});</pre>
</body>
</html>