]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * Component layout for grid column headers which have a title element at the top followed by content.\r | |
3 | * @private\r | |
4 | */\r | |
5 | Ext.define('Ext.grid.ColumnComponentLayout', {\r | |
6 | extend: 'Ext.layout.component.Auto',\r | |
7 | alias: 'layout.columncomponent',\r | |
8 | \r | |
9 | type: 'columncomponent',\r | |
10 | \r | |
11 | setWidthInDom: true,\r | |
12 | \r | |
13 | _paddingReset: {\r | |
14 | paddingTop: '', // reset back to default padding of the style\r | |
15 | paddingBottom: ''\r | |
16 | },\r | |
17 | \r | |
18 | columnAutoCls: Ext.baseCSSPrefix + 'column-header-text-container-auto',\r | |
19 | \r | |
20 | beginLayout: function(ownerContext) {\r | |
21 | this.callParent(arguments);\r | |
22 | ownerContext.titleContext = ownerContext.getEl('titleEl');\r | |
23 | },\r | |
24 | \r | |
25 | beginLayoutCycle: function(ownerContext) {\r | |
26 | var me = this,\r | |
27 | owner = me.owner,\r | |
28 | shrinkWrap = ownerContext.widthModel.shrinkWrap;\r | |
29 | \r | |
30 | me.callParent(arguments);\r | |
31 | \r | |
32 | // If shrinkwrapping, allow content width to stretch the element\r | |
33 | if (shrinkWrap) {\r | |
34 | owner.el.setWidth('');\r | |
35 | }\r | |
36 | owner.textContainerEl[shrinkWrap && !owner.isGroupHeader ? 'addCls' : 'removeCls'](me.columnAutoCls);\r | |
37 | owner.titleEl.setStyle(me._paddingReset);\r | |
38 | },\r | |
39 | \r | |
40 | // If not shrink wrapping, push height info down into child items\r | |
41 | publishInnerHeight: function(ownerContext, outerHeight) {\r | |
42 | var me = this,\r | |
43 | owner = me.owner,\r | |
44 | innerHeight;\r | |
45 | \r | |
46 | // TreePanels (and grids with hideHeaders: true) set their column container height to zero to hide them.\r | |
47 | // This is because they need to lay out in order to calculate widths for the columns (eg flexes).\r | |
48 | // If there is no height to lay out, bail out early.\r | |
49 | if (owner.getRootHeaderCt().hiddenHeaders) {\r | |
50 | ownerContext.setProp('innerHeight', 0);\r | |
51 | return;\r | |
52 | }\r | |
53 | \r | |
54 | \r | |
55 | // If this ia a group header; that is, it contains subheaders...\r | |
56 | // hasRawContent = !(target.isContainer && target.items.items.length > 0)\r | |
57 | if (!ownerContext.hasRawContent) {\r | |
58 | // We do not have enough information to get the height of the titleEl\r | |
59 | if (owner.headerWrap && !ownerContext.hasDomProp('width')) {\r | |
60 | me.done = false;\r | |
61 | return;\r | |
62 | }\r | |
63 | \r | |
64 | innerHeight = outerHeight - ownerContext.getBorderInfo().height;\r | |
65 | ownerContext.setProp('innerHeight', innerHeight - owner.titleEl.getHeight(), false);\r | |
66 | }\r | |
67 | },\r | |
68 | \r | |
69 | // We do not need the Direct2D sub pixel measurement here. Just the offsetHeight will do.\r | |
70 | // TODO: When https://sencha.jira.com/browse/EXTJSIV-7734 is fixed to not do subpixel adjustment on height,\r | |
71 | // remove this override.\r | |
72 | measureContentHeight: function(ownerContext) {\r | |
73 | return ownerContext.el.dom.offsetHeight;\r | |
74 | },\r | |
75 | \r | |
76 | // If not shrink wrapping, push width info down into child items\r | |
77 | publishInnerWidth: function(ownerContext, outerWidth) {\r | |
78 | // If we are acting as a container, publish the innerWidth for the ColumnLayout to use\r | |
79 | if (!ownerContext.hasRawContent) {\r | |
80 | ownerContext.setProp('innerWidth', outerWidth - ownerContext.getBorderInfo().width, false);\r | |
81 | }\r | |
82 | },\r | |
83 | \r | |
84 | // Push content height outwards when we are shrinkwrapping\r | |
85 | calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\r | |
86 | var result = this.callParent(arguments),\r | |
87 | owner = this.owner;\r | |
88 | \r | |
89 | // If we are NOT a group header, we just use the auto component's measurement\r | |
90 | if (!ownerContext.hasRawContent) {\r | |
91 | if (!owner.headerWrap || ownerContext.hasDomProp('width')) {\r | |
92 | return contentHeight + owner.titleEl.getHeight() + ownerContext.getBorderInfo().height;\r | |
93 | }\r | |
94 | \r | |
95 | // We do not have the information to return the height yet because we cannot know\r | |
96 | // the final height of the text el\r | |
97 | return null;\r | |
98 | }\r | |
99 | return result;\r | |
100 | },\r | |
101 | \r | |
102 | // Push content width outwards when we are shrinkwrapping\r | |
103 | calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {\r | |
104 | var owner = this.owner,\r | |
105 | padWidth = ownerContext.getPaddingInfo().width,\r | |
106 | triggerOffset = this.getTriggerOffset(owner, ownerContext),\r | |
107 | inner;\r | |
108 | \r | |
109 | // Only measure the content if we're not grouped, otherwise\r | |
110 | // the size should be governed by the children\r | |
111 | if (owner.isGroupHeader) {\r | |
112 | inner = contentWidth;\r | |
113 | } else {\r | |
114 | inner = Math.max(contentWidth, owner.textEl.getWidth() + ownerContext.titleContext.getPaddingInfo().width);\r | |
115 | }\r | |
116 | return inner + padWidth + triggerOffset;\r | |
117 | },\r | |
118 | \r | |
119 | getTriggerOffset: function(owner, ownerContext) {\r | |
120 | var width = 0;\r | |
121 | \r | |
122 | if (ownerContext.widthModel.shrinkWrap && !owner.menuDisabled) {\r | |
123 | // If we have any children underneath, then we already have space reserved\r | |
124 | if (owner.query('>:not([hidden])').length === 0) {\r | |
125 | width = owner.getTriggerElWidth();\r | |
126 | }\r | |
127 | }\r | |
128 | return width;\r | |
129 | }\r | |
130 | });\r |