|
|
|
@ -835,6 +835,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 从root里面查找层级为level的控件 |
|
|
|
|
*/ |
|
|
|
|
private XCreator xCreatorAt(int x, int y, XCreator root, int level) { |
|
|
|
|
if (root == null || !root.isVisible()) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
x -= root.getX(); |
|
|
|
|
y -= root.getY(); |
|
|
|
|
|
|
|
|
|
if (root instanceof XLayoutContainer) { |
|
|
|
|
XLayoutContainer rootContainer = (XLayoutContainer) root; |
|
|
|
|
int count = rootContainer.getXCreatorCount(); |
|
|
|
|
for (int i = 0; i < count; i++) { |
|
|
|
|
XCreator child = rootContainer.getXCreator(i); |
|
|
|
|
XCreator dest = xCreatorAt(x, y, child, level); |
|
|
|
|
|
|
|
|
|
if (dest != null && dest.getLevel() == level) { |
|
|
|
|
return dest; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Rectangle rect = ComponentUtils.computeVisibleRect(root); |
|
|
|
|
if (isIntersectArea(x, y, rect)) { |
|
|
|
|
// 判断是否处于交叉区域
|
|
|
|
|
return root; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 从已选择的组件中找x,y所在的组件 |
|
|
|
|
*/ |
|
|
|
@ -1095,25 +1127,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
* */ |
|
|
|
|
@Override |
|
|
|
|
public XCreator getComponentAt(int x, int y) { |
|
|
|
|
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; |
|
|
|
|
if (container == null) { |
|
|
|
|
container = rootComponent; |
|
|
|
|
} |
|
|
|
|
int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX(); |
|
|
|
|
int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY(); |
|
|
|
|
XCreator result = xCreatorAt(relativeX, relativeY, container); |
|
|
|
|
XLayoutContainer container = getRootContainer(y); |
|
|
|
|
XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container); |
|
|
|
|
return result == null ? getComponentAt(x, y, null) : result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
public XCreator getComponentAt(int x, int y, XCreator[] except) { |
|
|
|
|
XLayoutContainer container = getRootContainer(y); |
|
|
|
|
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, except); |
|
|
|
|
return comp == null ? container : comp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public XCreator getComponentAt(int x, int y, int level) { |
|
|
|
|
XLayoutContainer container = getRootContainer(y); |
|
|
|
|
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, level); |
|
|
|
|
return comp == null ? container : comp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private XLayoutContainer getRootContainer(int y) { |
|
|
|
|
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; |
|
|
|
|
if (container == null) { |
|
|
|
|
container = rootComponent; |
|
|
|
|
} |
|
|
|
|
XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, |
|
|
|
|
except); |
|
|
|
|
return comp == null ? container : comp; |
|
|
|
|
return container; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int getRelativeScaleX(int x) { |
|
|
|
|
return x + (int)(formArea.getHorizontalValue() / scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int getRelativeScaleY(int y) { |
|
|
|
|
return y + (int)(formArea.getVerticalValue() / scale); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public SelectionModel getSelectionModel() { |
|
|
|
|