diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 2847cd8c0..6b72255ed 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -67,6 +67,8 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { } else { container.add(creator, creator.toData().getWidgetName()); } + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + layout.updateBoundsWidget(creator); LayoutUtils.layoutRootContainer(container); } @@ -84,6 +86,9 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter { WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); fix(creator,creator.getX(),creator.getY()); wabs.setBounds(creator.toData(),creator.getBounds()); + + XWAbsoluteLayout layout = (XWAbsoluteLayout) container; + layout.updateBoundsWidget(creator); } /** diff --git a/designer_form/src/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer_form/src/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index a09b61424..61bd612ad 100644 --- a/designer_form/src/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -30,6 +30,8 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ private int cornerSize = 15; private int noneSize = 0; + protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150); + public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); } diff --git a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java index e477b7d7a..49d193199 100644 --- a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java +++ b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java @@ -187,7 +187,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { * @return 返回大小. */ public Dimension initEditorSize() { - return new Dimension(250, 100); + return BORDER_PREFERRED_SIZE; } /** diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index 090561cf8..474acfbb9 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -182,7 +182,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme * @return 尺寸 */ public Dimension initEditorSize() { - return new Dimension(250, 100); + return BORDER_PREFERRED_SIZE; } /** 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 b729ce049..3a110e321 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -8,6 +8,7 @@ import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.beans.IntrospectionException; +import java.util.ArrayList; import java.util.HashMap; import com.fr.design.designer.beans.AdapterBus; @@ -17,10 +18,12 @@ import com.fr.design.designer.beans.adapters.layout.AbsoluteLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.models.SelectionModel; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.EditingMouseListener; +import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; @@ -30,6 +33,8 @@ import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; +import com.fr.form.ui.container.WFitLayout; +import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.core.PropertyChangeAdapter; @@ -42,6 +47,9 @@ public class XWAbsoluteLayout extends XLayoutContainer { private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_HEIGHT = 24; + + //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 + protected double containerPercent = 1.0; private HashMap xConnectorMap; @@ -61,6 +69,61 @@ public class XWAbsoluteLayout extends XLayoutContainer { connector = widget.getConnectorIndex(i); xConnectorMap.put(connector, new XConnector(connector, this)); } + + initPercent(); + } + + //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% + private void initPercent(){ + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Dimension scrnsize = toolkit.getScreenSize(); + double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + if(screenValue != FormArea.DEFAULT_SLIDER){ + this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); + } + } + + /** + * 返回容器大小的百分比 + * @return the containerPercent + */ + public double getContainerPercent() { + return containerPercent; + } + + /** + * 设置容器大小的百分比 + * @param containerPercent the containerPercent to set + */ + public void setContainerPercent(double containerPercent) { + this.containerPercent = containerPercent; + } + + /** + * 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 + */ + private Rectangle dealWidgetBound(Rectangle rec) { + if (containerPercent == 1.0) { + return rec; + } + rec.x = (int) (rec.x/containerPercent); + rec.y = (int) (rec.y/containerPercent); + rec.width = (int) (rec.width/containerPercent); + rec.height = (int) (rec.height/containerPercent); + return rec; + } + + /** + * 新增删除拉伸后更新每个组件的BoundsWidget + */ + public void updateBoundsWidget(XCreator xCreator) { + WAbsoluteLayout layout = this.toData(); + if (xCreator.shouldScaleCreator() || xCreator.hasTitleStyle()) { + xCreator = (XLayoutContainer)xCreator.getParent(); + } + BoundsWidget boundsWidget = layout.getBoundsWidget(xCreator.toData()); + Rectangle rectangle = dealWidgetBound(xCreator.getBounds()); + boundsWidget.setCalculatedBounds(rectangle); } /** diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 346a5ce3a..e5d8d44d2 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -88,6 +88,14 @@ public class XWCardLayout extends XLayoutContainer { return (WCardLayout) data; } + /** + * 初始化时默认的组件大小 + * @return 默认Dimension + */ + public Dimension initEditorSize() { + return new Dimension(500, 300); + } + @Override protected void initLayoutManager() { cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap());