Browse Source

调整下菜单的UI实现

persist/11.0-arabic
obo 4 months ago
parent
commit
97c9f8ba02
  1. 9
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java
  2. 6
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuUI.java

9
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java

@ -35,17 +35,16 @@ public class UIMenuItemUI extends BasicMenuItemUI {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRect(0, 0, menuWidth, menuHeight);
int bidiX = BidiUtils.rtl() ? 10 : 30;
int bidiWidth = BidiUtils.rtl() ? menuWidth - 35 : menuWidth - 30;
int bidiX = BidiUtils.rtl() ? 5 : 30;
if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
} else {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7);
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7);
}
g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
g.setColor(oldColor);
}
}

6
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuUI.java

@ -1,5 +1,6 @@
package com.fr.design.gui.imenu;
import com.fr.base.i18n.BidiUtils;
import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUIPaintUtils;
@ -17,11 +18,12 @@ public class UIMenuUI extends BasicMenuUI {
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight();
int bidiX = BidiUtils.rtl() ? 5 : 30;
if (menuItem.isOpaque()) {
if (menuItem.getParent() instanceof JPopupMenu && model.isSelected()) {
g.setColor(UIConstants.UI_MENU_BACKGOURND);
g.fillRect(0, 0, menuWidth, menuHeight);
GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
} else if (model.isSelected()) {
paintPressed(g, menuWidth, menuHeight);
} else {
@ -54,7 +56,7 @@ public class UIMenuUI extends BasicMenuUI {
ButtonModel model = menuItem.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
int mnemIndex = -1;
BidiUtils.applyOrientationByLocale(menuItem);
if (!model.isEnabled()) {
// *** paint the text disabled
if (UIManager.get("MenuItem.disabledForeground") instanceof Color) {

Loading…
Cancel
Save