|
|
|
@ -11,8 +11,11 @@ import com.fr.design.designer.creator.cardlayout.XWCardLayout;
|
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; |
|
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.event.GlobalNameListener; |
|
|
|
|
import com.fr.design.event.GlobalNameObserver; |
|
|
|
|
import com.fr.design.event.UIObserver; |
|
|
|
|
import com.fr.design.event.UIObserverListener; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
import com.fr.design.gui.ispinner.UISpinner; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
@ -81,7 +84,8 @@ public class WidgetBoundPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (jTemplate.isJWorkBook() || !((JForm)jTemplate).isSelectRootPane()) { |
|
|
|
|
ratioLockedButton = new AspectRatioLockedButton(width, height, creator); |
|
|
|
|
ratioLockedButton = new AspectRatioLockedButton(width, height); |
|
|
|
|
ratioLockedButton.setGlobalName(i18nText("Fine-Design_Form_Coords_And_Size")); |
|
|
|
|
ratioLockedButton.setLockEnabled(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -121,7 +125,7 @@ public class WidgetBoundPane extends BasicPane {
|
|
|
|
|
limitHeight(wabs, h, bounds, rec); |
|
|
|
|
} |
|
|
|
|
if (ratioLockedButton != null) { |
|
|
|
|
ratioLockedButton.setLocked(creator.toData().isAspectRatioLocked()); |
|
|
|
|
ratioLockedButton.update(creator); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -191,21 +195,24 @@ public class WidgetBoundPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static class AspectRatioLockedButton extends UIButton { |
|
|
|
|
protected static class AspectRatioLockedButton extends JButton implements UIObserver, GlobalNameObserver { |
|
|
|
|
|
|
|
|
|
private final Icon enabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_enabled.png"); |
|
|
|
|
private final Icon disabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_disabled.png"); |
|
|
|
|
private final Icon enabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_enabled.png"); |
|
|
|
|
private final Icon disabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_disabled.png"); |
|
|
|
|
|
|
|
|
|
private UISpinner mWidthSpinner; |
|
|
|
|
private UISpinner mHeightSpinner; |
|
|
|
|
private XCreator mCreator; |
|
|
|
|
private UIObserverListener uiObserverListener; |
|
|
|
|
private GlobalNameListener globalNameListener; |
|
|
|
|
private String globalName = null; |
|
|
|
|
|
|
|
|
|
private final UISpinner mWidthSpinner; |
|
|
|
|
private final UISpinner mHeightSpinner; |
|
|
|
|
|
|
|
|
|
protected double width4Backup = 0; |
|
|
|
|
protected double height4Backup = 0; |
|
|
|
|
|
|
|
|
|
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner, XCreator creator) { |
|
|
|
|
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) { |
|
|
|
|
setUI(new BasicButtonUI()); |
|
|
|
|
setBorderPainted(false); |
|
|
|
|
setBorder(null); |
|
|
|
@ -214,25 +221,25 @@ public class WidgetBoundPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
this.mWidthSpinner = widthSpinner; |
|
|
|
|
this.mHeightSpinner = heightSpinner; |
|
|
|
|
this.mCreator = creator; |
|
|
|
|
|
|
|
|
|
addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
setSelected(!isSelected()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
addChangeListener(new ChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
|
mCreator.toData().setAspectRatioLocked(isLocked()); |
|
|
|
|
|
|
|
|
|
setToolTipText(isLockEnabled() ? null : i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Button_ToolTip")); |
|
|
|
|
// 改变图标icon
|
|
|
|
|
setLocked(!isLocked()); |
|
|
|
|
|
|
|
|
|
if (isLocked() && isLockEnabled()) { |
|
|
|
|
width4Backup = mWidthSpinner.getValue(); |
|
|
|
|
height4Backup = mHeightSpinner.getValue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (globalNameListener != null) { |
|
|
|
|
globalNameListener.setGlobalName(globalName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (uiObserverListener != null) { |
|
|
|
|
uiObserverListener.doChange(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -285,15 +292,44 @@ public class WidgetBoundPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
public void setLockEnabled(boolean enabled) { |
|
|
|
|
this.setEnabled(enabled); |
|
|
|
|
setToolTipText(isLockEnabled() ? null : i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Button_ToolTip")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(XCreator creator) { |
|
|
|
|
Rectangle bounds = new Rectangle(creator.getBounds()); |
|
|
|
|
mCreator = creator; |
|
|
|
|
width4Backup = bounds.width; |
|
|
|
|
height4Backup = bounds.height; |
|
|
|
|
Widget widget = creator.toData(); |
|
|
|
|
setLocked(widget.isAspectRatioLocked()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update(XCreator creator) { |
|
|
|
|
creator.toData().setAspectRatioLocked(this.isLocked()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void registerChangeListener(UIObserverListener listener) { |
|
|
|
|
uiObserverListener = listener; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void registerNameListener(GlobalNameListener listener) { |
|
|
|
|
this.globalNameListener = listener; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean shouldResponseNameListener() { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setGlobalName(String name) { |
|
|
|
|
this.globalName = name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|