From 69e8f1f79f5e11d3a35e7856a02998408e4f11e7 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 12 Dec 2017 14:12:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-5908=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E8=8F=9C=E5=8D=95=E3=80=81=E5=8F=B3=E5=87=BB?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=A7=86=E8=A7=89=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/DeprecatedActionManager.java | 2 +- .../com/fr/grid/selection/FloatSelection.java | 3 +- .../com/fr/design/constants/UIConstants.java | 2 + .../com/fr/design/gui/imenu/UIHeadMenu.java | 274 ++++++++++++++++++ .../src/com/fr/design/gui/imenu/UIMenu.java | 237 ++++++++++++++- .../com/fr/design/gui/imenu/UIMenuItem.java | 2 +- .../src/com/fr/design/gui/imenu/UIMenuUI.java | 4 +- .../com/fr/design/gui/imenu/UIPopupMenu.java | 24 +- .../gui/imenu/UIPopupMenuSeparatorUI.java | 2 +- .../design/gui/imenu/UIScrollPopUpMenu.java | 9 +- .../com/fr/design/images/control/clear.png | Bin 0 -> 500 bytes .../com/fr/design/images/control/remove.png | Bin 511 -> 167 bytes .../mainframe/toolbar/ToolBarMenuDock.java | 5 + .../src/com/fr/design/menu/MenuDef.java | 12 +- .../fr/design/utils/gui/GUIPaintUtils.java | 37 +++ 15 files changed, 593 insertions(+), 20 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java create mode 100644 designer_base/src/com/fr/design/images/control/clear.png diff --git a/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java b/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java index 89bbd82bf..c072b620d 100644 --- a/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java +++ b/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java @@ -49,7 +49,7 @@ public class DeprecatedActionManager { */ public static UIMenu getClearMenu(ElementCasePane ePane) { 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'); ClearAction ReportComponentAction = new ClearAllAction(ePane); diff --git a/designer/src/com/fr/grid/selection/FloatSelection.java b/designer/src/com/fr/grid/selection/FloatSelection.java index de44152f7..17b8ca7aa 100644 --- a/designer/src/com/fr/grid/selection/FloatSelection.java +++ b/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.FloatElementsClip; import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -114,7 +115,7 @@ public class FloatSelection extends Selection { @Override public JPopupMenu createPopupMenu(ElementCasePane ePane) { - JPopupMenu popup = new JPopupMenu(); + UIPopupMenu popup = new UIPopupMenu(); if (BaseUtils.isAuthorityEditing()) { popup.add(new CleanAuthorityAction(ePane).createMenuItem()); return popup; diff --git a/designer_base/src/com/fr/design/constants/UIConstants.java b/designer_base/src/com/fr/design/constants/UIConstants.java index 5a35c98d4..c1aacd7c9 100644 --- a/designer_base/src/com/fr/design/constants/UIConstants.java +++ b/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_ROLLOVER = new Color(0xC8C9CD); 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 FONT_COLOR = new Color(51, 51, 51); public static final Color LIGHT_BLUE = new Color(182, 217, 253); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java new file mode 100644 index 000000000..627982ffe --- /dev/null +++ b/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(); + } + + + + +} diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIMenu.java index 9c905a83f..bcdf2ab9f 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenu.java +++ b/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.border.Border; import java.awt.*; +import java.awt.geom.RoundRectangle2D; public class UIMenu extends JMenu { + private static final float REC = 8f; + private JPopupMenu popupMenu; + public UIMenu(String name) { super(name); setName(name); @@ -24,14 +28,17 @@ public class UIMenu extends JMenu { } public JPopupMenu getPopupMenu() { - JPopupMenu popupMenu = super.getPopupMenu(); - popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND); + ensurePopupMenuCreated(); + popupMenu.setOpaque(false); popupMenu.setBorder(new Border() { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - g.setColor(UIConstants.LINE_COLOR); - g.drawRect(x, y, width - 1, height - 1); + Graphics2D g2d = (Graphics2D) g; + 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)) { g.setColor(UIConstants.NORMAL_BACKGROUND); g.drawLine(1, 0, UIMenu.this.getWidth() - 2, 0); @@ -51,8 +58,230 @@ public class UIMenu extends JMenu { 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 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(); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java b/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java index e35f440a1..a0f164361 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java @@ -95,7 +95,7 @@ public class UIMenuItem extends JMenuItem{ } else { // *** paint the text normally 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, -1, textRect.x, textRect.y + fm.getAscent()); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java b/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java index 9e79ecd65..33f86582f 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java @@ -72,8 +72,8 @@ public class UIMenuUI extends BasicMenuUI { } } else { // *** paint the text normally - if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(selectionForeground); // Uses protected field. + if (model.isArmed() || (menuItem instanceof JMenu && menuItem.isSelected() && menuItem.getIcon() != null)) { + g.setColor(Color.WHITE); // Uses protected field. } SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java index 44b36ae11..9fcf821e0 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java @@ -1,23 +1,37 @@ package com.fr.design.gui.imenu; -import java.awt.Graphics; -import java.awt.Insets; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; -import javax.swing.JPopupMenu; +import javax.swing.*; import com.fr.design.constants.UIConstants; public class UIPopupMenu extends JPopupMenu{ + private static final float REC = 8f; private boolean onlyText = false; public UIPopupMenu() { super(); 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 protected void paintBorder(Graphics g) { - g.setColor(UIConstants.LINE_COLOR); - g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + Graphics2D g2d = (Graphics2D) g; + 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 diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java index df90a1bbe..b9497dcd1 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java +++ b/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) { Dimension s = c.getSize(); - g.setColor(UIConstants.FONT_COLOR); + g.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); g.drawLine(2, 1, s.width - 3, 1); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java index 3f8fd6a42..c2713fc26 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java @@ -1,6 +1,7 @@ package com.fr.design.gui.imenu; +import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; import java.awt.*; @@ -16,12 +17,13 @@ import java.awt.event.MouseWheelListener; */ public class UIScrollPopUpMenu extends UIPopupMenu { private static final int MAX_SHOW_NUM = 27; - + private static final float REC = 8f; private UIScrollBar scrollBar; public UIScrollPopUpMenu() { super(); + setOpaque(false); setLayout(new ScrollPopupMenuLayout()); super.add(getScrollBar()); addMouseWheelListener(new MouseWheelListener() { @@ -39,6 +41,11 @@ public class UIScrollPopUpMenu extends UIPopupMenu { 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(); g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom); super.paintChildren(g); diff --git a/designer_base/src/com/fr/design/images/control/clear.png b/designer_base/src/com/fr/design/images/control/clear.png new file mode 100644 index 0000000000000000000000000000000000000000..6e6282a3f394a5916b3432cdc3da4f58a7620907 GIT binary patch literal 500 zcmVPx$u1Q2eR5%fpQN2sUKoq~1>sJV&*r8x4T|}@h3ay1wP(ctu1Rc6d2SHq11i{7G z&B;yw1gC;S2bUO$iK~Lr$tt)AYH1rx&UcXu*HWQ9NZ$K>z2xqIjJYb6N~YKAU1IFb zw(U)2oIDSAyY4k(q=dOio(%_7tJTpC zsmp@giy?$04=l?vWi1?F+opxWvnHY*Bg z$XN7HC={6hq5>%A0PF}4u7=z)V=#w9SMfSeky{czUi%JF2#onPG~c7#p_K0Hx;BNu qFMJk-N7SKzAjDDX&_5U@C_KN?QJ%F+E%$-|0000e`^%>Zm-AdO%X zaY?2mH6u zPXao-yYt4FZDO91e85CyBDxp=_9&mP_tx|ga4whXwA%*^Y=8EG;*_bUGTwMi?j9A&)nOiM8PN!N0KRj3(Lv-0kpqHdWw5Go*yuOYW z_A#?57GaCawyDZL8rRXrsZBl31iD-Ws7#`lyn3^L{$KEg^ zSvwxp|7y1L(9i_sa;-QgvG2x*hsm%~S=3)8fIyyS<9Qd!582-<{t$Tw3WBcZi@oK+ P00000NkvXXu0mjf+yUXr diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index f43419d47..4831c60f8 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -228,6 +228,11 @@ public abstract class ToolBarMenuDock { addAllUpdateActionsToList(menuList); UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList); + for (MenuDef menuDef : menuList + ) { + menuDef.setHasRecMenu(true); + } + return menuList.toArray(new MenuDef[menuList.size()]); } diff --git a/designer_base/src/com/fr/design/menu/MenuDef.java b/designer_base/src/com/fr/design/menu/MenuDef.java index 00dd2ff3a..bc5e3a8b7 100644 --- a/designer_base/src/com/fr/design/menu/MenuDef.java +++ b/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.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenu; -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.imenu.*; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; @@ -41,6 +38,7 @@ public class MenuDef extends ShortCut { protected UIButton createdButton; protected JPopupMenu popupMenu; private boolean hasScrollSubMenu; + private boolean isHeadMenu; private String anchor; @@ -88,6 +86,10 @@ public class MenuDef extends ShortCut { this.hasScrollSubMenu = scrollSubMenu; } + public void setHasRecMenu(boolean headMenu) { + this.isHeadMenu = headMenu; + } + public String getIconPath() { return iconPath; } @@ -186,6 +188,8 @@ public class MenuDef extends ShortCut { if (createdJMenu == null) { if (hasScrollSubMenu) { createdJMenu = new UIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new UIHeadMenu(this.getName()); } else { createdJMenu = new UIMenu(this.getName()); } diff --git a/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java b/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java index 286e44cd6..fcff66e07 100644 --- a/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java +++ b/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 java.awt.*; +import java.awt.geom.GeneralPath; import java.awt.geom.RoundRectangle2D; public class GUIPaintUtils { @@ -202,4 +203,40 @@ public class GUIPaintUtils { 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); + } + } \ No newline at end of file From e45eb353fec58446d637311f8d36c081aaecaaf9 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 12 Dec 2017 14:19:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-5840=20=E6=8E=A7=E4=BB=B6=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=92=8C=E4=BD=BF=E7=94=A8=E5=A1=AB=E6=8A=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 4831c60f8..24059928b 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -180,6 +180,7 @@ public abstract class ToolBarMenuDock { this.menus = menus(plus); for (int i = 0; i < menus.length; i++) { + menus[i].setHasRecMenu(true); UIMenu subMenu = menus[i].createJMenu(); jMenuBar.add(subMenu); menus[i].updateMenu(); @@ -228,11 +229,6 @@ public abstract class ToolBarMenuDock { addAllUpdateActionsToList(menuList); UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList); - for (MenuDef menuDef : menuList - ) { - menuDef.setHasRecMenu(true); - } - return menuList.toArray(new MenuDef[menuList.size()]); }