|
|
|
@ -18,7 +18,6 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
|
|
|
|
|
import com.fr.form.ui.container.WBodyLayoutType; |
|
|
|
|
import com.fr.form.ui.container.WFitLayout; |
|
|
|
|
import com.fr.form.ui.container.WLayout; |
|
|
|
|
import com.fr.form.ui.widget.CRBoundsWidget; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.FRScreen; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
@ -130,7 +129,6 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 直接拖动滑条改变整体像素大小时,不用考虑控件的最小高度宽度,内部组件全部一起缩小放大 |
|
|
|
|
* 只是界面显示大小改变,不改变对应的BoundsWidget大小 |
|
|
|
@ -139,24 +137,28 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
public void adjustCreatorsWhileSlide(double percent) { |
|
|
|
|
int count = this.getComponentCount(); |
|
|
|
|
if (count == 0) { |
|
|
|
|
Dimension size = new Dimension(this.toData().getContentWidth(), this.toData().getContentHeight()); |
|
|
|
|
Dimension size = new Dimension(this.getSize()); |
|
|
|
|
size.width += size.width*percent; |
|
|
|
|
size.height += size.height*percent; |
|
|
|
|
this.setSize(size); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 初始化时还未加间隔
|
|
|
|
|
if (hasCalGap) { |
|
|
|
|
moveContainerMargin(); |
|
|
|
|
moveCompInterval(backupGap); |
|
|
|
|
LayoutUtils.layoutContainer(this); |
|
|
|
|
} |
|
|
|
|
int containerW = 0; |
|
|
|
|
int containerH = 0; |
|
|
|
|
int[] hors = getDataHors(); |
|
|
|
|
int[] veris = getDataVeris(); |
|
|
|
|
PaddingMargin margin = new PaddingMargin(); |
|
|
|
|
int[] hors = getHors(false); |
|
|
|
|
int[] veris = getVeris(false); |
|
|
|
|
PaddingMargin margin = toData().getMargin(); |
|
|
|
|
for (int i=0; i<count; i++) { |
|
|
|
|
XCreator creator = getXCreator(i); |
|
|
|
|
WFitLayout fitLayout = this.toData(); |
|
|
|
|
CRBoundsWidget boundsWidget = fitLayout.getBoundsWidget(creator.toData()); |
|
|
|
|
// 百分比和updateBoundsWidget时都会调整大小
|
|
|
|
|
// 子组件非空时,调整界面大小、 撤销、再次打开表单,都会按屏幕百分比调整,此时必须考虑内边距
|
|
|
|
|
Rectangle rec = modifyCreatorPoint(boundsWidget.getBounds(), percent, hors, veris); |
|
|
|
|
Rectangle rec = modifyCreatorPoint(creator.getBounds(), percent, hors, veris); |
|
|
|
|
if (rec.x == margin.getLeft()) { |
|
|
|
|
containerH += rec.height; |
|
|
|
|
} |
|
|
|
@ -173,7 +175,10 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
); |
|
|
|
|
updateCreatorsBackupBound(); |
|
|
|
|
// 间隔也按显示大小比例调整
|
|
|
|
|
if (!hasCalGap) { |
|
|
|
|
moveContainerMargin(); |
|
|
|
|
addCompInterval(getAcualInterval()); |
|
|
|
|
} |
|
|
|
|
LayoutUtils.layoutContainer(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -181,7 +186,6 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
* 调整控件的point和size,避免拖动滑块出现空隙 |
|
|
|
|
*/ |
|
|
|
|
private Rectangle modifyCreatorPoint(Rectangle rec, double percent, int[] hors, int[] veris) { |
|
|
|
|
rec = new Rectangle(rec); |
|
|
|
|
int xIndex = 0, yIndex = 0; |
|
|
|
|
PaddingMargin margin = toData().getMargin(); |
|
|
|
|
Rectangle bound = new Rectangle(rec); |
|
|
|
@ -260,41 +264,6 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int[] getDataHors() { |
|
|
|
|
List<Integer> posX = new ArrayList<Integer>(); |
|
|
|
|
// 保存实际大小时,组件大小已经去除内边距,此处也判断下
|
|
|
|
|
posX.add(0); |
|
|
|
|
int width = this.toData().getContainerWidth(); |
|
|
|
|
posX.add(width); |
|
|
|
|
for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) { |
|
|
|
|
CRBoundsWidget widget = (CRBoundsWidget) this.toData().getWidget(i); |
|
|
|
|
Rectangle rec = widget.getBounds(); |
|
|
|
|
if (!posX.contains(rec.x)) { |
|
|
|
|
posX.add(rec.x); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Collections.sort(posX); |
|
|
|
|
return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int[] getDataVeris() { |
|
|
|
|
List<Integer> posY = new ArrayList<Integer>(); |
|
|
|
|
// 保存实际大小时,组件大小已经去除内边距,此处也判断下
|
|
|
|
|
posY.add(0); |
|
|
|
|
int height = this.toData().getContainerHeight(); |
|
|
|
|
posY.add(height); |
|
|
|
|
for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) { |
|
|
|
|
CRBoundsWidget boundsWidget = (CRBoundsWidget) this.toData().getWidget(i); |
|
|
|
|
Rectangle rec = boundsWidget.getBounds(); |
|
|
|
|
if (!posY.contains(rec.y)) { |
|
|
|
|
posY.add(rec.y); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Collections.sort(posY); |
|
|
|
|
return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取内部组件纵坐标值 |
|
|
|
|
* @param isActualSize 实际大小 |
|
|
|
@ -321,7 +290,6 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否能缩小 |
|
|
|
|
* @param percent 百分比 |
|
|
|
@ -892,14 +860,12 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
} |
|
|
|
|
super.add(comp, constraints); |
|
|
|
|
XCreator creator = (XCreator) comp; |
|
|
|
|
creator.setScale(this.getScale()); |
|
|
|
|
dealDirections(creator, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void add(Component comp, Object constraints, boolean isInit) { |
|
|
|
|
super.add(comp, constraints); |
|
|
|
|
XCreator creator = (XCreator) comp; |
|
|
|
|
creator.setScale(this.getScale()); |
|
|
|
|
dealDirections(creator, isInit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1365,20 +1331,4 @@ public class XWFitLayout extends XLayoutContainer {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自适应布局的缩放 |
|
|
|
|
* |
|
|
|
|
* @param percent 百分比 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void adjustCompSize(double percent) { |
|
|
|
|
this.adjustCreatorsWhileSlide(percent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setScale(double scale) { |
|
|
|
|
super.setScale(scale); |
|
|
|
|
this.setContainerPercent(scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|