From 9b969909a264ff2e8d74f2042cd7b780cc676fcf Mon Sep 17 00:00:00 2001 From: zhouping Date: Thu, 10 Nov 2016 17:38:18 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-750=20=E8=A1=A8=E5=8D=95=E5=85=B1?= =?UTF-8?q?=E5=88=9B=E5=86=85=E6=B5=8B=E9=97=AE=E9=A2=98=20bugfix5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/creator/XCreator.java | 16 ++++++++++ .../designer/creator/XWAbsoluteLayout.java | 32 +++++++++++++++++++ .../design/designer/creator/XWFitLayout.java | 2 ++ 3 files changed, 50 insertions(+) diff --git a/designer_form/src/com/fr/design/designer/creator/XCreator.java b/designer_form/src/com/fr/design/designer/creator/XCreator.java index d47009ff95..ed692cd428 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreator.java @@ -601,4 +601,20 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } + + /** + * 按照比例调整组件的宽度 + * @param percent 比例 + */ + public void adjustCompWidth(double percent){ + return; + } + + /** + * 按照比例调整组件的高度 + * @param percent 比例 + */ + public void adjustCompHeight(double percent) { + return; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 210343f8ed..df28759393 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -444,4 +444,36 @@ public class XWAbsoluteLayout extends XLayoutContainer { } } } + + /** + * body大小手动调整的时候 + * 按照比例调整组件的宽度 + * @param percent 比例 + */ + @Override + public void adjustCompWidth(double percent) { + for (int i = 0; i < getComponentCount(); i++) { + XCreator xCreator = (XCreator) getComponent(i); + Rectangle rectangle = xCreator.getBounds(); + xCreator.setBounds((int) (rectangle.x * percent), rectangle.y, (int) (rectangle.width * percent), rectangle.height); + BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); + widget.setBounds(xCreator.getBounds()); + } + } + + /** + * body大小手动调整的时候 + * 按照比例调整组件的高度 + * @param percent 比例 + */ + @Override + public void adjustCompHeight(double percent) { + for (int i = 0; i < getComponentCount(); i++) { + XCreator xCreator = (XCreator) getComponent(i); + Rectangle rectangle = xCreator.getBounds(); + xCreator.setBounds(rectangle.x, (int) (rectangle.y * percent), rectangle.width, (int) (rectangle.height * percent)); + BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); + widget.setBounds(xCreator.getBounds()); + } + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java index 50fa38db93..04904a7238 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java @@ -381,6 +381,7 @@ public class XWFitLayout extends XLayoutContainer { needAddWidth = Math.max(needAddWidth, MIN_WIDTH-width); } } + creator.adjustCompWidth((double) creator.getBounds().width / rec.width); toData().setBounds(creator.toData(), creator.getBounds()); } @@ -504,6 +505,7 @@ public class XWFitLayout extends XLayoutContainer { needAddHeight = Math.max(needAddHeight, MIN_HEIGHT-h); } } + creator.adjustCompHeight((double) creator.getBounds().height / rec.height); toData().setBounds(creator.toData(), creator.getBounds()); }