From 7b12c56f9963e02fb52f55e3edc58e0d1c27451c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 15:18:59 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-6096=20TAB=E9=A1=B5=E4=B8=AD=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=9C=A8=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4=E5=90=8E?= =?UTF-8?q?=E4=BC=9A=E4=BD=8D=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/FormSelectionUtils.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java index ebf7328a2f..86a7536e2f 100644 --- a/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java @@ -12,6 +12,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; @@ -107,6 +108,7 @@ public class FormSelectionUtils { designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste")); return; } + resetTabSub2RealSize(copiedCreator); boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); if (addSuccess) { designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); @@ -121,6 +123,34 @@ public class FormSelectionUtils { } + /** + * REPORT-6096 复制得到的是显示的大小,如果因屏幕分辨率问题存在缩放的话,显示大小和实际大小会有区别,粘贴后tab内部调整大小时会再次缩放导致问题。 + * 因此在粘贴之前将tab内部的组件调整成实际的大小。 + * + * @param copiedCreator 复制的组件 + */ + private static void resetTabSub2RealSize(XCreator copiedCreator) { + ArrayList childrenList = copiedCreator.getTargetChildrenList(); + if (!childrenList.isEmpty()) { + for (Object aChildrenList : childrenList) { + XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList; + double percent = tabLayout.getContainerPercent(); + Component[] components = tabLayout.getComponents(); + for (Component component : components) { + Rectangle show = component.getBounds(); + component.setBounds(new Rectangle((int) (show.x * percent), (int) (show.y * percent), (int) (show.width * percent), (int) (show.height * percent))); + } + } + } + Component[] components = copiedCreator.getComponents(); + for (Component component : components) { + try { + resetTabSub2RealSize((XCreator) component); + } catch (ClassCastException ignored) { + } + } + } + /** * 相对布局粘贴 */ @@ -178,9 +208,9 @@ public class FormSelectionUtils { */ private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) { //当宽度为奇数时 设置偏移 - int xoffset = (copiedCreator.getWidth() & 1) == 1 ? 1 : 0; + int xoffset = copiedCreator.getWidth() & 1; //当高度为奇数时 设置偏移 - int yoffset = (copiedCreator.getHeight() & 1) == 1 ? 1 : 0; + int yoffset = copiedCreator.getHeight() & 1; if (!layoutAdapter.accept(copiedCreator, x, y)) { XLayoutContainer container = layoutAdapter.getContainer();