Browse Source

REPORT-5908 设计器下拉菜单、右击菜单视觉调整

master
MoMeak 7 years ago
parent
commit
69e8f1f79f
  1. 2
      designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java
  2. 3
      designer/src/com/fr/grid/selection/FloatSelection.java
  3. 2
      designer_base/src/com/fr/design/constants/UIConstants.java
  4. 274
      designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java
  5. 237
      designer_base/src/com/fr/design/gui/imenu/UIMenu.java
  6. 2
      designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java
  7. 4
      designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java
  8. 24
      designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java
  9. 2
      designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java
  10. 9
      designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java
  11. BIN
      designer_base/src/com/fr/design/images/control/clear.png
  12. BIN
      designer_base/src/com/fr/design/images/control/remove.png
  13. 5
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  14. 12
      designer_base/src/com/fr/design/menu/MenuDef.java
  15. 37
      designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java

2
designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java

@ -49,7 +49,7 @@ public class DeprecatedActionManager {
*/ */
public static UIMenu getClearMenu(ElementCasePane ePane) { public static UIMenu getClearMenu(ElementCasePane ePane) {
UIMenu clearMenu = new UIMenu(Inter.getLocText("M_Edit-Clear")); UIMenu clearMenu = new UIMenu(Inter.getLocText("M_Edit-Clear"));
clearMenu.setIcon(UIConstants.BLACK_ICON); clearMenu.setIcon(BaseUtils.readIcon("/com/fr/design/images/control/clear.png"));
clearMenu.setMnemonic('a'); clearMenu.setMnemonic('a');
ClearAction ReportComponentAction = new ClearAllAction(ePane); ClearAction ReportComponentAction = new ClearAllAction(ePane);

3
designer/src/com/fr/grid/selection/FloatSelection.java

@ -15,6 +15,7 @@ import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -114,7 +115,7 @@ public class FloatSelection extends Selection {
@Override @Override
public JPopupMenu createPopupMenu(ElementCasePane ePane) { public JPopupMenu createPopupMenu(ElementCasePane ePane) {
JPopupMenu popup = new JPopupMenu(); UIPopupMenu popup = new UIPopupMenu();
if (BaseUtils.isAuthorityEditing()) { if (BaseUtils.isAuthorityEditing()) {
popup.add(new CleanAuthorityAction(ePane).createMenuItem()); popup.add(new CleanAuthorityAction(ePane).createMenuItem());
return popup; return popup;

2
designer_base/src/com/fr/design/constants/UIConstants.java

@ -79,6 +79,8 @@ public interface UIConstants {
public static final Color COMBOBOX_BTN_NORMAL = new Color(0xD9DADD); public static final Color COMBOBOX_BTN_NORMAL = new Color(0xD9DADD);
public static final Color COMBOBOX_BTN_ROLLOVER = new Color(0xC8C9CD); public static final Color COMBOBOX_BTN_ROLLOVER = new Color(0xC8C9CD);
public static final Color COMBOBOX_BTN_PRESS = new Color(0xD8F2FD); public static final Color COMBOBOX_BTN_PRESS = new Color(0xD8F2FD);
public static final Color UIPOPUPMENU_LINE_COLOR = new Color(0xC8C9CD);
public static final Color UIPOPUPMENU_BACKGROUND = new Color(0xEDEDEE);
public static final Color LINE_COLOR = new Color(153, 153, 153); public static final Color LINE_COLOR = new Color(153, 153, 153);
public static final Color FONT_COLOR = new Color(51, 51, 51); public static final Color FONT_COLOR = new Color(51, 51, 51);
public static final Color LIGHT_BLUE = new Color(182, 217, 253); public static final Color LIGHT_BLUE = new Color(182, 217, 253);

274
designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java

@ -0,0 +1,274 @@
package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import com.fr.design.utils.gui.GUIPaintUtils;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class UIHeadMenu extends UIMenu {
private static final float REC = 8f;
private JPopupMenu popupMenu;
public UIHeadMenu(String name) {
super(name);
}
public JPopupMenu getPopupMenu() {
ensurePopupMenuCreated();
popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND);
popupMenu.setBorder(new Border() {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
GUIPaintUtils.paintShapeBorder(g2d, x, y, width, height, rec);
if (!(UIHeadMenu.this.getParent() instanceof JPopupMenu)) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.drawLine(1, 0, UIHeadMenu.this.getWidth() - 2, 0);
}
}
@Override
public boolean isBorderOpaque() {
return false;
}
@Override
public Insets getBorderInsets(Component c) {
return new Insets(5, 2, 10, 10);
}
});
return popupMenu;
}
protected void ensurePopupMenuCreated() {
if (popupMenu == null) {
this.popupMenu = new JPopupMenu() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
float wdith = getWidth();
float heigth = getHeight();
Shape shape = GUIPaintUtils.paintShape(g2d, wdith, heigth, REC);
g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d);
}
};
popupMenu.setInvoker(this);
popupListener = createWinListener(popupMenu);
}
}
/**
*画界面
*/
@Override
public void updateUI() {
setUI(new UIMenuUI());
}
/**
* 判断popupmeu是否隐藏
* @return 如果隐藏 返回true
*/
public boolean isPopupMenuVisible() {
ensurePopupMenuCreated();
return popupMenu.isVisible();
}
/**
* 设置popupmenu位置
* @param x
* @param y
*/
public void setMenuLocation(int x, int y) {
super.setMenuLocation(x, y);
if (popupMenu != null) {
popupMenu.setLocation(x, y);
}
}
/**
* 向popupmenu添加 JMenuItem
* @param menuItem 菜单项
* @return 菜单项
*/
public JMenuItem add(JMenuItem menuItem) {
ensurePopupMenuCreated();
return popupMenu.add(menuItem);
}
/**
* 添加组件
* @param c 组件
* @return 组件
*/
public Component add(Component c) {
ensurePopupMenuCreated();
popupMenu.add(c);
return c;
}
/**
* 向指定位置添加组件
* @param c 组件
* @param index 位置
* @return 组件
*/
public Component add(Component c, int index) {
ensurePopupMenuCreated();
popupMenu.add(c, index);
return c;
}
/**
* 添加分隔符
*/
public void addSeparator() {
ensurePopupMenuCreated();
popupMenu.addSeparator();
}
/**
* 添加menuitem到指定位置
* @param s 字符
* @param pos 位置
*/
public void insert(String s, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JMenuItem(s), pos);
}
/**
* 添加么会特么到指定位置
* @param mi 菜单项
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(JMenuItem mi, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加到指定位置
* @param a 事件
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(Action a, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
JMenuItem mi = new JMenuItem(a);
mi.setHorizontalTextPosition(JButton.TRAILING);
mi.setVerticalTextPosition(JButton.CENTER);
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加分隔符到指定位置
* @param index 指定位置
*/
public void insertSeparator(int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JPopupMenu.Separator(), index);
}
/**
* 移除
* @param item 菜单项
*/
public void remove(JMenuItem item) {
if (popupMenu != null) {
popupMenu.remove(item);
}
}
/**
* 移除指定位置菜单项
* @param pos 指定位置
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
if (pos > getItemCount()) {
throw new IllegalArgumentException("index greater than the number of items.");
}
if (popupMenu != null) {
popupMenu.remove(pos);
}
}
/**
* 移除组件
* @param c 组件
*/
public void remove(Component c) {
if (popupMenu != null) {
popupMenu.remove(c);
}
}
/**
* 移除所有
*/
public void removeAll() {
if (popupMenu != null) {
popupMenu.removeAll();
}
}
/**
* 组件总数
* @return 组件总数
*/
public int getMenuComponentCount() {
return (popupMenu == null) ? 0 : popupMenu.getComponentCount();
}
/**
* 指定位置组件
* @param n 指定位置
* @return 组件
*/
public Component getMenuComponent(int n) {
return (popupMenu == null) ? null : popupMenu.getComponent(n);
}
/**
* 所有组件
* @return 所有组件
*/
public Component[] getMenuComponents() {
return (popupMenu == null) ? new Component[0] : popupMenu.getComponents();
}
}

237
designer_base/src/com/fr/design/gui/imenu/UIMenu.java

@ -6,8 +6,12 @@ import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.geom.RoundRectangle2D;
public class UIMenu extends JMenu { public class UIMenu extends JMenu {
private static final float REC = 8f;
private JPopupMenu popupMenu;
public UIMenu(String name) { public UIMenu(String name) {
super(name); super(name);
setName(name); setName(name);
@ -24,14 +28,17 @@ public class UIMenu extends JMenu {
} }
public JPopupMenu getPopupMenu() { public JPopupMenu getPopupMenu() {
JPopupMenu popupMenu = super.getPopupMenu(); ensurePopupMenuCreated();
popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND); popupMenu.setOpaque(false);
popupMenu.setBorder(new Border() { popupMenu.setBorder(new Border() {
@Override @Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(UIConstants.LINE_COLOR); Graphics2D g2d = (Graphics2D) g;
g.drawRect(x, y, width - 1, height - 1); int rec = (int) REC;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g2d.drawRoundRect(x, y, width - 1, height - 1,rec, rec);
if (!(UIMenu.this.getParent() instanceof JPopupMenu)) { if (!(UIMenu.this.getParent() instanceof JPopupMenu)) {
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.drawLine(1, 0, UIMenu.this.getWidth() - 2, 0); g.drawLine(1, 0, UIMenu.this.getWidth() - 2, 0);
@ -51,8 +58,230 @@ public class UIMenu extends JMenu {
return popupMenu; return popupMenu;
} }
protected void ensurePopupMenuCreated() {
if (popupMenu == null) {
this.popupMenu = new JPopupMenu() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.NORMAL_BACKGROUND);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), rec, rec);
g2d.setClip(shape);
super.paintComponent(g2d);
}
};
popupMenu.setInvoker(this);
popupListener = createWinListener(popupMenu);
}
}
/**
*画界面
*/
@Override @Override
public void updateUI() { public void updateUI() {
setUI(new UIMenuUI()); setUI(new UIMenuUI());
} }
/**
* 判断popupmeu是否隐藏
* @return 如果隐藏 返回true
*/
public boolean isPopupMenuVisible() {
ensurePopupMenuCreated();
return popupMenu.isVisible();
}
/**
* 设置popupmenu位置
* @param x
* @param y
*/
public void setMenuLocation(int x, int y) {
super.setMenuLocation(x, y);
if (popupMenu != null) {
popupMenu.setLocation(x, y);
}
}
/**
* 向popupmenu添加 JMenuItem
* @param menuItem 菜单项
* @return 菜单项
*/
public JMenuItem add(JMenuItem menuItem) {
ensurePopupMenuCreated();
return popupMenu.add(menuItem);
}
/**
* 添加组件
* @param c 组件
* @return 组件
*/
public Component add(Component c) {
ensurePopupMenuCreated();
popupMenu.add(c);
return c;
}
/**
* 向指定位置添加组件
* @param c 组件
* @param index 位置
* @return 组件
*/
public Component add(Component c, int index) {
ensurePopupMenuCreated();
popupMenu.add(c, index);
return c;
}
/**
* 添加分隔符
*/
public void addSeparator() {
ensurePopupMenuCreated();
popupMenu.addSeparator();
}
/**
* 添加menuitem到指定位置
* @param s 字符
* @param pos 位置
*/
public void insert(String s, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JMenuItem(s), pos);
}
/**
* 添加么会特么到指定位置
* @param mi 菜单项
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(JMenuItem mi, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加到指定位置
* @param a 事件
* @param pos 位置
* @return 菜单项
*/
public JMenuItem insert(Action a, int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
JMenuItem mi = new JMenuItem(a);
mi.setHorizontalTextPosition(JButton.TRAILING);
mi.setVerticalTextPosition(JButton.CENTER);
popupMenu.insert(mi, pos);
return mi;
}
/**
* 添加分隔符到指定位置
* @param index 指定位置
*/
public void insertSeparator(int index) {
if (index < 0) {
throw new IllegalArgumentException("index less than zero.");
}
ensurePopupMenuCreated();
popupMenu.insert(new JPopupMenu.Separator(), index);
}
/**
* 移除
* @param item 菜单项
*/
public void remove(JMenuItem item) {
if (popupMenu != null) {
popupMenu.remove(item);
}
}
/**
* 移除指定位置菜单项
* @param pos 指定位置
*/
public void remove(int pos) {
if (pos < 0) {
throw new IllegalArgumentException("index less than zero.");
}
if (pos > getItemCount()) {
throw new IllegalArgumentException("index greater than the number of items.");
}
if (popupMenu != null) {
popupMenu.remove(pos);
}
}
/**
* 移除组件
* @param c 组件
*/
public void remove(Component c) {
if (popupMenu != null) {
popupMenu.remove(c);
}
}
/**
* 移除所有
*/
public void removeAll() {
if (popupMenu != null) {
popupMenu.removeAll();
}
}
/**
* 组件总数
* @return 组件总数
*/
public int getMenuComponentCount() {
return (popupMenu == null) ? 0 : popupMenu.getComponentCount();
}
/**
* 指定位置组件
* @param n 指定位置
* @return 组件
*/
public Component getMenuComponent(int n) {
return (popupMenu == null) ? null : popupMenu.getComponent(n);
}
/**
* 所有组件
* @return 所有组件
*/
public Component[] getMenuComponents() {
return (popupMenu == null) ? new Component[0] : popupMenu.getComponents();
}
} }

2
designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java

@ -95,7 +95,7 @@ public class UIMenuItem extends JMenuItem{
} else { } else {
// *** paint the text normally // *** paint the text normally
if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) {
g.setColor(selectionForeground); // Uses protected field. g.setColor(Color.WHITE); // Uses protected field.
} }
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text,
-1, textRect.x, textRect.y + fm.getAscent()); -1, textRect.x, textRect.y + fm.getAscent());

4
designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java

@ -72,8 +72,8 @@ public class UIMenuUI extends BasicMenuUI {
} }
} else { } else {
// *** paint the text normally // *** paint the text normally
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { if (model.isArmed() || (menuItem instanceof JMenu && menuItem.isSelected() && menuItem.getIcon() != null)) {
g.setColor(selectionForeground); // Uses protected field. g.setColor(Color.WHITE); // Uses protected field.
} }
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent()); mnemIndex, textRect.x, textRect.y + fm.getAscent());

24
designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java

@ -1,23 +1,37 @@
package com.fr.design.gui.imenu; package com.fr.design.gui.imenu;
import java.awt.Graphics; import java.awt.*;
import java.awt.Insets; import java.awt.geom.RoundRectangle2D;
import javax.swing.JPopupMenu; import javax.swing.*;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
public class UIPopupMenu extends JPopupMenu{ public class UIPopupMenu extends JPopupMenu{
private static final float REC = 8f;
private boolean onlyText = false; private boolean onlyText = false;
public UIPopupMenu() { public UIPopupMenu() {
super(); super();
setBackground(UIConstants.NORMAL_BACKGROUND); setBackground(UIConstants.NORMAL_BACKGROUND);
} }
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Shape shape = null;
shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d);
}
@Override @Override
protected void paintBorder(Graphics g) { protected void paintBorder(Graphics g) {
g.setColor(UIConstants.LINE_COLOR); Graphics2D g2d = (Graphics2D) g;
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); int rec = (int) REC;
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, rec, rec);
} }
@Override @Override

2
designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java

@ -23,7 +23,7 @@ public class UIPopupMenuSeparatorUI extends MetalSeparatorUI {
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
Dimension s = c.getSize(); Dimension s = c.getSize();
g.setColor(UIConstants.FONT_COLOR); g.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g.drawLine(2, 1, s.width - 3, 1); g.drawLine(2, 1, s.width - 3, 1);
} }
} }

9
designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java

@ -1,6 +1,7 @@
package com.fr.design.gui.imenu; package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import java.awt.*; import java.awt.*;
@ -16,12 +17,13 @@ import java.awt.event.MouseWheelListener;
*/ */
public class UIScrollPopUpMenu extends UIPopupMenu { public class UIScrollPopUpMenu extends UIPopupMenu {
private static final int MAX_SHOW_NUM = 27; private static final int MAX_SHOW_NUM = 27;
private static final float REC = 8f;
private UIScrollBar scrollBar; private UIScrollBar scrollBar;
public UIScrollPopUpMenu() { public UIScrollPopUpMenu() {
super(); super();
setOpaque(false);
setLayout(new ScrollPopupMenuLayout()); setLayout(new ScrollPopupMenuLayout());
super.add(getScrollBar()); super.add(getScrollBar());
addMouseWheelListener(new MouseWheelListener() { addMouseWheelListener(new MouseWheelListener() {
@ -39,6 +41,11 @@ public class UIScrollPopUpMenu extends UIPopupMenu {
public void paintChildren(Graphics g) { public void paintChildren(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.NORMAL_BACKGROUND);
g2d.fillRoundRect(1, 1, getWidth() - 2, getHeight() - 2, rec, rec);
Insets insets = getInsets(); Insets insets = getInsets();
g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom); g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom);
super.paintChildren(g); super.paintChildren(g);

BIN
designer_base/src/com/fr/design/images/control/clear.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

BIN
designer_base/src/com/fr/design/images/control/remove.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 167 B

5
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -228,6 +228,11 @@ public abstract class ToolBarMenuDock {
addAllUpdateActionsToList(menuList); addAllUpdateActionsToList(menuList);
UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList); UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList);
for (MenuDef menuDef : menuList
) {
menuDef.setHasRecMenu(true);
}
return menuList.toArray(new MenuDef[menuList.size()]); return menuList.toArray(new MenuDef[menuList.size()]);
} }

12
designer_base/src/com/fr/design/menu/MenuDef.java

@ -2,10 +2,7 @@ package com.fr.design.menu;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.*;
import com.fr.design.gui.imenu.UIPopupEastAttrMenu;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.imenu.UIScrollMenu;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -41,6 +38,7 @@ public class MenuDef extends ShortCut {
protected UIButton createdButton; protected UIButton createdButton;
protected JPopupMenu popupMenu; protected JPopupMenu popupMenu;
private boolean hasScrollSubMenu; private boolean hasScrollSubMenu;
private boolean isHeadMenu;
private String anchor; private String anchor;
@ -88,6 +86,10 @@ public class MenuDef extends ShortCut {
this.hasScrollSubMenu = scrollSubMenu; this.hasScrollSubMenu = scrollSubMenu;
} }
public void setHasRecMenu(boolean headMenu) {
this.isHeadMenu = headMenu;
}
public String getIconPath() { public String getIconPath() {
return iconPath; return iconPath;
} }
@ -186,6 +188,8 @@ public class MenuDef extends ShortCut {
if (createdJMenu == null) { if (createdJMenu == null) {
if (hasScrollSubMenu) { if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName()); createdJMenu = new UIScrollMenu(this.getName());
} else if (isHeadMenu){
createdJMenu = new UIHeadMenu(this.getName());
} else { } else {
createdJMenu = new UIMenu(this.getName()); createdJMenu = new UIMenu(this.getName());
} }

37
designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java

@ -5,6 +5,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import java.awt.*; import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
public class GUIPaintUtils { public class GUIPaintUtils {
@ -202,4 +203,40 @@ public class GUIPaintUtils {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }
/**
* 自定义popMenu画法,一种下面两圆角矩形
*
*/
public static final Shape paintShape(Graphics2D g2, float width, float height, float REC) {
REC = REC / 2;
float recdir = (float) (REC - (REC / Math.sqrt(2)));
GeneralPath gp1 = new GeneralPath();
gp1.moveTo(0f, 0f);
gp1.lineTo(width, 0f);
gp1.lineTo(width, height - REC);
gp1.quadTo(width - recdir, height - recdir, width - REC, height);
gp1.lineTo(REC, height);
gp1.quadTo(recdir, height - recdir, 0, height - REC);
gp1.closePath();
return gp1;
}
/**
* 自定义popMenu边框画法,一种下面两圆角矩形
*
*/
public static final void paintShapeBorder(Graphics2D g2, int x, int y, int width, int height, int rec) {
g2.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
width = width - 1;
height = height - 1;
rec = rec / 2;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2.drawLine(x, y, x + width, y);
g2.drawLine(x + width, y, x + width, y + height - rec);
g2.drawArc(x + width - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90);
g2.drawLine(x + width - rec, y + height, x + rec, y + height);
g2.drawArc(x - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90);
g2.drawLine(x, y + height - rec, x, y);
}
} }
Loading…
Cancel
Save