PDA

View Full Version : [FIXED][2.x/3.x] Wrapped components in border layout



Condor
30 Jun 2009, 6:36 AM
Wrapped components (getEl <> getDomPositionEl, e.g. HtmlEditor, Checkbox, Radio, TriggerField, ComboBox etc.) are positioned incorrectly in a border layout.

Example:

Ext.onReady(function() {
new Ext.Viewport({
layout: 'border',
items: [{
region: 'north',
height: 100
},{
region: 'center',
xtype: 'htmleditor'
}]
});
});

Suggested fix (based on current Ext 3.0 SVN):

Ext.override(Ext.layout.BorderLayout, {
onLayout : function(ct, target){
var collapsed;
if(!this.rendered){
target.addClass('x-border-layout-ct');
var items = ct.items.items;
collapsed = [];
for(var i = 0, len = items.length; i < len; i++) {
var c = items[i];
var pos = c.region;
if(c.collapsed){
collapsed.push(c);
}
c.collapsed = false;
if(!c.rendered){
//c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel';
c.render(target, i);
c.getDomPositionEl().addClass('x-border-panel');
}
this[pos] = pos != 'center' && c.split ?
new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
this[pos].render(target, c);
}
this.rendered = true;
}
var size = target.getViewSize();
if(size.width < 20 || size.height < 20){
if(collapsed){
this.restoreCollapsed = collapsed;
}
return;
}else if(this.restoreCollapsed){
collapsed = this.restoreCollapsed;
delete this.restoreCollapsed;
}
var w = size.width, h = size.height;
var centerW = w, centerH = h, centerY = 0, centerX = 0;
var n = this.north, s = this.south, west = this.west, e = this.east, c = this.center;
if(!c && Ext.layout.BorderLayout.WARN !== false){
throw 'No center region defined in BorderLayout ' + ct.id;
}
if(n && n.isVisible()){
var b = n.getSize();
var m = n.getMargins();
b.width = w - (m.left+m.right);
b.x = m.left;
b.y = m.top;
centerY = b.height + b.y + m.bottom;
centerH -= centerY;
n.applyLayout(b);
}
if(s && s.isVisible()){
var b = s.getSize();
var m = s.getMargins();
b.width = w - (m.left+m.right);
b.x = m.left;
var totalHeight = (b.height + m.top + m.bottom);
b.y = h - totalHeight + m.top;
centerH -= totalHeight;
s.applyLayout(b);
}
if(west && west.isVisible()){
var b = west.getSize();
var m = west.getMargins();
b.height = centerH - (m.top+m.bottom);
b.x = m.left;
b.y = centerY + m.top;
var totalWidth = (b.width + m.left + m.right);
centerX += totalWidth;
centerW -= totalWidth;
west.applyLayout(b);
}
if(e && e.isVisible()){
var b = e.getSize();
var m = e.getMargins();
b.height = centerH - (m.top+m.bottom);
var totalWidth = (b.width + m.left + m.right);
b.x = w - totalWidth + m.left;
b.y = centerY + m.top;
centerW -= totalWidth;
e.applyLayout(b);
}
if(c){
var m = c.getMargins();
var centerBox = {
x: centerX + m.left,
y: centerY + m.top,
width: centerW - (m.left+m.right),
height: centerH - (m.top+m.bottom)
};
c.applyLayout(centerBox);
}
if(collapsed){
for(var i = 0, len = collapsed.length; i < len; i++){
collapsed[i].collapse(false);
}
}
if(Ext.isIE && Ext.isStrict){
target.repaint();
}
}
});

Condor
2 Jul 2009, 1:47 AM
What does a report status [NEW] mean?

Is it the same as [OPEN] or is it not yet processed?

mjlecomte
2 Jul 2009, 3:38 AM
Something like 'needs to be verified'.

Changing status to OPEN.

evant
5 Aug 2009, 11:28 PM
Fixed in SVN, thanks.