Java 类com.intellij.openapi.actionSystem.impl.ActionButtonWithText 实例源码

项目:consulo    文件:ActionButtonUI.java   
@Override
public void paint(Graphics g, JComponent c) {
  if(c instanceof ActionButtonWithText) {
    paintTextButton(g, (ActionButtonWithText)c);
  }
  else {
    paintDefaultButton(g, (ActionButton)c);
  }
}
项目:consulo    文件:ActionButtonUI.java   
private void paintTextButton(Graphics g, ActionButtonWithText c) {
  AnAction action = c.getAction();

  Icon icon = c.getIcon();
  FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, c.getFont());
  Rectangle viewRect = new Rectangle(c.getSize());
  Insets i = c.getInsets();
  viewRect.x += i.left;
  viewRect.y += i.top;
  viewRect.width -= (i.right + viewRect.x);
  viewRect.height -= (i.bottom + viewRect.y);

  Rectangle iconRect = new Rectangle();
  Rectangle textRect = new Rectangle();
  String text = SwingUtilities
          .layoutCompoundLabel(c, fm, c.getText(), icon, SwingConstants.CENTER, c.horizontalTextAlignment(), SwingConstants.CENTER,
                               SwingConstants.TRAILING, viewRect, iconRect, textRect, c.iconTextSpace());
  int state = c.getPopState();

  if (state != ActionButtonComponent.NORMAL) {
    paintBackground(c, g, c.getSize(), state);
  }

  icon.paintIcon(null, g, iconRect.x, iconRect.y);

  UIUtil.applyRenderingHints(g);
  g.setColor(c.isButtonEnabled() ? c.getForeground() : UIUtil.getInactiveTextColor());
  SwingUtilities2.drawStringUnderlineCharAt(c, g, text, getMnemonicCharIndex(c, action, text), textRect.x, textRect.y + fm.getAscent());
}
项目:intellij-ce-playground    文件:IconWithTextAction.java   
public static JComponent createCustomComponentImpl(final AnAction action, final Presentation presentation) {
  return new ActionButtonWithText(action, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
}
项目:tools-idea    文件:IconWithTextAction.java   
public static JComponent createCustomComponentImpl(final AnAction action, final Presentation presentation) {
  return new ActionButtonWithText(action, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
}
项目:tools-idea    文件:ContentEntryEditingAction.java   
@Override
public JComponent createCustomComponent(Presentation presentation) {
  return new ActionButtonWithText(this, presentation, ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
}
项目:consulo    文件:IconWithTextAction.java   
public static JComponent createCustomComponentImpl(final AnAction action, final Presentation presentation) {
  return new ActionButtonWithText(action, presentation, ActionPlaces.UNKNOWN, JBUI.size(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE));
}
项目:consulo    文件:ContentEntryEditingAction.java   
@Override
public JComponent createCustomComponent(Presentation presentation) {
  return new ActionButtonWithText(this, presentation, ActionPlaces.UNKNOWN, JBUI.size(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE));
}