|
|
|
@ -758,6 +758,11 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
int[] veris = getVeris(true); |
|
|
|
|
int containerWidth = 0; |
|
|
|
|
int containerHeight = 0; |
|
|
|
|
|
|
|
|
|
PaddingMargin margin = toData().getMargin(); |
|
|
|
|
int maxW = this.getWidth() - margin.getRight(); |
|
|
|
|
int maxH = this.getHeight() - margin.getBottom(); |
|
|
|
|
|
|
|
|
|
for (int index=0, n=this.getComponentCount(); index<n; index++) { |
|
|
|
|
XCreator creator = (XCreator) this.getComponent(index); |
|
|
|
|
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); |
|
|
|
@ -782,6 +787,14 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
} |
|
|
|
|
//如果子组件是绝对布局,则内部的widget也要更新
|
|
|
|
|
if (creator.acceptType(XWAbsoluteLayout.class)){ |
|
|
|
|
|
|
|
|
|
// backupBounds处理下内边距 否则计算缩放比例时总是存在一个内边距的误差
|
|
|
|
|
if (creator.getBackupBound() != null) { |
|
|
|
|
Rectangle backUpBound = creator.getBackupBound(); |
|
|
|
|
processContainerMargin(margin, backUpBound, maxW, maxH); |
|
|
|
|
creator.setBackupBound(backUpBound); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//更新的时候一定要带上backupBound
|
|
|
|
|
if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) { |
|
|
|
|
creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds())); |
|
|
|
@ -1056,24 +1069,28 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
for (int i=0; i<num; i++) { |
|
|
|
|
Component comp = this.getComponent(i); |
|
|
|
|
Rectangle rec = comp.getBounds(); |
|
|
|
|
if (rec.x == margin.getLeft()) { |
|
|
|
|
rec.x = 0; |
|
|
|
|
rec.width += margin.getLeft(); |
|
|
|
|
} |
|
|
|
|
if (rec.y == margin.getTop()) { |
|
|
|
|
rec.y = 0; |
|
|
|
|
rec.height += margin.getTop(); |
|
|
|
|
} |
|
|
|
|
if (rec.x +rec.width == maxW) { |
|
|
|
|
rec.width += margin.getRight(); |
|
|
|
|
} |
|
|
|
|
if (rec.y + rec.height == maxH) { |
|
|
|
|
rec.height += margin.getBottom(); |
|
|
|
|
} |
|
|
|
|
processContainerMargin(margin, rec, maxW, maxH); |
|
|
|
|
comp.setBounds(rec); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processContainerMargin(PaddingMargin margin, Rectangle rec, int maxW, int maxH) { |
|
|
|
|
if (rec.x == margin.getLeft()) { |
|
|
|
|
rec.x = 0; |
|
|
|
|
rec.width += margin.getLeft(); |
|
|
|
|
} |
|
|
|
|
if (rec.y == margin.getTop()) { |
|
|
|
|
rec.y = 0; |
|
|
|
|
rec.height += margin.getTop(); |
|
|
|
|
} |
|
|
|
|
if (rec.x +rec.width == maxW) { |
|
|
|
|
rec.width += margin.getRight(); |
|
|
|
|
} |
|
|
|
|
if (rec.y + rec.height == maxH) { |
|
|
|
|
rec.height += margin.getBottom(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Component getTopComp(int x, int y) { |
|
|
|
|
int val = getAcualInterval(); |
|
|
|
|
return this.getComponentAt(x, y-default_Length-val); |
|
|
|
|