Methods Summary |
---|
public static javax.swing.plaf.ComponentUI | createUI(javax.swing.JComponent c)
return new WindowsPopupMenuUI();
|
static int | getGutterWidth()Returns gutter width.
used only on Vista.
int rv = 2;
XPStyle xp = XPStyle.getXP();
if (xp != null) {
Skin skin = xp.getSkin(null, Part.MP_POPUPGUTTER);
rv = skin.getWidth();
}
return rv;
|
public javax.swing.Popup | getPopup(javax.swing.JPopupMenu popupMenu, int x, int y)Returns the Popup that will be responsible for
displaying the JPopupMenu .
PopupFactory popupFactory = PopupFactory.getSharedInstance();
return popupFactory.getPopup(popupMenu.getInvoker(), popupMenu, x, y);
|
static int | getSpanAfterGutter()Returns span after gutter.
used only on Vista.
return 3;
|
static int | getSpanBeforeGutter()Returns span before gutter.
used only on Vista.
return 3;
|
static int | getTextOffset(javax.swing.JComponent c)Returns offset for the text.
BasicMenuItemUI sets max text offset on the JPopupMenuUI.
int rv = -1;
Object maxTextOffset =
c.getClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET);
if (maxTextOffset instanceof Integer) {
/*
* this is in JMenuItem coordinates.
* Let's assume all the JMenuItem have the same offset along X.
*/
rv = (Integer) maxTextOffset;
int menuItemOffset = 0;
Component component = c.getComponent(0);
if (component != null) {
menuItemOffset = component.getX();
}
rv += menuItemOffset;
}
return rv;
|
public void | installListeners()
super.installListeners();
if (! UIManager.getBoolean("Button.showMnemonics") &&
mnemonicListener == null) {
mnemonicListener = new MnemonicListener();
MenuSelectionManager.defaultManager().
addChangeListener(mnemonicListener);
}
|
private static boolean | isLeftToRight(javax.swing.JComponent c)Checks if PopupMenu is leftToRight
The orientation is derived from the children of the component.
It is leftToRight if all the children are leftToRight
boolean leftToRight = true;
for (int i = c.getComponentCount() - 1; i >=0 && leftToRight; i-- ) {
leftToRight =
c.getComponent(i).getComponentOrientation().isLeftToRight();
}
return leftToRight;
|
public void | paint(java.awt.Graphics g, javax.swing.JComponent c)
if (WindowsMenuItemUI.isVistaPainting()) {
XPStyle xp = XPStyle.getXP();
Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND);
skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL);
int textOffset = getTextOffset(c);
if (textOffset >= 0
/* paint gutter only for leftToRight case */
&& isLeftToRight(c)) {
skin = xp.getSkin(c, Part.MP_POPUPGUTTER);
int gutterWidth = getGutterWidth();
int gutterOffset =
textOffset - getSpanAfterGutter() - gutterWidth;
c.putClientProperty(GUTTER_OFFSET_KEY,
Integer.valueOf(gutterOffset));
Insets insets = c.getInsets();
skin.paintSkin(g, gutterOffset, insets.top,
gutterWidth, c.getHeight() - insets.bottom - insets.top,
State.NORMAL);
} else {
if (c.getClientProperty(GUTTER_OFFSET_KEY) != null) {
c.putClientProperty(GUTTER_OFFSET_KEY, null);
}
}
} else {
super.paint(g, c);
}
|